Mesa (master): st/mesa: optimize binding and unbinding shader images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 15 10:07:39 UTC 2021
Module: Mesa
Branch: master
Commit: f8fe2ca600b2c1a0029fd71ab502e51385e4526d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8fe2ca600b2c1a0029fd71ab502e51385e4526d
Author: Marek Olšák <marek.olsak at amd.com>
Date: Mon Jan 11 10:37:57 2021 -0500
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 at amd.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
---
src/mesa/state_tracker/st_atom_image.c | 18 +++++++++---------
src/mesa/state_tracker/st_context.h | 1 +
2 files changed, 10 insertions(+), 9 deletions(-)
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;
More information about the mesa-commit
mailing list