static void
iris_batch_reset(struct iris_batch *batch);
+static unsigned
+num_fences(struct iris_batch *batch)
+{
+ return util_dynarray_num_elements(&batch->exec_fences,
+ struct drm_i915_gem_exec_fence);
+}
+
+/**
+ * Debugging code to dump the fence list, used by INTEL_DEBUG=submit.
+ */
+static void
+dump_fence_list(struct iris_batch *batch)
+{
+ fprintf(stderr, "Fence list (length %u): ", num_fences(batch));
+
+ util_dynarray_foreach(&batch->exec_fences,
+ struct drm_i915_gem_exec_fence, f) {
+ fprintf(stderr, "%s%u%s ",
+ (f->flags & I915_EXEC_FENCE_WAIT) ? "..." : "",
+ f->handle,
+ (f->flags & I915_EXEC_FENCE_SIGNAL) ? "!" : "");
+ }
+
+ fprintf(stderr, "\n");
+}
+
/**
* Debugging code to dump the validation list, used by INTEL_DEBUG=submit.
*/
batch->hw_ctx_id = iris_create_hw_context(screen->bufmgr);
assert(batch->hw_ctx_id);
+ util_dynarray_init(&batch->exec_fences, ralloc_context(NULL));
+
batch->exec_count = 0;
batch->exec_array_size = 100;
batch->exec_bos =
}
free(batch->exec_bos);
free(batch->validation_list);
+
+ ralloc_free(batch->exec_fences.mem_ctx);
+
iris_bo_unreference(batch->bo);
batch->bo = NULL;
batch->map = NULL;
* Submit the batch to the GPU via execbuffer2.
*/
static int
-submit_batch(struct iris_batch *batch, int in_fence_fd, int *out_fence_fd)
+submit_batch(struct iris_batch *batch)
{
iris_bo_unmap(batch->bo);
.rsvd1 = batch->hw_ctx_id, /* rsvd1 is actually the context ID */
};
- unsigned long cmd = DRM_IOCTL_I915_GEM_EXECBUFFER2;
-
- if (in_fence_fd != -1) {
- execbuf.rsvd2 = in_fence_fd;
- execbuf.flags |= I915_EXEC_FENCE_IN;
- }
-
- if (out_fence_fd != NULL) {
- cmd = DRM_IOCTL_I915_GEM_EXECBUFFER2_WR;
- *out_fence_fd = -1;
- execbuf.flags |= I915_EXEC_FENCE_OUT;
+ if (num_fences(batch)) {
+ execbuf.flags |= I915_EXEC_FENCE_ARRAY;
+ execbuf.num_cliprects = num_fences(batch);
+ execbuf.cliprects_ptr =
+ (uintptr_t)util_dynarray_begin(&batch->exec_fences);
}
- int ret = drm_ioctl(batch->screen->fd, cmd, &execbuf);
+ int ret = drm_ioctl(batch->screen->fd,
+ DRM_IOCTL_I915_GEM_EXECBUFFER2,
+ &execbuf);
if (ret != 0) {
ret = -errno;
DBG("execbuf FAILED: errno = %d\n", -ret);
bo->index = -1;
}
- if (ret == 0 && out_fence_fd != NULL)
- *out_fence_fd = execbuf.rsvd2 >> 32;
-
return ret;
}
* \param out_fence_fd is ignored if NULL. Otherwise, the caller must
* take ownership of the returned fd.
*/
-int
-_iris_batch_flush_fence(struct iris_batch *batch,
- int in_fence_fd, int *out_fence_fd,
- const char *file, int line)
+void
+_iris_batch_flush(struct iris_batch *batch, const char *file, int line)
{
if (iris_batch_bytes_used(batch) == 0)
- return 0;
+ return;
iris_finish_batch(batch);
100.0f * bytes_for_commands / BATCH_SZ,
batch->exec_count,
(float) batch->aperture_space / (1024 * 1024));
+ dump_fence_list(batch);
dump_validation_list(batch);
}
decode_batch(batch);
}
- int ret = submit_batch(batch, in_fence_fd, out_fence_fd);
+ int ret = submit_batch(batch);
//throttle(iris);
batch->exec_count = 0;
batch->aperture_space = 0;
+ util_dynarray_clear(&batch->exec_fences);
+
/* Start a new batch buffer. */
iris_batch_reset(batch);
-
- return 0;
}
/**
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
+
+#include "util/u_dynarray.h"
+
#include "i915_drm.h"
#include "common/gen_decoder.h"
int exec_count;
int exec_array_size;
+ /** 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;
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);