[Mesa-dev] [PATCH v2 5/7] gallium: add flags parameter to texture barrier

Ilia Mirkin imirkin at alum.mit.edu
Sat Jan 14 21:28:41 UTC 2017


This is so that we can differentiate between flushing any framebuffer
reading caches from regular sampler caches.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
---

v1 -> v2: fix FBREAD -> FBFETCH typo

 src/gallium/docs/source/context.rst             | 3 ++-
 src/gallium/drivers/ddebug/dd_context.c         | 4 ++--
 src/gallium/drivers/ilo/ilo_draw.c              | 2 +-
 src/gallium/drivers/nouveau/nv50/nv50_context.c | 2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 2 +-
 src/gallium/drivers/r300/r300_state.c           | 2 +-
 src/gallium/drivers/r600/r600_state_common.c    | 2 +-
 src/gallium/drivers/radeonsi/si_state.c         | 2 +-
 src/gallium/drivers/softpipe/sp_flush.c         | 4 ++--
 src/gallium/drivers/softpipe/sp_flush.h         | 2 +-
 src/gallium/drivers/trace/tr_context.c          | 5 +++--
 src/gallium/include/pipe/p_context.h            | 2 +-
 src/gallium/include/pipe/p_defines.h            | 6 ++++++
 src/mesa/state_tracker/st_cb_texturebarrier.c   | 2 +-
 14 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 35f51a0..d8b2560 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -578,7 +578,8 @@ texture_barrier
 %%%%%%%%%%%%%%%
 
 This function flushes all pending writes to the currently-set surfaces and
-invalidates all read caches of the currently-set samplers.
+invalidates all read caches of the currently-set samplers. This can be used
+for both regular textures as well as for framebuffers read via FBFETCH.
 
 
 
diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c
index edcbf2c..0b1dfbb 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -676,11 +676,11 @@ dd_context_texture_subdata(struct pipe_context *_pipe,
  */
 
 static void
-dd_context_texture_barrier(struct pipe_context *_pipe)
+dd_context_texture_barrier(struct pipe_context *_pipe, unsigned flags)
 {
    struct pipe_context *pipe = dd_context(_pipe)->pipe;
 
-   pipe->texture_barrier(pipe);
+   pipe->texture_barrier(pipe, flags);
 }
 
 static void
diff --git a/src/gallium/drivers/ilo/ilo_draw.c b/src/gallium/drivers/ilo/ilo_draw.c
index 6831d2c..bef238a 100644
--- a/src/gallium/drivers/ilo/ilo_draw.c
+++ b/src/gallium/drivers/ilo/ilo_draw.c
@@ -603,7 +603,7 @@ ilo_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 }
 
 static void
-ilo_texture_barrier(struct pipe_context *pipe)
+ilo_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
    struct ilo_context *ilo = ilo_context(pipe);
 
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index fc852d7..ece7da9 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -43,7 +43,7 @@ nv50_flush(struct pipe_context *pipe,
 }
 
 static void
-nv50_texture_barrier(struct pipe_context *pipe)
+nv50_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
    struct nouveau_pushbuf *push = nv50_context(pipe)->base.pushbuf;
 
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index c711cb0..8f2b974 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -44,7 +44,7 @@ nvc0_flush(struct pipe_context *pipe,
 }
 
 static void
-nvc0_texture_barrier(struct pipe_context *pipe)
+nvc0_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
    struct nouveau_pushbuf *push = nvc0_context(pipe)->base.pushbuf;
 
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 196c0df..8c49bfd 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -2068,7 +2068,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
     }
 }
 
-static void r300_texture_barrier(struct pipe_context *pipe)
+static void r300_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
     struct r300_context *r300 = r300_context(pipe);
 
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 60490b0..a9dbc8b 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -91,7 +91,7 @@ void r600_emit_alphatest_state(struct r600_context *rctx, struct r600_atom *atom
 	radeon_set_context_reg(cs, R_028438_SX_ALPHA_REF, alpha_ref);
 }
 
