case vtn_value_type_ssa:
return val->ssa;
- case vtn_value_type_access_chain:
+ case vtn_value_type_pointer:
/* This is needed for function parameters */
- return vtn_variable_load(b, val->access_chain);
+ return vtn_variable_load(b, val->pointer);
default:
unreachable("Invalid type for an SSA value");
for (unsigned i = 0; i < call->num_params; i++) {
unsigned arg_id = w[4 + i];
struct vtn_value *arg = vtn_untyped_value(b, arg_id);
- if (arg->value_type == vtn_value_type_access_chain) {
- nir_deref_var *d = vtn_access_chain_to_deref(b, arg->access_chain);
+ if (arg->value_type == vtn_value_type_pointer) {
+ nir_deref_var *d = vtn_pointer_to_deref(b, arg->pointer);
call->params[i] = nir_deref_var_clone(d, call);
} else {
struct vtn_ssa_value *arg_ssa = vtn_ssa_value(b, arg_id);
vtn_push_value(b, w[2], vtn_value_type_sampled_image);
val->sampled_image = ralloc(b, struct vtn_sampled_image);
val->sampled_image->image =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
val->sampled_image->sampler =
- vtn_value(b, w[4], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[4], vtn_value_type_pointer)->pointer;
return;
} else if (opcode == SpvOpImage) {
- struct vtn_value *val =
- vtn_push_value(b, w[2], vtn_value_type_access_chain);
+ struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
struct vtn_value *src_val = vtn_untyped_value(b, w[3]);
if (src_val->value_type == vtn_value_type_sampled_image) {
- val->access_chain = src_val->sampled_image->image;
+ val->pointer = src_val->sampled_image->image;
} else {
- assert(src_val->value_type == vtn_value_type_access_chain);
- val->access_chain = src_val->access_chain;
+ assert(src_val->value_type == vtn_value_type_pointer);
+ val->pointer = src_val->pointer;
}
return;
}
if (sampled_val->value_type == vtn_value_type_sampled_image) {
sampled = *sampled_val->sampled_image;
} else {
- assert(sampled_val->value_type == vtn_value_type_access_chain);
+ assert(sampled_val->value_type == vtn_value_type_pointer);
sampled.image = NULL;
- sampled.sampler = sampled_val->access_chain;
+ sampled.sampler = sampled_val->pointer;
}
const struct glsl_type *image_type;
unreachable("Invalid base type for sampler result");
}
- nir_deref_var *sampler = vtn_access_chain_to_deref(b, sampled.sampler);
+ nir_deref_var *sampler = vtn_pointer_to_deref(b, sampled.sampler);
nir_deref_var *texture;
if (sampled.image) {
- nir_deref_var *image = vtn_access_chain_to_deref(b, sampled.image);
+ nir_deref_var *image = vtn_pointer_to_deref(b, sampled.image);
texture = image;
} else {
texture = sampler;
vtn_push_value(b, w[2], vtn_value_type_image_pointer);
val->image = ralloc(b, struct vtn_image_pointer);
- val->image->image =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ val->image->image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
val->image->coord = get_image_coord(b, w[4]);
val->image->sample = vtn_ssa_value(b, w[5])->def;
return;
break;
case SpvOpImageQuerySize:
- image.image =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
image.coord = NULL;
image.sample = NULL;
break;
case SpvOpImageRead:
- image.image =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ image.image = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
image.coord = get_image_coord(b, w[4]);
if (count > 5 && (w[5] & SpvImageOperandsSampleMask)) {
break;
case SpvOpImageWrite:
- image.image =
- vtn_value(b, w[1], vtn_value_type_access_chain)->access_chain;
+ image.image = vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
image.coord = get_image_coord(b, w[2]);
/* texel = w[3] */
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_pointer_to_deref(b, image.image);
intrin->variables[0] = nir_deref_var_clone(image_deref, intrin);
/* ImageQuerySize doesn't take any extra parameters */
vtn_handle_ssbo_or_shared_atomic(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
{
- struct vtn_access_chain *chain;
+ struct vtn_access_chain *ptr;
nir_intrinsic_instr *atomic;
switch (opcode) {
case SpvOpAtomicAnd:
case SpvOpAtomicOr:
case SpvOpAtomicXor:
- chain =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ ptr = vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
break;
case SpvOpAtomicStore:
- chain =
- vtn_value(b, w[1], vtn_value_type_access_chain)->access_chain;
+ ptr = vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
break;
default:
SpvMemorySemanticsMask semantics = w[5];
*/
- if (chain->var->mode == vtn_variable_mode_workgroup) {
- nir_deref_var *deref = vtn_access_chain_to_deref(b, chain);
+ if (ptr->var->mode == vtn_variable_mode_workgroup) {
+ nir_deref_var *deref = vtn_pointer_to_deref(b, ptr);
const struct glsl_type *deref_type = nir_deref_tail(&deref->deref)->type;
nir_intrinsic_op op = get_shared_nir_atomic_op(opcode);
atomic = nir_intrinsic_instr_create(b->nb.shader, op);
}
} else {
- assert(chain->var->mode == vtn_variable_mode_ssbo);
+ assert(ptr->var->mode == vtn_variable_mode_ssbo);
struct vtn_type *type;
nir_ssa_def *offset, *index;
- offset = vtn_access_chain_to_offset(b, chain, &index, &type, NULL, false);
+ offset = vtn_pointer_to_offset(b, ptr, &index, &type, NULL, false);
nir_intrinsic_op op = get_ssbo_nir_atomic_op(opcode);
case SpvOpImageQuerySize: {
struct vtn_access_chain *image =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
if (glsl_type_is_image(image->var->var->interface_type)) {
vtn_handle_image(b, opcode, w, count);
} else {
if (pointer->value_type == vtn_value_type_image_pointer) {
vtn_handle_image(b, opcode, w, count);
} else {
- assert(pointer->value_type == vtn_value_type_access_chain);
+ assert(pointer->value_type == vtn_value_type_pointer);
vtn_handle_ssbo_or_shared_atomic(b, opcode, w, count);
}
break;
if (pointer->value_type == vtn_value_type_image_pointer) {
vtn_handle_image(b, opcode, w, count);
} else {
- assert(pointer->value_type == vtn_value_type_access_chain);
+ assert(pointer->value_type == vtn_value_type_pointer);
vtn_handle_ssbo_or_shared_atomic(b, opcode, w, count);
}
break;
break;
case SpvOpFunctionParameter: {
- struct vtn_value *val =
- vtn_push_value(b, w[2], vtn_value_type_access_chain);
+ struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
struct vtn_type *type = vtn_value(b, w[1], vtn_value_type_type)->type;
struct vtn_variable *vtn_var = rzalloc(b, struct vtn_variable);
vtn_var->type = type;
vtn_var->var = param;
- vtn_var->chain.var = vtn_var;
- vtn_var->chain.length = 0;
+ vtn_var->ptr.var = vtn_var;
+ vtn_var->ptr.length = 0;
struct vtn_type *without_array = type;
while(glsl_type_is_array(without_array->type))
vtn_var->mode = vtn_variable_mode_param;
}
- val->access_chain = &vtn_var->chain;
+ val->pointer = &vtn_var->ptr;
break;
}
vtn_value_type_decoration_group,
vtn_value_type_type,
vtn_value_type_constant,
- vtn_value_type_access_chain,
+ vtn_value_type_pointer,
vtn_value_type_function,
vtn_value_type_block,
vtn_value_type_ssa,
*/
struct vtn_access_chain *copy_prop_sampler;
- struct vtn_access_chain chain;
+ struct vtn_access_chain ptr;
};
struct vtn_image_pointer {
nir_constant *constant;
const struct glsl_type *const_type;
};
- struct vtn_access_chain *access_chain;
+ struct vtn_access_chain *pointer;
struct vtn_image_pointer *image;
struct vtn_sampled_image *sampled_image;
struct vtn_function *func;
nir_deref_var *vtn_nir_deref(struct vtn_builder *b, uint32_t id);
-nir_deref_var *vtn_access_chain_to_deref(struct vtn_builder *b,
- struct vtn_access_chain *chain);
+nir_deref_var *vtn_pointer_to_deref(struct vtn_builder *b,
+ struct vtn_access_chain *ptr);
nir_ssa_def *
-vtn_access_chain_to_offset(struct vtn_builder *b,
- struct vtn_access_chain *chain,
- nir_ssa_def **index_out, struct vtn_type **type_out,
- unsigned *end_idx_out, bool stop_at_matrix);
+vtn_pointer_to_offset(struct vtn_builder *b,
+ struct vtn_access_chain *ptr,
+ nir_ssa_def **index_out, struct vtn_type **type_out,
+ unsigned *end_idx_out, bool stop_at_matrix);
struct vtn_ssa_value *vtn_local_load(struct vtn_builder *b, nir_deref_var *src);
}
nir_deref_var *
-vtn_access_chain_to_deref(struct vtn_builder *b, struct vtn_access_chain *chain)
+vtn_pointer_to_deref(struct vtn_builder *b, struct vtn_access_chain *chain)
{
/* Do on-the-fly copy propagation for samplers. */
if (chain->var->copy_prop_sampler)
- return vtn_access_chain_to_deref(b, chain->var->copy_prop_sampler);
+ return vtn_pointer_to_deref(b, chain->var->copy_prop_sampler);
nir_deref_var *deref_var;
if (chain->var->var) {
vtn_nir_deref(struct vtn_builder *b, uint32_t id)
{
struct vtn_access_chain *chain =
- vtn_value(b, id, vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, id, vtn_value_type_pointer)->pointer;
- return vtn_access_chain_to_deref(b, chain);
+ return vtn_pointer_to_deref(b, chain);
}
/*
}
nir_ssa_def *
-vtn_access_chain_to_offset(struct vtn_builder *b,
- struct vtn_access_chain *chain,
- nir_ssa_def **index_out, struct vtn_type **type_out,
- unsigned *end_idx_out, bool stop_at_matrix)
+vtn_pointer_to_offset(struct vtn_builder *b,
+ struct vtn_access_chain *chain,
+ nir_ssa_def **index_out, struct vtn_type **type_out,
+ unsigned *end_idx_out, bool stop_at_matrix)
{
unsigned idx = 0;
struct vtn_type *type;
nir_ssa_def *offset, *index = NULL;
struct vtn_type *type;
unsigned chain_idx;
- offset = vtn_access_chain_to_offset(b, src, &index, &type, &chain_idx, true);
+ offset = vtn_pointer_to_offset(b, src, &index, &type, &chain_idx, true);
struct vtn_ssa_value *value = NULL;
_vtn_block_load_store(b, op, true, index, offset,
nir_ssa_def *offset, *index = NULL;
struct vtn_type *type;
unsigned chain_idx;
- offset = vtn_access_chain_to_offset(b, dst, &index, &type, &chain_idx, true);
+ offset = vtn_pointer_to_offset(b, dst, &index, &type, &chain_idx, true);
_vtn_block_load_store(b, nir_intrinsic_store_ssbo, false, index, offset,
0, 0, dst, chain_idx, type, &src);
* are storred row-major in a UBO.
*/
if (load) {
- *inout = vtn_local_load(b, vtn_access_chain_to_deref(b, chain));
+ *inout = vtn_local_load(b, vtn_pointer_to_deref(b, chain));
} else {
- vtn_local_store(b, *inout, vtn_access_chain_to_deref(b, chain));
+ vtn_local_store(b, *inout, vtn_pointer_to_deref(b, chain));
}
return;
break;
}
- if (val->value_type == vtn_value_type_access_chain) {
- assert(val->access_chain->length == 0);
- assert(val->access_chain->var == void_var);
+ if (val->value_type == vtn_value_type_pointer) {
+ assert(val->pointer->length == 0);
+ assert(val->pointer->var == void_var);
assert(member == -1);
} else {
assert(val->value_type == vtn_value_type_type);
struct vtn_variable *var = rzalloc(b, struct vtn_variable);
var->type = vtn_value(b, w[1], vtn_value_type_type)->type;
- var->chain.var = var;
- var->chain.length = 0;
+ var->ptr.var = var;
+ var->ptr.length = 0;
- struct vtn_value *val =
- vtn_push_value(b, w[2], vtn_value_type_access_chain);
- val->access_chain = &var->chain;
+ struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
+ val->pointer = &var->ptr;
struct vtn_type *without_array = var->type;
while(glsl_type_is_array(without_array->type))
*/
base = base_val->sampled_image->image;
} else {
- assert(base_val->value_type == vtn_value_type_access_chain);
- base = base_val->access_chain;
+ assert(base_val->value_type == vtn_value_type_pointer);
+ base = base_val->pointer;
}
chain = vtn_access_chain_extend(b, base, count - 4);
val->sampled_image->sampler = base_val->sampled_image->sampler;
} else {
struct vtn_value *val =
- vtn_push_value(b, w[2], vtn_value_type_access_chain);
- val->access_chain = chain;
+ vtn_push_value(b, w[2], vtn_value_type_pointer);
+ val->pointer = chain;
}
break;
}
case SpvOpCopyMemory: {
- struct vtn_value *dest = vtn_value(b, w[1], vtn_value_type_access_chain);
- struct vtn_value *src = vtn_value(b, w[2], vtn_value_type_access_chain);
+ struct vtn_value *dest = vtn_value(b, w[1], vtn_value_type_pointer);
+ struct vtn_value *src = vtn_value(b, w[2], vtn_value_type_pointer);
- vtn_variable_copy(b, dest->access_chain, src->access_chain);
+ vtn_variable_copy(b, dest->pointer, src->pointer);
break;
}
case SpvOpLoad: {
struct vtn_access_chain *src =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
if (src->var->mode == vtn_variable_mode_image ||
src->var->mode == vtn_variable_mode_sampler) {
- vtn_push_value(b, w[2], vtn_value_type_access_chain)->access_chain = src;
+ vtn_push_value(b, w[2], vtn_value_type_pointer)->pointer = src;
return;
}
case SpvOpStore: {
struct vtn_access_chain *dest =
- vtn_value(b, w[1], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[1], vtn_value_type_pointer)->pointer;
if (glsl_type_is_sampler(dest->var->type->type)) {
vtn_warn("OpStore of a sampler detected. Doing on-the-fly copy "
"propagation to workaround the problem.");
assert(dest->var->copy_prop_sampler == NULL);
dest->var->copy_prop_sampler =
- vtn_value(b, w[2], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[2], vtn_value_type_pointer)->pointer;
break;
}
case SpvOpArrayLength: {
struct vtn_access_chain *chain =
- vtn_value(b, w[3], vtn_value_type_access_chain)->access_chain;
+ vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
const uint32_t offset = chain->var->type->offsets[w[4]];
const uint32_t stride = chain->var->type->members[w[4]]->stride;