From 6d428669d5c6b50c8d38df3ee790087870afecc4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 21 Feb 2017 10:21:48 +0000 Subject: [PATCH] Follow up to c088c9186d1 - opcodes can shift by scalar or component-wise --- renderdoc/driver/shaders/dxbc/dxbc_debug.cpp | 70 +++++++++++++++----- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 80d0ab157..72360b7df 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -1521,13 +1521,6 @@ State State::GetNext(GlobalState &global, State quad[4]) const break; } - case OPCODE_ISHL: - s.SetDst(op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x << (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.y << (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.z << (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.w << (srcOpers[1].value.u.x & 0x1f))); - break; case OPCODE_IBFE: { // bottom 5 bits @@ -1617,20 +1610,63 @@ State State::GetNext(GlobalState &global, State quad[4]) const s.SetDst(op.operands[0], op, dest); break; } + case OPCODE_ISHL: + { + uint32_t shifts[] = { + srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, + srcOpers[1].value.u.w & 0x1f, + }; + + // if we were only given a single component, it's the form that shifts all components + // by the same amount + if(op.operands[2].numComponents == NUMCOMPS_1 || + (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) + shifts[3] = shifts[2] = shifts[1] = shifts[0]; + + s.SetDst( + op.operands[0], op, + ShaderVariable("", srcOpers[0].value.i.x << shifts[0], srcOpers[0].value.i.y << shifts[1], + srcOpers[0].value.i.z << shifts[2], srcOpers[0].value.i.w << shifts[3])); + break; + } case OPCODE_USHR: - s.SetDst(op.operands[0], op, - ShaderVariable("", srcOpers[0].value.u.x >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.u.y >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.u.z >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.u.w >> (srcOpers[1].value.u.x & 0x1f))); + { + uint32_t shifts[] = { + srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, + srcOpers[1].value.u.w & 0x1f, + }; + + // if we were only given a single component, it's the form that shifts all components + // by the same amount + if(op.operands[2].numComponents == NUMCOMPS_1 || + (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) + shifts[3] = shifts[2] = shifts[1] = shifts[0]; + + s.SetDst( + op.operands[0], op, + ShaderVariable("", srcOpers[0].value.u.x >> shifts[0], srcOpers[0].value.u.y >> shifts[1], + srcOpers[0].value.u.z >> shifts[2], srcOpers[0].value.u.w >> shifts[3])); break; + } case OPCODE_ISHR: - s.SetDst(op.operands[0], op, - ShaderVariable("", srcOpers[0].value.i.x >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.y >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.z >> (srcOpers[1].value.u.x & 0x1f), - srcOpers[0].value.i.w >> (srcOpers[1].value.u.x & 0x1f))); + { + uint32_t shifts[] = { + srcOpers[1].value.u.x & 0x1f, srcOpers[1].value.u.y & 0x1f, srcOpers[1].value.u.z & 0x1f, + srcOpers[1].value.u.w & 0x1f, + }; + + // if we were only given a single component, it's the form that shifts all components + // by the same amount + if(op.operands[2].numComponents == NUMCOMPS_1 || + (op.operands[2].comps[2] < 4 && op.operands[2].comps[2] == 0xff)) + shifts[3] = shifts[2] = shifts[1] = shifts[0]; + + s.SetDst( + op.operands[0], op, + ShaderVariable("", srcOpers[0].value.i.x >> shifts[0], srcOpers[0].value.i.y >> shifts[1], + srcOpers[0].value.i.z >> shifts[2], srcOpers[0].value.i.w >> shifts[3])); break; + } case OPCODE_AND: s.SetDst(op.operands[0], op, ShaderVariable("", srcOpers[0].value.i.x & srcOpers[1].value.i.x, srcOpers[0].value.i.y & srcOpers[1].value.i.y,