From 32843133993c7350d4108a8c39f5b3072bb20c6d Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Tue, 27 Oct 2020 01:19:22 +0100 Subject: [PATCH] Mark font textures as something that shouldn't be downscaled --- libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp | 4 ++-- libraries/gpu/src/gpu/Texture.h | 4 ++++ libraries/render-utils/src/text/Font.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp index 2b9b209c67..af865b3ad7 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp @@ -223,7 +223,7 @@ void GLTextureTransferEngineDefault::updateMemoryPressure() { idealMemoryAllocation += texture->evalTotalSize(); // Track how much we're actually using totalVariableMemoryAllocation += gltexture->size(); - if (vartexture->canDemote()) { + if (!gltexture->_gpuObject.getImportant() && vartexture->canDemote()) { canDemote |= true; } if (vartexture->canPromote()) { @@ -503,7 +503,7 @@ void GLTextureTransferEngineDefault::processDemotes(size_t reliefRequired, const for (const auto& texture : strongTextures) { GLTexture* gltexture = Backend::getGPUObject(*texture); GLVariableAllocationSupport* vargltexture = dynamic_cast(gltexture); - if (vargltexture->canDemote()) { + if (!gltexture->_gpuObject.getImportant() && vargltexture->canDemote()) { demoteQueue.push({ texture, (float)gltexture->size() }); } } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index debedf02a5..54c7d49421 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -571,6 +571,9 @@ public: void setExternalRecycler(const ExternalRecycler& recycler); ExternalRecycler getExternalRecycler() const; + bool getImportant() const { return _important; } + void setImportant(bool important) { _important = important; } + const GPUObjectPointer gpuObject {}; ExternalUpdates getUpdates() const; @@ -632,6 +635,7 @@ protected: bool _autoGenerateMips = false; bool _isIrradianceValid = false; bool _defined = false; + bool _important = false; static TexturePointer create(TextureUsageType usageType, Type type, const Element& texelFormat, uint16 width, uint16 height, uint16 depth, uint16 numSamples, uint16 numSlices, uint16 numMips, const Sampler& sampler); diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index 024be6598d..a30bbad0e5 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -260,6 +260,7 @@ void Font::read(QIODevice& in) { gpu::Sampler(gpu::Sampler::FILTER_MIN_POINT_MAG_LINEAR)); _texture->setStoredMipFormat(formatMip); _texture->assignStoredMip(0, image.sizeInBytes(), image.constBits()); + _texture->setImportant(true); } void Font::setupGPU() {