spirv: Rename vtn_type::deref to vtn_type::pointed

To avoid confusion with the vtn_pointer::deref that is a NIR deref.  New
name comes from description of OpTypePointer, where is described as the
"type of the object pointed to".

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31069>
This commit is contained in:
Caio Oliveira 2024-09-06 11:06:40 -07:00 committed by Marge Bot
parent c92e49e8f4
commit 95d08643ed
5 changed files with 34 additions and 34 deletions

View file

@ -1081,7 +1081,7 @@ vtn_types_compatible(struct vtn_builder *b,
vtn_types_compatible(b, t1->array_element, t2->array_element);
case vtn_base_type_pointer:
return vtn_types_compatible(b, t1->deref, t2->deref);
return vtn_types_compatible(b, t1->pointed, t2->pointed);
case vtn_base_type_struct:
if (t1->length != t2->length)
@ -1945,9 +1945,9 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
"OpTypeForwardPointer is only allowed in Vulkan with "
"the PhysicalStorageBuffer storage class");
struct vtn_type *deref_type = NULL;
struct vtn_type *pointed_type = NULL;
if (opcode == SpvOpTypePointer)
deref_type = vtn_get_type(b, w[3]);
pointed_type = vtn_get_type(b, w[3]);
bool has_forward_pointer = false;
if (val->value_type == vtn_value_type_invalid) {
@ -1961,7 +1961,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
* values so they need a real glsl_type.
*/
enum vtn_variable_mode mode = vtn_storage_class_to_mode(
b, storage_class, deref_type, NULL);
b, storage_class, pointed_type, NULL);
/* The deref type should only matter for the UniformConstant storage
* class. In particular, it should never matter for any storage
@ -1984,17 +1984,17 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
}
if (opcode == SpvOpTypePointer) {
vtn_fail_if(val->type->deref != NULL,
vtn_fail_if(val->type->pointed != NULL,
"While OpTypeForwardPointer can be used to provide a "
"forward declaration of a pointer, OpTypePointer can "
"only be used once for a given id.");
vtn_fail_if(has_forward_pointer &&
deref_type->base_type != vtn_base_type_struct,
pointed_type->base_type != vtn_base_type_struct,
"An OpTypePointer instruction must declare "
"Pointer Type to be a pointer to an OpTypeStruct.");
val->type->deref = deref_type;
val->type->pointed = pointed_type;
/* Only certain storage classes use ArrayStride. */
switch (storage_class) {
@ -2222,7 +2222,7 @@ vtn_null_constant(struct vtn_builder *b, struct vtn_type *type)
case vtn_base_type_pointer: {
enum vtn_variable_mode mode = vtn_storage_class_to_mode(
b, type->storage_class, type->deref, NULL);
b, type->storage_class, type->pointed, NULL);
nir_address_format addr_format = vtn_mode_to_address_format(b, mode);
const nir_const_value *null_value = nir_address_format_null_value(addr_format);
@ -5767,7 +5767,7 @@ vtn_handle_ptr(struct vtn_builder *b, SpvOp opcode,
case SpvOpPtrDiff: {
/* OpPtrDiff returns the difference in number of elements (not byte offset). */
unsigned elem_size, elem_align;
glsl_get_natural_size_align_bytes(type1->deref->type,
glsl_get_natural_size_align_bytes(type1->pointed->type,
&elem_size, &elem_align);
def = nir_build_addr_isub(&b->nb,
@ -6792,7 +6792,7 @@ vtn_emit_kernel_entry_point_wrapper(struct vtn_builder *b,
if (is_by_val) {
in_var->data.mode = nir_var_uniform;
in_var->type = param_type->deref->type;
in_var->type = param_type->pointed->type;
} else if (param_type->base_type == vtn_base_type_image) {
in_var->data.mode = nir_var_image;
in_var->type = param_type->glsl_image;
@ -7328,7 +7328,7 @@ vtn_print_value(struct vtn_builder *b, struct vtn_value *val, FILE *f)
fprintf(f, " %s", vtn_base_type_to_string(type->base_type));
switch (type->base_type) {
case vtn_base_type_pointer:
fprintf(f, " deref=%d", vtn_id_for_type(b, type->deref));
fprintf(f, " deref=%d", vtn_id_for_type(b, type->pointed));
fprintf(f, " %s", spirv_storageclass_to_string(val->type->storage_class));
break;
default:

View file

@ -149,7 +149,7 @@ vtn_ssa_value_load_function_param(struct vtn_builder *b,
if (glsl_type_is_vector_or_scalar(value->type)) {
/* if the parameter is passed by value, we need to create a local copy if it's a pointer */
if (info->by_value && type && type->base_type == vtn_base_type_pointer) {
struct vtn_type *pointee_type = type->deref;
struct vtn_type *pointee_type = type->pointed;
nir_variable *copy =
nir_local_variable_create(b->nb.impl, pointee_type->type, NULL);

View file

@ -70,8 +70,8 @@ vtn_opencl_mangle(const char *in_name,
if (address_space > 0)
args_str += sprintf(args_str, "U3AS%d", address_space);
type = src_types[i]->deref->type;
base_type = src_types[i]->deref->base_type;
type = src_types[i]->pointed->type;
base_type = src_types[i]->pointed->base_type;
}
if (const_mask & (1 << i))
@ -86,7 +86,7 @@ vtn_opencl_mangle(const char *in_name,
bool substitution = false;
for (unsigned j = 0; j < i; ++j) {
const struct glsl_type *other_type = src_types[j]->base_type == vtn_base_type_pointer ?
src_types[j]->deref->type : src_types[j]->type;
src_types[j]->pointed->type : src_types[j]->type;
if (type == other_type) {
substitution = true;
break;
@ -403,7 +403,7 @@ get_pointer_type(struct vtn_builder *b, struct vtn_type *t, SpvStorageClass stor
b, vtn_storage_class_to_mode(b, storage_class, NULL, NULL)));
ret->base_type = vtn_base_type_pointer;
ret->storage_class = storage_class;
ret->deref = t;
ret->pointed = t;
return ret;
}
@ -411,7 +411,7 @@ static struct vtn_type *
get_signed_type(struct vtn_builder *b, struct vtn_type *t)
{
if (t->base_type == vtn_base_type_pointer) {
return get_pointer_type(b, get_signed_type(b, t->deref), t->storage_class);
return get_pointer_type(b, get_signed_type(b, t->pointed), t->storage_class);
}
return get_vtn_type_for_glsl_type(
b, glsl_vector_type(glsl_signed_base_type_of(glsl_get_base_type(t->type)),
@ -596,11 +596,11 @@ handle_core(struct vtn_builder *b, uint32_t opcode,
*/
for (unsigned i = 0; i < num_srcs; ++i) {
if (src_types[i]->base_type == vtn_base_type_pointer &&
src_types[i]->deref->base_type == vtn_base_type_vector &&
src_types[i]->deref->length == 3) {
src_types[i]->pointed->base_type == vtn_base_type_vector &&
src_types[i]->pointed->length == 3) {
src_types[i] =
get_pointer_type(b,
get_vtn_type_for_glsl_type(b, glsl_replace_vector_type(src_types[i]->deref->type, 4)),
get_vtn_type_for_glsl_type(b, glsl_replace_vector_type(src_types[i]->pointed->type, 4)),
src_types[i]->storage_class);
}
}

View file

@ -364,8 +364,8 @@ struct vtn_type {
/* Members for pointer types */
struct {
/* For pointers, the vtn_type for dereferenced type */
struct vtn_type *deref;
/* For pointers, the vtn_type of the object pointed to. */
struct vtn_type *pointed;
/* Storage class for pointers */
SpvStorageClass storage_class;

View file

@ -1956,16 +1956,16 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_def *ssa,
struct vtn_pointer *ptr = vtn_zalloc(b, struct vtn_pointer);
struct vtn_type *without_array =
vtn_type_without_array(ptr_type->deref);
vtn_type_without_array(ptr_type->pointed);
nir_variable_mode nir_mode;
ptr->mode = vtn_storage_class_to_mode(b, ptr_type->storage_class,
without_array, &nir_mode);
ptr->type = ptr_type->deref;
ptr->type = ptr_type->pointed;
ptr->ptr_type = ptr_type;
const struct glsl_type *deref_type =
vtn_type_get_nir_type(b, ptr_type->deref, ptr->mode);
vtn_type_get_nir_type(b, ptr_type->pointed, ptr->mode);
if (!vtn_pointer_is_external_block(b, ptr) &&
ptr->mode != vtn_variable_mode_accel_struct) {
ptr->deref = nir_build_deref_cast(&b->nb, ssa, nir_mode,
@ -2088,9 +2088,9 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
struct vtn_value *initializer)
{
vtn_assert(ptr_type->base_type == vtn_base_type_pointer);
struct vtn_type *type = ptr_type->deref;
struct vtn_type *type = ptr_type->pointed;
struct vtn_type *without_array = vtn_type_without_array(ptr_type->deref);
struct vtn_type *without_array = vtn_type_without_array(ptr_type->pointed);
enum vtn_variable_mode mode;
nir_variable_mode nir_mode;
@ -2669,7 +2669,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
struct vtn_type *ptr_type = vtn_zalloc(b, struct vtn_type);
ptr_type->base_type = vtn_base_type_pointer;
ptr_type->deref = sampler_type;
ptr_type->pointed = sampler_type;
ptr_type->storage_class = SpvStorageClassUniform;
ptr_type->type = nir_address_format_to_glsl_type(
@ -2736,8 +2736,8 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
struct vtn_pointer *dest = vtn_value_to_pointer(b, dest_val);
struct vtn_pointer *src = vtn_value_to_pointer(b, src_val);
vtn_assert_types_equal(b, opcode, dest_val->type->deref,
src_val->type->deref);
vtn_assert_types_equal(b, opcode, dest_val->type->pointed,
src_val->type->pointed);
unsigned idx = 3, dest_alignment, src_alignment;
SpvMemoryAccessMask dest_access, src_access;
@ -2800,7 +2800,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
struct vtn_value *src_val = vtn_value(b, w[3], vtn_value_type_pointer);
struct vtn_pointer *src = vtn_value_to_pointer(b, src_val);
vtn_assert_types_equal(b, opcode, res_type, src_val->type->deref);
vtn_assert_types_equal(b, opcode, res_type, src_val->type->pointed);
unsigned idx = 4, alignment;
SpvMemoryAccessMask access;
@ -2842,7 +2842,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
break;
}
vtn_assert_types_equal(b, opcode, dest_val->type->deref, src_val->type);
vtn_assert_types_equal(b, opcode, dest_val->type->pointed, src_val->type);
unsigned idx = 3, alignment;
SpvMemoryAccessMask access;
@ -2936,7 +2936,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
"storage class specified in the instruction");
vtn_fail_if(src_type->base_type != vtn_base_type_pointer ||
src_type->deref->id != dst_type->deref->id,
src_type->pointed->id != dst_type->pointed->id,
"Source pointer of an SpvOpGenericCastToPtrExplicit must "
"have a type of OpTypePointer whose Type is the same as "
"the Type of Result Type");
@ -2955,7 +2955,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
nir_variable_mode nir_mode;
enum vtn_variable_mode mode =
vtn_storage_class_to_mode(b, storage_class, dst_type->deref, &nir_mode);
vtn_storage_class_to_mode(b, storage_class, dst_type->pointed, &nir_mode);
nir_address_format addr_format = vtn_mode_to_address_format(b, mode);
nir_def *null_value =