From b924f84d8d33cedfdd8e322df38c9d8e424f568e Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 27 Nov 2019 14:37:33 +0000 Subject: [PATCH] Apply swizzle on resource parameter when doing loads. Closes #1619 --- renderdoc/driver/shaders/dxbc/dxbc_debug.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index cddc31171..1eb5407e3 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -2914,6 +2914,8 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua bool load = true; + uint8_t resComps[4] = {0, 1, 2, 3}; + if(op.operation == OPCODE_STORE_UAV_TYPED || op.operation == OPCODE_STORE_RAW || op.operation == OPCODE_STORE_STRUCTURED) { @@ -2930,6 +2932,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua resIndex = (uint32_t)op.operands[3].indices[0].index; srv = (op.operands[3].type == TYPE_RESOURCE); gsm = (op.operands[3].type == TYPE_THREAD_GROUP_SHARED_MEMORY); + memcpy(resComps, op.operands[3].comps, sizeof(resComps)); stride = op.stride; } @@ -2979,6 +2982,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua { resIndex = (uint32_t)op.operands[2].indices[0].index; gsm = (op.operands[2].type == TYPE_THREAD_GROUP_SHARED_MEMORY); + memcpy(resComps, op.operands[2].comps, sizeof(resComps)); } else { @@ -3119,7 +3123,19 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua if(load) { - ShaderVariable fetch = TypedUAVLoad(fmt, data); + ShaderVariable result = TypedUAVLoad(fmt, data); + + // apply the swizzle on the resource operand + ShaderVariable fetch("", 0U, 0U, 0U, 0U); + + for(int c = 0; c < 4; c++) + { + uint8_t comp = resComps[c]; + if(comp == 0xff) + comp = 0; + + fetch.value.uv[c] = result.value.uv[comp]; + } if(op.operation != OPCODE_LD_RAW && op.operation != OPCODE_LD_STRUCTURED) {