[Mesa-dev] [PATCH v2 5/6] mesa/st: use invalidate_surface() for scissored clears
Rob Clark
robdclark at gmail.com
Wed Dec 12 15:48:42 UTC 2018
Now that we have pipe_context::invalidate_surface(), we can also
use this to hint to driver about scissored clears (which use draw_vbo()).
This is useful in particular for tilers because the driver can avoid
bringing (some) tiles back into the tile buffer from system memory.
Signed-off-by: Rob Clark <robdclark at gmail.com>
---
src/mesa/state_tracker/st_cb_clear.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 88fc12789e3..90647807561 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -357,6 +357,22 @@ is_stencil_masked(struct gl_context *ctx, struct gl_renderbuffer *rb)
return (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
}
+static void
+handle_scissor_invalidate(struct gl_context *ctx, struct gl_renderbuffer *rb)
+{
+ struct st_context *st = st_context(ctx);
+
+ if (st->pipe->invalidate_surface &&
+ is_scissor_enabled(ctx, rb)) {
+ struct st_renderbuffer *strb = st_renderbuffer(rb);
+ struct pipe_scissor_state *s = &st->state.scissor[0];
+ struct pipe_box region;
+
+ u_box_2d(s->minx, s->miny, s->maxx - s->minx, s->maxy - s->miny, ®ion);
+
+ st->pipe->invalidate_surface(st->pipe, strb->surface, ®ion);
+ }
+}
/**
* Called via ctx->Driver.Clear()
@@ -415,6 +431,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
struct st_renderbuffer *strb = st_renderbuffer(depthRb);
if (strb->surface && ctx->Depth.Mask) {
+ handle_scissor_invalidate(ctx, depthRb);
if (is_scissor_enabled(ctx, depthRb) ||
is_window_rectangle_enabled(ctx))
quad_buffers |= PIPE_CLEAR_DEPTH;
@@ -426,6 +443,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
struct st_renderbuffer *strb = st_renderbuffer(stencilRb);
if (strb->surface && !is_stencil_disabled(ctx, stencilRb)) {
+ handle_scissor_invalidate(ctx, stencilRb);
if (is_scissor_enabled(ctx, stencilRb) ||
is_window_rectangle_enabled(ctx) ||
is_stencil_masked(ctx, stencilRb))
--
2.19.2
More information about the mesa-dev
mailing list