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@itsqueeze.com>
This commit is contained in:

committed by
Arcady Goldmints-Orlov

parent
75d8b4e795
commit
7d7ab34d5f
@@ -2143,6 +2143,19 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
|
|||||||
var->var->interface_type = NULL;
|
var->var->interface_type = NULL;
|
||||||
break;
|
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:
|
case vtn_variable_mode_workgroup:
|
||||||
if (b->options->lower_workgroup_access_to_offsets) {
|
if (b->options->lower_workgroup_access_to_offsets) {
|
||||||
var->shared_location = -1;
|
var->shared_location = -1;
|
||||||
@@ -2255,8 +2268,6 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case vtn_variable_mode_ubo:
|
|
||||||
case vtn_variable_mode_ssbo:
|
|
||||||
case vtn_variable_mode_push_constant:
|
case vtn_variable_mode_push_constant:
|
||||||
case vtn_variable_mode_cross_workgroup:
|
case vtn_variable_mode_cross_workgroup:
|
||||||
/* These don't need actual variables. */
|
/* These don't need actual variables. */
|
||||||
|
Reference in New Issue
Block a user