-static void r600_texture_barrier(struct pipe_context *ctx)
+static void r600_texture_barrier(struct pipe_context *ctx, unsigned flags)
 {
 	struct r600_context *rctx = (struct r600_context *)ctx;
 
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 6e7d8da..b994edf 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3481,7 +3481,7 @@ static void si_set_tess_state(struct pipe_context *ctx,
 	pipe_resource_reference(&cb.buffer, NULL);
 }
 
-static void si_texture_barrier(struct pipe_context *ctx)
+static void si_texture_barrier(struct pipe_context *ctx, unsigned flags)
 {
 	struct si_context *sctx = (struct si_context *)ctx;
 
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index 656d8a3..3bf8c49 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -169,7 +169,7 @@ softpipe_flush_resource(struct pipe_context *pipe,
    return TRUE;
 }
 
-void softpipe_texture_barrier(struct pipe_context *pipe)
+void softpipe_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    uint i, sh;
@@ -192,5 +192,5 @@ void softpipe_texture_barrier(struct pipe_context *pipe)
 
 void softpipe_memory_barrier(struct pipe_context *pipe, unsigned flags)
 {
-   softpipe_texture_barrier(pipe);
+   softpipe_texture_barrier(pipe, 0);
 }
diff --git a/src/gallium/drivers/softpipe/sp_flush.h b/src/gallium/drivers/softpipe/sp_flush.h
index 0674b4a..abbc098 100644
--- a/src/gallium/drivers/softpipe/sp_flush.h
+++ b/src/gallium/drivers/softpipe/sp_flush.h
@@ -55,6 +55,6 @@ softpipe_flush_resource(struct pipe_context *pipe,
                         boolean cpu_access,
                         boolean do_not_block);
 
-void softpipe_texture_barrier(struct pipe_context *pipe);
+void softpipe_texture_barrier(struct pipe_context *pipe, unsigned flags);
 void softpipe_memory_barrier(struct pipe_context *pipe, unsigned flags);
 #endif
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 8423bb2..de03e29 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1681,7 +1681,7 @@ trace_context_render_condition(struct pipe_context *_context,
 
 
 static void
-trace_context_texture_barrier(struct pipe_context *_context)
+trace_context_texture_barrier(struct pipe_context *_context, unsigned flags)
 {
    struct trace_context *tr_context = trace_context(_context);
    struct pipe_context *context = tr_context->pipe;
@@ -1689,10 +1689,11 @@ trace_context_texture_barrier(struct pipe_context *_context)
    trace_dump_call_begin("pipe_context", "texture_barrier");
 
    trace_dump_arg(ptr, context);
+   trace_dump_arg(uint, flags);
 
    trace_dump_call_end();
 
-   context->texture_barrier(context);
+   context->texture_barrier(context, flags);
 }
 
 
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 171dc57..45098c9 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -566,7 +566,7 @@ struct pipe_context {
    /**
     * Flush any pending framebuffer writes and invalidate texture caches.
     */
-   void (*texture_barrier)(struct pipe_context *);
+   void (*texture_barrier)(struct pipe_context *, unsigned flags);
 
    /**
     * Flush caches according to flags.
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index d5139c7..3eb5b3b 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -400,6 +400,12 @@ enum pipe_flush_flags
 #define PIPE_BARRIER_ALL               ((1 << 12) - 1)
 
 /**
+ * Flags for pipe_context::texture_barrier.
+ */
+#define PIPE_TEXTURE_BARRIER_SAMPLER      (1 << 0)
+#define PIPE_TEXTURE_BARRIER_FRAMEBUFFER  (1 << 1)
+
+/**
  * Resource binding flags -- state tracker must specify in advance all
  * the ways a resource might be used.
  */
diff --git a/src/mesa/state_tracker/st_cb_texturebarrier.c b/src/mesa/state_tracker/st_cb_texturebarrier.c
index fecba65..7fd1cbd 100644
--- a/src/mesa/state_tracker/st_cb_texturebarrier.c
+++ b/src/mesa/state_tracker/st_cb_texturebarrier.c
@@ -50,7 +50,7 @@ st_TextureBarrier(struct gl_context *ctx)
 {
    struct pipe_context *pipe = st_context(ctx)->pipe;
 
-   pipe->texture_barrier(pipe);
+   pipe->texture_barrier(pipe, PIPE_TEXTURE_BARRIER_SAMPLER);
 }
 
 
-- 
2.10.2



More information about the mesa-dev mailing list