Tests for Pfm.hpp, Pfm bugfix related to the endian swapping

This commit is contained in:
Vladyslav Baranovskyi
2024-10-10 15:35:08 +03:00
parent 9010007729
commit 64c60b3726
2 changed files with 173 additions and 3 deletions

View File

@@ -96,6 +96,10 @@ namespace OpenVulkano
inStream >> header;
size_t size = header.GetElementCount();
image = std::make_unique<float[]>(size);
inStream.read(reinterpret_cast<char*>(image.get()), size * sizeof(float));
if ((std::endian::native == std::endian::little) != header.littleEndian)
{
char* data = reinterpret_cast<char*>(image.get());
@@ -105,9 +109,6 @@ namespace OpenVulkano
std::reverse(&data[idx], &data[idx + sizeof(float)]);
}
}
image = std::make_unique<float[]>(size);
inStream.read(reinterpret_cast<char*>(image.get()), size * sizeof(float));
}
static PfmImage ReadImage(std::istream& inStream)