From b0eaaf90f3e145c65e0fe5649bd84e0cc94ee7b1 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 3 Sep 2021 15:26:53 +0200 Subject: [PATCH] panvk: Merge identical BO entries before submitting a job This should ideally be filtered when BOs are attached to a batch, but let's do it in the submit path until then. Signed-off-by: Boris Brezillon Reviewed-by: Tomeu Vizoso Part-of: --- src/panfrost/vulkan/panvk_vX_device.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/panfrost/vulkan/panvk_vX_device.c b/src/panfrost/vulkan/panvk_vX_device.c index 3f0147c4a9f..b607f6ce718 100644 --- a/src/panfrost/vulkan/panvk_vX_device.c +++ b/src/panfrost/vulkan/panvk_vX_device.c @@ -262,6 +262,16 @@ panvk_per_arch(QueueSubmit)(VkQueue _queue, bos[bo_idx++] = pdev->sample_positions->gem_handle; assert(bo_idx == nr_bos); + /* Merge identical BO entries. */ + for (unsigned x = 0; x < nr_bos; x++) { + for (unsigned y = x + 1; y < nr_bos; ) { + if (bos[x] == bos[y]) + bos[y] = bos[--nr_bos]; + else + y++; + } + } + unsigned nr_in_fences = 0; unsigned max_wait_event_syncobjs = util_dynarray_num_elements(&batch->event_ops,