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 <eric@anholt.net>
This commit is contained in:
@@ -134,7 +134,8 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
|
|||||||
storage->opaque[sh].active) {
|
storage->opaque[sh].active) {
|
||||||
for (unsigned i = 0; i < elements; i++) {
|
for (unsigned i = 0; i < elements; i++) {
|
||||||
const unsigned index = storage->opaque[sh].index + 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 &&
|
} 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) {
|
if (shader && storage->opaque[sh].active) {
|
||||||
unsigned index = storage->opaque[sh].index;
|
unsigned index = storage->opaque[sh].index;
|
||||||
|
|
||||||
shader->SamplerUnits[index] = storage->storage[0].i;
|
shader->Program->SamplerUnits[index] = storage->storage[0].i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2360,14 +2360,6 @@ struct gl_linked_shader
|
|||||||
GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
|
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) */
|
/** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
|
||||||
gl_texture_index SamplerTargets[MAX_SAMPLERS];
|
gl_texture_index SamplerTargets[MAX_SAMPLERS];
|
||||||
|
|
||||||
|
@@ -866,8 +866,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
|
|||||||
bool changed = false;
|
bool changed = false;
|
||||||
for (int j = 0; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
unsigned unit = uni->opaque[i].index + offset + j;
|
unsigned unit = uni->opaque[i].index + offset + j;
|
||||||
if (sh->SamplerUnits[unit] != ((unsigned *) values)[j]) {
|
if (sh->Program->SamplerUnits[unit] != ((unsigned *) values)[j]) {
|
||||||
sh->SamplerUnits[unit] = ((unsigned *) values)[j];
|
sh->Program->SamplerUnits[unit] = ((unsigned *) values)[j];
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -879,8 +879,6 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct gl_program *const prog = sh->Program;
|
struct gl_program *const prog = sh->Program;
|
||||||
assert(sizeof(prog->SamplerUnits) == sizeof(sh->SamplerUnits));
|
|
||||||
|
|
||||||
_mesa_update_shader_textures_used(shProg, prog);
|
_mesa_update_shader_textures_used(shProg, prog);
|
||||||
if (ctx->Driver.SamplerUniformChange)
|
if (ctx->Driver.SamplerUniformChange)
|
||||||
ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog);
|
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;
|
mask = shader->Program->SamplersUsed;
|
||||||
while (mask) {
|
while (mask) {
|
||||||
const int s = u_bit_scan(&mask);
|
const int s = u_bit_scan(&mask);
|
||||||
GLuint unit = shader->SamplerUnits[s];
|
GLuint unit = shader->Program->SamplerUnits[s];
|
||||||
GLuint tgt = shader->SamplerTargets[s];
|
GLuint tgt = shader->SamplerTargets[s];
|
||||||
|
|
||||||
/* FIXME: Samplers are initialized to 0 and Mesa doesn't do a
|
/* FIXME: Samplers are initialized to 0 and Mesa doesn't do a
|
||||||
|
@@ -73,14 +73,13 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
|
|||||||
|
|
||||||
assert(shader);
|
assert(shader);
|
||||||
|
|
||||||
memcpy(prog->SamplerUnits, shader->SamplerUnits, sizeof(prog->SamplerUnits));
|
|
||||||
memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
|
memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
|
||||||
|
|
||||||
shProg->SamplersValidated = GL_TRUE;
|
shProg->SamplersValidated = GL_TRUE;
|
||||||
|
|
||||||
while (mask) {
|
while (mask) {
|
||||||
const int s = u_bit_scan(&mask);
|
const int s = u_bit_scan(&mask);
|
||||||
GLuint unit = shader->SamplerUnits[s];
|
GLuint unit = prog->SamplerUnits[s];
|
||||||
GLuint tgt = shader->SamplerTargets[s];
|
GLuint tgt = shader->SamplerTargets[s];
|
||||||
assert(unit < ARRAY_SIZE(prog->TexturesUsed));
|
assert(unit < ARRAY_SIZE(prog->TexturesUsed));
|
||||||
assert(tgt < NUM_TEXTURE_TARGETS);
|
assert(tgt < NUM_TEXTURE_TARGETS);
|
||||||
|
Reference in New Issue
Block a user