Fix ktx dependencies

This commit is contained in:
Ryan Huffman 2017-04-12 17:01:13 -07:00 committed by Atlante45
parent b20fcbfcdb
commit aca7ad27c6
8 changed files with 14 additions and 7 deletions

View file

@ -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;
}

View file

@ -321,6 +321,7 @@ public:
protected:
std::string _filename;
//storage::FileStorage _cacheFile;
ktx::KTXDescriptorPointer _ktxDescriptor;
friend class Texture;
};

View file

@ -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;
}

View file

@ -30,7 +30,6 @@
#include <gpu/Batch.h>
#include <ktx/KTX.h>
#include <image/Image.h>
@ -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

View file

@ -23,6 +23,7 @@
#include <ResourceCache.h>
#include <model/TextureMap.h>
#include <image/Image.h>
#include <ktx/KTX.h>
#include "KTXCache.h"
@ -102,6 +103,8 @@ private:
ResourceRequest* _ktxMipRequest { nullptr };
QByteArray _ktxHeaderData;
QByteArray _ktxHighMipData;
ktx::KTXDescriptorPointer _ktxDescriptor;
int _originalWidth { 0 };
int _originalHeight { 0 };

View file

@ -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)

View file

@ -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)

View file

@ -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)