iris: Annotate all BO uses with domain and sequence number information.
[mesa.git] / src / gallium / drivers / iris / iris_batch.h
index d82782795513210689fd6b6f8a0bd0d7d8bbec20..bfea20d268cc66d9c25f49eccd55f716ad2f1ef7 100644 (file)
@@ -34,7 +34,7 @@
 #include "common/gen_decoder.h"
 
 #include "iris_fence.h"
-#include "iris_seqno.h"
+#include "iris_fine_fence.h"
 
 struct iris_context;
 
@@ -57,12 +57,6 @@ enum iris_batch_name {
 
 #define IRIS_BATCH_COUNT 2
 
-struct iris_address {
-   struct iris_bo *bo;
-   uint64_t offset;
-   bool write;
-};
-
 struct iris_batch {
    struct iris_screen *screen;
    struct pipe_debug_callback *dbg;
@@ -123,10 +117,10 @@ struct iris_batch {
 
       /** The sequence number to write the next time we add a fence. */
       uint32_t next;
-   } seqno;
+   } fine_fences;
 
    /** A seqno (and syncobj) for the last batch that was submitted. */
-   struct iris_seqno *last_seqno;
+   struct iris_fine_fence *last_fence;
 
    /** List of other batches which we might need to flush to use a BO */
    struct iris_batch *other_batches[IRIS_BATCH_COUNT - 1];
@@ -150,9 +144,21 @@ struct iris_batch {
    struct gen_batch_decode_ctx decoder;
    struct hash_table_u64 *state_sizes;
 
+   /**
+    * Sequence number used to track the completion of any subsequent memory
+    * operations in the batch until the next sync boundary.
+    */
+   uint64_t next_seqno;
+
    /** Have we emitted any draw calls to this batch? */
    bool contains_draw;
 
+   /**
+    * Number of times iris_batch_sync_region_start() has been called without a
+    * matching iris_batch_sync_region_end() on this batch.
+    */
+   uint32_t sync_region_depth;
+
    uint32_t last_aux_map_state;
 };
 
@@ -168,14 +174,12 @@ void _iris_batch_flush(struct iris_batch *batch, const char *file, int line);
 
 bool iris_batch_references(struct iris_batch *batch, struct iris_bo *bo);
 
-uint64_t iris_batch_prepare_noop(struct iris_batch *batch,
-                                 bool noop_enable,
-                                 uint64_t dirty_flags);
+bool iris_batch_prepare_noop(struct iris_batch *batch, bool noop_enable);
 
 #define RELOC_WRITE EXEC_OBJECT_WRITE
 
 void iris_use_pinned_bo(struct iris_batch *batch, struct iris_bo *bo,
-                        bool writable);
+                        bool writable, enum iris_domain access);
 
 enum pipe_reset_status iris_batch_check_for_reset(struct iris_batch *batch);
 
@@ -268,4 +272,41 @@ iris_record_state_size(struct hash_table_u64 *ht,
    }
 }
 
+/**
+ * Mark the start of a region in the batch with stable synchronization
+ * sequence number.  Any buffer object accessed by the batch buffer only needs
+ * to be marked once (e.g. via iris_bo_bump_seqno()) within a region delimited
+ * by iris_batch_sync_region_start() and iris_batch_sync_region_end().
+ */
+static inline void
+iris_batch_sync_region_start(struct iris_batch *batch)
+{
+   batch->sync_region_depth++;
+}
+
+/**
+ * Mark the end of a region in the batch with stable synchronization sequence
+ * number.  Should be called once after each call to
+ * iris_batch_sync_region_start().
+ */
+static inline void
+iris_batch_sync_region_end(struct iris_batch *batch)
+{
+   assert(batch->sync_region_depth);
+   batch->sync_region_depth--;
+}
+
+/**
+ * Start a new synchronization section at the current point of the batch,
+ * unless disallowed by a previous iris_batch_sync_region_start().
+ */
+static inline void
+iris_batch_sync_boundary(struct iris_batch *batch)
+{
+   if (!batch->sync_region_depth) {
+      batch->next_seqno = p_atomic_inc_return(&batch->screen->last_seqno);
+      assert(batch->next_seqno > 0);
+   }
+}
+
 #endif