From e0487f7e0408c6a6fc265f4f81c66c14374254d7 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 22 May 2017 16:51:54 -0700 Subject: [PATCH] Solving the size evaluation for compressed format --- interface/resources/qml/Stats.qml | 10 +++++----- .../gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp | 5 +++-- libraries/gpu/src/gpu/Texture.h | 3 ++- scripts/developer/utilities/render/textureMonitor.qml | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/Stats.qml b/interface/resources/qml/Stats.qml index 7b5c81d683..119f24c71f 100644 --- a/interface/resources/qml/Stats.qml +++ b/interface/resources/qml/Stats.qml @@ -270,17 +270,17 @@ Item { StatText { text: "GPU Textures: "; } - StatText { - text: " Pressure State: " + root.gpuTextureMemoryPressureState; - } StatText { text: " Count: " + root.gpuTextures; } StatText { - text: " Pending Transfer: " + root.texturePendingTransfers + " MB"; + text: " Pressure State: " + root.gpuTextureMemoryPressureState; } StatText { - text: " Resource Allocated/Populated: " + root.gpuTextureResourceMemory + " / " + root.gpuTextureResourcePopulatedMemory + " MB"; + text: " Resource Allocated / Populated / Pending: "; + } + StatText { + text: " " + root.gpuTextureResourceMemory + " / " + root.gpuTextureResourcePopulatedMemory + " / " + root.texturePendingTransfers + " MB"; } StatText { text: " Resident Memory: " + root.gpuTextureResidentMemory + " MB"; diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp index 5bf022d515..1ae3b405c3 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp @@ -42,7 +42,6 @@ GL45VariableAllocationTexture::~GL45VariableAllocationTexture() { void GL45VariableAllocationTexture::incrementPopulatedSize(Size delta) const { _populatedSize += delta; if (_size < _populatedSize) { - Backend::textureResourcePopulatedGPUMemSize.update(0, delta); } else { Backend::textureResourcePopulatedGPUMemSize.update(0, delta); @@ -101,6 +100,9 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) { _size = 0; bool wtf = false; for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) { + if (_gpuObject.evalMipSize(mip) == 0) { + wtf = true; + } _size += _gpuObject.evalMipSize(mip); } Backend::textureResourceGPUMemSize.update(0, _size); @@ -198,7 +200,6 @@ void GL45ResourceTexture::demote() { auto numPopulatedDemoted = _populatedMip - oldPopulatedMip; Size amountUnpopulated = 0; for (int i = 0; i < numPopulatedDemoted; i++) { - //amountUnpopulated += _gpuObject.getStoredMipSize(oldPopulatedMip + i); amountUnpopulated += _gpuObject.evalMipSize(oldPopulatedMip + i); } decrementPopulatedSize(amountUnpopulated); diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index da6071e72a..98a4add3c8 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -429,7 +429,8 @@ public: // // Here are the static function to compute the different sizes from parametered dimensions and format // Tile size must be a power of 2 - static uint16 evalTiledLength(uint16 length, int tile) { return length / tile + ((~length & tile) != 0); } + static uint16 evalTiledPadding(uint16 length, int tile) { int tileMinusOne = (tile - 1); return (tileMinusOne - (length + tileMinusOne) % tile); } + static uint16 evalTiledLength(uint16 length, int tile) { return length / tile + (evalTiledPadding(length, tile) != 0); } static uint16 evalTiledWidth(uint16 width, int tileX) { return evalTiledLength(width, tileX); } static uint16 evalTiledHeight(uint16 height, int tileY) { return evalTiledLength(height, tileY); } static Size evalLineSize(uint16 width, const Element& format) { return evalPaddedSize(evalTiledWidth(width, format.getTile().x) * format.getSize()); } diff --git a/scripts/developer/utilities/render/textureMonitor.qml b/scripts/developer/utilities/render/textureMonitor.qml index d29db439c9..97cc577ff9 100644 --- a/scripts/developer/utilities/render/textureMonitor.qml +++ b/scripts/developer/utilities/render/textureMonitor.qml @@ -49,7 +49,7 @@ Item { { prop: "textureResidentGPUMemSize", label: "Resident", - color: "#FF6309" + color: "#A2277C" }, { prop: "textureFramebufferGPUMemSize", @@ -69,7 +69,7 @@ Item { { prop: "texturePendingGPUTransferSize", label: "Transfer", - color: "#A2277C" + color: "#FF6309" } ] }