r600: implement basic memory barrier.
authorDave Airlie <airlied@redhat.com>
Tue, 14 Nov 2017 23:48:29 +0000 (09:48 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 17 Nov 2017 01:31:40 +0000 (11:31 +1000)
This isn't 100% perfect (fglrx also fails a bunch of those tests)
but implement the start of a memory barrier for image support.

Tested-By: Gert Wollny <gw.fossdev@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/r600_pipe_common.c
src/gallium/drivers/r600/r600_state_common.c

index e2d0e32bb2bb5773ac5a2469862164b484ebaf6a..23f7d74ce05d794ef4ac6a63c293b73385695082 100644 (file)
@@ -321,10 +321,6 @@ void r600_need_dma_space(struct r600_common_context *ctx, unsigned num_dw,
        ctx->num_dma_calls++;
 }
 
-static void r600_memory_barrier(struct pipe_context *ctx, unsigned flags)
-{
-}
-
 void r600_preflush_suspend_features(struct r600_common_context *ctx)
 {
        /* suspend queries */
@@ -664,7 +660,6 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        rctx->b.transfer_flush_region = u_transfer_flush_region_vtbl;
        rctx->b.transfer_unmap = u_transfer_unmap_vtbl;
        rctx->b.texture_subdata = u_default_texture_subdata;
-       rctx->b.memory_barrier = r600_memory_barrier;
        rctx->b.flush = r600_flush_from_st;
        rctx->b.set_debug_callback = r600_set_debug_callback;
        rctx->b.fence_server_sync = r600_fence_server_sync;
index ead5b86e0c57bc75aa42205750c6231476f67253..4ae18fc14c5a9f080ba75f76fc1f2f29a39c382a 100644 (file)
@@ -91,6 +91,29 @@ 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_memory_barrier(struct pipe_context *ctx, unsigned flags)
+{
+       struct r600_context *rctx = (struct r600_context *)ctx;
+       if (flags & PIPE_BARRIER_CONSTANT_BUFFER)
+               rctx->b.flags |= R600_CONTEXT_INV_CONST_CACHE;
+
+       if (flags & (PIPE_BARRIER_VERTEX_BUFFER |
+                    PIPE_BARRIER_SHADER_BUFFER |
+                    PIPE_BARRIER_TEXTURE |
+                    PIPE_BARRIER_IMAGE |
+                    PIPE_BARRIER_STREAMOUT_BUFFER |
+                    PIPE_BARRIER_GLOBAL_BUFFER)) {
+               rctx->b.flags |= R600_CONTEXT_INV_VERTEX_CACHE|
+                       R600_CONTEXT_INV_TEX_CACHE;
+       }
+
+       if (flags & (PIPE_BARRIER_FRAMEBUFFER|
+                    PIPE_BARRIER_IMAGE))
+               rctx->b.flags |= R600_CONTEXT_FLUSH_AND_INV;
+
+       rctx->b.flags |= R600_CONTEXT_WAIT_3D_IDLE;
+}
+
 static void r600_texture_barrier(struct pipe_context *ctx, unsigned flags)
 {
        struct r600_context *rctx = (struct r600_context *)ctx;
@@ -3014,6 +3037,7 @@ void r600_init_common_state_functions(struct r600_context *rctx)
        rctx->b.b.set_vertex_buffers = r600_set_vertex_buffers;
        rctx->b.b.set_sampler_views = r600_set_sampler_views;
        rctx->b.b.sampler_view_destroy = r600_sampler_view_destroy;
+       rctx->b.b.memory_barrier = r600_memory_barrier;
        rctx->b.b.texture_barrier = r600_texture_barrier;
        rctx->b.b.set_stream_output_targets = r600_set_streamout_targets;
        rctx->b.b.set_active_query_state = r600_set_active_query_state;