zink: don't emit ubos or bindings for ubo variables

we want to only emit the full ubo block here to be used in the binding
table, not each ubo member variable, the likes of which are denoted by
having var->data.location != 0

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6981>
This commit is contained in:
Mike Blumenkrantz 2020-06-26 15:46:44 -04:00 committed by Marge Bot
parent d369c00c83
commit 59027a2682
2 changed files with 9 additions and 0 deletions

View File

@ -588,6 +588,12 @@ emit_sampler(struct ntv_context *ctx, struct nir_variable *var)
static void
emit_ubo(struct ntv_context *ctx, struct nir_variable *var)
{
/* variables accessed inside a uniform block will get merged into a big
* memory blob and accessed by offset
*/
if (var->data.location)
return;
uint32_t size = glsl_count_attribute_slots(var->interface_type, false);
SpvId vec4_type = get_uvec_type(ctx, 32, 4);
SpvId array_length = emit_uint_const(ctx, 32, size);

View File

@ -284,6 +284,9 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
nir_foreach_variable_with_modes(var, nir, nir_var_uniform |
nir_var_mem_ubo) {
if (var->data.mode == nir_var_mem_ubo) {
/* ignore variables being accessed if they aren't the base of the UBO */
if (var->data.location)
continue;
int binding = zink_binding(nir->info.stage,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
var->data.binding);