summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/vtn_variables.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-12-12 16:07:07 -0600
committerJason Ekstrand <[email protected]>2019-01-08 00:38:30 +0000
commitbf1a1eed882980a1cd08482386e3a001ce64a5a4 (patch)
treead641a504f2b72ed480f7a01d7d933f791ad1504 /src/compiler/spirv/vtn_variables.c
parent6cebeb4f71918aded1ddade5727f79fae83780fd (diff)
spirv: Propagate layout decorations to created glsl_types
Instead of just storing the decorations in the vtn_type, propagate them all the way through to the glsl_type. For array strides, this means we need to handle them earlier so we break array stride handling into it's own function and explicitly call it for both pointer and array types. Due to type deduplication in the SPIR-V, we may have explicit layout decorations on all sorts of types that don't actually want them. In order to prevent these leaking into unfortunate places in NIR, we explicitly strip them off before creating NIR variables and when casting pointers to non-external memory. Reviewed-by: Alejandro PiƱeiro <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_variables.c')
-rw-r--r--src/compiler/spirv/vtn_variables.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index fb497fc2d06..6e96cb606b4 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1624,8 +1624,10 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
ptr->block_index = NULL;
ptr->offset = ssa;
} else {
+ assert(!vtn_pointer_is_external_block(b, ptr));
+ const struct glsl_type *deref_type = ptr_type->deref->type;
ptr->deref = nir_build_deref_cast(&b->nb, ssa, nir_mode,
- ptr_type->deref->type);
+ glsl_get_bare_type(deref_type));
}
return ptr;
@@ -1701,14 +1703,17 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
var->var = rzalloc(b->shader, nir_variable);
var->var->name = ralloc_strdup(var->var, val->name);
- /* Need to tweak the nir type here as at vtn_handle_type we don't have
- * the access to storage_class, that is the one that points us that is
- * an atomic uint.
- */
if (storage_class == SpvStorageClassAtomicCounter) {
+ /* Need to tweak the nir type here as at vtn_handle_type we don't
+ * have the access to storage_class, that is the one that points us
+ * that is an atomic uint.
+ */
var->var->type = repair_atomic_type(var->type->type);
} else {
- var->var->type = var->type->type;
+ /* Private variables don't have any explicit layout but some layouts
+ * may have leaked through due to type deduplication in the SPIR-V.
+ */
+ var->var->type = glsl_get_bare_type(var->type->type);
}
var->var->data.mode = nir_mode;
var->var->data.location = -1;
@@ -1722,7 +1727,11 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
/* Create the variable normally */
var->var = rzalloc(b->shader, nir_variable);
var->var->name = ralloc_strdup(var->var, val->name);
- var->var->type = var->type->type;
+ /* Workgroup variables don't have any explicit layout but some
+ * layouts may have leaked through due to type deduplication in the
+ * SPIR-V.
+ */
+ var->var->type = glsl_get_bare_type(var->type->type);
var->var->data.mode = nir_var_shared;
}
break;
@@ -1775,7 +1784,11 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
var->var = rzalloc(b->shader, nir_variable);
var->var->name = ralloc_strdup(var->var, val->name);
- var->var->type = var->type->type;
+ /* In Vulkan, shader I/O variables don't have any explicit layout but
+ * some layouts may have leaked through due to type deduplication in
+ * the SPIR-V.
+ */
+ var->var->type = glsl_get_bare_type(var->type->type);
var->var->interface_type = interface_type->type;
var->var->data.mode = nir_mode;
var->var->data.patch = var->patch;