freedreno: rebind resource in all contexts
[mesa.git] / src / gallium / drivers / freedreno / freedreno_context.h
index 422d6c01a3bf1010863647141d1900befe77910f..57a172eede8f7732ede68314bd3a5cdf58b7976e 100644 (file)
@@ -66,6 +66,7 @@ struct fd_constbuf_stateobj {
 struct fd_shaderbuf_stateobj {
        struct pipe_shader_buffer sb[PIPE_MAX_SHADER_BUFFERS];
        uint32_t enabled_mask;
+       uint32_t writable_mask;
 };
 
 struct fd_shaderimg_stateobj {
@@ -142,9 +143,11 @@ enum fd_dirty_3d_state {
        FD_DIRTY_PROG        = BIT(16),
        FD_DIRTY_CONST       = BIT(17),
        FD_DIRTY_TEX         = BIT(18),
+       FD_DIRTY_IMAGE       = BIT(19),
+       FD_DIRTY_SSBO        = BIT(20),
 
        /* only used by a2xx.. possibly can be removed.. */
-       FD_DIRTY_TEXSTATE    = BIT(19),
+       FD_DIRTY_TEXSTATE    = BIT(21),
 };
 
 /* per shader-stage dirty state: */
@@ -159,12 +162,22 @@ enum fd_dirty_shader_state {
 struct fd_context {
        struct pipe_context base;
 
+       struct list_head node;   /* node in screen->context_list */
+
+       /* We currently need to serialize emitting GMEM batches, because of
+        * VSC state access in the context.
+        *
+        * In practice this lock should not be contended, since pipe_context
+        * use should be single threaded.  But it is needed to protect the
+        * case, with batch reordering where a ctxB batch triggers flushing
+        * a ctxA batch
+        */
+       mtx_t gmem_lock;
+
        struct fd_device *dev;
        struct fd_screen *screen;
        struct fd_pipe *pipe;
 
-       struct util_queue flush_queue;
-
        struct blitter_context *blitter;
        void *clear_rs_state;
        struct primconvert_context *primconvert;
@@ -193,6 +206,16 @@ struct fd_context {
        struct list_head acc_active_queries;
        /*@}*/
 
+       /* Whether we need to walk the acc_active_queries next fd_set_stage() to
+        * update active queries (even if stage doesn't change).
+        */
+       bool update_active_queries;
+
+       /* Current state of pctx->set_active_query_state() (i.e. "should drawing
+        * be counted against non-perfcounter queries")
+        */
+       bool active_queries;
+
        /* table with PIPE_PRIM_MAX entries mapping PIPE_PRIM_x to
         * DI_PT_x value to use for draw initiator.  There are some
         * slight differences between generation:
@@ -249,7 +272,7 @@ struct fd_context {
         * contents.  Main point is to eliminate blits from fd_try_shadow_resource().
         * For example, in case of texture upload + gen-mipmaps.
         */
-       bool in_blit : 1;
+       bool in_discard_blit : 1;
 
        struct pipe_scissor_state scissor;
 
@@ -259,14 +282,6 @@ struct fd_context {
         */
        struct pipe_scissor_state disabled_scissor;
 
-       /* Current gmem/tiling configuration.. gets updated on render_tiles()
-        * if out of date with current maximal-scissor/cpp:
-        *
-        * (NOTE: this is kind of related to the batch, but moving it there
-        * means we'd always have to recalc tiles ever batch)
-        */
-       struct fd_gmem_stateobj gmem;
-
        /* Per vsc pipe bo's (a2xx-a5xx): */
        struct fd_bo *vsc_pipe_bo[32];
 
@@ -311,11 +326,11 @@ struct fd_context {
 
        /* GMEM/tile handling fxns: */
        void (*emit_tile_init)(struct fd_batch *batch);
-       void (*emit_tile_prep)(struct fd_batch *batch, struct fd_tile *tile);
-       void (*emit_tile_mem2gmem)(struct fd_batch *batch, struct fd_tile *tile);
-       void (*emit_tile_renderprep)(struct fd_batch *batch, struct fd_tile *tile);
-       void (*emit_tile)(struct fd_batch *batch, struct fd_tile *tile);
-       void (*emit_tile_gmem2mem)(struct fd_batch *batch, struct fd_tile *tile);
+       void (*emit_tile_prep)(struct fd_batch *batch, const struct fd_tile *tile);
+       void (*emit_tile_mem2gmem)(struct fd_batch *batch, const struct fd_tile *tile);
+       void (*emit_tile_renderprep)(struct fd_batch *batch, const struct fd_tile *tile);
+       void (*emit_tile)(struct fd_batch *batch, const struct fd_tile *tile);
+       void (*emit_tile_gmem2mem)(struct fd_batch *batch, const struct fd_tile *tile);
        void (*emit_tile_fini)(struct fd_batch *batch);   /* optional */
 
        /* optional, for GMEM bypass: */
@@ -344,6 +359,14 @@ struct fd_context {
        /* handling for barriers: */
        void (*framebuffer_barrier)(struct fd_context *ctx);
 
+       /* logger: */
+       void (*record_timestamp)(struct fd_ringbuffer *ring, struct fd_bo *bo, unsigned offset);
+       uint64_t (*ts_to_ns)(uint64_t ts);
+
+       struct list_head log_chunks;  /* list of flushed log chunks in fifo order */
+       unsigned frame_nr;            /* frame counter (for fd_log) */
+       FILE *log_out;
+
        /*
         * Common pre-cooked VBO state (used for a3xx and later):
         */
@@ -462,16 +485,6 @@ fd_batch_set_stage(struct fd_batch *batch, enum fd_render_stage stage)
 {
        struct fd_context *ctx = batch->ctx;
 
-       /* special case: internal blits (like mipmap level generation)
-        * go through normal draw path (via util_blitter_blit()).. but
-        * we need to ignore the FD_STAGE_DRAW which will be set, so we
-        * don't enable queries which should be paused during internal
-        * blits:
-        */
-       if ((batch->stage == FD_STAGE_BLIT) &&
-                       (stage != FD_STAGE_NULL))
-               return;
-
        if (ctx->query_set_stage)
                ctx->query_set_stage(batch, stage);