spirv: Fix SpvOpFwidth, SpvOpFwidthFine and SpvOpFwidthCoarse
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Wed, 17 Feb 2016 23:28:52 +0000 (15:28 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Wed, 17 Feb 2016 23:28:52 +0000 (15:28 -0800)
   "Result is the same as computing the sum of the absolute values of
    OpDPdx and OpDPdy on P."

We were doing sum of absolute values of OpDPdx of P and OpDPdx of NULL.

src/compiler/nir/spirv/vtn_alu.c

index d866da7445e16d4e5709cde8762e362b452e78fc..450bc158be9fa874e3dfbd90f9a0932feddf55fb 100644 (file)
@@ -404,17 +404,17 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
    case SpvOpFwidth:
       val->ssa->def = nir_fadd(&b->nb,
                                nir_fabs(&b->nb, nir_fddx(&b->nb, src[0])),
-                               nir_fabs(&b->nb, nir_fddx(&b->nb, src[1])));
+                               nir_fabs(&b->nb, nir_fddy(&b->nb, src[0])));
       return;
    case SpvOpFwidthFine:
       val->ssa->def = nir_fadd(&b->nb,
                                nir_fabs(&b->nb, nir_fddx_fine(&b->nb, src[0])),
-                               nir_fabs(&b->nb, nir_fddx_fine(&b->nb, src[1])));
+                               nir_fabs(&b->nb, nir_fddy_fine(&b->nb, src[0])));
       return;
    case SpvOpFwidthCoarse:
       val->ssa->def = nir_fadd(&b->nb,
                                nir_fabs(&b->nb, nir_fddx_coarse(&b->nb, src[0])),
-                               nir_fabs(&b->nb, nir_fddx_coarse(&b->nb, src[1])));
+                               nir_fabs(&b->nb, nir_fddy_coarse(&b->nb, src[0])));
       return;
 
    case SpvOpVectorTimesScalar: