summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2015-06-18 17:34:55 -0700
committerConnor Abbott <[email protected]>2015-06-18 17:34:55 -0700
commit22854a60efc3ee2442b9150e2bf328e7441d6794 (patch)
tree58d274d526943e30b4210a72636702939f6dcf88 /src/glsl
parent0e86ab7c0a438d86c2177a0e02847798ef81e343 (diff)
nir/builder: add a nir_fdot() convenience function
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/nir_builder.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h
index 9223e838095..cffe38abf0e 100644
--- a/src/glsl/nir/nir_builder.h
+++ b/src/glsl/nir/nir_builder.h
@@ -240,6 +240,23 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
nir_imov_alu(build, alu_src, num_components);
}
+/* Selects the right fdot given the number of components in each source. */
+static inline nir_ssa_def *
+nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1)
+{
+ assert(src0->num_components == src1->num_components);
+ switch (src0->num_components) {
+ case 1: return nir_fmul(build, src0, src1);
+ case 2: return nir_fdot2(build, src0, src1);
+ case 3: return nir_fdot3(build, src0, src1);
+ case 4: return nir_fdot4(build, src0, src1);
+ default:
+ unreachable("bad component size");
+ }
+
+ return NULL;
+}
+
/**
* Turns a nir_src into a nir_ssa_def * so it can be passed to
* nir_build_alu()-based builder calls.