From 2c67e87c171d4cdcba5888d28b10cd869bd95b54 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 25 Feb 2025 12:35:11 +0000 Subject: [PATCH] Fix handling of out-of-bounds raw buffer loads in DXBC debug --- renderdoc/driver/shaders/dxbc/dxbc_debug.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 3a8efa34a..10aa147ba 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -3510,9 +3510,10 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, fmt.numComps = 4; // clamp to out of bounds based on numElems - fmt.numComps = RDCMIN(fmt.numComps, int(numElems - elemIdx) / 4); + int boundsClampedComps = int(numElems - elemIdx) / 4; + fmt.numComps = RDCMIN(fmt.numComps, boundsClampedComps); - for(int c = 0; c < 4; c++) + for(int c = 0; c < boundsClampedComps; c++) { if(c < fmt.numComps) RDCASSERTEQUAL(op.operands[0].comps[c], c); @@ -3530,7 +3531,7 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper, // apply the swizzle on the resource operand ShaderVariable fetch("", 0U, 0U, 0U, 0U); - for(int c = 0; c < 4; c++) + for(int c = 0; c < fmt.numComps; c++) { uint8_t comp = resComps[c]; if(comp == 0xff)