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 <eric@anholt.net>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6379>
This commit is contained in:
Jason Ekstrand
2020-08-18 15:30:26 -05:00
committed by Marge Bot
parent bb8d8ba9c7
commit 1bdf850638
4 changed files with 12 additions and 6 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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,

View File

@@ -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);