From d07fa0ef60ee3ffda5864d0cbadabe8e62e9037c Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Fri, 11 Jun 2021 16:25:01 -0700 Subject: [PATCH] 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 Signed-off-by: Paulo Zanoni Part-of: --- 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); } }