spirv: Add explicit pointer types
Instead of baking in uvec2 for UBO and SSBO pointers and uint for push constant and shared memory pointers, make it configurable. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
This commit is contained in:

committed by
Jason Ekstrand

parent
be039cb467
commit
adc155a815
@@ -247,6 +247,10 @@ radv_shader_compile_to_nir(struct radv_device *device,
|
|||||||
.transform_feedback = true,
|
.transform_feedback = true,
|
||||||
.storage_image_ms = true,
|
.storage_image_ms = true,
|
||||||
},
|
},
|
||||||
|
.ubo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
|
||||||
|
.ssbo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
|
||||||
|
.push_const_ptr_type = glsl_uint_type(),
|
||||||
|
.shared_ptr_type = glsl_uint_type(),
|
||||||
};
|
};
|
||||||
entry_point = spirv_to_nir(spirv, module->size / 4,
|
entry_point = spirv_to_nir(spirv, module->size / 4,
|
||||||
spec_entries, num_spec_entries,
|
spec_entries, num_spec_entries,
|
||||||
|
@@ -61,6 +61,12 @@ struct spirv_to_nir_options {
|
|||||||
|
|
||||||
struct spirv_supported_capabilities caps;
|
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 *push_const_ptr_type;
|
||||||
|
const struct glsl_type *shared_ptr_type;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void (*func)(void *private_data,
|
void (*func)(void *private_data,
|
||||||
enum nir_spirv_debug_level level,
|
enum nir_spirv_debug_level level,
|
||||||
|
@@ -1279,26 +1279,21 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||||||
|
|
||||||
vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL);
|
vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL);
|
||||||
|
|
||||||
if (storage_class == SpvStorageClassUniform ||
|
/* These can actually be stored to nir_variables and used as SSA
|
||||||
storage_class == SpvStorageClassStorageBuffer) {
|
* values so they need a real glsl_type.
|
||||||
/* These can actually be stored to nir_variables and used as SSA
|
*/
|
||||||
* values so they need a real glsl_type.
|
switch (storage_class) {
|
||||||
*/
|
case SpvStorageClassUniform:
|
||||||
val->type->type = glsl_vector_type(GLSL_TYPE_UINT, 2);
|
val->type->type = b->options->ubo_ptr_type;
|
||||||
}
|
break;
|
||||||
|
case SpvStorageClassStorageBuffer:
|
||||||
if (storage_class == SpvStorageClassPushConstant) {
|
val->type->type = b->options->ssbo_ptr_type;
|
||||||
/* These can actually be stored to nir_variables and used as SSA
|
break;
|
||||||
* values so they need a real glsl_type.
|
case SpvStorageClassPushConstant:
|
||||||
*/
|
val->type->type = b->options->push_const_ptr_type;
|
||||||
val->type->type = glsl_uint_type();
|
break;
|
||||||
}
|
case SpvStorageClassWorkgroup:
|
||||||
|
val->type->type = b->options->shared_ptr_type;
|
||||||
if (storage_class == SpvStorageClassWorkgroup) {
|
|
||||||
/* These can actually be stored to nir_variables and used as SSA
|
|
||||||
* values so they need a real glsl_type.
|
|
||||||
*/
|
|
||||||
val->type->type = glsl_uint_type();
|
|
||||||
if (b->options->lower_workgroup_access_to_offsets) {
|
if (b->options->lower_workgroup_access_to_offsets) {
|
||||||
uint32_t size, align;
|
uint32_t size, align;
|
||||||
val->type->deref = vtn_type_layout_std430(b, val->type->deref,
|
val->type->deref = vtn_type_layout_std430(b, val->type->deref,
|
||||||
@@ -1306,6 +1301,13 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||||||
val->type->length = size;
|
val->type->length = size;
|
||||||
val->type->align = align;
|
val->type->align = align;
|
||||||
}
|
}
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -158,6 +158,10 @@ anv_shader_compile_to_nir(struct anv_pipeline *pipeline,
|
|||||||
.storage_8bit = device->instance->physicalDevice.info.gen >= 8,
|
.storage_8bit = device->instance->physicalDevice.info.gen >= 8,
|
||||||
.post_depth_coverage = device->instance->physicalDevice.info.gen >= 9,
|
.post_depth_coverage = device->instance->physicalDevice.info.gen >= 9,
|
||||||
},
|
},
|
||||||
|
.ubo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
|
||||||
|
.ssbo_ptr_type = glsl_vector_type(GLSL_TYPE_UINT, 2),
|
||||||
|
.push_const_ptr_type = glsl_uint_type(),
|
||||||
|
.shared_ptr_type = glsl_uint_type(),
|
||||||
};
|
};
|
||||||
|
|
||||||
nir_function *entry_point =
|
nir_function *entry_point =
|
||||||
|
Reference in New Issue
Block a user