diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index d713e31566b..ae45cbc5424 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -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); diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 942d6b21d15..eca835c0daf 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -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);