Skip to content

Commit

Permalink
DXIL Debugger support for float cast instructions
Browse files Browse the repository at this point in the history
FPTrunc
FPExt
  • Loading branch information
Zorro666 committed Oct 16, 2024
1 parent d987baf commit bb87fef
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
41 changes: 39 additions & 2 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3021,6 +3021,45 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
}
break;
}
case Operation::FPTrunc:
case Operation::FPExt:
{
// Result & Value must be Float
const uint32_t srcBitWidth = inst.args[0]->type->bitWidth;
RDCASSERTEQUAL(inst.args[0]->type->type, Type::TypeKind::Scalar);
RDCASSERTEQUAL(inst.args[0]->type->scalarType, Type::Float);
RDCASSERTEQUAL(retType->type, Type::TypeKind::Scalar);
RDCASSERTEQUAL(retType->scalarType, Type::Float);

ShaderVariable a;
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, a));
const uint32_t c = 0;

if(opCode == Operation::FPTrunc)
{
// Result bit_width < Value bit_width
RDCASSERT(retType->bitWidth < srcBitWidth);
}
else if(opCode == Operation::FPExt)
{
// Result bit_width > Value bit_width
RDCASSERT(retType->bitWidth > srcBitWidth);
}
double x = 0.0;

#undef _IMPL
#define _IMPL(T) x = comp<T>(a, c);
IMPL_FOR_FLOAT_TYPES_FOR_TYPE(_IMPL, a.type);

if(result.type == VarType::Float)
comp<float>(result, c) = (float)x;
else if(result.type == VarType::Half)
comp<half_float::half>(result, c) = (float)x;
else if(result.type == VarType::Double)
comp<double>(result, c) = (double)x;

break;
}
case Operation::And:
case Operation::Or:
case Operation::Xor:
Expand Down Expand Up @@ -3055,8 +3094,6 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
result.value.s64v[0] = a.value.s64v[0] << b.value.u64v[0];
break;
}
case Operation::FPTrunc:
case Operation::FPExt:
case Operation::PtrToI:
case Operation::IToPtr:
case Operation::AddrSpaceCast:
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::FPTrunc:
case Operation::FPExt:
case Operation::PtrToI:
case Operation::IToPtr:
case Operation::AddrSpaceCast:
Expand Down

0 comments on commit bb87fef

Please sign in to comment.