svga: check for NaN shader immediates
authorBrian Paul <brianp@vmware.com>
Thu, 31 Jan 2013 00:44:25 +0000 (17:44 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 1 Feb 2013 15:00:28 +0000 (08:00 -0700)
The svga device doesn't handle them.  Replace with zeros.
Fixes several piglit tests, such as "glsl-const-builtin-inversesqrt".

Reviewed-by: Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_tgsi_insn.c

index 36ed0089fbac216e587f154a6a070131dde9da79..d439e5b13aa4fbea516fe37b4045fa7377fcb695 100644 (file)
@@ -2716,8 +2716,10 @@ static boolean svga_emit_immediate( struct svga_shader_emitter *emit,
    unsigned i;
 
    assert(1 <= imm->Immediate.NrTokens && imm->Immediate.NrTokens <= 5);
-   for (i = 0; i < imm->Immediate.NrTokens - 1; i++)
-      value[i] = imm->u[i].Float;
+   for (i = 0; i < imm->Immediate.NrTokens - 1; i++) {
+      float f = imm->u[i].Float;
+      value[i] = util_is_inf_or_nan(f) ? 0.0f : f;
+   }
 
    for ( ; i < 4; i++ )
       value[i] = id[i];