Guard against integer division by zero

* The SPIR-V spec doesn't state what will happen, only that it's undefined. For
  the sake of something sensible (and because it has a good chance of matching
  at least some hardware) we use D3D's behaviour and set the value to 0xFFFFFFFF
This commit is contained in:
baldurk
2020-04-01 17:38:44 +01:00
parent 53ca92965d
commit 528a0c5f5e
+12 -2
View File
@@ -783,12 +783,22 @@ void ThreadState::StepNext(ShaderDebugState *state,
else if(opdata.op == Op::SDiv)
{
for(uint8_t c = 0; c < var.columns; c++)
var.value.iv[c] /= b.value.iv[c];
{
if(b.value.uv[c] == 0)
var.value.uv[c] = ~0U;
else
var.value.iv[c] /= b.value.iv[c];
}
}
else if(opdata.op == Op::UDiv)
{
for(uint8_t c = 0; c < var.columns; c++)
var.value.uv[c] /= b.value.uv[c];
{
if(b.value.uv[c] == 0)
var.value.uv[c] = ~0U;
else
var.value.uv[c] /= b.value.uv[c];
}
}
else if(opdata.op == Op::IAdd)
{