st/mesa: don't track FS sampler views for bitmap/drawpix 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:
Marek Olšák
2021-06-05 22:10:12 -04:00
committed by Marge Bot
parent 3f9ee64505
commit 8106d9a807
5 changed files with 32 additions and 40 deletions
+2 -4
View File
@@ -319,10 +319,8 @@ st_update_fragment_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
update_textures(st,
PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current,
st->state.frag_sampler_views);
update_textures_local(st, PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current);
}
+11 -14
View File
@@ -241,16 +241,19 @@ setup_render_state(struct gl_context *ctx,
/* user textures, plus the bitmap texture */
{
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
uint num = MAX2(fpv->bitmap_sampler + 1,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
memcpy(sampler_views, st->state.frag_sampler_views,
sizeof(sampler_views));
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS] = {};
unsigned num_views =
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current, sampler_views);
num_views = MAX2(fpv->bitmap_sampler + 1, num_views);
sampler_views[fpv->bitmap_sampler] = sv;
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, 0,
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
sampler_views);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
for (unsigned i = 0; i < num_views; i++)
pipe_sampler_view_reference(&sampler_views[i], NULL);
}
/* viewport state: viewport matching window dims */
@@ -456,8 +459,6 @@ st_flush_bitmap_cache(struct st_context *st)
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
sv,
cache->color);
pipe_sampler_view_reference(&sv, NULL);
}
/* release/free the texture */
@@ -643,8 +644,6 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
if (sv) {
draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],
width, height, sv, ctx->Current.RasterColor);
pipe_sampler_view_reference(&sv, NULL);
}
/* release/free the texture */
@@ -785,8 +784,6 @@ out:
pipe_resource_reference(&vb.buffer.resource, NULL);
pipe_sampler_view_reference(&sv, NULL);
/* We uploaded modified constants, need to invalidate them. */
st->dirty |= ST_NEW_FS_CONSTANTS;
}
+19 -15
View File
@@ -867,30 +867,38 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
}
}
unsigned tex_width = sv[0]->texture->width0;
unsigned tex_height = sv[0]->texture->height0;
/* user textures, plus the drawpix textures */
if (fpv) {
/* drawing a color image */
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
uint num = MAX3(fpv->drawpix_sampler + 1,
fpv->pixelmap_sampler + 1,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS] = {0};
unsigned num_views =
st_get_sampler_views(st, PIPE_SHADER_FRAGMENT,
ctx->FragmentProgram._Current, sampler_views);
memcpy(sampler_views, st->state.frag_sampler_views,
sizeof(sampler_views));
num_views = MAX3(fpv->drawpix_sampler + 1, fpv->pixelmap_sampler + 1,
num_views);
sampler_views[fpv->drawpix_sampler] = sv[0];
if (sv[1])
sampler_views[fpv->pixelmap_sampler] = sv[1];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, 0,
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, 0,
sampler_views);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = num_views;
for (unsigned i = 0; i < num_views; i++)
pipe_sampler_view_reference(&sampler_views[i], NULL);
} else {
/* drawing a depth/stencil image */
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view,
0, sv);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num_sampler_view);
for (unsigned i = 0; i < num_sampler_view; i++)
pipe_sampler_view_reference(&sv[i], NULL);
}
/* viewport state: viewport matching window dims */
@@ -923,9 +931,9 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
const float clip_x1 = x1 / (float) fb_width * 2.0f - 1.0f;
const float clip_y1 = y1 / (float) fb_height * 2.0f - 1.0f;
const float maxXcoord = normalized ?
((float) width / sv[0]->texture->width0) : (float) width;
((float) width / tex_width) : (float) width;
const float maxYcoord = normalized
? ((float) height / sv[0]->texture->height0) : (float) height;
? ((float) height / tex_height) : (float) height;
const float sLeft = 0.0f, sRight = maxXcoord;
const float tTop = invertTex ? maxYcoord : 0.0f;
const float tBot = invertTex ? 0.0f : maxYcoord;
@@ -1435,9 +1443,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
driver_fp, fpv,
ctx->Current.RasterColor,
GL_FALSE, write_depth, write_stencil);
pipe_sampler_view_reference(&sv[0], NULL);
if (num_sampler_view > 1)
pipe_sampler_view_reference(&sv[1], NULL);
/* free the texture (but may persist in the cache) */
pipe_resource_reference(&pt, NULL);
@@ -1975,7 +1980,6 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
invertTex, write_depth, write_stencil);
pipe_resource_reference(&pt, NULL);
pipe_sampler_view_reference(&sv[0], NULL);
}
-6
View File
@@ -454,8 +454,6 @@ st_context_free_zombie_objects(struct st_context *st)
static void
st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
{
uint i;
st_destroy_atoms(st);
st_destroy_draw(st);
st_destroy_clear(st);
@@ -467,10 +465,6 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe)
st_destroy_bound_texture_handles(st);
st_destroy_bound_image_handles(st);
for (i = 0; i < ARRAY_SIZE(st->state.frag_sampler_views); i++) {
pipe_sampler_view_reference(&st->state.frag_sampler_views[i], NULL);
}
/* free glReadPixels cache data */
st_invalidate_readpix_cache(st);
util_throttle_deinit(st->screen, &st->throttle);
-1
View File
@@ -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 *frag_sampler_views[PIPE_MAX_SAMPLERS];
GLuint num_sampler_views[PIPE_SHADER_TYPES];
unsigned num_images[PIPE_SHADER_TYPES];
struct pipe_clip_state clip;