shader-packing
[mesa.git] / src / gallium / drivers / freedreno / freedreno_batch.h
index 8b05f0657aa36ccf6126102f4ccc79bab03d7671..a40d36094cd5960ee4bf39ae01cdc3bb1c951379 100644 (file)
@@ -70,6 +70,7 @@ struct fd_batch {
 
        int in_fence_fd;
        bool needs_out_fence_fd;
+       struct pipe_fence_handle *fence;
 
        struct fd_context *ctx;
 
@@ -83,6 +84,10 @@ struct fd_batch {
         * The 'cleared' bits will be set for buffers which are *entirely*
         * cleared, and 'partial_cleared' bits will be set if you must
         * check cleared_scissor.
+        *
+        * The 'invalidated' bits are set for cleared buffers, and buffers
+        * where the contents are undefined, ie. what we don't need to restore
+        * to gmem.
         */
        enum {
                /* align bitmask values w/ PIPE_CLEAR_*.. since that is convenient.. */
@@ -90,9 +95,12 @@ struct fd_batch {
                FD_BUFFER_DEPTH   = PIPE_CLEAR_DEPTH,
                FD_BUFFER_STENCIL = PIPE_CLEAR_STENCIL,
                FD_BUFFER_ALL     = FD_BUFFER_COLOR | FD_BUFFER_DEPTH | FD_BUFFER_STENCIL,
-       } cleared, partial_cleared, restore, resolve;
+       } invalidated, cleared, fast_cleared, restore, resolve;
 
+       /* is this a non-draw batch (ie compute/blit which has no pfb state)? */
+       bool nondraw : 1;
        bool needs_flush : 1;
+       bool flushed : 1;
        bool blit : 1;
        bool back_blit : 1;      /* only blit so far is resource shadowing back-blit */
 
@@ -112,11 +120,11 @@ struct fd_batch {
                FD_GMEM_DEPTH_ENABLED        = 0x02,
                FD_GMEM_STENCIL_ENABLED      = 0x04,
 
-               FD_GMEM_MSAA_ENABLED         = 0x08,
                FD_GMEM_BLEND_ENABLED        = 0x10,
                FD_GMEM_LOGICOP_ENABLED      = 0x20,
        } gmem_reason;
        unsigned num_draws;   /* number of draws in current batch */
+       unsigned num_vertices;   /* number of vertices in current batch */
 
        /* Track the maximal bounds of the scissor of all the draws within a
         * batch.  Used at the tile rendering step (fd_gmem_render_tiles(),
@@ -124,14 +132,6 @@ struct fd_batch {
         */
        struct pipe_scissor_state max_scissor;
 
-       /* Track the cleared scissor for color/depth/stencil, so we know
-        * which, if any, tiles need to be restored (mem2gmem).  Only valid
-        * if the corresponding bit in ctx->cleared is set.
-        */
-       struct {
-               struct pipe_scissor_state color, depth, stencil;
-       } cleared_scissor;
-
        /* Keep track of DRAW initiators that need to be patched up depending
         * on whether we using binning or not:
         */
@@ -147,6 +147,8 @@ struct fd_batch {
 
        struct pipe_framebuffer_state framebuffer;
 
+       struct fd_submit *submit;
+
        /** draw pass cmdstream: */
        struct fd_ringbuffer *draw;
        /** binning pass cmdstream: */
@@ -156,6 +158,12 @@ struct fd_batch {
 
        // TODO maybe more generically split out clear and clear_binning rings?
        struct fd_ringbuffer *lrz_clear;
+       struct fd_ringbuffer *tile_setup;
+       struct fd_ringbuffer *tile_fini;
+
+       union pipe_color_union clear_color[MAX_RENDER_TARGETS];
+       double clear_depth;
+       unsigned clear_stencil;
 
        /**
         * hw query related state:
@@ -201,11 +209,12 @@ struct fd_batch {
        uint32_t dependents_mask;
 };
 
-struct fd_batch * fd_batch_create(struct fd_context *ctx);
+struct fd_batch * fd_batch_create(struct fd_context *ctx, bool nondraw);
 
 void fd_batch_reset(struct fd_batch *batch);
 void fd_batch_sync(struct fd_batch *batch);
-void fd_batch_flush(struct fd_batch *batch, bool sync);
+void fd_batch_flush(struct fd_batch *batch, bool sync, bool force);
+void fd_batch_add_dep(struct fd_batch *batch, struct fd_batch *dep);
 void fd_batch_resource_used(struct fd_batch *batch, struct fd_resource *rsc, bool write);
 void fd_batch_check_size(struct fd_batch *batch);
 
@@ -224,16 +233,6 @@ void __fd_batch_destroy(struct fd_batch *batch);
  * __fd_batch_destroy() needs to unref resources)
  */
 
-static inline void
-fd_batch_reference(struct fd_batch **ptr, struct fd_batch *batch)
-{
-       struct fd_batch *old_batch = *ptr;
-       if (pipe_reference_described(&(*ptr)->reference, &batch->reference,
-                       (debug_reference_descriptor)__fd_batch_describe))
-               __fd_batch_destroy(old_batch);
-       *ptr = batch;
-}
-
 /* fwd-decl prototypes to untangle header dependency :-/ */
 static inline void fd_context_assert_locked(struct fd_context *ctx);
 static inline void fd_context_lock(struct fd_context *ctx);
@@ -244,21 +243,32 @@ fd_batch_reference_locked(struct fd_batch **ptr, struct fd_batch *batch)
 {
        struct fd_batch *old_batch = *ptr;
 
+       /* only need lock if a reference is dropped: */
        if (old_batch)
                fd_context_assert_locked(old_batch->ctx);
-       else if (batch)
-               fd_context_assert_locked(batch->ctx);
 
        if (pipe_reference_described(&(*ptr)->reference, &batch->reference,
-                       (debug_reference_descriptor)__fd_batch_describe)) {
-               struct fd_context *ctx = old_batch->ctx;
-               fd_context_unlock(ctx);
+                       (debug_reference_descriptor)__fd_batch_describe))
                __fd_batch_destroy(old_batch);
-               fd_context_lock(ctx);
-       }
+
        *ptr = batch;
 }
 
+static inline void
+fd_batch_reference(struct fd_batch **ptr, struct fd_batch *batch)
+{
+       struct fd_batch *old_batch = *ptr;
+       struct fd_context *ctx = old_batch ? old_batch->ctx : NULL;
+
+       if (ctx)
+               fd_context_lock(ctx);
+
+       fd_batch_reference_locked(ptr, batch);
+
+       if (ctx)
+               fd_context_unlock(ctx);
+}
+
 #include "freedreno_context.h"
 
 static inline void