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});
This commit is contained in:
Jake Turner
2024-05-06 09:22:46 +01:00
parent 0d3c118666
commit 03be4a7973
2 changed files with 60 additions and 0 deletions
@@ -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,
@@ -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<uint32_t>(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."))
{
}