[Mesa-dev] [PATCH 08/28] spirv/glsl450: fix reflect(denorm, denorm) FTZ = 0.0 case

Samuel Iglesias Gonsálvez siglesias at igalia.com
Wed Dec 5 15:55:23 UTC 2018


Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/spirv/vtn_glsl450.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 0115648cbb0..69588f56968 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -692,13 +692,18 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
                        src[0], nir_fneg(nb, src[0]));
       return;
 
-   case GLSLstd450Reflect:
+   case GLSLstd450Reflect: {
       /* I - 2 * dot(N, I) * N */
-      val->ssa->def =
+      nir_ssa_def *reflect =
          nir_fsub(nb, src[0], nir_fmul(nb, NIR_IMM_FP(nb, 2.0),
-                              nir_fmul(nb, nir_fdot(nb, src[0], src[1]),
-                                           src[1])));
+                                       nir_fmul(nb, nir_fdot(nb, src[0], src[1]),
+                                                src[1])));
+      nir_ssa_def *zero = NIR_IMM_FP(nb, 0.0);
+      val->ssa->def = nir_bcsel(nb, nir_iand(nb,
+                                            nir_feq(nb, src[0], zero),
+                                            nir_feq(nb, src[1], zero)), zero, reflect);
       return;
+   }
 
    case GLSLstd450Refract: {
       nir_ssa_def *I = src[0];
-- 
2.19.1



More information about the mesa-dev mailing list