Mesa (main): st/mesa: don't track VS sampler views for st_draw_feedback in st_context
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jun 27 13:07:33 UTC 2021
Module: Mesa
Branch: main
Commit: 3f9ee64505037e0283708a13141048b7d5723755
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f9ee64505037e0283708a13141048b7d5723755
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sat Jun 5 22:10:12 2021 -0400
st/mesa: don't track VS sampler views for st_draw_feedback in st_context
Just query the sampler views from the update function. This will help
optimize sampler view updates.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11428>
---
src/mesa/state_tracker/st_atom_texture.c | 31 ++++++++++++++++++++-----------
src/mesa/state_tracker/st_context.c | 1 -
src/mesa/state_tracker/st_context.h | 1 -
src/mesa/state_tracker/st_draw_feedback.c | 18 +++++++++++-------
src/mesa/state_tracker/st_texture.h | 6 ++++++
5 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fbc6aee4c44..8d0d343fbaf 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -97,11 +97,11 @@ st_update_single_texture(struct st_context *st,
-static void
-update_textures(struct st_context *st,
- enum pipe_shader_type shader_stage,
- const struct gl_program *prog,
- struct pipe_sampler_view **sampler_views)
+unsigned
+st_get_sampler_views(struct st_context *st,
+ enum pipe_shader_type shader_stage,
+ const struct gl_program *prog,
+ struct pipe_sampler_view **sampler_views)
{
struct pipe_context *pipe = st->pipe;
const GLuint old_max = st->state.num_sampler_views[shader_stage];
@@ -112,7 +112,7 @@ update_textures(struct st_context *st,
GLuint unit;
if (samplers_used == 0x0 && old_max == 0)
- return;
+ return 0;
unsigned num_textures = 0;
@@ -264,7 +264,18 @@ update_textures(struct st_context *st,
num_textures = MAX2(num_textures, extra + 1);
}
- /* Unbind old textures. */
+ return num_textures;
+}
+
+static void
+update_textures(struct st_context *st, enum pipe_shader_type shader_stage,
+ const struct gl_program *prog,
+ struct pipe_sampler_view **sampler_views)
+{
+ struct pipe_context *pipe = st->pipe;
+ unsigned num_textures =
+ st_get_sampler_views(st, shader_stage, prog, sampler_views);
+
unsigned old_num_textures = st->state.num_sampler_views[shader_stage];
unsigned num_unbind = old_num_textures > num_textures ?
old_num_textures - num_textures : 0;
@@ -297,10 +308,8 @@ st_update_vertex_textures(struct st_context *st)
const struct gl_context *ctx = st->ctx;
if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
- update_textures(st,
- PIPE_SHADER_VERTEX,
- ctx->VertexProgram._Current,
- st->state.vert_sampler_views);
+ update_textures_local(st, PIPE_SHADER_VERTEX,
+ ctx->VertexProgram._Current);
}
}
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 9f3b861299a..a79c8ba0636 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -468,7 +468,6 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
st_destroy_bound_image_handles(st);
for (i = 0; i < ARRAY_SIZE(st->state.frag_sampler_views); i++) {
- pipe_sampler_view_reference(&st->state.vert_sampler_views[i], NULL);
pipe_sampler_view_reference(&st->state.frag_sampler_views[i], NULL);
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 303b4d32ad9..618fe760691 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -210,7 +210,6 @@ struct st_context
struct pipe_sampler_state frag_samplers[PIPE_MAX_SAMPLERS];
GLuint num_vert_samplers;
GLuint num_frag_samplers;
- 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];
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 010730fb246..06021842159 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -311,14 +311,16 @@ st_feedback_draw_vbo(struct gl_context *ctx,
st->state.num_vert_samplers);
/* sampler views */
- draw_set_sampler_views(draw, PIPE_SHADER_VERTEX,
- st->state.vert_sampler_views,
- st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
+ struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS] = {0};
+ unsigned num_views =
+ st_get_sampler_views(st, PIPE_SHADER_VERTEX, prog, views);
+
+ draw_set_sampler_views(draw, PIPE_SHADER_VERTEX, views, num_views);
struct pipe_transfer *sv_transfer[PIPE_MAX_SAMPLERS][PIPE_MAX_TEXTURE_LEVELS];
- for (unsigned i = 0; i < st->state.num_sampler_views[PIPE_SHADER_VERTEX]; i++) {
- struct pipe_sampler_view *view = st->state.vert_sampler_views[i];
+ for (unsigned i = 0; i < num_views; i++) {
+ struct pipe_sampler_view *view = views[i];
if (!view)
continue;
@@ -472,8 +474,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
}
/* unmap sampler views */
- for (unsigned i = 0; i < st->state.num_sampler_views[PIPE_SHADER_VERTEX]; i++) {
- struct pipe_sampler_view *view = st->state.vert_sampler_views[i];
+ for (unsigned i = 0; i < num_views; i++) {
+ struct pipe_sampler_view *view = views[i];
if (view) {
if (view->texture->target != PIPE_BUFFER) {
@@ -484,6 +486,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
} else {
pipe_buffer_unmap(pipe, sv_transfer[i][0]);
}
+
+ pipe_sampler_view_reference(&views[i], NULL);
}
}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 92bfbf3b8cf..960c88a3728 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -362,6 +362,12 @@ st_update_single_texture(struct st_context *st,
GLuint texUnit, bool glsl130_or_later,
bool ignore_srgb_decode);
+unsigned
+st_get_sampler_views(struct st_context *st,
+ enum pipe_shader_type shader_stage,
+ const struct gl_program *prog,
+ struct pipe_sampler_view **sampler_views);
+
void
st_make_bound_samplers_resident(struct st_context *st,
struct gl_program *prog);
More information about the mesa-commit
mailing list