[Mesa-dev] [PATCH 42/70] st/mesa/glsl: set num_images directly in shader_info

Timothy Arceri timothy.arceri at collabora.com
Tue Dec 20 10:37:52 UTC 2016


This change also removes the now duplicate NumImages field.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
 src/compiler/glsl/link_uniforms.cpp        |  2 +-
 src/compiler/glsl/linker.cpp               |  7 ++++---
 src/mesa/main/mtypes.h                     |  7 -------
 src/mesa/main/shaderapi.c                  |  1 -
 src/mesa/state_tracker/st_atom_image.c     | 12 ++++++------
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |  4 ++--
 6 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 57a7db4..86711e2 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1318,7 +1318,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
       }
 
       sh->Program->info.num_textures = uniform_size.num_shader_samplers;
-      sh->NumImages = uniform_size.num_shader_images;
+      sh->Program->info.num_images = uniform_size.num_shader_images;
       sh->num_uniform_components = uniform_size.num_shader_uniform_components;
       sh->num_combined_uniform_components = sh->num_uniform_components;
 
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 3b325e5..2c90141 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3222,12 +3222,13 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
       if (sh) {
-         if (sh->NumImages > ctx->Const.Program[i].MaxImageUniforms)
+         if (sh->Program->info.num_images > ctx->Const.Program[i].MaxImageUniforms)
             linker_error(prog, "Too many %s shader image uniforms (%u > %u)\n",
-                         _mesa_shader_stage_to_string(i), sh->NumImages,
+                         _mesa_shader_stage_to_string(i),
+                         sh->Program->info.num_images,
                          ctx->Const.Program[i].MaxImageUniforms);
 
-         total_image_units += sh->NumImages;
+         total_image_units += sh->Program->info.num_images;
          total_shader_storage_blocks += sh->Program->info.num_ssbos;
 
          if (i == MESA_SHADER_FRAGMENT) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 797e1e9..0c86f21 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2380,13 +2380,6 @@ struct gl_linked_shader
    struct exec_list *fragdata_arrays;
    struct glsl_symbol_table *symbols;
 
-   /**
-    * Number of image uniforms defined in the shader.  It specifies
-    * the number of valid elements in the \c ImageUnits and \c
-    * ImageAccess arrays.
-    */
-   GLuint NumImages;
-
    struct gl_shader_info info;
 };
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6d0f0e0..afe7060 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2168,7 +2168,6 @@ _mesa_copy_linked_program_data(const struct gl_shader_program *src,
 
    struct gl_program *dst = dst_sh->Program;
 
-   dst->info.num_images = dst_sh->NumImages;
    dst->info.separate_shader = src->SeparateShader;
 
    switch (dst_sh->Stage) {
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index b30006a..2fb37f5 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -57,7 +57,7 @@ st_bind_images(struct st_context *st, struct gl_linked_shader *shader,
 
    c = &st->ctx->Const.Program[shader->Stage];
 
-   for (i = 0; i < shader->NumImages; i++) {
+   for (i = 0; i < shader->Program->info.num_images; i++) {
       struct gl_image_unit *u =
          &st->ctx->ImageUnits[shader->Program->sh.ImageUnits[i]];
       struct st_texture_object *stObj = st_texture_object(u->TexObj);
@@ -118,14 +118,14 @@ st_bind_images(struct st_context *st, struct gl_linked_shader *shader,
          }
       }
    }
-   cso_set_shader_images(st->cso_context, shader_type, 0, shader->NumImages,
-                         images);
+   cso_set_shader_images(st->cso_context, shader_type, 0,
+                         shader->Program->info.num_images, images);
    /* clear out any stale shader images */
-   if (shader->NumImages < c->MaxImageUniforms)
+   if (shader->Program->info.num_images < c->MaxImageUniforms)
       cso_set_shader_images(
             st->cso_context, shader_type,
-            shader->NumImages,
-            c->MaxImageUniforms - shader->NumImages,
+            shader->Program->info.num_images,
+            c->MaxImageUniforms - shader->Program->info.num_images,
             NULL);
 }
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 5c4c13d..543256c 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6346,7 +6346,7 @@ st_translate_program(
    if (program->use_shared_memory)
       t->shared_memory = ureg_DECL_memory(ureg, TGSI_MEMORY_TYPE_SHARED);
 
-   for (i = 0; i < program->shader->NumImages; i++) {
+   for (i = 0; i < program->shader->Program->info.num_images; i++) {
       if (program->images_used & (1 << i)) {
          t->images[i] = ureg_DECL_image(ureg, i,
                                         program->image_targets[i],
@@ -6615,7 +6615,7 @@ set_affected_state_flags(uint64_t *states,
    if (prog->info.num_textures)
       *states |= new_sampler_views | new_samplers;
 
-   if (shader->NumImages)
+   if (prog->info.num_images)
       *states |= new_images;
 
    if (prog->info.num_ubos)
-- 
2.9.3



More information about the mesa-dev mailing list