aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/nir_spirv.h16
-rw-r--r--src/compiler/spirv/spirv_to_nir.c30
-rw-r--r--src/compiler/spirv/vtn_variables.c8
3 files changed, 30 insertions, 24 deletions
diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index 7a16422b291..1e9e0727b63 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -72,14 +72,14 @@ struct spirv_to_nir_options {
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,
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 5e91f8815e8..fdea592e8c2 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1364,36 +1364,38 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
/* 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 "
@@ -3774,18 +3776,18 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
"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,
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 6fbe6900e48..91f7002734e 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -99,14 +99,18 @@ vk_desc_type_for_mode(struct vtn_builder *b, enum vtn_variable_mode mode)
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 *