summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-10-18 17:58:11 -0700
committerJason Ekstrand <[email protected]>2017-12-05 22:01:54 -0800
commit992aabf2393f22969a3333a3f680384f752ffd1b (patch)
treef105cdc4a68b48d5d6d52a6769d44f74a8b2bd38 /src/compiler/spirv
parent843c192e2be3d194f4640a273f4efde561bcc8fc (diff)
spirv: Add theoretical support for single component pointers
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. Reviewed-by: Kristian H. Kristensen <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/vtn_variables.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index c67b34e7931..3369ae05a95 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1502,7 +1502,7 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
vtn_assert(ptr->ptr_type);
vtn_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.
*/
@@ -1520,15 +1520,22 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
ptr = vtn_ssa_offset_pointer_dereference(b, ptr, &chain);
}
- vtn_assert(ptr->offset && ptr->block_index);
- return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
+ vtn_assert(ptr->offset);
+ if (ptr->block_index) {
+ vtn_assert(ptr->mode == vtn_variable_mode_ubo ||
+ ptr->mode == vtn_variable_mode_ssbo);
+ return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
+ } else {
+ vtn_fail("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)
{
- vtn_assert(ssa->num_components == 2 && ssa->bit_size == 32);
+ vtn_assert(ssa->num_components <= 2 && ssa->bit_size == 32);
vtn_assert(ptr_type->base_type == vtn_base_type_pointer);
vtn_assert(ptr_type->deref->base_type != vtn_base_type_pointer);
/* This pointer type needs to have actual storage */
@@ -1539,8 +1546,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) {
+ vtn_assert(ssa->num_components == 2);
+ vtn_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 {
+ vtn_assert(ssa->num_components == 1);
+ unreachable("Invalid pointer");
+ ptr->block_index = NULL;
+ ptr->offset = ssa;
+ }
return ptr;
}