Implement OpIsNan and OpIsInf

This commit is contained in:
baldurk
2020-04-14 18:02:10 +01:00
parent 22dcb1f539
commit 07f60abf9e
2 changed files with 50 additions and 0 deletions
@@ -1111,6 +1111,36 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
SetDst(state, comp.result, var);
break;
}
case Op::IsNan:
{
OpIsNan is(it);
ShaderVariable var = GetSrc(is.x);
for(uint8_t c = 0; c < var.columns; c++)
var.value.uv[c] = isnan(var.value.fv[c]) ? 1 : 0;
// TODO we should add a bool type
var.type = VarType::UInt;
SetDst(state, is.result, var);
break;
}
case Op::IsInf:
{
OpIsNan is(it);
ShaderVariable var = GetSrc(is.x);
for(uint8_t c = 0; c < var.columns; c++)
var.value.uv[c] = isinf(var.value.fv[c]) ? 1 : 0;
// TODO we should add a bool type
var.type = VarType::UInt;
SetDst(state, is.result, var);
break;
}
//////////////////////////////////////////////////////////////////////////////
//
@@ -479,6 +479,26 @@ void main()
Color = fwidthFine(vec4(inpos, inposIncreased));
break;
}
case 52:
{
Color = vec4(isinf(posone) ? 1.0f : 0.0f, isinf(zerof) ? 1.0f : 0.0f, isinf(negone) ? 1.0f : 0.0f, 1.0f);
break;
}
case 53:
{
Color = vec4(isnan(posone) ? 1.0f : 0.0f, isnan(zerof) ? 1.0f : 0.0f, isnan(negone) ? 1.0f : 0.0f, 1.0f);
break;
}
case 54:
{
Color = vec4(isinf(posinf) ? 1.0f : 0.0f, isinf(neginf) ? 1.0f : 0.0f, isinf(nan) ? 1.0f : 0.0f, 1.0f);
break;
}
case 55:
{
Color = vec4(isnan(posinf) ? 1.0f : 0.0f, isnan(neginf) ? 1.0f : 0.0f, isnan(nan) ? 1.0f : 0.0f, 1.0f);
break;
}
default: break;
}
}