st/mesa: unbind sampler views, images, and vertex buffers after meta ops

v2: use a null array to unbind sampler views

Reviewed-by: Eric Anholt <eric@anholt.net> (v1)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
This commit is contained in:
Marek Olšák 2021-01-11 10:33:54 -05:00
parent 211ec4226b
commit 8436d9c594
7 changed files with 53 additions and 0 deletions

View file

@ -248,6 +248,8 @@ setup_render_state(struct gl_context *ctx,
sizeof(sampler_views));
sampler_views[fpv->bitmap_sampler] = sv;
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, sampler_views);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
}
/* viewport state: viewport matching window dims */
@ -270,9 +272,19 @@ restore_render_state(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
struct cso_context *cso = st->cso_context;
struct pipe_context *pipe = st->pipe;
cso_restore_state(cso);
/* Unbind all because st/mesa won't do it if the current shader doesn't
* use them.
*/
static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
null);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
st->dirty |= ST_NEW_VERTEX_ARRAYS |
ST_NEW_FS_SAMPLER_VIEWS;
}
@ -763,6 +775,8 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
u_upload_unmap(pipe->stream_uploader);
cso_set_vertex_buffers(st->cso_context, 0, 1, &vb);
st->last_num_vbuffers = MAX2(st->last_num_vbuffers, 1);
cso_draw_arrays(st->cso_context, PIPE_PRIM_QUADS, 0, num_verts);
out:

View file

@ -882,9 +882,13 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
if (sv[1])
sampler_views[fpv->pixelmap_sampler] = sv[1];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num, sampler_views);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num);
} else {
/* drawing a depth/stencil image */
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_sampler_view, sv);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], num_sampler_view);
}
/* viewport state: viewport matching window dims */
@ -933,6 +937,15 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
/* restore state */
cso_restore_state(cso);
/* Unbind all because st/mesa won't do it if the current shader doesn't
* use them.
*/
static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
null);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
st->dirty |= ST_NEW_VERTEX_ARRAYS |
ST_NEW_FS_SAMPLER_VIEWS;
}

View file

@ -338,6 +338,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
numAttribs); /* attribs/vert */
st->last_num_vbuffers = MAX2(st->last_num_vbuffers, 1);
pipe_resource_reference(&vbuffer, NULL);

View file

@ -190,6 +190,8 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
goto fail;
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_view);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
pipe_sampler_view_reference(&sampler_view, NULL);
@ -253,6 +255,16 @@ try_pbo_readpixels(struct st_context *st, struct st_renderbuffer *strb,
fail:
cso_restore_state(cso);
/* Unbind all because st/mesa won't do it if the current shader doesn't
* use them.
*/
static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
null);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
pipe->set_shader_images(pipe, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
st->dirty |= ST_NEW_FS_CONSTANTS |
ST_NEW_FS_IMAGES |
ST_NEW_FS_SAMPLER_VIEWS |

View file

@ -1313,6 +1313,8 @@ try_pbo_upload_common(struct gl_context *ctx,
goto fail;
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &sampler_view);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] =
MAX2(st->state.num_sampler_views[PIPE_SHADER_FRAGMENT], 1);
pipe_sampler_view_reference(&sampler_view, NULL);
}
@ -1349,6 +1351,15 @@ try_pbo_upload_common(struct gl_context *ctx,
fail:
cso_restore_state(cso);
/* Unbind all because st/mesa won't do it if the current shader doesn't
* use them.
*/
static struct pipe_sampler_view *null[PIPE_MAX_SAMPLERS];
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT],
null);
st->state.num_sampler_views[PIPE_SHADER_FRAGMENT] = 0;
st->dirty |= ST_NEW_VERTEX_ARRAYS |
ST_NEW_FS_CONSTANTS |
ST_NEW_FS_SAMPLER_VIEWS;

View file

@ -543,6 +543,7 @@ st_draw_quad(struct st_context *st,
u_upload_unmap(st->pipe->stream_uploader);
cso_set_vertex_buffers(st->cso_context, 0, 1, &vb);
st->last_num_vbuffers = MAX2(st->last_num_vbuffers, 1);
if (num_instances > 1) {
cso_draw_arrays_instanced(st->cso_context, PIPE_PRIM_TRIANGLE_FAN, 0, 4,

View file

@ -256,6 +256,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
cso_set_vertex_elements(cso, &velem);
cso_set_vertex_buffers(cso, 0, 1, &vbo);
st->last_num_vbuffers = MAX2(st->last_num_vbuffers, 1);
pipe_resource_reference(&vbo.buffer.resource, NULL);
}