From 99a87a283a19ca9925f62c7831bf077f806f53d4 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 2 Dec 2020 12:36:07 -0500 Subject: [PATCH] zink: break out bo array type construction into ntv util function Reviewed-by: Adam Jackson Part-of: --- .../drivers/zink/nir_to_spirv/nir_to_spirv.c | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) 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 fdc269932c1..20eed34f05b 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 @@ -862,17 +862,9 @@ emit_image(struct ntv_context *ctx, struct nir_variable *var) spirv_builder_emit_binding(&ctx->builder, var_id, binding); } -static void -emit_bo(struct ntv_context *ctx, struct nir_variable *var) +static SpvId +get_bo_array_type(struct ntv_context *ctx, struct nir_variable *var) { - bool is_ubo_array = glsl_type_is_array(var->type) && glsl_type_is_interface(glsl_without_array(var->type)); - /* variables accessed inside a uniform block will get merged into a big - * memory blob and accessed by offset - */ - if (var->data.location && !is_ubo_array && var->type != var->interface_type) - return; - bool ssbo = var->data.mode == nir_var_mem_ssbo; - SpvId array_type; SpvId uint_type = spirv_builder_type_uint(&ctx->builder, 32); uint32_t array_size = glsl_count_attribute_slots(var->interface_type, false); @@ -884,6 +876,21 @@ emit_bo(struct ntv_context *ctx, struct nir_variable *var) array_length); } spirv_builder_emit_array_stride(&ctx->builder, array_type, 4); + return array_type; +} + +static void +emit_bo(struct ntv_context *ctx, struct nir_variable *var) +{ + bool is_ubo_array = glsl_type_is_array(var->type) && glsl_type_is_interface(glsl_without_array(var->type)); + /* variables accessed inside a uniform block will get merged into a big + * memory blob and accessed by offset + */ + if (var->data.location && !is_ubo_array && var->type != var->interface_type) + return; + bool ssbo = var->data.mode == nir_var_mem_ssbo; + + SpvId array_type = get_bo_array_type(ctx, var); // wrap UBO-array in a struct SpvId runtime_array = 0;