[Mesa-dev] [PATCH 09/12] spirv: Add theoretical support for single component pointers
Jason Ekstrand
jason at jlekstrand.net
Thu Oct 19 18:04:11 UTC 2017
Up until now, all pointers have been ivec2s. We're about to add support
for pointers to workgroup storage and those are going to be uints.
---
src/compiler/spirv/vtn_variables.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 8272c72..74204f1 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1500,7 +1500,7 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
assert(ptr->ptr_type);
assert(ptr->ptr_type->type);
- if (!ptr->offset || !ptr->block_index) {
+ if (!ptr->offset) {
/* If we don't have an offset then we must be a pointer to the variable
* itself.
*/
@@ -1518,15 +1518,22 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
ptr = vtn_ssa_offset_pointer_dereference(b, ptr, &chain);
}
- assert(ptr->offset && ptr->block_index);
- return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
+ assert(ptr->offset);
+ if (ptr->block_index) {
+ assert(ptr->mode == vtn_variable_mode_ubo ||
+ ptr->mode == vtn_variable_mode_ssbo);
+ return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
+ } else {
+ unreachable("Invalid pointer");
+ return ptr->offset;
+ }
}
struct vtn_pointer *
vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
struct vtn_type *ptr_type)
{
- assert(ssa->num_components == 2 && ssa->bit_size == 32);
+ assert(ssa->num_components <= 2 && ssa->bit_size == 32);
assert(ptr_type->base_type == vtn_base_type_pointer);
assert(ptr_type->deref->base_type != vtn_base_type_pointer);
/* This pointer type needs to have actual storage */
@@ -1537,8 +1544,19 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
ptr_type, NULL);
ptr->type = ptr_type->deref;
ptr->ptr_type = ptr_type;
- ptr->block_index = nir_channel(&b->nb, ssa, 0);
- ptr->offset = nir_channel(&b->nb, ssa, 1);
+
+ if (ssa->num_components > 1) {
+ assert(ssa->num_components == 2);
+ assert(ptr->mode == vtn_variable_mode_ubo ||
+ ptr->mode == vtn_variable_mode_ssbo);
+ ptr->block_index = nir_channel(&b->nb, ssa, 0);
+ ptr->offset = nir_channel(&b->nb, ssa, 1);
+ } else {
+ assert(ssa->num_components == 1);
+ unreachable("Invalid pointer");
+ ptr->block_index = NULL;
+ ptr->offset = ssa;
+ }
return ptr;
}
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list