iris: Tag each submitted batch with a syncobj
[mesa.git] / src / gallium / drivers / iris / iris_batch.h
index 7d446817d3df5f5aa960278610c52e6a4490955e..daa57fce6b5376a9f6e33c0443128c050fada5ea 100644 (file)
 #include <stdint.h>
 #include <stdbool.h>
 #include <string.h>
+
+#include "util/u_dynarray.h"
+
 #include "i915_drm.h"
 #include "common/gen_decoder.h"
-#include "iris_binder.h"
 
 /* The kernel assumes batchbuffers are smaller than 256kB. */
 #define MAX_BATCH_SIZE (256 * 1024)
@@ -37,6 +39,8 @@
 /* Our target batch size - flush approximately at this point. */
 #define BATCH_SZ (20 * 1024)
 
+#define IRIS_BATCH_COUNT 2
+
 struct iris_address {
    struct iris_bo *bo;
    uint64_t offset;
@@ -48,6 +52,9 @@ struct iris_batch {
    struct iris_vtable *vtbl;
    struct pipe_debug_callback *dbg;
 
+   /** The name of this batch for debug info (e.g. "render") */
+   const char *name;
+
    /** Current batchbuffer being queued up. */
    struct iris_bo *bo;
    void *map;
@@ -55,8 +62,8 @@ struct iris_batch {
    /** Size of the primary batch if we've moved on to a secondary. */
    unsigned primary_batch_size;
 
-   /** Last BO submitted to the hardware.  Used for glFinish(). */
-   struct iris_bo *last_bo;
+   /** Last Surface State Base Address set in this hardware context. */
+   uint64_t last_surface_base_address;
 
    uint32_t hw_ctx_id;
 
@@ -69,11 +76,23 @@ struct iris_batch {
    int exec_count;
    int exec_array_size;
 
+   /**
+    * A list of iris_syncpts associated with this batch.
+    *
+    * The first list entry will always be a signalling sync-point, indicating
+    * that this batch has completed.  The others are likely to be sync-points
+    * to wait on before executing the batch.
+    */
+   struct util_dynarray syncpts;
+
+   /** A list of drm_i915_exec_fences to have execbuf signal or wait on */
+   struct util_dynarray exec_fences;
+
    /** The amount of aperture space (in bytes) used by all exec_bos */
    int aperture_space;
 
-   /** Binder (containing binding tables) */
-   struct iris_binder binder;
+   /** List of other batches which we might need to flush to use a BO */
+   struct iris_batch *other_batches[IRIS_BATCH_COUNT - 1];
 
    struct {
       /**
@@ -104,21 +123,15 @@ void iris_init_batch(struct iris_batch *batch,
                      struct iris_screen *screen,
                      struct iris_vtable *vtbl,
                      struct pipe_debug_callback *dbg,
+                     struct iris_batch **other_batches,
+                     const char *name,
                      uint8_t ring);
 void iris_chain_to_new_batch(struct iris_batch *batch);
 void iris_batch_free(struct iris_batch *batch);
 void iris_batch_maybe_flush(struct iris_batch *batch, unsigned estimate);
 
-int _iris_batch_flush_fence(struct iris_batch *batch,
-                            int in_fence_fd, int *out_fence_fd,
-                            const char *file, int line);
-
-
-#define iris_batch_flush_fence(batch, in_fence_fd, out_fence_fd) \
-   _iris_batch_flush_fence((batch), (in_fence_fd), (out_fence_fd), \
-                           __FILE__, __LINE__)
-
-#define iris_batch_flush(batch) iris_batch_flush_fence((batch), -1, NULL)
+void _iris_batch_flush(struct iris_batch *batch, const char *file, int line);
+#define iris_batch_flush(batch) _iris_batch_flush((batch), __FILE__, __LINE__)
 
 bool iris_batch_references(struct iris_batch *batch, struct iris_bo *bo);