[Mesa-dev] [PATCH 3/4] gallium/u_blitter: save/restore window rectangles
Marek Olšák
maraeo at gmail.com
Thu Aug 9 01:29:44 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_blitter.c | 10 ++++++++++
src/gallium/auxiliary/util/u_blitter.h | 19 +++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index a9df71108b4..fc86fa367c6 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -650,20 +650,27 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter)
ctx->base.is_sample_mask_saved = false;
}
/* Miscellaneous states. */
/* XXX check whether these are saved and whether they need to be restored
* (depending on the operation) */
pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
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)
{
assert(ctx->base.saved_fb_state.nr_cbufs != (ubyte) ~0);
}
static void blitter_disable_render_cond(struct blitter_context_priv *ctx)
{
struct pipe_context *pipe = ctx->base.pipe;
@@ -1217,20 +1224,23 @@ void util_blitter_cache_all_shaders(struct blitter_context *blitter)
TGSI_INTERPOLATE_CONSTANT, true);
ctx->cached_all_shaders = true;
}
static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
bool scissor)
{
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)
pipe->bind_gs_state(pipe, NULL);
if (ctx->has_tessellation) {
pipe->bind_tcs_state(pipe, NULL);
pipe->bind_tes_state(pipe, NULL);
}
if (ctx->has_stream_out)
pipe->set_stream_output_targets(pipe, 0, NULL, NULL);
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 9ea1dc9b6b2..c1f1ae47443 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -130,20 +130,24 @@ struct blitter_context
unsigned vb_slot;
struct pipe_vertex_buffer saved_vertex_buffer;
unsigned saved_num_so_targets;
struct pipe_stream_output_target *saved_so_targets[PIPE_MAX_SO_BUFFERS];
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];
};
/**
* Create a blitter context.
*/
struct blitter_context *util_blitter_create(struct pipe_context *pipe);
/**
* Destroy a blitter context.
*/
@@ -556,20 +560,35 @@ static inline void
util_blitter_save_render_condition(struct blitter_context *blitter,
struct pipe_query *query,
bool condition,
enum pipe_render_cond_flag mode)
{
blitter->saved_render_cond_query = query;
blitter->saved_render_cond_mode = mode;
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,
void *custom_blend, void *custom_dsa);
void util_blitter_set_running_flag(struct blitter_context *blitter);
void util_blitter_unset_running_flag(struct blitter_context *blitter);
void util_blitter_restore_vertex_states(struct blitter_context *blitter);
void util_blitter_restore_fragment_states(struct blitter_context *blitter);
--
2.17.1
More information about the mesa-dev
mailing list