#include "common/gen_decoder.h"
#include "iris_fence.h"
+#include "iris_fine_fence.h"
struct iris_context;
#define MAX_BATCH_SIZE (256 * 1024)
/* Terminating the batch takes either 4 bytes for MI_BATCH_BUFFER_END
- * or 12 bytes for MI_BATCH_BUFFER_START (when chaining). Plus, we may
- * need an extra 4 bytes to pad out to the nearest QWord. So reserve 16.
+ * or 12 bytes for MI_BATCH_BUFFER_START (when chaining). Plus another
+ * 24 bytes for the seqno write (using PIPE_CONTROL).
*/
-#define BATCH_RESERVED 16
+#define BATCH_RESERVED 36
/* Our target batch size - flush approximately at this point. */
#define BATCH_SZ (64 * 1024 - BATCH_RESERVED)
#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;
/** The amount of aperture space (in bytes) used by all exec_bos */
int aperture_space;
- /** A drm_syncobj for the last batch that was submitted. */
- struct iris_syncobj *last_syncobj;
+ struct {
+ /** Uploader to use for sequence numbers */
+ struct u_upload_mgr *uploader;
+
+ /** GPU buffer and CPU map where our seqno's will be written. */
+ struct iris_state_ref ref;
+ uint32_t *map;
+
+ /** The sequence number to write the next time we add a fence. */
+ uint32_t next;
+ } fine_fences;
+
+ /** A seqno (and syncobj) for the last batch that was submitted. */
+ 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];
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;
};
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);
}
}
+/**
+ * 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