[Mesa-dev] [PATCH 54/70] mesa/glsl: set num_textures per stage directly in shader_info

Timothy Arceri timothy.arceri at collabora.com
Fri Nov 11 00:46:36 UTC 2016


---
 src/compiler/glsl/glsl_to_nir.cpp          | 1 -
 src/compiler/glsl/link_uniforms.cpp        | 2 +-
 src/compiler/glsl/linker.cpp               | 3 ++-
 src/mesa/main/mtypes.h                     | 1 -
 src/mesa/main/uniform_query.cpp            | 2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
 6 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 867cb50..84ce1f0 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -147,7 +147,6 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    shader->info->name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
    if (shader_prog->Label)
       shader->info->label = ralloc_strdup(shader, shader_prog->Label);
-   shader->info->num_textures = util_last_bit(sh->Program->SamplersUsed);
    shader->info->uses_clip_distance_out =
       sh->Program->ClipDistanceArraySize != 0;
    shader->info->has_transform_feedback_varyings =
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 3f8d81f..747de53 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -1321,7 +1321,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
          uniform_size.process(var);
       }
 
-      sh->num_samplers = uniform_size.num_shader_samplers;
+      sh->Program->info.num_textures = uniform_size.num_shader_samplers;
       sh->NumImages = 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 437c8a0..6125d06 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3041,7 +3041,8 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       if (sh == NULL)
          continue;
 
-      if (sh->num_samplers > ctx->Const.Program[i].MaxTextureImageUnits) {
+      if (sh->Program->info.num_textures >
+          ctx->Const.Program[i].MaxTextureImageUnits) {
          linker_error(prog, "Too many %s shader texture samplers\n",
                       _mesa_shader_stage_to_string(i));
       }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3d82750..8067de7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2347,7 +2347,6 @@ struct gl_linked_shader
     * \note Each of these fields is only set post-linking.
     */
    /*@{*/
-   unsigned num_samplers;	/**< Number of samplers used by this shader. */
    GLbitfield active_samplers;	/**< Bitfield of which samplers are used */
    GLbitfield shadow_samplers;	/**< Samplers used for shadow sampling. */
    /*@}*/
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index ec6d277..73e7b0b 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1141,7 +1141,7 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
          TexturesUsed[unit] |= (1 << tgt);
       }
 
-      active_samplers += shader->num_samplers;
+      active_samplers += shader->Program->info.num_textures;
    }
 
    if (active_samplers > MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index adaae70..4542f91 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6591,7 +6591,7 @@ set_affected_state_flags(uint64_t *states,
    if (prog->Parameters->NumParameters)
       *states |= new_constants;
 
-   if (shader->num_samplers)
+   if (prog->info.num_textures)
       *states |= new_sampler_views | new_samplers;
 
    if (shader->NumImages)
-- 
2.7.4



More information about the mesa-dev mailing list