mesa/glsl: set sampler units directly in gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 4 Nov 2016 06:05:22 +0000 (17:05 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:42 +0000 (11:21 +1100)
Now that we create gl_program earlier there is no need to mess about
copying things to gl_linked_shader then to gl_program.

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

index 6f05a3a8098c8c7ab45cbb71fa65711579ebb71e..7439fd3789aeda2a89f0bd629cbc5f02ec462b27 100644 (file)
@@ -134,7 +134,8 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
                 storage->opaque[sh].active) {
                for (unsigned i = 0; i < elements; i++) {
                   const unsigned index = storage->opaque[sh].index + i;
-                  shader->SamplerUnits[index] = storage->storage[i].i;
+                  shader->Program->SamplerUnits[index] =
+                     storage->storage[i].i;
                }
 
             } else if (storage->type->base_type == GLSL_TYPE_IMAGE &&
@@ -242,7 +243,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
             if (shader && storage->opaque[sh].active) {
                unsigned index = storage->opaque[sh].index;
 
-               shader->SamplerUnits[index] = storage->storage[0].i;
+               shader->Program->SamplerUnits[index] = storage->storage[0].i;
             }
          }
       }
index 69241beadd1bca9d5dc1f2c630b3bf5c4b533cf9..d05c25205ce79acd548f3097bf7f7c9e2db6da2a 100644 (file)
@@ -2360,14 +2360,6 @@ struct gl_linked_shader
    GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
    /*@}*/
 
-   /**
-    * Map from sampler unit to texture unit (set by glUniform1i())
-    *
-    * A sampler unit is associated with each sampler uniform by the linker.
-    * The sampler unit associated with each uniform is stored in the
-    * \c gl_uniform_storage::sampler field.
-    */
-   GLubyte SamplerUnits[MAX_SAMPLERS];
    /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
    gl_texture_index SamplerTargets[MAX_SAMPLERS];
 
index ffb20ca2ac1062a3769f32f6f8cd0d8cc995ec09..047d21a85cf45f43c917352392e477b1c300a4e4 100644 (file)
@@ -866,8 +866,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
          bool changed = false;
          for (int j = 0; j < count; j++) {
             unsigned unit = uni->opaque[i].index + offset + j;
-            if (sh->SamplerUnits[unit] != ((unsigned *) values)[j]) {
-               sh->SamplerUnits[unit] = ((unsigned *) values)[j];
+            if (sh->Program->SamplerUnits[unit] != ((unsigned *) values)[j]) {
+               sh->Program->SamplerUnits[unit] = ((unsigned *) values)[j];
                changed = true;
             }
          }
@@ -879,8 +879,6 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
            }
 
             struct gl_program *const prog = sh->Program;
-            assert(sizeof(prog->SamplerUnits) == sizeof(sh->SamplerUnits));
-
            _mesa_update_shader_textures_used(shProg, prog);
             if (ctx->Driver.SamplerUniformChange)
               ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog);
@@ -1108,7 +1106,7 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
       mask = shader->Program->SamplersUsed;
       while (mask) {
          const int s = u_bit_scan(&mask);
-         GLuint unit = shader->SamplerUnits[s];
+         GLuint unit = shader->Program->SamplerUnits[s];
          GLuint tgt = shader->SamplerTargets[s];
 
          /* FIXME: Samplers are initialized to 0 and Mesa doesn't do a
index f26fd784e71a979db2f55af85a7cd752dbc41d27..5534fcf2abe588a1a72a36be4ec013d21c102dca 100644 (file)
@@ -73,14 +73,13 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
 
    assert(shader);
 
-   memcpy(prog->SamplerUnits, shader->SamplerUnits, sizeof(prog->SamplerUnits));
    memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
 
    shProg->SamplersValidated = GL_TRUE;
 
    while (mask) {
       const int s = u_bit_scan(&mask);
-      GLuint unit = shader->SamplerUnits[s];
+      GLuint unit = prog->SamplerUnits[s];
       GLuint tgt = shader->SamplerTargets[s];
       assert(unit < ARRAY_SIZE(prog->TexturesUsed));
       assert(tgt < NUM_TEXTURE_TARGETS);