diff options
author | Jason Ekstrand <jason@jlekstrand.net> | 2020-07-14 13:27:53 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-07-22 23:43:35 +0000 |
commit | c475e29be4f81b3bef8b55b1bc78023fdfdf26bb (patch) | |
tree | b8e61ad9c18ec54e0dd986f3d2297b82f94f9856 | |
parent | 0338db5e6b0f81bec7703fbce45b387d20143229 (diff) |
nir: Allow for system values with variable numbers of destination components
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5927>
-rw-r--r-- | src/compiler/nir/nir_builder_opcodes_h.py | 16 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_system_values.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_nir_lower_blend.c | 4 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_builder_opcodes_h.py b/src/compiler/nir/nir_builder_opcodes_h.py index ec212f4e309..2c37be7c20e 100644 --- a/src/compiler/nir/nir_builder_opcodes_h.py +++ b/src/compiler/nir/nir_builder_opcodes_h.py @@ -53,12 +53,17 @@ nir_${name}(nir_builder *build, ${src_decl_list(opcode.num_inputs)}) /* Generic builder for system values. */ static inline nir_ssa_def * nir_load_system_value(nir_builder *build, nir_intrinsic_op op, int index, - unsigned bit_size) + unsigned num_components, unsigned bit_size) { nir_intrinsic_instr *load = nir_intrinsic_instr_create(build->shader, op); + if (nir_intrinsic_infos[op].dest_components > 0) + assert(num_components == nir_intrinsic_infos[op].dest_components); + else + load->num_components = num_components; load->const_index[0] = index; + nir_ssa_dest_init(&load->instr, &load->dest, - nir_intrinsic_infos[op].dest_components, bit_size, NULL); + num_components, bit_size, NULL); nir_builder_instr_insert(build, &load->instr); return &load->dest.ssa; } @@ -68,6 +73,8 @@ def sysval_decl_list(opcode): res = '' if opcode.indices: res += ', unsigned ' + opcode.indices[0].lower() + if opcode.dest_components == 0: + res += ', unsigned num_components' if len(opcode.bit_sizes) != 1: res += ', unsigned bit_size' return res @@ -79,6 +86,11 @@ def sysval_arg_list(opcode): else: args.append('0') + if opcode.dest_components == 0: + args.append('num_components') + else: + args.append(str(opcode.dest_components)) + if len(opcode.bit_sizes) == 1: bit_size = opcode.bit_sizes[0] args.append(str(bit_size)) diff --git a/src/compiler/nir/nir_lower_system_values.c b/src/compiler/nir/nir_lower_system_values.c index bc9d23cf52d..bdc337aecfc 100644 --- a/src/compiler/nir/nir_lower_system_values.c +++ b/src/compiler/nir/nir_lower_system_values.c @@ -305,6 +305,7 @@ lower_system_value_instr(nir_builder *b, nir_instr *instr, void *_state) nir_intrinsic_op sysval_op = nir_intrinsic_from_system_value(var->data.location); return nir_load_system_value(b, sysval_op, 0, + intrin->dest.ssa.num_components, intrin->dest.ssa.bit_size); } diff --git a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c index c915b8c5089..192abe99291 100644 --- a/src/gallium/drivers/vc4/vc4_nir_lower_blend.c +++ b/src/gallium/drivers/vc4/vc4_nir_lower_blend.c @@ -100,7 +100,7 @@ vc4_blend_channel_f(nir_builder *b, return nir_load_system_value(b, nir_intrinsic_load_blend_const_color_r_float + channel, - 0, 32); + 0, 1, 32); case PIPE_BLENDFACTOR_CONST_ALPHA: return nir_load_blend_const_color_a_float(b); case PIPE_BLENDFACTOR_ZERO: @@ -118,7 +118,7 @@ vc4_blend_channel_f(nir_builder *b, nir_load_system_value(b, nir_intrinsic_load_blend_const_color_r_float + channel, - 0, 32)); + 0, 1, 32)); case PIPE_BLENDFACTOR_INV_CONST_ALPHA: return nir_fsub(b, nir_imm_float(b, 1.0), nir_load_blend_const_color_a_float(b)); |