DXIL Debugger flesh out DXOp::Round* support

This commit is contained in:
Jake Turner
2024-10-24 14:20:00 +01:00
parent d3fdc3c18f
commit 0e4f8e2e09
3 changed files with 37 additions and 8 deletions
@@ -386,6 +386,16 @@ float round_ne(float x)
return x - rem;
}
double round_ne(double x)
{
if(!RDCISFINITE(x))
return x;
double rem = remainder(x, 1.0);
return x - rem;
}
float flush_denorm(const float f)
{
uint32_t x;
+1
View File
@@ -114,6 +114,7 @@ double dxbc_min(double a, double b);
float dxbc_max(float a, float b);
double dxbc_max(double a, double b);
float round_ne(float x);
double round_ne(double x);
float flush_denorm(const float f);
void get_sample_position(uint32_t sampleIndex, uint32_t sampleCount, float *position);
+26 -8
View File
@@ -1796,24 +1796,42 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
{
ShaderVariable arg;
RDCASSERT(GetShaderVariable(inst.args[1], opCode, dxOpCode, arg));
// TODO: HALF TYPE
// TODO: DOUBLE TYPE
RDCASSERTEQUAL(arg.rows, 1);
RDCASSERTEQUAL(arg.columns, 1);
RDCASSERTEQUAL(arg.type, VarType::Float);
const uint32_t c = 0;
if(dxOpCode == DXOp::Round_pi)
{
// Round_pi(value) : positive infinity -> ceil()
result.value.f32v[0] = ceilf(arg.value.f32v[0]);
#undef _IMPL
#define _IMPL(T) comp<T>(result, c) = ceil(comp<T>(arg, c));
IMPL_FOR_FLOAT_TYPES_FOR_TYPE(_IMPL, arg.type);
}
else if(dxOpCode == DXOp::Round_ne)
{
// Round_ne(value) : to nearest even int (banker's rounding)
result.value.f32v[0] = round_ne(arg.value.f32v[0]);
#undef _IMPL
#define _IMPL(T) comp<T>(result, c) = round_ne(comp<T>(arg, c));
IMPL_FOR_FLOAT_TYPES_FOR_TYPE(_IMPL, arg.type);
}
else if(dxOpCode == DXOp::Round_ni)
{
// Round_ni(value) : negative infinity -> floor()
result.value.f32v[0] = floorf(arg.value.f32v[0]);
#undef _IMPL
#define _IMPL(T) comp<T>(result, c) = floor(comp<T>(arg, c));
IMPL_FOR_FLOAT_TYPES_FOR_TYPE(_IMPL, arg.type);
}
else if(dxOpCode == DXOp::Round_z)
{
// Round_z(value) : towards zero
result.value.f32v[0] =
arg.value.f32v[0] < 0 ? ceilf(arg.value.f32v[0]) : floorf(arg.value.f32v[0]);
#undef _IMPL
#define _IMPL(T) \
comp<T>(result, c) = comp<T>(arg, c) < 0.0 ? ceil(comp<T>(arg, c)) : floor(comp<T>(arg, c));
IMPL_FOR_FLOAT_TYPES_FOR_TYPE(_IMPL, arg.type);
}
break;
}
case DXOp::FAbs: