mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 06:56:40 +00:00
Implement indexable temps in shader debugging.
* These often come up when you have an inline array that are dynamically indexed into (e.g. an array of offsets in a poisson disk used in a loop that isn't unrolled).
This commit is contained in:
@@ -520,8 +520,21 @@ void State::Init()
|
||||
|
||||
registers[t] = ShaderVariable(buf, 0l, 0l, 0l, 0l);
|
||||
}
|
||||
}
|
||||
if(dxbc->m_Declarations[i].declaration == OPCODE_DCL_INDEXABLE_TEMP)
|
||||
{
|
||||
if(indexableTemps.size() <= dxbc->m_Declarations[i].tempReg)
|
||||
indexableTemps.resize(dxbc->m_Declarations[i].tempReg+1);
|
||||
|
||||
break;
|
||||
indexableTemps[dxbc->m_Declarations[i].tempReg].resize(dxbc->m_Declarations[i].numTemps);
|
||||
for(uint32_t t=0; t < dxbc->m_Declarations[i].numTemps; t++)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
|
||||
StringFormat::snprintf(buf, 63, "x%u[%u]", dxbc->m_Declarations[i].tempReg, t);
|
||||
|
||||
indexableTemps[dxbc->m_Declarations[i].tempReg][t] = ShaderVariable(buf, 0l, 0l, 0l, 0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -534,19 +547,58 @@ bool State::Finished()
|
||||
void State::SetDst(const ASMOperand &dstoper, const ASMOperation &op, const ShaderVariable &val)
|
||||
{
|
||||
ShaderVariable *v = NULL;
|
||||
|
||||
uint32_t indices[4];
|
||||
|
||||
RDCASSERT(dstoper.indices.size() <= 4);
|
||||
|
||||
for(size_t i=0; i < dstoper.indices.size(); i++)
|
||||
{
|
||||
if(dstoper.indices[i].absolute)
|
||||
indices[i] = (uint32_t)dstoper.indices[i].index;
|
||||
else
|
||||
indices[i] = 0;
|
||||
|
||||
if(dstoper.indices[i].relative)
|
||||
{
|
||||
ShaderVariable idx = GetSrc(dstoper.indices[i].operand, op);
|
||||
|
||||
indices[i] += idx.value.i.x;
|
||||
}
|
||||
}
|
||||
|
||||
switch(dstoper.type)
|
||||
{
|
||||
case TYPE_TEMP:
|
||||
{
|
||||
RDCASSERT(dstoper.indices[0].index < (uint32_t)registers.count);
|
||||
v = ®isters[(size_t)dstoper.indices[0].index];
|
||||
RDCASSERT(indices[0] < (uint32_t)registers.count);
|
||||
if(indices[0] < (uint32_t)registers.count)
|
||||
v = ®isters[(size_t)indices[0]];
|
||||
break;
|
||||
}
|
||||
case TYPE_INDEXABLE_TEMP:
|
||||
{
|
||||
RDCASSERT(dstoper.indices.size() == 2);
|
||||
|
||||
if(dstoper.indices.size() == 2)
|
||||
{
|
||||
RDCASSERT(indices[0] < (uint32_t)indexableTemps.size());
|
||||
if(indices[0] < (uint32_t)indexableTemps.size())
|
||||
{
|
||||
RDCASSERT(indices[1] < (uint32_t)indexableTemps[ indices[0] ].size());
|
||||
if(indices[1] < (uint32_t)indexableTemps[ indices[0] ].size())
|
||||
{
|
||||
v = &indexableTemps[ indices[0] ][ indices[1] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_OUTPUT:
|
||||
{
|
||||
RDCASSERT(dstoper.indices[0].index < (uint32_t)outputs.count);
|
||||
v = &outputs[(size_t)dstoper.indices[0].index];
|
||||
RDCASSERT(indices[0] < (uint32_t)outputs.count);
|
||||
if(indices[0] < (uint32_t)outputs.count)
|
||||
v = &outputs[(size_t)indices[0]];
|
||||
break;
|
||||
}
|
||||
case TYPE_INPUT:
|
||||
@@ -706,6 +758,24 @@ ShaderVariable State::GetSrc(const ASMOperand &oper, const ASMOperation &op) con
|
||||
|
||||
break;
|
||||
}
|
||||
case TYPE_INDEXABLE_TEMP:
|
||||
{
|
||||
RDCASSERT(oper.indices.size() == 2);
|
||||
|
||||
if(oper.indices.size() == 2)
|
||||
{
|
||||
RDCASSERT(indices[0] < (uint32_t)indexableTemps.size());
|
||||
if(indices[0] < (uint32_t)indexableTemps.size())
|
||||
{
|
||||
RDCASSERT(indices[1] < (uint32_t)indexableTemps[ indices[0] ].size());
|
||||
if(indices[1] < (uint32_t)indexableTemps[ indices[0] ].size())
|
||||
{
|
||||
v = s = indexableTemps[ indices[0] ][ indices[1] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TYPE_INPUT:
|
||||
{
|
||||
RDCASSERT(indices[0] < (uint32_t)trace->inputs.count);
|
||||
|
||||
@@ -141,6 +141,8 @@ class State : public ShaderDebugState
|
||||
|
||||
VarType OperationType(const DXBC::OpcodeType &op) const;
|
||||
|
||||
vector< vector<ShaderVariable> > indexableTemps;
|
||||
|
||||
DXBC::DXBCFile *dxbc;
|
||||
const ShaderDebugTrace *trace;
|
||||
WrappedID3D11Device *device;
|
||||
|
||||
Reference in New Issue
Block a user