summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
commit1d35364040c0ffa99133522fa5ab3bd6131d8bf7 (patch)
tree0ea3d9ca4ad10692c6477168b67e98cb50ea6bd3 /lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
parentb24b5b9049e889ee4eb39b565bcc8d48bd45ab48 (diff)
Merge Mesa 21.3.7
Diffstat (limited to 'lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c')
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c b/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
index b6a97c13c..c20de39a8 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -101,6 +101,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
unsigned start,
unsigned num,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
struct pipe_sampler_view **views)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -117,7 +118,13 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
struct sp_sampler_view *sp_sviewdst =
&softpipe->tgsi.sampler[shader]->sp_sview[start + i];
struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i];
- pipe_sampler_view_reference(pview, views[i]);
+
+ if (take_ownership) {
+ pipe_sampler_view_reference(pview, NULL);
+ *pview = views[i];
+ } else {
+ pipe_sampler_view_reference(pview, views[i]);
+ }
sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
views[i]);
/*
@@ -255,9 +262,6 @@ prepare_shader_sampling(
}
else {
/* display target texture/surface */
- /*
- * XXX: Where should this be unmapped?
- */
struct softpipe_screen *screen = softpipe_screen(tex->screen);
struct sw_winsys *winsys = screen->winsys;
addr = winsys->displaytarget_map(winsys, sp_tex->dt,
@@ -278,6 +282,20 @@ prepare_shader_sampling(
}
}
+static void
+sp_sampler_view_display_target_unmap(struct softpipe_context *sp,
+ struct pipe_sampler_view *view)
+{
+ if (view) {
+ struct pipe_resource *tex = view->texture;
+ struct softpipe_resource *sp_tex = softpipe_resource(tex);
+ if (sp_tex->dt) {
+ struct softpipe_screen *screen = softpipe_screen(tex->screen);
+ struct sw_winsys *winsys = screen->winsys;
+ winsys->displaytarget_unmap(winsys, sp_tex->dt);
+ }
+ }
+}
/**
* Called during state validation when SP_NEW_TEXTURE is set.
@@ -296,6 +314,8 @@ softpipe_cleanup_vertex_sampling(struct softpipe_context *ctx)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(ctx->mapped_vs_tex); i++) {
+ sp_sampler_view_display_target_unmap(
+ ctx, ctx->sampler_views[PIPE_SHADER_VERTEX][i]);
pipe_resource_reference(&ctx->mapped_vs_tex[i], NULL);
}
}
@@ -318,6 +338,8 @@ softpipe_cleanup_geometry_sampling(struct softpipe_context *ctx)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(ctx->mapped_gs_tex); i++) {
+ sp_sampler_view_display_target_unmap(
+ ctx, ctx->sampler_views[PIPE_SHADER_GEOMETRY][i]);
pipe_resource_reference(&ctx->mapped_gs_tex[i], NULL);
}
}