diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c index f4c0a1ad4cf..37f12cf5989 100644 --- a/src/mesa/state_tracker/st_atom_image.c +++ b/src/mesa/state_tracker/st_atom_image.c @@ -161,14 +161,13 @@ st_bind_images(struct st_context *st, struct gl_program *prog, { unsigned i; struct pipe_image_view images[MAX_IMAGE_UNIFORMS]; - struct gl_program_constants *c; if (!prog || !st->pipe->set_shader_images) return; - c = &st->ctx->Const.Program[prog->info.stage]; + unsigned num_images = prog->info.num_images; - for (i = 0; i < prog->info.num_images; i++) { + for (i = 0; i < num_images; i++) { struct pipe_image_view *img = &images[i]; st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i], @@ -176,14 +175,15 @@ st_bind_images(struct st_context *st, struct gl_program *prog, } struct pipe_context *pipe = st->pipe; - pipe->set_shader_images(pipe, shader_type, 0, - prog->info.num_images, images); + pipe->set_shader_images(pipe, shader_type, 0, num_images, images); + /* clear out any stale shader images */ - if (prog->info.num_images < c->MaxImageUniforms) { - pipe->set_shader_images(pipe, shader_type, prog->info.num_images, - c->MaxImageUniforms - prog->info.num_images, - NULL); + unsigned last_num_images = st->state.num_images[shader_type]; + if (num_images < last_num_images) { + pipe->set_shader_images(pipe, shader_type, num_images, + last_num_images - num_images, NULL); } + st->state.num_images[shader_type] = num_images; } void st_bind_vs_images(struct st_context *st) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 274bda960b8..b8246ddb5dc 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -208,6 +208,7 @@ struct st_context struct pipe_sampler_view *vert_sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_sampler_view *frag_sampler_views[PIPE_MAX_SAMPLERS]; GLuint num_sampler_views[PIPE_SHADER_TYPES]; + unsigned num_images[PIPE_SHADER_TYPES]; struct pipe_clip_state clip; unsigned constbuf0_enabled_shader_mask; unsigned fb_width;