mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
st/mesa: optimize binding and unbinding shader images
- use local variable num_images - only unbind the number of shader images that we have bound Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
This commit is contained in:
parent
8436d9c594
commit
f8fe2ca600
2 changed files with 10 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue