mirror of
https://github.com/overte-org/overte.git
synced 2025-06-24 04:20:15 +02:00
Fix warnings
This commit is contained in:
parent
de564d92b9
commit
9051c84b6d
8 changed files with 11 additions and 16 deletions
|
@ -72,7 +72,6 @@ GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
|
||||||
incrementTextureGPUCount();
|
incrementTextureGPUCount();
|
||||||
withPreservedTexture([&] {
|
withPreservedTexture([&] {
|
||||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||||
const Sampler& sampler = _gpuObject.getSampler();
|
|
||||||
auto numMips = _gpuObject.evalNumMips();
|
auto numMips = _gpuObject.evalNumMips();
|
||||||
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) {
|
||||||
// Get the mip level dimensions, accounting for the downgrade level
|
// Get the mip level dimensions, accounting for the downgrade level
|
||||||
|
|
|
@ -412,7 +412,6 @@ void Texture::assignStoredMip(uint16 level, storage::StoragePointer& storage) {
|
||||||
// THen check that the mem texture passed make sense with its format
|
// THen check that the mem texture passed make sense with its format
|
||||||
Size expectedSize = evalStoredMipSize(level, getStoredMipFormat());
|
Size expectedSize = evalStoredMipSize(level, getStoredMipFormat());
|
||||||
auto size = storage->size();
|
auto size = storage->size();
|
||||||
auto bytes = storage->data();
|
|
||||||
if (storage->size() == expectedSize) {
|
if (storage->size() == expectedSize) {
|
||||||
_storage->assignMipData(level, storage);
|
_storage->assignMipData(level, storage);
|
||||||
_maxMip = std::max(_maxMip, level);
|
_maxMip = std::max(_maxMip, level);
|
||||||
|
@ -442,7 +441,6 @@ void Texture::assignStoredMipFace(uint16 level, uint8 face, storage::StoragePoin
|
||||||
// THen check that the mem texture passed make sense with its format
|
// THen check that the mem texture passed make sense with its format
|
||||||
Size expectedSize = evalStoredMipFaceSize(level, getStoredMipFormat());
|
Size expectedSize = evalStoredMipFaceSize(level, getStoredMipFormat());
|
||||||
auto size = storage->size();
|
auto size = storage->size();
|
||||||
auto bytes = storage->data();
|
|
||||||
if (size == expectedSize) {
|
if (size == expectedSize) {
|
||||||
_storage->assignMipFaceData(level, face, storage);
|
_storage->assignMipFaceData(level, face, storage);
|
||||||
_maxMip = std::max(_maxMip, level);
|
_maxMip = std::max(_maxMip, level);
|
||||||
|
|
|
@ -117,6 +117,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ktxBuffer = ktx::KTX::create(header, images);
|
auto ktxBuffer = ktx::KTX::create(header, images);
|
||||||
|
#if 0
|
||||||
auto expectedMipCount = texture.evalNumMips();
|
auto expectedMipCount = texture.evalNumMips();
|
||||||
assert(expectedMipCount == ktxBuffer->_images.size());
|
assert(expectedMipCount == ktxBuffer->_images.size());
|
||||||
assert(expectedMipCount == header.numberOfMipmapLevels);
|
assert(expectedMipCount == header.numberOfMipmapLevels);
|
||||||
|
@ -141,6 +142,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) {
|
||||||
assert(0 == memcmp(expectedFace, actualFace, expected._faceSize));
|
assert(0 == memcmp(expectedFace, actualFace, expected._faceSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ktxBuffer;
|
return ktxBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,15 +402,15 @@ namespace ktx {
|
||||||
Image(uint32_t imageSize, uint32_t padding, const Byte* bytes) :
|
Image(uint32_t imageSize, uint32_t padding, const Byte* bytes) :
|
||||||
_numFaces(1),
|
_numFaces(1),
|
||||||
_imageSize(imageSize),
|
_imageSize(imageSize),
|
||||||
_padding(padding),
|
|
||||||
_faceSize(imageSize),
|
_faceSize(imageSize),
|
||||||
|
_padding(padding),
|
||||||
_faceBytes(1, bytes) {}
|
_faceBytes(1, bytes) {}
|
||||||
|
|
||||||
Image(uint32_t pageSize, uint32_t padding, const FaceBytes& cubeFaceBytes) :
|
Image(uint32_t pageSize, uint32_t padding, const FaceBytes& cubeFaceBytes) :
|
||||||
_numFaces(NUM_CUBEMAPFACES),
|
_numFaces(NUM_CUBEMAPFACES),
|
||||||
_imageSize(pageSize * NUM_CUBEMAPFACES),
|
_imageSize(pageSize * NUM_CUBEMAPFACES),
|
||||||
_padding(padding),
|
_faceSize(pageSize),
|
||||||
_faceSize(pageSize)
|
_padding(padding)
|
||||||
{
|
{
|
||||||
if (cubeFaceBytes.size() == NUM_CUBEMAPFACES) {
|
if (cubeFaceBytes.size() == NUM_CUBEMAPFACES) {
|
||||||
_faceBytes = cubeFaceBytes;
|
_faceBytes = cubeFaceBytes;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define NOEXCEPT noexcept
|
#define NOEXCEPT noexcept
|
||||||
|
@ -68,7 +69,7 @@ namespace ktx {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the first null character \0
|
// find the first null character \0
|
||||||
int keyLength = 0;
|
uint32_t keyLength = 0;
|
||||||
while (reinterpret_cast<const char*>(src[++keyLength]) != '\0') {
|
while (reinterpret_cast<const char*>(src[++keyLength]) != '\0') {
|
||||||
if (keyLength == keyValueByteSize) {
|
if (keyLength == keyValueByteSize) {
|
||||||
// key must be null-terminated, and there must be space for the value
|
// key must be null-terminated, and there must be space for the value
|
||||||
|
@ -119,8 +120,8 @@ namespace ktx {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (ReaderException& e) {
|
catch (const ReaderException& e) {
|
||||||
qWarning(e.what());
|
qWarning() << e.what();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +129,6 @@ namespace ktx {
|
||||||
Images KTX::parseImages(const Header& header, size_t srcSize, const Byte* srcBytes) {
|
Images KTX::parseImages(const Header& header, size_t srcSize, const Byte* srcBytes) {
|
||||||
Images images;
|
Images images;
|
||||||
auto currentPtr = srcBytes;
|
auto currentPtr = srcBytes;
|
||||||
auto numMips = header.getNumberOfLevels();
|
|
||||||
auto numFaces = header.numberOfFaces;
|
auto numFaces = header.numberOfFaces;
|
||||||
|
|
||||||
// Keep identifying new mip as long as we can at list query the next imageSize
|
// Keep identifying new mip as long as we can at list query the next imageSize
|
||||||
|
|
|
@ -105,14 +105,14 @@ namespace ktx {
|
||||||
|
|
||||||
// Single face vs cubes
|
// Single face vs cubes
|
||||||
if (srcImages[l]._numFaces == 1) {
|
if (srcImages[l]._numFaces == 1) {
|
||||||
auto copied = memcpy(currentPtr, srcImages[l]._faceBytes[0], imageSize);
|
memcpy(currentPtr, srcImages[l]._faceBytes[0], imageSize);
|
||||||
destImages.emplace_back(Image((uint32_t) imageSize, padding, currentPtr));
|
destImages.emplace_back(Image((uint32_t) imageSize, padding, currentPtr));
|
||||||
currentPtr += imageSize;
|
currentPtr += imageSize;
|
||||||
} else {
|
} else {
|
||||||
Image::FaceBytes faceBytes(6);
|
Image::FaceBytes faceBytes(6);
|
||||||
auto faceSize = srcImages[l]._faceSize;
|
auto faceSize = srcImages[l]._faceSize;
|
||||||
for (int face = 0; face < 6; face++) {
|
for (int face = 0; face < 6; face++) {
|
||||||
auto copied = memcpy(currentPtr, srcImages[l]._faceBytes[face], faceSize);
|
memcpy(currentPtr, srcImages[l]._faceBytes[face], faceSize);
|
||||||
faceBytes[face] = currentPtr;
|
faceBytes[face] = currentPtr;
|
||||||
currentPtr += faceSize;
|
currentPtr += faceSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,12 +116,10 @@ gpu::Texture* cacheTexture(const std::string& name, gpu::Texture* srcTexture, bo
|
||||||
auto ktxMemory = gpu::Texture::serialize(*srcTexture);
|
auto ktxMemory = gpu::Texture::serialize(*srcTexture);
|
||||||
if (ktxMemory) {
|
if (ktxMemory) {
|
||||||
const auto& ktxStorage = ktxMemory->getStorage();
|
const auto& ktxStorage = ktxMemory->getStorage();
|
||||||
auto header = ktxMemory->getHeader();
|
|
||||||
QFile outFile(cacheFilename.c_str());
|
QFile outFile(cacheFilename.c_str());
|
||||||
if (!outFile.open(QFile::Truncate | QFile::ReadWrite)) {
|
if (!outFile.open(QFile::Truncate | QFile::ReadWrite)) {
|
||||||
throw std::runtime_error("Unable to open file");
|
throw std::runtime_error("Unable to open file");
|
||||||
}
|
}
|
||||||
//auto ktxSize = sizeof(ktx::Header); // ktxStorage->size()
|
|
||||||
auto ktxSize = ktxStorage->size();
|
auto ktxSize = ktxStorage->size();
|
||||||
outFile.resize(ktxSize);
|
outFile.resize(ktxSize);
|
||||||
auto dest = outFile.map(0, ktxSize);
|
auto dest = outFile.map(0, ktxSize);
|
||||||
|
|
|
@ -99,12 +99,10 @@ int main(int argc, char** argv) {
|
||||||
auto ktxMemory = gpu::Texture::serialize(*testTexture);
|
auto ktxMemory = gpu::Texture::serialize(*testTexture);
|
||||||
{
|
{
|
||||||
const auto& ktxStorage = ktxMemory->getStorage();
|
const auto& ktxStorage = ktxMemory->getStorage();
|
||||||
auto header = ktxMemory->getHeader();
|
|
||||||
QFile outFile(TEST_IMAGE_KTX);
|
QFile outFile(TEST_IMAGE_KTX);
|
||||||
if (!outFile.open(QFile::Truncate | QFile::ReadWrite)) {
|
if (!outFile.open(QFile::Truncate | QFile::ReadWrite)) {
|
||||||
throw std::runtime_error("Unable to open file");
|
throw std::runtime_error("Unable to open file");
|
||||||
}
|
}
|
||||||
//auto ktxSize = sizeof(ktx::Header); // ktxStorage->size()
|
|
||||||
auto ktxSize = ktxStorage->size();
|
auto ktxSize = ktxStorage->size();
|
||||||
outFile.resize(ktxSize);
|
outFile.resize(ktxSize);
|
||||||
auto dest = outFile.map(0, ktxSize);
|
auto dest = outFile.map(0, ktxSize);
|
||||||
|
|
Loading…
Reference in a new issue