st/mesa/glsl: move SamplerTargets to gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Tue, 8 Nov 2016 22:49:59 +0000 (09:49 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:42 +0000 (11:21 +1100)
This will help allow us to simplify the handling of samplers by
storing them in a single location rather than duplicating them in
both gl_linked_shader and gl_program.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/link_uniforms.cpp
src/mesa/main/mtypes.h
src/mesa/main/uniform_query.cpp
src/mesa/main/uniforms.c
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 8604dba4b0798c115ec06066f695941a259cf84b..57a7db41ff4b3d12a9029c1b73beef0fc0a6de7e 100644 (file)
@@ -1248,10 +1248,11 @@ link_assign_uniform_storage(struct gl_context *ctx,
          parcel.shader_samplers_used;
       prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers;
 
-      STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->SamplerTargets) ==
+      STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->Program->sh.SamplerTargets) ==
                     sizeof(parcel.targets));
-      memcpy(prog->_LinkedShaders[i]->SamplerTargets, parcel.targets,
-             sizeof(prog->_LinkedShaders[i]->SamplerTargets));
+      memcpy(prog->_LinkedShaders[i]->Program->sh.SamplerTargets,
+             parcel.targets,
+             sizeof(prog->_LinkedShaders[i]->Program->sh.SamplerTargets));
    }
 
 #ifndef NDEBUG
index 6ab5cdeec4e72a41b95ae4e6861cd8eb0aecf25a..243c76ded14ef1257e8b5dde7b8a81d5e75ab9ae 100644 (file)
@@ -2004,6 +2004,11 @@ struct gl_program
          struct gl_uniform_block **UniformBlocks;
          struct gl_uniform_block **ShaderStorageBlocks;
 
+         /** Which texture target is being sampled
+          * (TEXTURE_1D/2D/3D/etc_INDEX)
+          */
+         gl_texture_index SamplerTargets[MAX_SAMPLERS];
+
          union {
             struct {
                /**
@@ -2359,9 +2364,6 @@ struct gl_linked_shader
    GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
    /*@}*/
 
-   /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
-   gl_texture_index SamplerTargets[MAX_SAMPLERS];
-
    /**
     * Number of default uniform block components used by this shader.
     *
@@ -2392,14 +2394,14 @@ struct gl_linked_shader
    struct gl_shader_info info;
 };
 
-static inline GLbitfield gl_external_samplers(struct gl_linked_shader *shader)
+static inline GLbitfield gl_external_samplers(struct gl_program *prog)
 {
    GLbitfield external_samplers = 0;
-   GLbitfield mask = shader->Program->SamplersUsed;
+   GLbitfield mask = prog->SamplersUsed;
 
    while (mask) {
       int idx = u_bit_scan(&mask);
-      if (shader->SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX)
+      if (prog->sh.SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX)
          external_samplers |= (1 << idx);
    }
 
index 047d21a85cf45f43c917352392e477b1c300a4e4..145eff01756cc9918911ceb9c26f417d43d0cb71 100644 (file)
@@ -1107,7 +1107,7 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
       while (mask) {
          const int s = u_bit_scan(&mask);
          GLuint unit = shader->Program->SamplerUnits[s];
-         GLuint tgt = shader->SamplerTargets[s];
+         GLuint tgt = shader->Program->sh.SamplerTargets[s];
 
          /* FIXME: Samplers are initialized to 0 and Mesa doesn't do a
           * great job of eliminating unused uniforms currently so for now
index 5534fcf2abe588a1a72a36be4ec013d21c102dca..51db39e63a0ac784bec81359161df353a79dca13 100644 (file)
@@ -80,7 +80,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
    while (mask) {
       const int s = u_bit_scan(&mask);
       GLuint unit = prog->SamplerUnits[s];
-      GLuint tgt = shader->SamplerTargets[s];
+      GLuint tgt = prog->sh.SamplerTargets[s];
       assert(unit < ARRAY_SIZE(prog->TexturesUsed));
       assert(tgt < NUM_TEXTURE_TARGETS);
 
index 59aef12b1e3934b37e3833070292358177b96440..f7797e28fa3660c110a17cd5a4db48bb67a145d6 100644 (file)
@@ -2918,7 +2918,7 @@ get_mesa_program(struct gl_context *ctx,
    do_set_program_inouts(shader->ir, prog, shader->Stage);
 
    prog->ShadowSamplers = shader->shadow_samplers;
-   prog->ExternalSamplersUsed = gl_external_samplers(shader);
+   prog->ExternalSamplersUsed = gl_external_samplers(prog);
    _mesa_update_shader_textures_used(shader_program, prog);
 
    /* Set the gl_FragDepth layout. */
index d5309e49fab448a7f33ae2d39c2916729b9facd9..60d101c91d8a559c77b6189819173f9dcae631ed 100644 (file)
@@ -413,7 +413,7 @@ st_nir_get_mesa_program(struct gl_context *ctx,
    }
 
    prog->ShadowSamplers = shader->shadow_samplers;
-   prog->ExternalSamplersUsed = gl_external_samplers(shader);
+   prog->ExternalSamplersUsed = gl_external_samplers(prog);
    _mesa_update_shader_textures_used(shader_program, prog);
 
    /* Avoid reallocation of the program parameter list, because the uniform