From 1bdf8506384fce4c9dc13504e1b3272d1ddc1097 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 18 Aug 2020 15:30:26 -0500 Subject: [PATCH] spirv: Use nir_var_mem_constant for UniformConstant data in CL For now, we leave the constant_as_global option intact and get rid of the UBO path which no one upstream is using today. Reviewed-by: Eric Anholt Reviewed-by: Jesse Natalie Part-of: --- src/compiler/spirv/nir_spirv.h | 1 + src/compiler/spirv/spirv_to_nir.c | 8 ++++---- src/compiler/spirv/vtn_private.h | 1 + src/compiler/spirv/vtn_variables.c | 8 ++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h index 3cbd0269ffe..dd7b5b36996 100644 --- a/src/compiler/spirv/nir_spirv.h +++ b/src/compiler/spirv/nir_spirv.h @@ -78,6 +78,7 @@ struct spirv_to_nir_options { nir_address_format shared_addr_format; nir_address_format global_addr_format; nir_address_format temp_addr_format; + nir_address_format constant_addr_format; /* Whether UniformConstant memory should be treated as normal global memory. * This is usefull for CL 2.0 implementations with fine grain system SVM diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 3a886ce6556..b9f1fae0115 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -4482,8 +4482,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, assert(nir_address_format_bit_size(b->options->shared_addr_format) == 32); assert(nir_address_format_num_components(b->options->shared_addr_format) == 1); if (!b->options->constant_as_global) { - assert(nir_address_format_bit_size(b->options->ubo_addr_format) == 32); - assert(nir_address_format_num_components(b->options->ubo_addr_format) == 1); + assert(nir_address_format_bit_size(b->options->constant_addr_format) == 32); + assert(nir_address_format_num_components(b->options->constant_addr_format) == 1); } break; case SpvAddressingModelPhysical64: @@ -4496,8 +4496,8 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, assert(nir_address_format_bit_size(b->options->shared_addr_format) == 64); assert(nir_address_format_num_components(b->options->shared_addr_format) == 1); if (!b->options->constant_as_global) { - assert(nir_address_format_bit_size(b->options->ubo_addr_format) == 64); - assert(nir_address_format_num_components(b->options->ubo_addr_format) == 1); + assert(nir_address_format_bit_size(b->options->constant_addr_format) == 64); + assert(nir_address_format_num_components(b->options->constant_addr_format) == 1); } break; case SpvAddressingModelLogical: diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index c67d75a6fdd..300fb017257 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -484,6 +484,7 @@ enum vtn_variable_mode { vtn_variable_mode_push_constant, vtn_variable_mode_workgroup, vtn_variable_mode_cross_workgroup, + vtn_variable_mode_constant, vtn_variable_mode_input, vtn_variable_mode_output, vtn_variable_mode_image, diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index df80fca5dae..52c2837e9eb 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1807,8 +1807,8 @@ vtn_storage_class_to_mode(struct vtn_builder *b, mode = vtn_variable_mode_cross_workgroup; nir_mode = nir_var_mem_global; } else { - mode = vtn_variable_mode_ubo; - nir_mode = nir_var_mem_ubo; + mode = vtn_variable_mode_constant; + nir_mode = nir_var_mem_constant; } } else { mode = vtn_variable_mode_uniform; @@ -1885,6 +1885,9 @@ vtn_mode_to_address_format(struct vtn_builder *b, enum vtn_variable_mode mode) case vtn_variable_mode_cross_workgroup: return b->options->global_addr_format; + case vtn_variable_mode_constant: + return b->options->constant_addr_format; + case vtn_variable_mode_function: if (b->physical_ptrs) return b->options->temp_addr_format; @@ -2175,6 +2178,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_private: case vtn_variable_mode_uniform: case vtn_variable_mode_atomic_counter: + case vtn_variable_mode_constant: /* For these, we create the variable normally */ var->var = rzalloc(b->shader, nir_variable); var->var->name = ralloc_strdup(var->var, val->name); -- 2.30.2