summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2020-10-01 13:02:34 +0200
committerMarge Bot <eric+marge@anholt.net>2020-10-02 07:14:18 +0000
commit1c4929953575ad1216c12737c72f30ca31a7acfc (patch)
treee1fd1df96d441373da2ed0a5491d95f7caec7c9f
parente7e0468f73034b9dc0234cc5e0c82dfa69b5ba07 (diff)
gallium/util: allow scissored blits for stencil-fallback
It's also useful to be able to use scissor-testing for fallback-blits, as an CTS test-case does just that. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6960>
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c25
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h3
2 files changed, 22 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 1de3f754d67..01b56f3de3e 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -2821,7 +2821,8 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
const struct pipe_box *dstbox,
struct pipe_resource *src,
unsigned src_level,
- const struct pipe_box *srcbox)
+ const struct pipe_box *srcbox,
+ const struct pipe_scissor_state *scissor)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv *)blitter;
struct pipe_context *pipe = ctx->base.pipe;
@@ -2857,13 +2858,24 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
- blitter_set_common_draw_rect_state(ctx, false,
+ blitter_set_common_draw_rect_state(ctx, scissor != NULL,
util_framebuffer_get_num_samples(&fb_state) > 1);
blitter_set_dst_dimensions(ctx, dst_view->width, dst_view->height);
- pipe->clear_depth_stencil(pipe, dst_view, PIPE_CLEAR_STENCIL, 0.0, 0,
- dstbox->x, dstbox->y, dstbox->width, dstbox->height,
- true);
+ if (scissor) {
+ pipe->clear_depth_stencil(pipe, dst_view, PIPE_CLEAR_STENCIL, 0.0, 0,
+ MAX2(dstbox->x, scissor->minx),
+ MAX2(dstbox->y, scissor->miny),
+ MIN2(dstbox->x + dstbox->width, scissor->maxx) - dstbox->x,
+ MIN2(dstbox->y + dstbox->height, scissor->maxy) - dstbox->y,
+ true);
+ pipe->set_scissor_states(pipe, 0, 1, scissor);
+ } else {
+ pipe->clear_depth_stencil(pipe, dst_view, PIPE_CLEAR_STENCIL, 0.0, 0,
+ dstbox->x, dstbox->y,
+ dstbox->width, dstbox->height,
+ true);
+ }
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src_view);
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &ctx->sampler_state);
@@ -2904,6 +2916,9 @@ util_blitter_stencil_fallback(struct blitter_context *blitter,
&coord);
}
+ if (scissor)
+ pipe->set_scissor_states(pipe, 0, 1, &ctx->base.saved_scissor);
+
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_textures(blitter);
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 2ec113d5cdd..79605d3d1af 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -407,7 +407,8 @@ void util_blitter_stencil_fallback(struct blitter_context *blitter,
const struct pipe_box *dstbox,
struct pipe_resource *src,
unsigned src_level,
- const struct pipe_box *srcbox);
+ const struct pipe_box *srcbox,
+ const struct pipe_scissor_state *scissor);
/* The functions below should be used to save currently bound constant state
* objects inside a driver. The objects are automatically restored at the end