Mesa (master): gallium/u_blitter: add helper to save FS const buffer state

Rob Clark robclark at kemper.freedesktop.org
Tue Aug 16 13:36:05 UTC 2016


Module: Mesa
Branch: master
Commit: 2b2f436c696c4da9e1a45fb03406876340ae31ed
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b2f436c696c4da9e1a45fb03406876340ae31ed

Author: Rob Clark <robdclark at gmail.com>
Date:   Sat Aug 13 10:36:00 2016 -0400

gallium/u_blitter: add helper to save FS const buffer state

Not (currently) state that is overwridden by u_blitter itself, but
drivers with custom blit/clear which are reusing part of the u_blitter
infrastructure will use it.

Signed-off-by: Rob Clark <robdclark at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/gallium/auxiliary/util/u_blitter.c | 10 ++++++++++
 src/gallium/auxiliary/util/u_blitter.h | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 8e5ed45..9fbef9b 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -283,6 +283,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
       ctx->rs_discard_state = pipe->create_rasterizer_state(pipe, &rs_state);
    }
 
+   ctx->base.cb_slot = 0; /* 0 for now */
    ctx->base.vb_slot = 0; /* 0 for now */
 
    /* vertex elements states */
@@ -698,6 +699,15 @@ void util_blitter_restore_textures(struct blitter_context *blitter)
    ctx->base.saved_num_sampler_views = ~0;
 }
 
+void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter)
+{
+   struct pipe_context *pipe = blitter->pipe;
+
+   pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, blitter->cb_slot,
+                            &blitter->saved_fs_constant_buffer);
+   pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer, NULL);
+}
+
 static void blitter_set_rectangle(struct blitter_context_priv *ctx,
                                   int x1, int y1, int x2, int y2,
                                   float depth)
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 06e21e6..0f5da6b 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -111,6 +111,9 @@ struct blitter_context
    unsigned saved_num_sampler_views;
    struct pipe_sampler_view *saved_sampler_views[PIPE_MAX_SAMPLERS];
 
+   unsigned cb_slot;
+   struct pipe_constant_buffer saved_fs_constant_buffer;
+
    unsigned vb_slot;
    struct pipe_vertex_buffer saved_vertex_buffer;
 
@@ -486,6 +489,17 @@ util_blitter_save_fragment_sampler_views(struct blitter_context *blitter,
 }
 
 static inline void
+util_blitter_save_fragment_constant_buffer_slot(
+                  struct blitter_context *blitter,
+                  struct pipe_constant_buffer *constant_buffers)
+{
+   pipe_resource_reference(&blitter->saved_fs_constant_buffer.buffer,
+                           constant_buffers[blitter->cb_slot].buffer);
+   memcpy(&blitter->saved_fs_constant_buffer, &constant_buffers[blitter->cb_slot],
+          sizeof(struct pipe_constant_buffer));
+}
+
+static inline void
 util_blitter_save_vertex_buffer_slot(struct blitter_context *blitter,
                                      struct pipe_vertex_buffer *vertex_buffers)
 {
@@ -536,6 +550,7 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter);
 void util_blitter_restore_render_cond(struct blitter_context *blitter);
 void util_blitter_restore_fb_state(struct blitter_context *blitter);
 void util_blitter_restore_textures(struct blitter_context *blitter);
+void util_blitter_restore_constant_buffer_state(struct blitter_context *blitter);
 
 #ifdef __cplusplus
 }




More information about the mesa-commit mailing list