st/mesa/glsl: set num_images directly in shader_info
authorTimothy Arceri <timothy.arceri@collabora.com>
Wed, 9 Nov 2016 02:35:11 +0000 (13:35 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Mon, 9 Jan 2017 04:27:35 +0000 (15:27 +1100)
This change also removes the now duplicate NumImages field.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c
src/mesa/state_tracker/st_atom_image.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 57a7db41ff4b3d12a9029c1b73beef0fc0a6de7e..86711e228227e9ffd0a942ed16db2b49fc7a6097 100644 (file)
@@ -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;
 
index bf902bd862a3c8404608c13b8e8d00e28cda8422..d187b66ab53adcef12c6a9b969414b7993efef97 100644 (file)
@@ -3220,12 +3220,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) {
index 691323d8f3c0728d0173bd58f2910fbf991d9c6b..793a527cb450b21586072f602fc801fcf68a5214 100644 (file)
@@ -2382,13 +2382,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;
 };
 
index 7771b7ce7da2f3ec674621b70307940895eba461..e67dc52c156a44085aba4b8f015f4d5fdd7d9eec 100644 (file)
@@ -2175,7 +2175,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) {
index b30006a143c9ab58ff36d283672a31f913160dfa..2fb37f5b0c6ef2c1b8fdbd7109f591e2060da60d 100644 (file)
@@ -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);
 }
 
index 12a53ecb73df5bf938a7c5a21f330e8d91a68343..5de125897f8451b142a22be1d91397889b2058b2 100644 (file)
@@ -6370,7 +6370,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],
@@ -6639,7 +6639,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)