From a1c84842710268793c4a8de3cad8db95b6f37a82 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Sun, 1 Jan 2017 23:42:17 -0500 Subject: [PATCH] gallium: add flags parameter to texture barrier MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is so that we can differentiate between flushing any framebuffer reading caches from regular sampler caches. Signed-off-by: Ilia Mirkin Reviewed-by: Nicolai Hähnle --- 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 35f51a09410..d8b25601a62 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 edcbf2cdfec..0b1dfbbc57c 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 6831d2c4eff..bef238aa833 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 fc852d7068c..ece7da9c5b4 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 c711cb07de9..8f2b974b34a 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 196c0df8864..8c49bfdddd1 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 60490b0d695..a9dbc8bc982 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 865a75dbe64..4aa1cd7436d 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -3498,7 +3498,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 656d8a3257a..3bf8c499218 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 0674b4a7e48..abbc098657c 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 8423bb28c01..de03e29b4e3 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 171dc570ba0..45098c9c74f 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 d5139c7f8f1..3eb5b3b8873 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -399,6 +399,12 @@ enum pipe_flush_flags #define PIPE_BARRIER_GLOBAL_BUFFER (1 << 11) #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 fecba65a64d..7fd1cbd1d7c 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.30.2