From c52de6c685ec9186748c7b850acc1eeac46f667a Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 21 Sep 2016 07:34:22 -0700 Subject: [PATCH] Fixing mip deallocation --- .../gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index 886c7b8145..de61952a93 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -476,16 +476,15 @@ void GL45Texture::stripToMip(uint16_t newMinMip) { uint8_t maxFace = (uint8_t)((_target == GL_TEXTURE_CUBE_MAP) ? GLTexture::CUBE_NUM_FACES : 1); for (uint16_t mip = _minMip; mip < newMinMip; ++mip) { + auto id = _id; auto mipDimensions = _gpuObject.evalMipDimensions(mip); - auto deallocatedPages = _sparseInfo.getPageCount(mipDimensions); - for (uint8_t face = 0; face < maxFace; ++face) { - glTexturePageCommitmentEXT(_id, mip, - 0, 0, face, - mipDimensions.x, mipDimensions.y, mipDimensions.z, - GL_FALSE); - assert(deallocatedPages < _allocatedPages); - _allocatedPages -= deallocatedPages; - } + _textureTransferHelper->queueExecution([id, mip, mipDimensions, maxFace] { + glTexturePageCommitmentEXT(id, mip, 0, 0, 0, mipDimensions.x, mipDimensions.y, maxFace, GL_FALSE); + }); + + auto deallocatedPages = _sparseInfo.getPageCount(mipDimensions) * maxFace; + assert(deallocatedPages < _allocatedPages); + _allocatedPages -= deallocatedPages; } _minMip = newMinMip;