out->tag_write_disable = true;
/* Late sysval lowering creates large loads. Load lowering creates unpacks */
- NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes,
- nir_var_mem_ssbo | nir_var_mem_constant |
- nir_var_mem_task_payload | nir_var_shader_temp |
- nir_var_function_temp | nir_var_mem_global |
- nir_var_mem_shared,
- mem_access_size_align_cb, NULL);
+ nir_lower_mem_access_bit_sizes_options lower_mem_access_options = {
+ .modes = nir_var_mem_ssbo | nir_var_mem_constant |
+ nir_var_mem_task_payload | nir_var_shader_temp |
+ nir_var_function_temp | nir_var_mem_global | nir_var_mem_shared,
+ .callback = mem_access_size_align_cb,
+ };
+ NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes, &lower_mem_access_options);
NIR_PASS_V(nir, nir_lower_pack);
/* Late blend lowering creates vectors */
bool offset_is_const,
const void *cb_data);
+typedef struct {
+ nir_lower_mem_access_bit_sizes_cb callback;
+ nir_variable_mode modes;
+ void *cb_data;
+} nir_lower_mem_access_bit_sizes_options;
+
bool nir_lower_mem_access_bit_sizes(nir_shader *shader,
- nir_variable_mode modes,
- nir_lower_mem_access_bit_sizes_cb cb,
- const void *cb_data);
+ const nir_lower_mem_access_bit_sizes_options *options);
typedef bool (*nir_should_vectorize_mem_func)(unsigned align_mul,
unsigned align_offset,
return true;
}
-struct lower_mem_access_state {
- nir_variable_mode modes;
- nir_lower_mem_access_bit_sizes_cb cb;
- const void *cb_data;
-};
-
static nir_variable_mode
intrin_to_variable_mode(nir_intrinsic_op intrin)
{
static bool
lower_mem_access_instr(nir_builder *b, nir_instr *instr, void *_data)
{
- struct lower_mem_access_state *state = _data;
+ const nir_lower_mem_access_bit_sizes_options *state = _data;
if (instr->type != nir_instr_type_intrinsic)
return false;
case nir_intrinsic_load_shared:
case nir_intrinsic_load_scratch:
case nir_intrinsic_load_task_payload:
- return lower_mem_load(b, intrin, state->cb, state->cb_data);
+ return lower_mem_load(b, intrin, state->callback, state->cb_data);
case nir_intrinsic_store_global:
case nir_intrinsic_store_ssbo:
case nir_intrinsic_store_shared:
case nir_intrinsic_store_scratch:
case nir_intrinsic_store_task_payload:
- return lower_mem_store(b, intrin, state->cb, state->cb_data);
+ return lower_mem_store(b, intrin, state->callback, state->cb_data);
default:
return false;
bool
nir_lower_mem_access_bit_sizes(nir_shader *shader,
- nir_variable_mode modes,
- nir_lower_mem_access_bit_sizes_cb cb,
- const void *cb_data)
+ const nir_lower_mem_access_bit_sizes_options *options)
{
- struct lower_mem_access_state state = {
- .modes = modes,
- .cb = cb,
- .cb_data = cb_data
- };
-
return nir_shader_instructions_pass(shader, lower_mem_access_instr,
nir_metadata_block_index |
nir_metadata_dominance,
- (void *)&state);
+ (void *)options);
}
}
}
- OPT(nir_lower_mem_access_bit_sizes,
- nir_var_mem_ssbo |
- nir_var_mem_constant |
- nir_var_mem_task_payload |
- nir_var_shader_temp |
- nir_var_function_temp |
- nir_var_mem_global |
- nir_var_mem_shared,
- get_mem_access_size_align, NULL);
+ nir_lower_mem_access_bit_sizes_options mem_access_options = {
+ .modes = nir_var_mem_ssbo |
+ nir_var_mem_constant |
+ nir_var_mem_task_payload |
+ nir_var_shader_temp |
+ nir_var_function_temp |
+ nir_var_mem_global |
+ nir_var_mem_shared,
+ .callback = get_mem_access_size_align,
+ };
+ OPT(nir_lower_mem_access_bit_sizes, &mem_access_options);
while (progress) {
progress = false;
NIR_PASS_V(nir, pan_nir_lower_store_component);
}
- NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes,
- nir_var_mem_ubo | nir_var_mem_ssbo | nir_var_mem_constant |
- nir_var_mem_task_payload | nir_var_shader_temp |
- nir_var_function_temp | nir_var_mem_global |
- nir_var_mem_shared,
- mem_access_size_align_cb, NULL);
+ nir_lower_mem_access_bit_sizes_options mem_size_options = {
+ .modes = nir_var_mem_ubo | nir_var_mem_ssbo | nir_var_mem_constant |
+ nir_var_mem_task_payload | nir_var_shader_temp |
+ nir_var_function_temp | nir_var_mem_global | nir_var_mem_shared,
+ .callback = mem_access_size_align_cb,
+ };
+ NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes, &mem_size_options);
NIR_PASS_V(nir, nir_lower_ssbo);
NIR_PASS_V(nir, pan_lower_sample_pos);