aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorAlejandro PiƱeiro <[email protected]>2017-11-19 09:47:36 +0100
committerArcady Goldmints-Orlov <[email protected]>2019-06-30 16:58:26 -0500
commit7d7ab34d5f5c280d635a54ae080cffc40e74584a (patch)
treee42d076ecc9debaa5f1ff1727bd3cd0a3796396b /src/compiler
parent75d8b4e79542e08a42cab28378b830836f078eb5 (diff)
spirv/nir: create nir variable for UBO/SSBO
Providing nir variables for UBO/SSBO it is not required for Vulkan, but it is needed for OpenGL (ARB_gl_spirv), like for example, to gather info from the UBO/SSBO while linking. In opposite with most cases where the nir variables is created, here the type assigned is the full type (not just the bare type). This is needed because while linking using the nir shader we need the explicit layout info (explicit stride, explicit offset, row_major, etc). Also, we need to assign an interface type, used also on the OpenGL linker if it is a UBO/SSBO. See ir_variable::is_in_buffer_block as example. v2: assign interface_type to be the variable type, not need to be arrayness (Timothy) Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/spirv/vtn_variables.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index a7d74a0cf46..c640e3aa670 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -2143,6 +2143,19 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
var->var->interface_type = NULL;
break;
+ case vtn_variable_mode_ubo:
+ case vtn_variable_mode_ssbo:
+ var->var = rzalloc(b->shader, nir_variable);
+ var->var->name = ralloc_strdup(var->var, val->name);
+
+ var->var->type = var->type->type;
+ var->var->interface_type = var->type->type;
+
+ var->var->data.mode = nir_mode;
+ var->var->data.location = -1;
+
+ break;
+
case vtn_variable_mode_workgroup:
if (b->options->lower_workgroup_access_to_offsets) {
var->shared_location = -1;
@@ -2255,8 +2268,6 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
break;
}
- case vtn_variable_mode_ubo:
- case vtn_variable_mode_ssbo:
case vtn_variable_mode_push_constant:
case vtn_variable_mode_cross_workgroup:
/* These don't need actual variables. */