diff options
author | Karol Herbst <[email protected]> | 2019-03-20 18:11:20 +0100 |
---|---|---|
committer | Karol Herbst <[email protected]> | 2019-05-04 12:27:51 +0200 |
commit | d11b807da52c0ca3fddb5eae8f99a4f5696b3282 (patch) | |
tree | 6a8a2aa937bda2646e51a32403200697dda7b07f /src/compiler/nir | |
parent | 681fb7ea05d5f77d6a754c27ae938ebcd00cab3b (diff) |
nir: Add nir_op_vec helper
with that we can simplify code where nir vectors are created
v2: merge both lines in nir_vec
Signed-off-by: Karol Herbst <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.h | 12 | ||||
-rw-r--r-- | src/compiler/nir/nir_builder.h | 14 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ed21032e5e1..37161e83e4d 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -862,6 +862,18 @@ nir_get_nir_type_for_glsl_type(const struct glsl_type *type) nir_op nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd); +static inline nir_op +nir_op_vec(unsigned components) +{ + switch (components) { + case 1: return nir_op_imov; + case 2: return nir_op_vec2; + case 3: return nir_op_vec3; + case 4: return nir_op_vec4; + default: unreachable("bad component count"); + } +} + typedef enum { NIR_OP_IS_COMMUTATIVE = (1 << 0), NIR_OP_IS_ASSOCIATIVE = (1 << 1), diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 5f6bb0b1d5a..ced009a66c7 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -489,19 +489,7 @@ nir_build_alu_src_arr(nir_builder *build, nir_op op, nir_ssa_def **srcs) static inline nir_ssa_def * nir_vec(nir_builder *build, nir_ssa_def **comp, unsigned num_components) { - switch (num_components) { - case 4: - return nir_vec4(build, comp[0], comp[1], comp[2], comp[3]); - case 3: - return nir_vec3(build, comp[0], comp[1], comp[2]); - case 2: - return nir_vec2(build, comp[0], comp[1]); - case 1: - return comp[0]; - default: - unreachable("bad component count"); - return NULL; - } + return nir_build_alu_src_arr(build, nir_op_vec(num_components), comp); } /** |