nir: Make nir_copy_deref follow the "clone" pattern
We rename it to nir_deref_clone, re-order the sources to match the other clone functions, and expose nir_deref_var_clone. This past part, in particular, lets us get rid of quite a few lines since we no longer have to call nir_copy_deref and wrap it in deref_as_var. Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
@@ -1178,8 +1178,7 @@ nir_visitor::visit(ir_assignment *ir)
|
|||||||
nir_intrinsic_instr_create(this->shader, nir_intrinsic_store_var);
|
nir_intrinsic_instr_create(this->shader, nir_intrinsic_store_var);
|
||||||
store->num_components = ir->lhs->type->vector_elements;
|
store->num_components = ir->lhs->type->vector_elements;
|
||||||
nir_intrinsic_set_write_mask(store, ir->write_mask);
|
nir_intrinsic_set_write_mask(store, ir->write_mask);
|
||||||
nir_deref *store_deref = nir_copy_deref(store, &lhs_deref->deref);
|
store->variables[0] = nir_deref_var_clone(lhs_deref, store);
|
||||||
store->variables[0] = nir_deref_as_var(store_deref);
|
|
||||||
store->src[0] = nir_src_for_ssa(src);
|
store->src[0] = nir_src_for_ssa(src);
|
||||||
|
|
||||||
if (ir->condition) {
|
if (ir->condition) {
|
||||||
|
@@ -624,18 +624,21 @@ nir_deref_struct_create(void *mem_ctx, unsigned field_index)
|
|||||||
return deref;
|
return deref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nir_deref_var *
|
nir_deref_var *
|
||||||
copy_deref_var(void *mem_ctx, nir_deref_var *deref)
|
nir_deref_var_clone(const nir_deref_var *deref, void *mem_ctx)
|
||||||
{
|
{
|
||||||
|
if (deref == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);
|
nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var);
|
||||||
ret->deref.type = deref->deref.type;
|
ret->deref.type = deref->deref.type;
|
||||||
if (deref->deref.child)
|
if (deref->deref.child)
|
||||||
ret->deref.child = nir_copy_deref(ret, deref->deref.child);
|
ret->deref.child = nir_deref_clone(deref->deref.child, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nir_deref_array *
|
static nir_deref_array *
|
||||||
copy_deref_array(void *mem_ctx, nir_deref_array *deref)
|
deref_array_clone(const nir_deref_array *deref, void *mem_ctx)
|
||||||
{
|
{
|
||||||
nir_deref_array *ret = nir_deref_array_create(mem_ctx);
|
nir_deref_array *ret = nir_deref_array_create(mem_ctx);
|
||||||
ret->base_offset = deref->base_offset;
|
ret->base_offset = deref->base_offset;
|
||||||
@@ -645,33 +648,33 @@ copy_deref_array(void *mem_ctx, nir_deref_array *deref)
|
|||||||
}
|
}
|
||||||
ret->deref.type = deref->deref.type;
|
ret->deref.type = deref->deref.type;
|
||||||
if (deref->deref.child)
|
if (deref->deref.child)
|
||||||
ret->deref.child = nir_copy_deref(ret, deref->deref.child);
|
ret->deref.child = nir_deref_clone(deref->deref.child, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static nir_deref_struct *
|
static nir_deref_struct *
|
||||||
copy_deref_struct(void *mem_ctx, nir_deref_struct *deref)
|
deref_struct_clone(const nir_deref_struct *deref, void *mem_ctx)
|
||||||
{
|
{
|
||||||
nir_deref_struct *ret = nir_deref_struct_create(mem_ctx, deref->index);
|
nir_deref_struct *ret = nir_deref_struct_create(mem_ctx, deref->index);
|
||||||
ret->deref.type = deref->deref.type;
|
ret->deref.type = deref->deref.type;
|
||||||
if (deref->deref.child)
|
if (deref->deref.child)
|
||||||
ret->deref.child = nir_copy_deref(ret, deref->deref.child);
|
ret->deref.child = nir_deref_clone(deref->deref.child, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_deref *
|
nir_deref *
|
||||||
nir_copy_deref(void *mem_ctx, nir_deref *deref)
|
nir_deref_clone(const nir_deref *deref, void *mem_ctx)
|
||||||
{
|
{
|
||||||
if (deref == NULL)
|
if (deref == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (deref->deref_type) {
|
switch (deref->deref_type) {
|
||||||
case nir_deref_type_var:
|
case nir_deref_type_var:
|
||||||
return ©_deref_var(mem_ctx, nir_deref_as_var(deref))->deref;
|
return &nir_deref_var_clone(nir_deref_as_var(deref), mem_ctx)->deref;
|
||||||
case nir_deref_type_array:
|
case nir_deref_type_array:
|
||||||
return ©_deref_array(mem_ctx, nir_deref_as_array(deref))->deref;
|
return &deref_array_clone(nir_deref_as_array(deref), mem_ctx)->deref;
|
||||||
case nir_deref_type_struct:
|
case nir_deref_type_struct:
|
||||||
return ©_deref_struct(mem_ctx, nir_deref_as_struct(deref))->deref;
|
return &deref_struct_clone(nir_deref_as_struct(deref), mem_ctx)->deref;
|
||||||
default:
|
default:
|
||||||
unreachable("Invalid dereference type");
|
unreachable("Invalid dereference type");
|
||||||
}
|
}
|
||||||
|
@@ -1932,8 +1932,6 @@ nir_deref_var *nir_deref_var_create(void *mem_ctx, nir_variable *var);
|
|||||||
nir_deref_array *nir_deref_array_create(void *mem_ctx);
|
nir_deref_array *nir_deref_array_create(void *mem_ctx);
|
||||||
nir_deref_struct *nir_deref_struct_create(void *mem_ctx, unsigned field_index);
|
nir_deref_struct *nir_deref_struct_create(void *mem_ctx, unsigned field_index);
|
||||||
|
|
||||||
nir_deref *nir_copy_deref(void *mem_ctx, nir_deref *deref);
|
|
||||||
|
|
||||||
typedef bool (*nir_deref_foreach_leaf_cb)(nir_deref_var *deref, void *state);
|
typedef bool (*nir_deref_foreach_leaf_cb)(nir_deref_var *deref, void *state);
|
||||||
bool nir_deref_foreach_leaf(nir_deref_var *deref,
|
bool nir_deref_foreach_leaf(nir_deref_var *deref,
|
||||||
nir_deref_foreach_leaf_cb cb, void *state);
|
nir_deref_foreach_leaf_cb cb, void *state);
|
||||||
@@ -2241,6 +2239,8 @@ nir_shader *nir_shader_clone(void *mem_ctx, const nir_shader *s);
|
|||||||
nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi);
|
nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi);
|
||||||
nir_constant *nir_constant_clone(const nir_constant *c, nir_variable *var);
|
nir_constant *nir_constant_clone(const nir_constant *c, nir_variable *var);
|
||||||
nir_variable *nir_variable_clone(const nir_variable *c, nir_shader *shader);
|
nir_variable *nir_variable_clone(const nir_variable *c, nir_shader *shader);
|
||||||
|
nir_deref *nir_deref_clone(const nir_deref *deref, void *mem_ctx);
|
||||||
|
nir_deref_var *nir_deref_var_clone(const nir_deref_var *deref, void *mem_ctx);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void nir_validate_shader(nir_shader *shader);
|
void nir_validate_shader(nir_shader *shader);
|
||||||
|
@@ -437,7 +437,7 @@ nir_store_deref_var(nir_builder *build, nir_deref_var *deref,
|
|||||||
nir_intrinsic_instr_create(build->shader, nir_intrinsic_store_var);
|
nir_intrinsic_instr_create(build->shader, nir_intrinsic_store_var);
|
||||||
store->num_components = num_components;
|
store->num_components = num_components;
|
||||||
store->const_index[0] = writemask & ((1 << num_components) - 1);
|
store->const_index[0] = writemask & ((1 << num_components) - 1);
|
||||||
store->variables[0] = nir_deref_as_var(nir_copy_deref(store, &deref->deref));
|
store->variables[0] = nir_deref_var_clone(deref, store);
|
||||||
store->src[0] = nir_src_for_ssa(value);
|
store->src[0] = nir_src_for_ssa(value);
|
||||||
nir_builder_instr_insert(build, &store->instr);
|
nir_builder_instr_insert(build, &store->instr);
|
||||||
}
|
}
|
||||||
@@ -450,8 +450,8 @@ nir_copy_deref_var(nir_builder *build, nir_deref_var *dest, nir_deref_var *src)
|
|||||||
|
|
||||||
nir_intrinsic_instr *copy =
|
nir_intrinsic_instr *copy =
|
||||||
nir_intrinsic_instr_create(build->shader, nir_intrinsic_copy_var);
|
nir_intrinsic_instr_create(build->shader, nir_intrinsic_copy_var);
|
||||||
copy->variables[0] = nir_deref_as_var(nir_copy_deref(copy, &dest->deref));
|
copy->variables[0] = nir_deref_var_clone(dest, copy);
|
||||||
copy->variables[1] = nir_deref_as_var(nir_copy_deref(copy, &src->deref));
|
copy->variables[1] = nir_deref_var_clone(src, copy);
|
||||||
nir_builder_instr_insert(build, ©->instr);
|
nir_builder_instr_insert(build, ©->instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,7 +49,7 @@ convert_deref_to_param_deref(nir_instr *instr, nir_deref_var **deref,
|
|||||||
/* Now we make a new deref by concatenating the deref in the call's
|
/* Now we make a new deref by concatenating the deref in the call's
|
||||||
* parameter with the deref we were given.
|
* parameter with the deref we were given.
|
||||||
*/
|
*/
|
||||||
nir_deref_var *new_deref = nir_deref_as_var(nir_copy_deref(instr, &call_deref->deref));
|
nir_deref_var *new_deref = nir_deref_var_clone(call_deref, instr);
|
||||||
nir_deref *new_tail = nir_deref_tail(&new_deref->deref);
|
nir_deref *new_tail = nir_deref_tail(&new_deref->deref);
|
||||||
new_tail->child = (*deref)->deref.child;
|
new_tail->child = (*deref)->deref.child;
|
||||||
ralloc_steal(new_tail, new_tail->child);
|
ralloc_steal(new_tail, new_tail->child);
|
||||||
|
@@ -122,8 +122,7 @@ emit_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,
|
|||||||
nir_intrinsic_instr *load =
|
nir_intrinsic_instr *load =
|
||||||
nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var);
|
nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var);
|
||||||
load->num_components = orig_instr->num_components;
|
load->num_components = orig_instr->num_components;
|
||||||
load->variables[0] =
|
load->variables[0] = nir_deref_var_clone(deref, load);
|
||||||
nir_deref_as_var(nir_copy_deref(load, &deref->deref));
|
|
||||||
unsigned bit_size = orig_instr->dest.ssa.bit_size;
|
unsigned bit_size = orig_instr->dest.ssa.bit_size;
|
||||||
nir_ssa_dest_init(&load->instr, &load->dest,
|
nir_ssa_dest_init(&load->instr, &load->dest,
|
||||||
load->num_components, bit_size, NULL);
|
load->num_components, bit_size, NULL);
|
||||||
@@ -135,8 +134,7 @@ emit_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,
|
|||||||
nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var);
|
nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var);
|
||||||
store->num_components = orig_instr->num_components;
|
store->num_components = orig_instr->num_components;
|
||||||
nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(orig_instr));
|
nir_intrinsic_set_write_mask(store, nir_intrinsic_write_mask(orig_instr));
|
||||||
store->variables[0] =
|
store->variables[0] = nir_deref_var_clone(deref, store);
|
||||||
nir_deref_as_var(nir_copy_deref(store, &deref->deref));
|
|
||||||
store->src[0] = nir_src_for_ssa(src);
|
store->src[0] = nir_src_for_ssa(src);
|
||||||
nir_builder_instr_insert(b, &store->instr);
|
nir_builder_instr_insert(b, &store->instr);
|
||||||
}
|
}
|
||||||
|
@@ -163,11 +163,9 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)
|
|||||||
txs->is_shadow = tex->is_shadow;
|
txs->is_shadow = tex->is_shadow;
|
||||||
txs->is_new_style_shadow = tex->is_new_style_shadow;
|
txs->is_new_style_shadow = tex->is_new_style_shadow;
|
||||||
txs->texture_index = tex->texture_index;
|
txs->texture_index = tex->texture_index;
|
||||||
txs->texture = (nir_deref_var *)
|
txs->texture = nir_deref_var_clone(tex->texture, txs);
|
||||||
nir_copy_deref(txs, &tex->texture->deref);
|
|
||||||
txs->sampler_index = tex->sampler_index;
|
txs->sampler_index = tex->sampler_index;
|
||||||
txs->sampler = (nir_deref_var *)
|
txs->sampler = nir_deref_var_clone(tex->sampler, txs);
|
||||||
nir_copy_deref(txs, &tex->sampler->deref);
|
|
||||||
txs->dest_type = nir_type_int;
|
txs->dest_type = nir_type_int;
|
||||||
|
|
||||||
/* only single src, the lod: */
|
/* only single src, the lod: */
|
||||||
@@ -221,11 +219,9 @@ sample_plane(nir_builder *b, nir_tex_instr *tex, int plane)
|
|||||||
plane_tex->coord_components = 2;
|
plane_tex->coord_components = 2;
|
||||||
|
|
||||||
plane_tex->texture_index = tex->texture_index;
|
plane_tex->texture_index = tex->texture_index;
|
||||||
plane_tex->texture = (nir_deref_var *)
|
plane_tex->texture = nir_deref_var_clone(tex->texture, plane_tex);
|
||||||
nir_copy_deref(plane_tex, &tex->texture->deref);
|
|
||||||
plane_tex->sampler_index = tex->sampler_index;
|
plane_tex->sampler_index = tex->sampler_index;
|
||||||
plane_tex->sampler = (nir_deref_var *)
|
plane_tex->sampler = nir_deref_var_clone(tex->sampler, plane_tex);
|
||||||
nir_copy_deref(plane_tex, &tex->sampler->deref);
|
|
||||||
|
|
||||||
nir_ssa_dest_init(&plane_tex->instr, &plane_tex->dest, 4, 32, NULL);
|
nir_ssa_dest_init(&plane_tex->instr, &plane_tex->dest, 4, 32, NULL);
|
||||||
|
|
||||||
@@ -325,10 +321,8 @@ replace_gradient_with_lod(nir_builder *b, nir_ssa_def *lod, nir_tex_instr *tex)
|
|||||||
txl->is_shadow = tex->is_shadow;
|
txl->is_shadow = tex->is_shadow;
|
||||||
txl->is_new_style_shadow = tex->is_new_style_shadow;
|
txl->is_new_style_shadow = tex->is_new_style_shadow;
|
||||||
txl->sampler_index = tex->sampler_index;
|
txl->sampler_index = tex->sampler_index;
|
||||||
txl->texture = (nir_deref_var *)
|
txl->texture = nir_deref_var_clone(tex->texture, txl);
|
||||||
nir_copy_deref(txl, &tex->texture->deref);
|
txl->sampler = nir_deref_var_clone(tex->sampler, txl);
|
||||||
txl->sampler = (nir_deref_var *)
|
|
||||||
nir_copy_deref(txl, &tex->sampler->deref);
|
|
||||||
txl->coord_components = tex->coord_components;
|
txl->coord_components = tex->coord_components;
|
||||||
|
|
||||||
nir_ssa_dest_init(&txl->instr, &txl->dest, 4, 32, NULL);
|
nir_ssa_dest_init(&txl->instr, &txl->dest, 4, 32, NULL);
|
||||||
|
@@ -121,7 +121,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
nir_intrinsic_instr *load =
|
nir_intrinsic_instr *load =
|
||||||
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_load_var);
|
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_load_var);
|
||||||
load->num_components = num_components;
|
load->num_components = num_components;
|
||||||
load->variables[0] = nir_deref_as_var(nir_copy_deref(load, &src_head->deref));
|
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,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ emit_copy_load_store(nir_intrinsic_instr *copy_instr,
|
|||||||
nir_intrinsic_instr_create(mem_ctx, nir_intrinsic_store_var);
|
nir_intrinsic_instr_create(mem_ctx, 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_as_var(nir_copy_deref(store, &dest_head->deref));
|
store->variables[0] = nir_deref_var_clone(dest_head, store);
|
||||||
|
|
||||||
store->src[0].is_ssa = true;
|
store->src[0].is_ssa = true;
|
||||||
store->src[0].ssa = &load->dest.ssa;
|
store->src[0].ssa = &load->dest.ssa;
|
||||||
|
@@ -82,7 +82,7 @@ struct split_var_copies_state {
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
split_var_copy_instr(nir_intrinsic_instr *old_copy,
|
split_var_copy_instr(nir_intrinsic_instr *old_copy,
|
||||||
nir_deref *dest_head, nir_deref *src_head,
|
nir_deref_var *dest_head, nir_deref_var *src_head,
|
||||||
nir_deref *dest_tail, nir_deref *src_tail,
|
nir_deref *dest_tail, nir_deref *src_tail,
|
||||||
struct split_var_copies_state *state)
|
struct split_var_copies_state *state)
|
||||||
{
|
{
|
||||||
@@ -182,11 +182,8 @@ split_var_copy_instr(nir_intrinsic_instr *old_copy,
|
|||||||
* belongs to the copy instruction and b) the deref chains may
|
* belongs to the copy instruction and b) the deref chains may
|
||||||
* have some of the same links due to the way we constructed them
|
* have some of the same links due to the way we constructed them
|
||||||
*/
|
*/
|
||||||
nir_deref *src = nir_copy_deref(new_copy, src_head);
|
new_copy->variables[0] = nir_deref_var_clone(dest_head, new_copy);
|
||||||
nir_deref *dest = nir_copy_deref(new_copy, dest_head);
|
new_copy->variables[1] = nir_deref_var_clone(src_head, new_copy);
|
||||||
|
|
||||||
new_copy->variables[0] = nir_deref_as_var(dest);
|
|
||||||
new_copy->variables[1] = nir_deref_as_var(src);
|
|
||||||
|
|
||||||
/* Emit the copy instruction after the old instruction. We'll
|
/* Emit the copy instruction after the old instruction. We'll
|
||||||
* remove the old one later.
|
* remove the old one later.
|
||||||
@@ -216,10 +213,10 @@ split_var_copies_block(nir_block *block, struct split_var_copies_state *state)
|
|||||||
if (intrinsic->intrinsic != nir_intrinsic_copy_var)
|
if (intrinsic->intrinsic != nir_intrinsic_copy_var)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nir_deref *dest_head = &intrinsic->variables[0]->deref;
|
nir_deref_var *dest_head = intrinsic->variables[0];
|
||||||
nir_deref *src_head = &intrinsic->variables[1]->deref;
|
nir_deref_var *src_head = intrinsic->variables[1];
|
||||||
nir_deref *dest_tail = nir_deref_tail(dest_head);
|
nir_deref *dest_tail = nir_deref_tail(&dest_head->deref);
|
||||||
nir_deref *src_tail = nir_deref_tail(src_head);
|
nir_deref *src_tail = nir_deref_tail(&src_head->deref);
|
||||||
|
|
||||||
switch (glsl_get_base_type(src_tail->type)) {
|
switch (glsl_get_base_type(src_tail->type)) {
|
||||||
case GLSL_TYPE_ARRAY:
|
case GLSL_TYPE_ARRAY:
|
||||||
|
@@ -1206,7 +1206,7 @@ vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
|
|||||||
struct vtn_value *arg = vtn_untyped_value(b, arg_id);
|
struct vtn_value *arg = vtn_untyped_value(b, arg_id);
|
||||||
if (arg->value_type == vtn_value_type_access_chain) {
|
if (arg->value_type == vtn_value_type_access_chain) {
|
||||||
nir_deref_var *d = vtn_access_chain_to_deref(b, arg->access_chain);
|
nir_deref_var *d = vtn_access_chain_to_deref(b, arg->access_chain);
|
||||||
call->params[i] = nir_deref_as_var(nir_copy_deref(call, &d->deref));
|
call->params[i] = nir_deref_var_clone(d, call);
|
||||||
} else {
|
} else {
|
||||||
struct vtn_ssa_value *arg_ssa = vtn_ssa_value(b, arg_id);
|
struct vtn_ssa_value *arg_ssa = vtn_ssa_value(b, arg_id);
|
||||||
|
|
||||||
@@ -1542,15 +1542,15 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nir_deref_var *sampler = vtn_access_chain_to_deref(b, sampled.sampler);
|
nir_deref_var *sampler = vtn_access_chain_to_deref(b, sampled.sampler);
|
||||||
nir_deref *texture;
|
nir_deref_var *texture;
|
||||||
if (sampled.image) {
|
if (sampled.image) {
|
||||||
nir_deref_var *image = vtn_access_chain_to_deref(b, sampled.image);
|
nir_deref_var *image = vtn_access_chain_to_deref(b, sampled.image);
|
||||||
texture = &image->deref;
|
texture = image;
|
||||||
} else {
|
} else {
|
||||||
texture = &sampler->deref;
|
texture = sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
instr->texture = nir_deref_as_var(nir_copy_deref(instr, texture));
|
instr->texture = nir_deref_var_clone(texture, instr);
|
||||||
|
|
||||||
switch (instr->op) {
|
switch (instr->op) {
|
||||||
case nir_texop_tex:
|
case nir_texop_tex:
|
||||||
@@ -1558,7 +1558,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
|
|||||||
case nir_texop_txl:
|
case nir_texop_txl:
|
||||||
case nir_texop_txd:
|
case nir_texop_txd:
|
||||||
/* These operations require a sampler */
|
/* These operations require a sampler */
|
||||||
instr->sampler = nir_deref_as_var(nir_copy_deref(instr, &sampler->deref));
|
instr->sampler = nir_deref_var_clone(sampler, instr);
|
||||||
break;
|
break;
|
||||||
case nir_texop_txf:
|
case nir_texop_txf:
|
||||||
case nir_texop_txf_ms:
|
case nir_texop_txf_ms:
|
||||||
@@ -1599,8 +1599,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
|
|||||||
instrs[i]->is_new_style_shadow = instr->is_new_style_shadow;
|
instrs[i]->is_new_style_shadow = instr->is_new_style_shadow;
|
||||||
instrs[i]->component = instr->component;
|
instrs[i]->component = instr->component;
|
||||||
instrs[i]->dest_type = instr->dest_type;
|
instrs[i]->dest_type = instr->dest_type;
|
||||||
instrs[i]->texture =
|
instrs[i]->texture = nir_deref_var_clone(texture, instrs[i]);
|
||||||
nir_deref_as_var(nir_copy_deref(instrs[i], texture));
|
|
||||||
instrs[i]->sampler = NULL;
|
instrs[i]->sampler = NULL;
|
||||||
|
|
||||||
memcpy(instrs[i]->src, srcs, instr->num_srcs * sizeof(*instr->src));
|
memcpy(instrs[i]->src, srcs, instr->num_srcs * sizeof(*instr->src));
|
||||||
@@ -1807,8 +1806,7 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
|
|||||||
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
|
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
|
||||||
|
|
||||||
nir_deref_var *image_deref = vtn_access_chain_to_deref(b, image.image);
|
nir_deref_var *image_deref = vtn_access_chain_to_deref(b, image.image);
|
||||||
intrin->variables[0] =
|
intrin->variables[0] = nir_deref_var_clone(image_deref, intrin);
|
||||||
nir_deref_as_var(nir_copy_deref(&intrin->instr, &image_deref->deref));
|
|
||||||
|
|
||||||
/* ImageQuerySize doesn't take any extra parameters */
|
/* ImageQuerySize doesn't take any extra parameters */
|
||||||
if (opcode != SpvOpImageQuerySize) {
|
if (opcode != SpvOpImageQuerySize) {
|
||||||
@@ -1967,10 +1965,10 @@ vtn_handle_ssbo_or_shared_atomic(struct vtn_builder *b, SpvOp opcode,
|
|||||||
|
|
||||||
if (chain->var->mode == vtn_variable_mode_workgroup) {
|
if (chain->var->mode == vtn_variable_mode_workgroup) {
|
||||||
struct vtn_type *type = chain->var->type;
|
struct vtn_type *type = chain->var->type;
|
||||||
nir_deref *deref = &vtn_access_chain_to_deref(b, chain)->deref;
|
nir_deref_var *deref = vtn_access_chain_to_deref(b, chain);
|
||||||
nir_intrinsic_op op = get_shared_nir_atomic_op(opcode);
|
nir_intrinsic_op op = get_shared_nir_atomic_op(opcode);
|
||||||
atomic = nir_intrinsic_instr_create(b->nb.shader, op);
|
atomic = nir_intrinsic_instr_create(b->nb.shader, op);
|
||||||
atomic->variables[0] = nir_deref_as_var(nir_copy_deref(atomic, deref));
|
atomic->variables[0] = nir_deref_var_clone(deref, atomic);
|
||||||
|
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case SpvOpAtomicLoad:
|
case SpvOpAtomicLoad:
|
||||||
|
@@ -667,8 +667,7 @@ handle_glsl450_interpolation(struct vtn_builder *b, enum GLSLstd450 opcode,
|
|||||||
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->nb.shader, op);
|
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->nb.shader, op);
|
||||||
|
|
||||||
nir_deref_var *deref = vtn_nir_deref(b, w[5]);
|
nir_deref_var *deref = vtn_nir_deref(b, w[5]);
|
||||||
intrin->variables[0] =
|
intrin->variables[0] = nir_deref_var_clone(deref, intrin);
|
||||||
nir_deref_as_var(nir_copy_deref(intrin, &deref->deref));
|
|
||||||
|
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case GLSLstd450InterpolateAtCentroid:
|
case GLSLstd450InterpolateAtCentroid:
|
||||||
|
@@ -186,8 +186,7 @@ _vtn_local_load_store(struct vtn_builder *b, bool load, nir_deref_var *deref,
|
|||||||
nir_intrinsic_store_var;
|
nir_intrinsic_store_var;
|
||||||
|
|
||||||
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
|
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
|
||||||
intrin->variables[0] =
|
intrin->variables[0] = nir_deref_var_clone(deref, intrin);
|
||||||
nir_deref_as_var(nir_copy_deref(intrin, &deref->deref));
|
|
||||||
intrin->num_components = glsl_get_vector_elements(tail->type);
|
intrin->num_components = glsl_get_vector_elements(tail->type);
|
||||||
|
|
||||||
if (load) {
|
if (load) {
|
||||||
|
@@ -86,8 +86,7 @@ try_lower_input_load(nir_function_impl *impl, nir_intrinsic_instr *load)
|
|||||||
tex->is_array = true;
|
tex->is_array = true;
|
||||||
tex->is_shadow = false;
|
tex->is_shadow = false;
|
||||||
|
|
||||||
tex->texture =
|
tex->texture = nir_deref_var_clone(load->variables[0], tex);
|
||||||
nir_deref_as_var(nir_copy_deref(tex, &load->variables[0]->deref));
|
|
||||||
tex->sampler = NULL;
|
tex->sampler = NULL;
|
||||||
tex->texture_index = 0;
|
tex->texture_index = 0;
|
||||||
tex->sampler_index = 0;
|
tex->sampler_index = 0;
|
||||||
|
Reference in New Issue
Block a user