From f0644a2257ef519298672a2f6a876955e5f18071 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 9 Nov 2022 14:15:15 +0000 Subject: [PATCH] Fix issue where multiple thumbnails would be added for overlapping binds * Previously we iterated over each bind, and found the matching resources. Now we iterate over resources and find the matching bind. This matters when there are multiple overlapping binds so they are only found once (we don't disambguate which bind was used, as we don't elsewhere currently) --- qrenderdoc/Windows/TextureViewer.cpp | 35 ++++++++++------------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index bf0b3e020..234c05c65 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -2457,23 +2457,18 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage, ThumbnailStrip *prevs, int &prevIndex, bool copy, bool rw) { - for(int idx = 0; idx < mapping.count(); idx++) + for(int residx = 0; residx < ResList.count(); residx++) { - const Bindpoint &key = mapping[idx]; + const rdcarray &resArray = ResList[residx].resources; + uint32_t dynamicallyUsedResCount = ResList[residx].dynamicallyUsedCount; + int32_t firstIndex = ResList[residx].firstIndex; + int arrayLen = resArray.count(); - const rdcarray *resArray = NULL; - uint32_t dynamicallyUsedResCount = 1; - int32_t firstIndex = 0; + int idx = mapping.indexOf(ResList[residx].bindPoint); - int residx = ResList.indexOf(key); - if(residx >= 0) - { - resArray = &ResList[residx].resources; - dynamicallyUsedResCount = ResList[residx].dynamicallyUsedCount; - firstIndex = ResList[residx].firstIndex; - } - - int arrayLen = resArray != NULL ? resArray->count() : 1; + // don't display thumbnails for resources that are not bound + if(idx < 0) + continue; const bool collapseArray = arrayLen > 8 && dynamicallyUsedResCount > 20; @@ -2481,22 +2476,16 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage, { int arrayIdx = firstIndex + i; - if(resArray && i >= resArray->count()) - break; - - if(resArray && !resArray->at(i).dynamicallyUsed) + if(!resArray[i].dynamicallyUsed) continue; - BoundResource res = {}; - - if(resArray) - res = resArray->at(i); + const BoundResource &res = resArray[i]; Following follow(*this, rw ? FollowType::ReadWrite : FollowType::ReadOnly, stage, idx, arrayIdx); // show if it's referenced by the shader - regardless of empty or not - bool show = key.used || copy; + bool show = mapping[idx].used || copy; // omit buffers even if the shader uses them. if(res.resourceId != ResourceId() && m_Ctx.GetTexture(res.resourceId) == NULL)