.trinary_minmax = true,
.variable_pointers = true,
},
- .ubo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
- .ssbo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
- .phys_ssbo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT64, 1),
- .push_const_ptr_type = glsl_uint_type(),
- .shared_ptr_type = glsl_uint_type(),
+ .ubo_addr_format = nir_address_format_32bit_index_offset,
+ .ssbo_addr_format = nir_address_format_32bit_index_offset,
+ .phys_ssbo_addr_format = nir_address_format_64bit_global,
+ .push_const_addr_format = nir_address_format_logical,
+ .shared_addr_format = nir_address_format_32bit_offset,
};
entry_point = spirv_to_nir(spirv, module->size / 4,
spec_entries, num_spec_entries,
struct spirv_supported_capabilities caps;
- /* Storage types for various kinds of pointers. */
- const struct glsl_type *ubo_ptr_type;
- const struct glsl_type *ssbo_ptr_type;
- const struct glsl_type *phys_ssbo_ptr_type;
- const struct glsl_type *push_const_ptr_type;
- const struct glsl_type *shared_ptr_type;
- const struct glsl_type *global_ptr_type;
- const struct glsl_type *temp_ptr_type;
+ /* Address format for various kinds of pointers. */
+ nir_address_format ubo_addr_format;
+ nir_address_format ssbo_addr_format;
+ nir_address_format phys_ssbo_addr_format;
+ nir_address_format push_const_addr_format;
+ nir_address_format shared_addr_format;
+ nir_address_format global_addr_format;
+ nir_address_format temp_addr_format;
struct {
void (*func)(void *private_data,
/* These can actually be stored to nir_variables and used as SSA
* values so they need a real glsl_type.
*/
+ nir_address_format addr_format = nir_address_format_logical;
switch (storage_class) {
case SpvStorageClassUniform:
- val->type->type = b->options->ubo_ptr_type;
+ addr_format = b->options->ubo_addr_format;
break;
case SpvStorageClassStorageBuffer:
- val->type->type = b->options->ssbo_ptr_type;
+ addr_format = b->options->ssbo_addr_format;
break;
case SpvStorageClassPhysicalStorageBufferEXT:
- val->type->type = b->options->phys_ssbo_ptr_type;
+ addr_format = b->options->phys_ssbo_addr_format;
break;
case SpvStorageClassPushConstant:
- val->type->type = b->options->push_const_ptr_type;
+ addr_format = b->options->push_const_addr_format;
break;
case SpvStorageClassWorkgroup:
- val->type->type = b->options->shared_ptr_type;
+ addr_format = b->options->shared_addr_format;
break;
case SpvStorageClassCrossWorkgroup:
- val->type->type = b->options->global_ptr_type;
+ addr_format = b->options->global_addr_format;
break;
case SpvStorageClassFunction:
if (b->physical_ptrs)
- val->type->type = b->options->temp_ptr_type;
+ addr_format = b->options->temp_addr_format;
break;
default:
/* In this case, no variable pointers are allowed so all deref
* chains are complete back to the variable and it doesn't matter
- * what type gets used so we leave it NULL.
+ * what type gets.
*/
break;
}
+ val->type->type = nir_address_format_to_glsl_type(addr_format);
} else {
vtn_fail_if(val->type->storage_class != storage_class,
"The storage classes of an OpTypePointer and any "
"AddressingModelPhysical32 only supported for kernels");
b->shader->info.cs.ptr_size = 32;
b->physical_ptrs = true;
- b->options->shared_ptr_type = glsl_uint_type();
- b->options->global_ptr_type = glsl_uint_type();
- b->options->temp_ptr_type = glsl_uint_type();
+ b->options->shared_addr_format = nir_address_format_32bit_global;
+ b->options->global_addr_format = nir_address_format_32bit_global;
+ b->options->temp_addr_format = nir_address_format_32bit_global;
break;
case SpvAddressingModelPhysical64:
vtn_fail_if(b->shader->info.stage != MESA_SHADER_KERNEL,
"AddressingModelPhysical64 only supported for kernels");
b->shader->info.cs.ptr_size = 64;
b->physical_ptrs = true;
- b->options->shared_ptr_type = glsl_uint64_t_type();
- b->options->global_ptr_type = glsl_uint64_t_type();
- b->options->temp_ptr_type = glsl_uint64_t_type();
+ b->options->shared_addr_format = nir_address_format_64bit_global;
+ b->options->global_addr_format = nir_address_format_64bit_global;
+ b->options->temp_addr_format = nir_address_format_64bit_global;
break;
case SpvAddressingModelLogical:
vtn_fail_if(b->shader->info.stage >= MESA_SHADER_STAGES,
static const struct glsl_type *
vtn_ptr_type_for_mode(struct vtn_builder *b, enum vtn_variable_mode mode)
{
+ nir_address_format addr_format;
switch (mode) {
case vtn_variable_mode_ubo:
- return b->options->ubo_ptr_type;
+ addr_format = b->options->ubo_addr_format;
+ break;
case vtn_variable_mode_ssbo:
- return b->options->ssbo_ptr_type;
+ addr_format = b->options->ssbo_addr_format;
+ break;
default:
vtn_fail("Invalid mode for vulkan_resource_index");
}
+ return nir_address_format_to_glsl_type(addr_format);
}
static nir_ssa_def *
}
}
- nir_address_format ssbo_addr_format =
- anv_nir_ssbo_addr_format(pdevice, device->robust_buffer_access);
struct spirv_to_nir_options spirv_options = {
.lower_workgroup_access_to_offsets = true,
.caps = {
.transform_feedback = pdevice->info.gen >= 8,
.variable_pointers = true,
},
- .ubo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
- .ssbo_ptr_type = nir_address_format_to_glsl_type(ssbo_addr_format),
- .phys_ssbo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT64, 1),
- .push_const_ptr_type = glsl_uint_type(),
- .shared_ptr_type = glsl_uint_type(),
+ .ubo_addr_format = nir_address_format_32bit_index_offset,
+ .ssbo_addr_format =
+ anv_nir_ssbo_addr_format(pdevice, device->robust_buffer_access),
+ .phys_ssbo_addr_format = nir_address_format_64bit_global,
+ .push_const_addr_format = nir_address_format_logical,
+
+ /* TODO: Consider changing this to an address format that has the NULL
+ * pointer equals to 0. That might be a better format to play nice
+ * with certain code / code generators.
+ */
+ .shared_addr_format = nir_address_format_32bit_offset,
};