summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-04 16:41:30 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:42 +1100
commit7cc61cf706e857e27ea3ce9578b9c480bfbc94a1 (patch)
treedd9496b3d73fce531bd3512735319a2eb5d125a3 /src/mesa
parent4807a83da0e0f5e3272e85504ee3b2213ef1910a (diff)
mesa: simplify sampler setting code
There is no need to loop over active samplers the code above this would have already exited if the sampler was inactive, or errored if the count was larger than the uniforms array size. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/uniform_query.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 73e7b0bfdfd..ffb20ca2ac1 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -859,39 +859,28 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
- /* If the shader stage doesn't use the sampler uniform, skip this.
- */
- if (sh == NULL || !uni->opaque[i].active)
+ /* If the shader stage doesn't use the sampler uniform, skip this. */
+ if (!uni->opaque[i].active)
continue;
+ bool changed = false;
for (int j = 0; j < count; j++) {
- sh->SamplerUnits[uni->opaque[i].index + offset + j] =
- ((unsigned *) values)[j];
+ unsigned unit = uni->opaque[i].index + offset + j;
+ if (sh->SamplerUnits[unit] != ((unsigned *) values)[j]) {
+ sh->SamplerUnits[unit] = ((unsigned *) values)[j];
+ changed = true;
+ }
}
- struct gl_program *const prog = sh->Program;
-
- assert(sizeof(prog->SamplerUnits) == sizeof(sh->SamplerUnits));
-
- /* Determine if any of the samplers used by this shader stage have
- * been modified.
- */
- bool changed = false;
- GLbitfield mask = sh->active_samplers;
- while (mask) {
- const int j = u_bit_scan(&mask);
- if (prog->SamplerUnits[j] != sh->SamplerUnits[j]) {
- changed = true;
- break;
- }
- }
-
if (changed) {
if (!flushed) {
FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM);
flushed = true;
}
+ 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);