[Mesa-dev] [PATCH 19/26] nir/linker: use only the array element type for array of ssbo/ubo
Timothy Arceri
tarceri at itsqueeze.com
Wed Sep 19 05:20:47 UTC 2018
On 16/9/18 2:18 am, Alejandro PiƱeiro wrote:
> For this interfaces, the inner members are added only once as uniforms
> or resources, in opposite to other cases, like a uniform array of
> structs.
> ---
> src/compiler/glsl/gl_nir_link_uniforms.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
> index 00995fb3f76..c692cd0171f 100644
> --- a/src/compiler/glsl/gl_nir_link_uniforms.c
> +++ b/src/compiler/glsl/gl_nir_link_uniforms.c
> @@ -498,11 +498,33 @@ gl_nir_link_uniforms(struct gl_context *ctx,
>
> state.current_var = var;
>
> + /*
> + * From OpenGL 4.6 spec, section 7.3.1.1, "Naming Active Resources":
> + *
> + * "* For an active shader storage block member declared as an
> + * array of an aggregate type, an entry will be generated only
> + * for the first array element, regardless of its type. Such
> + * block members are referred to as top-level arrays. If the
> + * block member is an aggregate type, the enumeration rules are
> + * then applied recursively.
> + * * For an active interface block not declared as an array of
> + * block instances, a single entry will be generated, using the
> + * block name from the shader source."
> + *
> + * So for the UBO and SSBO case, we expand only the array element
> + * type.
> + */
> + const struct glsl_type *type = var->type;
> + if (nir_variable_is_in_block(var) &&
> + glsl_type_is_array(type)) {
> + type = glsl_get_array_element(type);
This also strips away vector and matrix type information while leaving
arrays for anything but a single dimension array.
Are you sure you don't want the following instead?
type = glsl_get_array_element(type);
> + }
> +
> struct type_tree_entry *type_tree =
> - build_type_tree_for_type(var->type);
> + build_type_tree_for_type(type);
> state.current_type = type_tree;
>
> - int res = nir_link_uniform(ctx, prog, sh->Program, shader_type, var->type,
> + int res = nir_link_uniform(ctx, prog, sh->Program, shader_type, type,
> location, &state);
>
> free_type_tree(type_tree);
>
More information about the mesa-dev
mailing list