nir: Allow nir_var_mem_global variables
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15486>
This commit is contained in:

committed by
Marge Bot

parent
dc8c77cc8f
commit
80a076382d
@@ -286,11 +286,8 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)
|
||||
case nir_var_shader_call_data:
|
||||
case nir_var_ray_hit_attrib:
|
||||
case nir_var_mem_task_payload:
|
||||
break;
|
||||
|
||||
case nir_var_mem_global:
|
||||
assert(!"nir_shader_add_variable cannot be used for global memory");
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"invalid mode");
|
||||
|
@@ -3614,6 +3614,9 @@ typedef struct nir_shader {
|
||||
*/
|
||||
unsigned num_inputs, num_uniforms, num_outputs;
|
||||
|
||||
/** Size in bytes of required implicitly bound global memory */
|
||||
unsigned global_mem_size;
|
||||
|
||||
/** Size in bytes of required scratch space */
|
||||
unsigned scratch_size;
|
||||
|
||||
|
@@ -806,6 +806,7 @@ system_value("aa_line_width", 1)
|
||||
system_value("scratch_base_ptr", 0, bit_sizes=[32,64], indices=[BASE])
|
||||
system_value("constant_base_ptr", 0, bit_sizes=[32,64])
|
||||
system_value("shared_base_ptr", 0, bit_sizes=[32,64])
|
||||
system_value("global_base_ptr", 0, bit_sizes=[32,64])
|
||||
|
||||
# System values for ray tracing.
|
||||
system_value("ray_launch_id", 3)
|
||||
|
@@ -886,6 +886,7 @@ build_addr_for_var(nir_builder *b, nir_variable *var,
|
||||
{
|
||||
assert(var->data.mode & (nir_var_uniform | nir_var_mem_shared |
|
||||
nir_var_mem_task_payload |
|
||||
nir_var_mem_global |
|
||||
nir_var_shader_temp | nir_var_function_temp |
|
||||
nir_var_mem_push_const | nir_var_mem_constant));
|
||||
|
||||
@@ -913,6 +914,10 @@ build_addr_for_var(nir_builder *b, nir_variable *var,
|
||||
base_addr = nir_load_shared_base_ptr(b, num_comps, bit_size);
|
||||
break;
|
||||
|
||||
case nir_var_mem_global:
|
||||
base_addr = nir_load_global_base_ptr(b, num_comps, bit_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
unreachable("Unsupported variable mode");
|
||||
}
|
||||
@@ -940,6 +945,10 @@ build_addr_for_var(nir_builder *b, nir_variable *var,
|
||||
assert(var->data.driver_location <= UINT32_MAX);
|
||||
return nir_imm_intN_t(b, var->data.driver_location | 1ull << 62, 64);
|
||||
|
||||
case nir_var_mem_global:
|
||||
return nir_iadd_imm(b, nir_load_global_base_ptr(b, num_comps, bit_size),
|
||||
var->data.driver_location);
|
||||
|
||||
default:
|
||||
unreachable("Unsupported variable mode");
|
||||
}
|
||||
@@ -2327,6 +2336,9 @@ lower_vars_to_explicit(nir_shader *shader,
|
||||
case nir_var_mem_task_payload:
|
||||
offset = shader->info.task_payload_size;
|
||||
break;
|
||||
case nir_var_mem_global:
|
||||
offset = shader->global_mem_size;
|
||||
break;
|
||||
case nir_var_mem_constant:
|
||||
offset = shader->constant_data_size;
|
||||
break;
|
||||
@@ -2373,6 +2385,9 @@ lower_vars_to_explicit(nir_shader *shader,
|
||||
case nir_var_mem_task_payload:
|
||||
shader->info.task_payload_size = offset;
|
||||
break;
|
||||
case nir_var_mem_global:
|
||||
shader->global_mem_size = offset;
|
||||
break;
|
||||
case nir_var_mem_constant:
|
||||
shader->constant_data_size = offset;
|
||||
break;
|
||||
@@ -2411,6 +2426,8 @@ nir_lower_vars_to_explicit_types(nir_shader *shader,
|
||||
|
||||
if (modes & nir_var_uniform)
|
||||
progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_uniform, type_info);
|
||||
if (modes & nir_var_mem_global)
|
||||
progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_mem_global, type_info);
|
||||
|
||||
if (modes & nir_var_mem_shared) {
|
||||
assert(!shader->info.shared_memory_explicit_layout);
|
||||
|
@@ -1772,6 +1772,7 @@ nir_validate_shader(nir_shader *shader, const char *when)
|
||||
nir_var_system_value |
|
||||
nir_var_mem_ssbo |
|
||||
nir_var_mem_shared |
|
||||
nir_var_mem_global |
|
||||
nir_var_mem_push_const |
|
||||
nir_var_mem_constant |
|
||||
nir_var_image;
|
||||
|
Reference in New Issue
Block a user