gallium/u_blitter: save/restore window rectangles
authorMarek Olšák <marek.olsak@amd.com>
Mon, 6 Aug 2018 08:16:47 +0000 (04:16 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 15 Aug 2018 01:19:01 +0000 (21:19 -0400)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h

index a9df71108b4390c36f073f4f2518dd6dd3c412b2..fc86fa367c66f534687ad868f5fb3eebf12b2a00 100644 (file)
@@ -657,6 +657,13 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter)
 
    if (!blitter->skip_viewport_restore)
       pipe->set_viewport_states(pipe, 0, 1, &ctx->base.saved_viewport);
+
+   if (blitter->saved_num_window_rectangles) {
+      pipe->set_window_rectangles(pipe,
+                                  blitter->saved_window_rectangles_include,
+                                  blitter->saved_num_window_rectangles,
+                                  blitter->saved_window_rectangles);
+   }
 }
 
 static void blitter_check_saved_fb_state(MAYBE_UNUSED struct blitter_context_priv *ctx)
@@ -1224,6 +1231,9 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
 {
    struct pipe_context *pipe = ctx->base.pipe;
 
+   if (ctx->base.saved_num_window_rectangles)
+      pipe->set_window_rectangles(pipe, false, 0, NULL);
+
    pipe->bind_rasterizer_state(pipe, scissor ? ctx->rs_state_scissor
                                              : ctx->rs_state);
    if (ctx->has_geometry_shader)
index 9ea1dc9b6b28e77aa43700958f0589438d4c1f05..c1f1ae4744394ee4f50840fe87460402e12c6374 100644 (file)
@@ -137,6 +137,10 @@ struct blitter_context
    struct pipe_query *saved_render_cond_query;
    uint saved_render_cond_mode;
    bool saved_render_cond_cond;
+
+   boolean saved_window_rectangles_include;
+   unsigned saved_num_window_rectangles;
+   struct pipe_scissor_state saved_window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];
 };
 
 /**
@@ -563,6 +567,21 @@ util_blitter_save_render_condition(struct blitter_context *blitter,
    blitter->saved_render_cond_cond = condition;
 }
 
+static inline void
+util_blitter_save_window_rectangles(struct blitter_context *blitter,
+                                    boolean include,
+                                    unsigned num_rectangles,
+                                    const struct pipe_scissor_state *rects)
+{
+   blitter->saved_window_rectangles_include = include;
+   blitter->saved_num_window_rectangles = num_rectangles;
+   if (num_rectangles > 0) {
+      assert(num_rectangles < ARRAY_SIZE(blitter->saved_window_rectangles));
+      memcpy(blitter->saved_window_rectangles, rects,
+             sizeof(*rects) * num_rectangles);
+   }
+}
+
 void util_blitter_common_clear_setup(struct blitter_context *blitter,
                                      unsigned width, unsigned height,
                                      unsigned clear_buffers,