Skip to content

Commit

Permalink
DXIL Debugger support for ptr cast instructions
Browse files Browse the repository at this point in the history
PtrToI
IToPtr
  • Loading branch information
Zorro666 committed Oct 17, 2024
1 parent 6a931a4 commit cd72381
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
41 changes: 41 additions & 0 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2496,6 +2496,7 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
}
case Operation::Bitcast:
{
RDCASSERTEQUAL(retType->bitWidth, inst.args[0]->type->bitWidth);
ShaderVariable a;
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, a));
result.value = a.value;
Expand Down Expand Up @@ -3128,7 +3129,47 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
break;
}
case Operation::PtrToI:
{
RDCASSERTEQUAL(inst.args[0]->type->type, Type::TypeKind::Pointer);
RDCASSERTEQUAL(inst.args[0]->type->scalarType, Type::Int);
RDCASSERTEQUAL(retType->type, Type::TypeKind::Scalar);
RDCASSERTEQUAL(retType->scalarType, Type::Int);
ShaderVariable a;
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, a));
const uint32_t c = 0;
uint64_t x = 0;

#undef _IMPL
#define _IMPL(I, S, U) x = comp<U>(a, c);
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);

#undef _IMPL
#define _IMPL(I, S, U) comp<U>(result, c) = (U)x;
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, result.type);

break;
}
case Operation::IToPtr:
{
RDCASSERTEQUAL(inst.args[0]->type->type, Type::TypeKind::Scalar);
RDCASSERTEQUAL(inst.args[0]->type->scalarType, Type::Int);
RDCASSERTEQUAL(retType->type, Type::TypeKind::Pointer);
RDCASSERTEQUAL(retType->scalarType, Type::Int);
ShaderVariable a;
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, a));
const uint32_t c = 0;
uint64_t x = 0;

#undef _IMPL
#define _IMPL(I, S, U) x = comp<U>(a, c);
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, a.type);

#undef _IMPL
#define _IMPL(I, S, U) comp<U>(result, c) = (U)x;
IMPL_FOR_INT_TYPES_FOR_TYPE(_IMPL, result.type);

break;
}
case Operation::AddrSpaceCast:
case Operation::ExtractElement:
case Operation::InsertElement:
Expand Down
2 changes: 0 additions & 2 deletions renderdoc/driver/shaders/dxil/dxil_reflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,8 +1768,6 @@ rdcstr Program::GetDebugStatus()
{
switch(inst->op)
{
case Operation::PtrToI:
case Operation::IToPtr:
case Operation::AddrSpaceCast:
case Operation::ExtractElement:
case Operation::InsertElement:
Expand Down

0 comments on commit cd72381

Please sign in to comment.