Mesa (main): iris: extract the code that adds BOs to the batch lists
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 22:38:14 UTC 2021
Module: Mesa
Branch: main
Commit: d07fa0ef60ee3ffda5864d0cbadabe8e62e9037c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d07fa0ef60ee3ffda5864d0cbadabe8e62e9037c
Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date: Fri Jun 11 16:25:01 2021 -0700
iris: extract the code that adds BOs to the batch lists
We want to add a new caller, so extract this first.
v2: kflags can never contain EXEC_OBJECT_WRITE (Ken).
v3: Rebase after s/gtt_offset/address/.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12194>
---
src/gallium/drivers/iris/iris_batch.c | 49 ++++++++++++++++-------------------
1 file changed, 23 insertions(+), 26 deletions(-)
diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index d11fa2e54c8..34a40a8abd0 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -263,6 +263,27 @@ ensure_exec_obj_space(struct iris_batch *batch, uint32_t count)
}
}
+static void
+add_bo_to_batch(struct iris_batch *batch, struct iris_bo *bo, bool writable)
+{
+ assert(batch->exec_array_size > batch->exec_count);
+
+ iris_bo_reference(bo);
+
+ batch->exec_bos[batch->exec_count] = bo;
+
+ batch->validation_list[batch->exec_count] =
+ (struct drm_i915_gem_exec_object2) {
+ .handle = bo->gem_handle,
+ .offset = bo->address,
+ .flags = bo->kflags | (writable ? EXEC_OBJECT_WRITE : 0),
+ };
+
+ bo->index = batch->exec_count;
+ batch->exec_count++;
+ batch->aperture_space += bo->size;
+}
+
/**
* Add a buffer to the current batch's validation list.
*
@@ -332,23 +353,8 @@ iris_use_pinned_bo(struct iris_batch *batch,
}
}
- /* Now, take a reference and add it to the validation list. */
- iris_bo_reference(bo);
-
ensure_exec_obj_space(batch, 1);
-
- batch->validation_list[batch->exec_count] =
- (struct drm_i915_gem_exec_object2) {
- .handle = bo->gem_handle,
- .offset = bo->address,
- .flags = bo->kflags | (writable ? EXEC_OBJECT_WRITE : 0),
- };
-
- bo->index = batch->exec_count;
- batch->exec_bos[batch->exec_count] = bo;
- batch->aperture_space += bo->size;
-
- batch->exec_count++;
+ add_bo_to_batch(batch, bo, writable);
}
static void
@@ -512,16 +518,7 @@ add_aux_map_bos_to_batch(struct iris_batch *batch)
(void**)&batch->exec_bos[batch->exec_count], count);
for (uint32_t i = 0; i < count; i++) {
struct iris_bo *bo = batch->exec_bos[batch->exec_count];
- iris_bo_reference(bo);
- batch->validation_list[batch->exec_count] =
- (struct drm_i915_gem_exec_object2) {
- .handle = bo->gem_handle,
- .offset = bo->address,
- .flags = bo->kflags,
- };
- batch->aperture_space += bo->size;
- bo->index = batch->exec_count;
- batch->exec_count++;
+ add_bo_to_batch(batch, bo, false);
}
}
More information about the mesa-commit
mailing list