nir/linker: take into account hidden uniforms
authorAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 8 Aug 2018 11:41:58 +0000 (13:41 +0200)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Mon, 13 Aug 2018 14:28:27 +0000 (16:28 +0200)
So they are not exposed through the introspection API.

It is worth to note that the number of hidden uniforms of GLSL linking
vs SPIR-V linking would be somewhat different due the differen order
of the nir lowerings/optimizations.

For example: gl_FbWposYTransform. This is introduced as part of
nir_lower_wpos_ytransform. On GLSL that is executed after the IR-based
linking. So that means that on GLSL the UniformStorage will not
include this uniform. With the SPIR-V linking, that uniform is already
present, but marked as hidden. So it will be included on the
UniformStorage, but as hidden.

One alternative would create a special how_declared for that case, but
seemed an overkill. Using hidden should be ok as far as it is used
properly.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/gl_nir_link_uniforms.c
src/compiler/glsl/gl_nir_linker.c

index f729fa988e29cd04e862fd4f8902c4802387fc40..1573e30c41e7f7a9f7d4aa26e8e1d065081eef74 100644 (file)
@@ -365,6 +365,10 @@ nir_link_uniform(struct gl_context *ctx,
          uniform->remap_location = UNMAPPED_UNIFORM_LOC;
       }
 
+      uniform->hidden = state->current_var->data.how_declared == nir_var_hidden;
+      if (uniform->hidden)
+         state->num_hidden_uniforms++;
+
       /* @FIXME: the initialization of the following will be done as we
        * implement support for their specific features, like SSBO, atomics,
        * etc.
@@ -374,7 +378,6 @@ nir_link_uniform(struct gl_context *ctx,
       uniform->matrix_stride = -1;
       uniform->array_stride = -1;
       uniform->row_major = false;
-      uniform->hidden = false;
       uniform->builtin = false;
       uniform->is_shader_storage = false;
       uniform->atomic_buffer_index = -1;
index d09a2c0a6c5810598d49acebf62e2284d777be9f..547549bc4e072ed2553eef139a920c68b0734baf 100644 (file)
@@ -56,6 +56,10 @@ nir_build_program_resource_list(struct gl_context *ctx,
    for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
       struct gl_uniform_storage *uniform = &prog->data->UniformStorage[i];
 
+      /* Do not add uniforms internally used by Mesa. */
+      if (uniform->hidden)
+         continue;
+
       if (!link_util_add_program_resource(prog, resource_set, GL_UNIFORM, uniform,
                                           uniform->active_shader_mask)) {
          return;