From 4a4b48fb057a4812fbc39cc054308818d2a19b32 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 3 Jul 2019 13:00:14 -0700 Subject: [PATCH] nir: Add nir_imm_vec4_16 We already have nir_imm_float16 and nir_imm_vec4; let's add the ability to easily make immediate fp16 vectors as well, now that fp16 support is maturing in NIR/GLSL. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Matt Turner --- src/compiler/nir/nir_builder.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index cef84a8914e..dbeec08b97e 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -318,6 +318,20 @@ nir_imm_vec4(nir_builder *build, float x, float y, float z, float w) return nir_build_imm(build, 4, 32, v); } +static inline nir_ssa_def * +nir_imm_vec4_16(nir_builder *build, float x, float y, float z, float w) +{ + nir_const_value v[4]; + + memset(v, 0, sizeof(v)); + v[0].u16 = _mesa_float_to_half(x); + v[1].u16 = _mesa_float_to_half(y); + v[2].u16 = _mesa_float_to_half(z); + v[3].u16 = _mesa_float_to_half(w); + + return nir_build_imm(build, 4, 16, v); +} + static inline nir_ssa_def * nir_imm_ivec2(nir_builder *build, int x, int y) { -- 2.30.2