union gl_constant_value *values)
: map(map), uniforms(uniforms), next_sampler(0), values(values)
{
- /* empty */
+ memset(this->targets, 0, sizeof(this->targets));
}
private:
* array elements for arrays.
*/
this->next_sampler += MAX2(1, this->uniforms[id].array_elements);
+
+ const gl_texture_index target = base_type->sampler_index();
+ for (unsigned i = this->uniforms[id].sampler
+ ; i < this->next_sampler
+ ; i++) {
+ this->targets[i] = target;
+ }
+
} else {
this->uniforms[id].sampler = ~0;
}
public:
union gl_constant_value *values;
+
+ gl_texture_index targets[MAX_SAMPLERS];
};
void
}
}
+ assert(sizeof(prog->SamplerTargets) == sizeof(parcel.targets));
+ memcpy(prog->SamplerTargets, parcel.targets, sizeof(prog->SamplerTargets));
+
#ifndef NDEBUG
for (unsigned i = 0; i < num_user_uniforms; i++) {
assert(uniforms[i].storage != NULL);
_mesa_propagate_uniforms_to_driver_storage(storage, 0, 1);
}
}
- _mesa_update_shader_textures_used(fp);
+ _mesa_update_shader_textures_used(p.shader_program, fp);
(void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp);
if (!p.shader_program->LinkStatus)
/** Map from sampler unit to texture unit (set by glUniform1i()) */
GLubyte SamplerUnits[MAX_SAMPLERS];
- /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
- gl_texture_index SamplerTargets[MAX_SAMPLERS];
/** Bitmask of which register files are read/written with indirect
* addressing. Mask of (1 << PROGRAM_x) bits.
shProg->SamplerUnits,
sizeof(shProg->SamplerUnits));
- _mesa_update_shader_textures_used(prog);
+ _mesa_update_shader_textures_used(shProg, prog);
(void) ctx->Driver.ProgramStringNotify(ctx, prog->Target, prog);
}
}
* We'll use that info for state validation before rendering.
*/
void
-_mesa_update_shader_textures_used(struct gl_program *prog)
+_mesa_update_shader_textures_used(struct gl_shader_program *shProg,
+ struct gl_program *prog)
{
GLuint s;
for (s = 0; s < MAX_SAMPLERS; s++) {
if (prog->SamplersUsed & (1 << s)) {
- GLuint unit = prog->SamplerUnits[s];
- GLuint tgt = prog->SamplerTargets[s];
+ GLuint unit = shProg->SamplerUnits[s];
+ GLuint tgt = shProg->SamplerTargets[s];
assert(unit < Elements(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
prog->TexturesUsed[unit] |= (1 << tgt);
unsigned count);
extern void
-_mesa_update_shader_textures_used(struct gl_program *prog);
+_mesa_update_shader_textures_used(struct gl_shader_program *shProg,
+ struct gl_program *prog);
extern bool
_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
* samplers, etc).
*/
static void
-count_resources(struct gl_program *prog)
+count_resources(struct gl_shader_program *shProg, struct gl_program *prog)
{
unsigned int i;
struct prog_instruction *inst = &prog->Instructions[i];
if (_mesa_is_tex_instruction(inst->Opcode)) {
- prog->SamplerTargets[inst->TexSrcUnit] =
- (gl_texture_index)inst->TexSrcTarget;
prog->SamplersUsed |= 1 << inst->TexSrcUnit;
if (inst->TexShadow) {
prog->ShadowSamplers |= 1 << inst->TexSrcUnit;
}
}
- _mesa_update_shader_textures_used(prog);
+ _mesa_update_shader_textures_used(shProg, prog);
}
class add_uniform_to_shader : public uniform_field_visitor {
mesa_instructions = NULL;
do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER);
- count_resources(prog);
+ count_resources(shader_program, prog);
/* Set the gl_FragDepth layout. */
if (target == GL_FRAGMENT_PROGRAM_ARB) {
if (is_tex_instruction(inst->op)) {
v->samplers_used |= 1 << inst->sampler;
- prog->SamplerTargets[inst->sampler] =
- (gl_texture_index)inst->tex_target;
if (inst->tex_shadow) {
prog->ShadowSamplers |= 1 << inst->sampler;
}
}
prog->SamplersUsed = v->samplers_used;
- _mesa_update_shader_textures_used(prog);
+
+ if (v->shader_program != NULL)
+ _mesa_update_shader_textures_used(v->shader_program, prog);
}
static void