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@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11428>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user