summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-04 17:05:22 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:42 +1100
commit53a509723ff10ae1494e611de3823f17b7e9f225 (patch)
tree807c5bffbfa4027f9c178787709187812c4570bc /src
parent7cc61cf706e857e27ea3ce9578b9c480bfbc94a1 (diff)
mesa/glsl: set sampler units directly in gl_program
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/link_uniform_initializers.cpp5
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/uniform_query.cpp8
-rw-r--r--src/mesa/main/uniforms.c3
4 files changed, 7 insertions, 17 deletions
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
index 6f05a3a8098..7439fd3789a 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -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;
}
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 69241beadd1..d05c25205ce 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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];
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index ffb20ca2ac1..047d21a85cf 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -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
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index f26fd784e71..5534fcf2abe 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -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);