nir/spirv/glsl450: Implement FaceForward built-in.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 29 Dec 2015 07:59:32 +0000 (23:59 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 29 Dec 2015 23:27:03 +0000 (15:27 -0800)
src/glsl/nir/spirv/vtn_glsl450.c

index 1b7751a6a887560e660f1dabd6d85691e543e25c..f81f16789beff109cf33aaf588e000aba7f1172e 100644 (file)
@@ -190,6 +190,13 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
       return;
    }
 
+   case GLSLstd450FaceForward:
+      val->ssa->def =
+         nir_bcsel(nb, nir_flt(nb, nir_fdot(nb, src[2], src[1]),
+                                   nir_imm_float(nb, 0.0)),
+                       src[0], nir_fneg(nb, src[0]));
+      return;
+
    case GLSLstd450Asin:
    case GLSLstd450Acos:
    case GLSLstd450Atan:
@@ -203,7 +210,6 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
    case GLSLstd450Frexp:
    case GLSLstd450PackDouble2x32:
    case GLSLstd450UnpackDouble2x32:
-   case GLSLstd450FaceForward:
    case GLSLstd450Reflect:
    case GLSLstd450Refract:
    case GLSLstd450IMix: