From 03be4a7973167cc6e5b48df0b9a38cc399c0b593 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Mon, 6 May 2024 09:22:46 +0100 Subject: [PATCH] RD DXIL Disassembly: decode "dx.op.dot[234]" Example Output %37 = call float @dx.op.dot2.f32(i32 54, float %12, float %15, float %18, float %21) %39 = call float @dx.op.dot3.f32(i32 55, float %18, float %21, float %24, float %27, float %30, float %33) %41 = call float @dx.op.dot4.f32(i32 56, float %27, float %30, float %33, float %36, float %12, float %12, float %12, float %12) Becomes: float _37 = dot({_12, _15}, {_18, _21}); float _39 = dot({_18, _21, _24}, {_27, _30, _33}); float _41 = dot({_27, _30, _33, _36}, {_12, _12, _12, _12}); --- renderdoc/driver/shaders/dxil/dxil_bytecode.h | 3 + .../driver/shaders/dxil/dxil_disassemble.cpp | 57 +++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.h b/renderdoc/driver/shaders/dxil/dxil_bytecode.h index 15f65776d..55cf92133 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.h +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.h @@ -315,6 +315,9 @@ enum class DXOp : uint32_t loadInput = 4, storeInput = 5, UMin = 40, + dot2 = 54, + dot3 = 55, + dot4 = 56, createHandle = 57, cbufferLoad = 59, cbufferLoadLegacy = 59, diff --git a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp index a8ca18361..437405245 100644 --- a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp @@ -2918,6 +2918,63 @@ void Program::MakeRDDisassemblyString(const DXBC::Reflection *reflection) showDxFuncName = true; } } + else if(showDxFuncName && funcCallName.beginsWith("dx.op.dot")) + { + // Dot4(ax,ay,az,aw,bx,by,bz,bw) + // Dot3(ax,ay,az,bx,by,bz) + // Dot2(ax,ay,bx,by) + showDxFuncName = false; + uint32_t dxopCode; + RDCASSERT(getival(inst.args[0], dxopCode)); + uint32_t countComponents = 0; + if(funcCallName.beginsWith("dx.op.dot4")) + { + countComponents = 4; + RDCASSERTEQUAL(dxopCode, (uint32_t)DXOp::dot4); + } + else if(funcCallName.beginsWith("dx.op.dot3")) + { + countComponents = 3; + RDCASSERTEQUAL(dxopCode, (uint32_t)DXOp::dot3); + } + else if(funcCallName.beginsWith("dx.op.dot2")) + { + countComponents = 2; + RDCASSERTEQUAL(dxopCode, (uint32_t)DXOp::dot2); + } + lineStr += "dot("; + lineStr += "{"; + bool needComma = false; + uint32_t aVecStart = 1; + uint32_t aVecEnd = 1 + countComponents; + for(uint32_t a = aVecStart; a < aVecEnd; ++a) + { + if(!isUndef(inst.args[a])) + { + if(needComma) + lineStr += ", "; + lineStr += ArgToString(inst.args[a], false); + needComma = true; + } + } + lineStr += "}"; + needComma = false; + uint32_t bVecStart = aVecEnd; + uint32_t bVecEnd = bVecStart + countComponents; + lineStr += ", {"; + for(uint32_t a = bVecStart; a < bVecEnd; ++a) + { + if(!isUndef(inst.args[a])) + { + if(needComma) + lineStr += ", "; + lineStr += ArgToString(inst.args[a], false); + needComma = true; + } + } + lineStr += "}"; + lineStr += ")"; + } else if(funcCallName.beginsWith("llvm.dbg.")) { }