nir/builder: Add a nir_build_ivec4() convenience helper.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 13 Jan 2016 21:32:44 +0000 (13:32 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 15 Jan 2016 05:32:59 +0000 (21:32 -0800)
nir_build_ivec4 is more readable and succinct than using nir_build_imm
directly, even if you have C99.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir_builder.h

index cfaaf8e03e3dd756ede7f7cabaf0559f9987a283..88ba3a1c2697aaaf6178d9bbd22df7629c5fa978 100644 (file)
@@ -120,6 +120,20 @@ nir_imm_int(nir_builder *build, int x)
    return nir_build_imm(build, 1, v);
 }
 
+static inline nir_ssa_def *
+nir_imm_ivec4(nir_builder *build, int x, int y, int z, int w)
+{
+   nir_const_value v;
+
+   memset(&v, 0, sizeof(v));
+   v.i[0] = x;
+   v.i[1] = y;
+   v.i[2] = z;
+   v.i[3] = w;
+
+   return nir_build_imm(build, 4, v);
+}
+
 static inline nir_ssa_def *
 nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0,
               nir_ssa_def *src1, nir_ssa_def *src2, nir_ssa_def *src3)