Mesa (master): spirv/nir: create nir variable for UBO/SSBO
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 1 10:29:26 UTC 2019
Module: Mesa
Branch: master
Commit: 7d7ab34d5f5c280d635a54ae080cffc40e74584a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d7ab34d5f5c280d635a54ae080cffc40e74584a
Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date: Sun Nov 19 09:47:36 2017 +0100
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 <tarceri at itsqueeze.com>
---
src/compiler/spirv/vtn_variables.c | 15 +++++++++++++--
1 file 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. */
More information about the mesa-commit
mailing list