From f5a58b8886e89e3213f478c823ad08ca59bee693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 10 Aug 2022 11:33:33 -0700 Subject: [PATCH] anv: Split i915 specific parts of anv_queue_submit_simple_batch() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make easier to spot more places where the code can simplified after the hasvk split. Reviewed-by: Lionel Landwerlin Signed-off-by: José Roberto de Souza Part-of: --- src/intel/vulkan/anv_batch_chain.c | 75 ++++++++++++++++-------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 88c2e088d3d..80937053e69 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1979,13 +1979,52 @@ anv_queue_submit(struct vk_queue *vk_queue, return result; } +static VkResult +anv_i915_execute_simple_batch(struct anv_queue *queue, + struct anv_bo *batch_bo, + uint32_t batch_bo_size) +{ + struct anv_device *device = queue->device; + struct anv_execbuf execbuf = { + .alloc = &queue->device->vk.alloc, + .alloc_scope = VK_SYSTEM_ALLOCATION_SCOPE_DEVICE, + }; + + VkResult result = anv_execbuf_add_bo(device, &execbuf, batch_bo, NULL, 0); + if (result != VK_SUCCESS) + return result; + + execbuf.execbuf = (struct drm_i915_gem_execbuffer2) { + .buffers_ptr = (uintptr_t) execbuf.objects, + .buffer_count = execbuf.bo_count, + .batch_start_offset = 0, + .batch_len = batch_bo_size, + .flags = I915_EXEC_HANDLE_LUT | queue->exec_flags | I915_EXEC_NO_RELOC, + .rsvd1 = device->context_id, + .rsvd2 = 0, + }; + + if (anv_gem_execbuffer(device, &execbuf.execbuf)) { + result = vk_device_set_lost(&device->vk, "anv_gem_execbuffer failed: %m"); + goto fail; + } + + result = anv_device_wait(device, batch_bo, INT64_MAX); + if (result != VK_SUCCESS) + result = vk_device_set_lost(&device->vk, + "anv_device_wait failed: %m"); + +fail: + anv_execbuf_finish(&execbuf); + return result; +} + VkResult anv_queue_submit_simple_batch(struct anv_queue *queue, struct anv_batch *batch) { struct anv_device *device = queue->device; VkResult result = VK_SUCCESS; - int err; if (queue->device->info->no_hw) return VK_SUCCESS; @@ -2006,15 +2045,6 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, if (device->physical->memory.need_clflush) intel_flush_range(batch_bo->map, batch_size); - struct anv_execbuf execbuf = { - .alloc = &queue->device->vk.alloc, - .alloc_scope = VK_SYSTEM_ALLOCATION_SCOPE_DEVICE, - }; - - result = anv_execbuf_add_bo(device, &execbuf, batch_bo, NULL, 0); - if (result != VK_SUCCESS) - goto fail; - if (INTEL_DEBUG(DEBUG_BATCH)) { intel_print_batch(&device->decoder_ctx, batch_bo->map, @@ -2022,31 +2052,8 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, batch_bo->offset, false); } - execbuf.execbuf = (struct drm_i915_gem_execbuffer2) { - .buffers_ptr = (uintptr_t) execbuf.objects, - .buffer_count = execbuf.bo_count, - .batch_start_offset = 0, - .batch_len = batch_size, - .flags = I915_EXEC_HANDLE_LUT | queue->exec_flags | I915_EXEC_NO_RELOC, - .rsvd1 = device->context_id, - .rsvd2 = 0, - }; + result = anv_i915_execute_simple_batch(queue, batch_bo, batch_size); - err = anv_gem_execbuffer(device, &execbuf.execbuf); - if (err) { - result = vk_device_set_lost(&device->vk, "anv_gem_execbuffer failed: %m"); - goto fail; - } - - result = anv_device_wait(device, batch_bo, INT64_MAX); - if (result != VK_SUCCESS) { - result = vk_device_set_lost(&device->vk, - "anv_device_wait failed: %m"); - goto fail; - } - -fail: - anv_execbuf_finish(&execbuf); anv_bo_pool_free(&device->batch_bo_pool, batch_bo); return result;