From f11e6a067eeee82aed8816c160dd2afb6e619808 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 24 Feb 2020 11:12:48 +0000 Subject: [PATCH] Fix mapping for arrays when element is selected. Closes #1736 --- renderdoc/driver/shaders/dxbc/dxbc_spdb.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_spdb.cpp b/renderdoc/driver/shaders/dxbc/dxbc_spdb.cpp index 09d0672d6..3d85ab882 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_spdb.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_spdb.cpp @@ -1249,8 +1249,9 @@ SPDBChunk::SPDBChunk(void *chunk) varOffset -= vartype->matArrayStride * idx; uint32_t comp = (varOffset % 16) / 4; - // should now be down to a vector, so the remaining offset is the component - RDCASSERT(varOffset < 16); + // should now be down to a vector, so the remaining offset is the component. Unless we had + // multiple indices in which case it's a multi-dimensional array + RDCASSERT(varOffset < 16 || defrange->regIndices > 1); if(vartype->leafType == LF_MATRIX) { @@ -1277,7 +1278,12 @@ SPDBChunk::SPDBChunk(void *chunk) // if this is an array, the index is just the array index. However if we're mapping the // whole array, don't add the index as the mapping will do that for us if(varLen < mapping.var.elements * vartype->matArrayStride) + { mapping.var.name += StringFormat::Fmt("[%u]", idx); + + // we've selected one element in the array, so it's not longer an array + mapping.var.elements = 1; + } } // set the offset explicitly to the component within the final vector we chose (whatever