nir/lower_var_copies: Use a shader rather than a void *mem_ctx
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
@@ -2312,7 +2312,7 @@ bool nir_inline_functions(nir_shader *shader);
|
|||||||
|
|
||||||
bool nir_propagate_invariant(nir_shader *shader);
|
bool nir_propagate_invariant(nir_shader *shader);
|
||||||
|
|
||||||
void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, void *mem_ctx);
|
void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, nir_shader *shader);
|
||||||
void nir_lower_var_copies(nir_shader *shader);
|
void nir_lower_var_copies(nir_shader *shader);
|
||||||
|
|
||||||
bool nir_lower_global_vars_to_local(nir_shader *shader);
|
bool nir_lower_global_vars_to_local(nir_shader *shader);
|
||||||
|
@@ -77,7 +77,8 @@ deref_next_wildcard_parent(nir_deref *deref)
|
|||||||
static void
|
static void
|
||||||
emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
||||||
nir_deref_var *dest_head, nir_deref_var *src_head,
|
nir_deref_var *dest_head, nir_deref_var *src_head,
|
||||||
nir_deref *dest_tail, nir_deref *src_tail, void *mem_ctx)
|
nir_deref *dest_tail, nir_deref *src_tail,
|
||||||
|
nir_shader *shader)
|
||||||
{
|
{
|
||||||
/* Find the next pair of wildcards */
|
/* Find the next pair of wildcards */
|
||||||
nir_deref *src_arr_parent = deref_next_wildcard_parent(src_tail);
|
nir_deref *src_arr_parent = deref_next_wildcard_parent(src_tail);
|
||||||
@@ -103,7 +104,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
src_arr->base_offset = i;
|
src_arr->base_offset = i;
|
||||||
dest_arr->base_offset = i;
|
dest_arr->base_offset = i;
|
||||||
emit_copy_load_store(copy_instr, dest_head, src_head,
|
emit_copy_load_store(copy_instr, dest_head, src_head,
|
||||||
&dest_arr->deref, &src_arr->deref, mem_ctx);
|
&dest_arr->deref, &src_arr->deref, shader);
|
||||||
}
|
}
|
||||||
src_arr->deref_array_type = nir_deref_array_type_wildcard;
|
src_arr->deref_array_type = nir_deref_array_type_wildcard;
|
||||||
dest_arr->deref_array_type = nir_deref_array_type_wildcard;
|
dest_arr->deref_array_type = nir_deref_array_type_wildcard;
|
||||||
@@ -119,7 +120,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
unsigned bit_size = glsl_get_bit_size(src_tail->type);
|
unsigned bit_size = glsl_get_bit_size(src_tail->type);
|
||||||
|
|
||||||
nir_intrinsic_instr *load =
|
nir_intrinsic_instr *load =
|
||||||
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_load_var);
|
nir_intrinsic_instr_create(shader, nir_intrinsic_load_var);
|
||||||
load->num_components = num_components;
|
load->num_components = num_components;
|
||||||
load->variables[0] = nir_deref_var_clone(src_head, load);
|
load->variables[0] = nir_deref_var_clone(src_head, load);
|
||||||
nir_ssa_dest_init(&load->instr, &load->dest, num_components, bit_size,
|
nir_ssa_dest_init(&load->instr, &load->dest, num_components, bit_size,
|
||||||
@@ -128,7 +129,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
nir_instr_insert_before(©_instr->instr, &load->instr);
|
nir_instr_insert_before(©_instr->instr, &load->instr);
|
||||||
|
|
||||||
nir_intrinsic_instr *store =
|
nir_intrinsic_instr *store =
|
||||||
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_store_var);
|
nir_intrinsic_instr_create(shader, nir_intrinsic_store_var);
|
||||||
store->num_components = num_components;
|
store->num_components = num_components;
|
||||||
nir_intrinsic_set_write_mask(store, (1 << num_components) - 1);
|
nir_intrinsic_set_write_mask(store, (1 << num_components) - 1);
|
||||||
store->variables[0] = nir_deref_var_clone(dest_head, store);
|
store->variables[0] = nir_deref_var_clone(dest_head, store);
|
||||||
@@ -145,18 +146,18 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
* The new instructions are placed before the copy instruction in the IR.
|
* The new instructions are placed before the copy instruction in the IR.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nir_lower_var_copy_instr(nir_intrinsic_instr *copy, void *mem_ctx)
|
nir_lower_var_copy_instr(nir_intrinsic_instr *copy, nir_shader *shader)
|
||||||
{
|
{
|
||||||
assert(copy->intrinsic == nir_intrinsic_copy_var);
|
assert(copy->intrinsic == nir_intrinsic_copy_var);
|
||||||
emit_copy_load_store(copy, copy->variables[0], copy->variables[1],
|
emit_copy_load_store(copy, copy->variables[0], copy->variables[1],
|
||||||
©->variables[0]->deref,
|
©->variables[0]->deref,
|
||||||
©->variables[1]->deref, mem_ctx);
|
©->variables[1]->deref, shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
lower_var_copies_impl(nir_function_impl *impl)
|
lower_var_copies_impl(nir_function_impl *impl)
|
||||||
{
|
{
|
||||||
void *mem_ctx = ralloc_parent(impl);
|
nir_shader *shader = impl->function->shader;
|
||||||
|
|
||||||
nir_foreach_block(block, impl) {
|
nir_foreach_block(block, impl) {
|
||||||
nir_foreach_instr_safe(instr, block) {
|
nir_foreach_instr_safe(instr, block) {
|
||||||
@@ -167,7 +168,7 @@ lower_var_copies_impl(nir_function_impl *impl)
|
|||||||
if (copy->intrinsic != nir_intrinsic_copy_var)
|
if (copy->intrinsic != nir_intrinsic_copy_var)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nir_lower_var_copy_instr(copy, mem_ctx);
|
nir_lower_var_copy_instr(copy, shader);
|
||||||
|
|
||||||
nir_instr_remove(©->instr);
|
nir_instr_remove(©->instr);
|
||||||
ralloc_free(copy);
|
ralloc_free(copy);
|
||||||
|
Reference in New Issue
Block a user