From aca7ad27c661a7e11c59bd50cbddee9274ef7c1e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 12 Apr 2017 17:01:13 -0700 Subject: [PATCH] Fix ktx dependencies --- .../gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp | 1 + libraries/gpu/src/gpu/Texture.h | 1 + libraries/gpu/src/gpu/Texture_ktx.cpp | 4 ++-- .../model-networking/src/model-networking/TextureCache.cpp | 6 ++++-- .../model-networking/src/model-networking/TextureCache.h | 3 +++ libraries/procedural/CMakeLists.txt | 2 +- libraries/script-engine/CMakeLists.txt | 2 +- plugins/openvr/CMakeLists.txt | 2 +- 8 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp index a453d4207d..f87240f9d0 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp @@ -171,6 +171,7 @@ void GL45ResourceTexture::populateTransferQueue() { auto targetMip = sourceMip - _allocatedMip; auto mipDimensions = _gpuObject.evalMipDimensions(sourceMip); for (uint8_t face = 0; face < maxFace; ++face) { + qDebug() << "populateTransferQueue " << QString::fromStdString(_gpuObject.source()) << sourceMip << " " << targetMip; if (!_gpuObject.isStoredMipFaceAvailable(sourceMip, face)) { continue; } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index e82566b852..832be610ba 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -321,6 +321,7 @@ public: protected: std::string _filename; + //storage::FileStorage _cacheFile; ktx::KTXDescriptorPointer _ktxDescriptor; friend class Texture; }; diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 1e6fe1115e..306d72e58a 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -60,6 +60,7 @@ KtxStorage::KtxStorage(const std::string& filename) : _filename(filename) { } PixelsPointer KtxStorage::getMipFace(uint16 level, uint8 face) const { + qDebug() << "getMipFace: " << QString::fromStdString(_filename) << ": " << level << " " << face; storage::StoragePointer result; auto faceOffset = _ktxDescriptor->getMipFaceTexelsOffset(level, face); auto faceSize = _ktxDescriptor->getMipFaceTexelsSize(level, face); @@ -75,11 +76,10 @@ Size KtxStorage::getMipFaceSize(uint16 level, uint8 face) const { bool KtxStorage::isMipAvailable(uint16 level, uint8 face) const { - return true; auto numLevels = _ktxDescriptor->header.numberOfMipmapLevels; auto minLevel = 7 > numLevels ? 0 : numLevels - 10; auto avail = level >= minLevel; - qDebug() << "isMipAvailable: " << level << " " << face << avail << minLevel << " " << _ktxDescriptor->header.numberOfMipmapLevels; + qDebug() << "isMipAvailable: " << QString::fromStdString(_filename) << ": " << level << " " << face << avail << minLevel << " " << _ktxDescriptor->header.numberOfMipmapLevels; //return true; return level > _ktxDescriptor->header.numberOfMipmapLevels - 7; } diff --git a/libraries/model-networking/src/model-networking/TextureCache.cpp b/libraries/model-networking/src/model-networking/TextureCache.cpp index 706c62c8a1..404c44d454 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.cpp +++ b/libraries/model-networking/src/model-networking/TextureCache.cpp @@ -30,7 +30,6 @@ #include -#include #include @@ -473,9 +472,11 @@ void NetworkTexture::maybeCreateKTX() { _file = file; } + _ktxDescriptor.reset(new ktx::KTXDescriptor(memKtx->toDescriptor())); + //auto texture = gpu::Texture::serializeHeader("test.ktx", *header, keyValues); gpu::TexturePointer texture; - texture.reset(gpu::Texture::unserialize(_file->getFilepath(), memKtx->toDescriptor())); + texture.reset(gpu::Texture::unserialize(_file->getFilepath(), *_ktxDescriptor)); texture->setKtxBacking(file->getFilepath()); // We replace the texture with the one stored in the cache. This deals with the possible race condition of two different @@ -496,6 +497,7 @@ void NetworkTexture::downloadFinished(const QByteArray& data) { void NetworkTexture::loadContent(const QByteArray& content) { if (_sourceIsKTX) { + assert(false); if (_ktxLoadState == LOADING_HEADER) { // TODO Handle case where we already have the source hash texture on disk // TODO Handle case where data isn't as large as the ktx header diff --git a/libraries/model-networking/src/model-networking/TextureCache.h b/libraries/model-networking/src/model-networking/TextureCache.h index 3998ba3408..a86c20c145 100644 --- a/libraries/model-networking/src/model-networking/TextureCache.h +++ b/libraries/model-networking/src/model-networking/TextureCache.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "KTXCache.h" @@ -102,6 +103,8 @@ private: ResourceRequest* _ktxMipRequest { nullptr }; QByteArray _ktxHeaderData; QByteArray _ktxHighMipData; + ktx::KTXDescriptorPointer _ktxDescriptor; + int _originalWidth { 0 }; int _originalHeight { 0 }; diff --git a/libraries/procedural/CMakeLists.txt b/libraries/procedural/CMakeLists.txt index 8c66442c59..3ebd0f3d14 100644 --- a/libraries/procedural/CMakeLists.txt +++ b/libraries/procedural/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME procedural) AUTOSCRIBE_SHADER_LIB(gpu model) setup_hifi_library() -link_hifi_libraries(shared gpu gpu-gl networking model model-networking image) +link_hifi_libraries(shared gpu gpu-gl networking model model-networking ktx image) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 7b176a6973..39338fd767 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -16,6 +16,6 @@ if (NOT ANDROID) endif () -link_hifi_libraries(shared networking octree gpu ui procedural model model-networking recording avatars fbx entities controllers animation audio physics image) +link_hifi_libraries(shared networking octree gpu ui procedural model model-networking ktx recording avatars fbx entities controllers animation audio physics image) # ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit include_hifi_library_headers(gl) diff --git a/plugins/openvr/CMakeLists.txt b/plugins/openvr/CMakeLists.txt index 2300a38e56..bc62117e70 100644 --- a/plugins/openvr/CMakeLists.txt +++ b/plugins/openvr/CMakeLists.txt @@ -13,7 +13,7 @@ if (WIN32) setup_hifi_plugin(OpenGL Script Qml Widgets) link_hifi_libraries(shared gl networking controllers ui plugins display-plugins ui-plugins input-plugins script-engine - render-utils model gpu gpu-gl render model-networking fbx image) + render-utils model gpu gpu-gl render model-networking fbx ktx image) include_hifi_library_headers(octree)