From 9e76cd1de3e313826f2225ef5828d361cd6f34cd Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Sat, 6 Jul 2024 21:02:03 -0700 Subject: [PATCH] chore: Update mesa to match Nobara's changes --- ...si-remove-has_syncobj-has_fence_to_h.patch | 153 -- ...lQueryDmaBufModifiersEXT-num_modifie.patch | 41 - spec_files/mesa/25352.patch | 1666 ----------------- spec_files/mesa/25576.patch | 1120 +++++++++++ spec_files/mesa/29979.patch | 75 - spec_files/mesa/fix-egl-on-s390x.patch | 131 -- spec_files/mesa/mesa-28923.patch | 39 - spec_files/mesa/mesa.spec | 16 +- spec_files/mesa/valve.patch | 68 +- 9 files changed, 1174 insertions(+), 2135 deletions(-) delete mode 100644 spec_files/mesa/0001-Revert-ac-radeonsi-remove-has_syncobj-has_fence_to_h.patch delete mode 100644 spec_files/mesa/0001-llvmpipe-Init-eglQueryDmaBufModifiersEXT-num_modifie.patch delete mode 100644 spec_files/mesa/25352.patch create mode 100644 spec_files/mesa/25576.patch delete mode 100644 spec_files/mesa/29979.patch delete mode 100644 spec_files/mesa/fix-egl-on-s390x.patch delete mode 100644 spec_files/mesa/mesa-28923.patch diff --git a/spec_files/mesa/0001-Revert-ac-radeonsi-remove-has_syncobj-has_fence_to_h.patch b/spec_files/mesa/0001-Revert-ac-radeonsi-remove-has_syncobj-has_fence_to_h.patch deleted file mode 100644 index 24600012..00000000 --- a/spec_files/mesa/0001-Revert-ac-radeonsi-remove-has_syncobj-has_fence_to_h.patch +++ /dev/null @@ -1,153 +0,0 @@ -From fddf49504e1bebb7efc52c1a0516300c0f217f18 Mon Sep 17 00:00:00 2001 -From: Pierre-Eric Pelloux-Prayer -Date: Wed, 26 Jun 2024 12:11:48 +0200 -Subject: [PATCH] Revert "ac, radeonsi: remove has_syncobj, - has_fence_to_handle" - -This reverts commit 02fe3c32cdfc3cf48cd691d6321978b8d4c3e61b. - -Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11352 ---- - src/amd/common/ac_gpu_info.c | 12 ++++++++++++ - src/amd/common/ac_gpu_info.h | 2 ++ - src/gallium/drivers/r600/r600_pipe_common.c | 1 + - src/gallium/drivers/radeonsi/si_fence.c | 10 ++++++++++ - src/gallium/drivers/radeonsi/si_get.c | 8 ++++++-- - 5 files changed, 31 insertions(+), 2 deletions(-) - -diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c -index 78febf796b4..3f711bd45ec 100644 ---- a/src/amd/common/ac_gpu_info.c -+++ b/src/amd/common/ac_gpu_info.c -@@ -355,6 +355,14 @@ static intptr_t readlink(const char *path, char *buf, size_t bufsiz) - - #define CIK_TILE_MODE_COLOR_2D 14 - -+static bool has_syncobj(int fd) -+{ -+ uint64_t value; -+ if (drmGetCap(fd, DRM_CAP_SYNCOBJ, &value)) -+ return false; -+ return value ? true : false; -+} -+ - static bool has_timeline_syncobj(int fd) - { - uint64_t value; -@@ -1068,7 +1076,9 @@ bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info, - info->memory_freq_mhz_effective *= ac_memory_ops_per_clock(info->vram_type); - - info->has_userptr = true; -+ info->has_syncobj = has_syncobj(fd); - info->has_timeline_syncobj = has_timeline_syncobj(fd); -+ info->has_fence_to_handle = info->has_syncobj; - info->has_local_buffers = true; - info->has_bo_metadata = true; - info->has_eqaa_surface_allocator = info->gfx_level < GFX11; -@@ -1974,7 +1984,9 @@ void ac_print_gpu_info(const struct radeon_info *info, FILE *f) - fprintf(f, "Kernel & winsys capabilities:\n"); - fprintf(f, " drm = %i.%i.%i\n", info->drm_major, info->drm_minor, info->drm_patchlevel); - fprintf(f, " has_userptr = %i\n", info->has_userptr); -+ fprintf(f, " has_syncobj = %u\n", info->has_syncobj); - fprintf(f, " has_timeline_syncobj = %u\n", info->has_timeline_syncobj); -+ fprintf(f, " has_fence_to_handle = %u\n", info->has_fence_to_handle); - fprintf(f, " has_local_buffers = %u\n", info->has_local_buffers); - fprintf(f, " has_bo_metadata = %u\n", info->has_bo_metadata); - fprintf(f, " has_eqaa_surface_allocator = %u\n", info->has_eqaa_surface_allocator); -diff --git a/src/amd/common/ac_gpu_info.h b/src/amd/common/ac_gpu_info.h -index 68fbe909a97..40670d87770 100644 ---- a/src/amd/common/ac_gpu_info.h -+++ b/src/amd/common/ac_gpu_info.h -@@ -218,7 +218,9 @@ struct radeon_info { - uint32_t max_submitted_ibs[AMD_NUM_IP_TYPES]; - bool is_amdgpu; - bool has_userptr; -+ bool has_syncobj; - bool has_timeline_syncobj; -+ bool has_fence_to_handle; - bool has_local_buffers; - bool has_bo_metadata; - bool has_eqaa_surface_allocator; -diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c -index aaa171a07ed..5a10aad5907 100644 ---- a/src/gallium/drivers/r600/r600_pipe_common.c -+++ b/src/gallium/drivers/r600/r600_pipe_common.c -@@ -1338,6 +1338,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, - printf("drm = %i.%i.%i\n", rscreen->info.drm_major, - rscreen->info.drm_minor, rscreen->info.drm_patchlevel); - printf("has_userptr = %i\n", rscreen->info.has_userptr); -+ printf("has_syncobj = %u\n", rscreen->info.has_syncobj); - - printf("r600_max_quad_pipes = %i\n", rscreen->info.r600_max_quad_pipes); - printf("max_gpu_freq_mhz = %i\n", rscreen->info.max_gpu_freq_mhz); -diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c -index a1ae9125e00..1d2406df9fd 100644 ---- a/src/gallium/drivers/radeonsi/si_fence.c -+++ b/src/gallium/drivers/radeonsi/si_fence.c -@@ -374,10 +374,16 @@ static void si_create_fence_fd(struct pipe_context *ctx, struct pipe_fence_handl - - switch (type) { - case PIPE_FD_TYPE_NATIVE_SYNC: -+ if (!sscreen->info.has_fence_to_handle) -+ goto finish; -+ - sfence->gfx = ws->fence_import_sync_file(ws, fd); - break; - - case PIPE_FD_TYPE_SYNCOBJ: -+ if (!sscreen->info.has_syncobj) -+ goto finish; -+ - sfence->gfx = ws->fence_import_syncobj(ws, fd); - break; - -@@ -385,6 +391,7 @@ static void si_create_fence_fd(struct pipe_context *ctx, struct pipe_fence_handl - unreachable("bad fence fd type when importing"); - } - -+finish: - if (!sfence->gfx) { - FREE(sfence); - return; -@@ -400,6 +407,9 @@ static int si_fence_get_fd(struct pipe_screen *screen, struct pipe_fence_handle - struct si_fence *sfence = (struct si_fence *)fence; - int gfx_fd = -1; - -+ if (!sscreen->info.has_fence_to_handle) -+ return -1; -+ - util_queue_fence_wait(&sfence->ready); - - /* Deferred fences aren't supported. */ -diff --git a/src/gallium/drivers/radeonsi/si_get.c b/src/gallium/drivers/radeonsi/si_get.c -index a9ac90dca52..3c8a75e9583 100644 ---- a/src/gallium/drivers/radeonsi/si_get.c -+++ b/src/gallium/drivers/radeonsi/si_get.c -@@ -168,8 +168,6 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) - case PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT: /* TODO: remove if it's slow */ - case PIPE_CAP_NULL_TEXTURES: - case PIPE_CAP_HAS_CONST_BW: -- case PIPE_CAP_FENCE_SIGNAL: -- case PIPE_CAP_NATIVE_FENCE_FD: - case PIPE_CAP_CL_GL_SHARING: - return 1; - -@@ -287,9 +285,15 @@ static int si_get_param(struct pipe_screen *pscreen, enum pipe_cap param) - PIPE_CONTEXT_PRIORITY_MEDIUM | - PIPE_CONTEXT_PRIORITY_HIGH; - -+ case PIPE_CAP_FENCE_SIGNAL: -+ return sscreen->info.has_syncobj; -+ - case PIPE_CAP_CONSTBUF0_FLAGS: - return SI_RESOURCE_FLAG_32BIT; - -+ case PIPE_CAP_NATIVE_FENCE_FD: -+ return sscreen->info.has_fence_to_handle; -+ - case PIPE_CAP_DRAW_PARAMETERS: - case PIPE_CAP_MULTI_DRAW_INDIRECT: - case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS: --- -2.45.2 - diff --git a/spec_files/mesa/0001-llvmpipe-Init-eglQueryDmaBufModifiersEXT-num_modifie.patch b/spec_files/mesa/0001-llvmpipe-Init-eglQueryDmaBufModifiersEXT-num_modifie.patch deleted file mode 100644 index ba224c27..00000000 --- a/spec_files/mesa/0001-llvmpipe-Init-eglQueryDmaBufModifiersEXT-num_modifie.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 1f3ea20998329788f6a14166d8ba9b3948b7e864 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= -Date: Thu, 27 Jun 2024 13:07:11 +0200 -Subject: [PATCH] llvmpipe: Init eglQueryDmaBufModifiersEXT num_modifiers -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Initialize the number of modifiers when `max` is 0 as documented [1]: - - If is 0, no formats are returned, but the total number - of formats is returned in , and no error is generated. - -[1] https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt -Fixes: d74ea2c117fe ("llvmpipe: Implement dmabuf handling") -Signed-off-by: José Expósito ---- - src/gallium/drivers/llvmpipe/lp_texture.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c -index 0044e689aab..30d5057cf9f 100644 ---- a/src/gallium/drivers/llvmpipe/lp_texture.c -+++ b/src/gallium/drivers/llvmpipe/lp_texture.c -@@ -1724,10 +1724,10 @@ llvmpipe_resource_get_param(struct pipe_screen *screen, - static void - llvmpipe_query_dmabuf_modifiers(struct pipe_screen *pscreen, enum pipe_format format, int max, uint64_t *modifiers, unsigned int *external_only, int *count) - { -- if (max) { -- *count = 1; -+ *count = 1; -+ -+ if (max) - *modifiers = DRM_FORMAT_MOD_LINEAR; -- } - } - - static bool --- -2.45.2 - diff --git a/spec_files/mesa/25352.patch b/spec_files/mesa/25352.patch deleted file mode 100644 index 373f455e..00000000 --- a/spec_files/mesa/25352.patch +++ /dev/null @@ -1,1666 +0,0 @@ -From c63ec27abdf33335c05fd8b536a94efdb648099b Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 09:32:08 -0400 -Subject: [PATCH 01/17] vk/queue: move VkPerformanceQuerySubmitInfoKHR handling - up - -this is only supported for actual submits ---- - src/vulkan/runtime/vk_queue.c | 26 +++++++++++++++----------- - 1 file changed, 15 insertions(+), 11 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 9e38299ed05fe..d95b694ef8b50 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -594,7 +594,8 @@ struct vulkan_submit_info { - - static VkResult - vk_queue_submit(struct vk_queue *queue, -- const struct vulkan_submit_info *info) -+ const struct vulkan_submit_info *info, -+ uint32_t perf_pass_index) - { - struct vk_device *device = queue->base.device; - VkResult result; -@@ -633,14 +634,7 @@ vk_queue_submit(struct vk_queue *queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- /* From the Vulkan 1.2.194 spec: -- * -- * "If the VkSubmitInfo::pNext chain does not include this structure, -- * the batch defaults to use counter pass index 0." -- */ -- const VkPerformanceQuerySubmitInfoKHR *perf_info = -- vk_find_struct_const(info->pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); -- submit->perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; -+ submit->perf_pass_index = perf_pass_index; - - bool has_binary_permanent_semaphore_wait = false; - for (uint32_t i = 0; i < info->wait_count; i++) { -@@ -1172,7 +1166,17 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - .signals = pSubmits[i].pSignalSemaphoreInfos, - .fence = i == submitCount - 1 ? fence : NULL - }; -- VkResult result = vk_queue_submit(queue, &info); -+ -+ /* From the Vulkan 1.2.194 spec: -+ * -+ * "If the VkSubmitInfo::pNext chain does not include this structure, -+ * the batch defaults to use counter pass index 0." -+ */ -+ const VkPerformanceQuerySubmitInfoKHR *perf_info = -+ vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); -+ uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; -+ -+ VkResult result = vk_queue_submit(queue, &info, perf_pass_index); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1274,7 +1278,7 @@ vk_common_QueueBindSparse(VkQueue _queue, - .image_binds = pBindInfo[i].pImageBinds, - .fence = i == bindInfoCount - 1 ? fence : NULL - }; -- VkResult result = vk_queue_submit(queue, &info); -+ VkResult result = vk_queue_submit(queue, &info, 0); - - STACK_ARRAY_FINISH(wait_semaphore_infos); - STACK_ARRAY_FINISH(signal_semaphore_infos); --- -GitLab - - -From d1936c0f4b72fbfb6f904e52cbd95c0ecb103aeb Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 09:46:41 -0400 -Subject: [PATCH 02/17] vk/queue: move WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA - handling up - -this (should) only come from mesa wsi, which does a single queue submit -per present, so handling it up front is both more logically consistent -and more performant ---- - src/vulkan/runtime/vk_queue.c | 43 +++++++++++++++++++---------------- - 1 file changed, 24 insertions(+), 19 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index d95b694ef8b50..8758b94d4a98d 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -595,7 +595,8 @@ struct vulkan_submit_info { - static VkResult - vk_queue_submit(struct vk_queue *queue, - const struct vulkan_submit_info *info, -- uint32_t perf_pass_index) -+ uint32_t perf_pass_index, -+ struct vk_sync *mem_sync) - { - struct vk_device *device = queue->base.device; - VkResult result; -@@ -613,12 +614,6 @@ vk_queue_submit(struct vk_queue *queue, - for (uint32_t i = 0; i < info->image_bind_count; ++i) - sparse_memory_image_bind_entry_count += info->image_binds[i].bindCount; - -- const struct wsi_memory_signal_submit_info *mem_signal = -- vk_find_struct_const(info->pNext, WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA); -- bool signal_mem_sync = mem_signal != NULL && -- mem_signal->memory != VK_NULL_HANDLE && -- queue->base.device->create_sync_for_memory != NULL; -- - struct vk_queue_submit *submit = - vk_queue_submit_alloc(queue, info->wait_count, - info->command_buffer_count, -@@ -628,7 +623,7 @@ vk_queue_submit(struct vk_queue *queue, - sparse_memory_bind_entry_count, - sparse_memory_image_bind_entry_count, - info->signal_count + -- signal_mem_sync + (info->fence != NULL), -+ (mem_sync != NULL) + (info->fence != NULL), - &sparse_memory_bind_entries, - &sparse_memory_image_bind_entries); - if (unlikely(submit == NULL)) -@@ -792,14 +787,7 @@ vk_queue_submit(struct vk_queue *queue, - } - - uint32_t signal_count = info->signal_count; -- if (signal_mem_sync) { -- struct vk_sync *mem_sync; -- result = queue->base.device->create_sync_for_memory(queue->base.device, -- mem_signal->memory, -- true, &mem_sync); -- if (unlikely(result != VK_SUCCESS)) -- goto fail; -- -+ if (mem_sync) { - submit->_mem_signal_temp = mem_sync; - - assert(submit->signals[signal_count].sync == NULL); -@@ -976,7 +964,7 @@ vk_queue_submit(struct vk_queue *queue, - - vk_queue_push_submit(queue, submit); - -- if (signal_mem_sync) { -+ if (mem_sync) { - /* If we're signaling a memory object, we have to ensure that - * vkQueueSubmit does not return until the kernel submission has - * happened. Otherwise, we may get a race between this process -@@ -1155,6 +1143,23 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - } - } - -+ /* WSI signal info comes from WSI, which does 1 submit */ -+ struct vk_sync *mem_sync = NULL; -+ if (submitCount == 1) { -+ const struct wsi_memory_signal_submit_info *mem_signal = -+ vk_find_struct_const(pSubmits->pNext, WSI_MEMORY_SIGNAL_SUBMIT_INFO_MESA); -+ bool signal_mem_sync = mem_signal != NULL && -+ mem_signal->memory != VK_NULL_HANDLE && -+ queue->base.device->create_sync_for_memory != NULL; -+ if (signal_mem_sync) { -+ VkResult result = queue->base.device->create_sync_for_memory(queue->base.device, -+ mem_signal->memory, -+ true, &mem_sync); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ } -+ } -+ - for (uint32_t i = 0; i < submitCount; i++) { - struct vulkan_submit_info info = { - .pNext = pSubmits[i].pNext, -@@ -1176,7 +1181,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- VkResult result = vk_queue_submit(queue, &info, perf_pass_index); -+ VkResult result = vk_queue_submit(queue, &info, perf_pass_index, mem_sync); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1278,7 +1283,7 @@ vk_common_QueueBindSparse(VkQueue _queue, - .image_binds = pBindInfo[i].pImageBinds, - .fence = i == bindInfoCount - 1 ? fence : NULL - }; -- VkResult result = vk_queue_submit(queue, &info, 0); -+ VkResult result = vk_queue_submit(queue, &info, 0, NULL); - - STACK_ARRAY_FINISH(wait_semaphore_infos); - STACK_ARRAY_FINISH(signal_semaphore_infos); --- -GitLab - - -From 78130ed25e0ddf5d44a87cce38afa4e1e0501c35 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 10:33:23 -0400 -Subject: [PATCH 03/17] vk/queue: precalc sparse bind counts before calling - submit - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 33 +++++++++++++++++++-------------- - 1 file changed, 19 insertions(+), 14 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 8758b94d4a98d..45a2de1dcaf38 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -596,24 +596,15 @@ static VkResult - vk_queue_submit(struct vk_queue *queue, - const struct vulkan_submit_info *info, - uint32_t perf_pass_index, -- struct vk_sync *mem_sync) -+ struct vk_sync *mem_sync, -+ uint32_t sparse_memory_bind_entry_count, -+ uint32_t sparse_memory_image_bind_entry_count) - { - struct vk_device *device = queue->base.device; - VkResult result; -- uint32_t sparse_memory_bind_entry_count = 0; -- uint32_t sparse_memory_image_bind_entry_count = 0; - VkSparseMemoryBind *sparse_memory_bind_entries = NULL; - VkSparseImageMemoryBind *sparse_memory_image_bind_entries = NULL; - -- for (uint32_t i = 0; i < info->buffer_bind_count; ++i) -- sparse_memory_bind_entry_count += info->buffer_binds[i].bindCount; -- -- for (uint32_t i = 0; i < info->image_opaque_bind_count; ++i) -- sparse_memory_bind_entry_count += info->image_opaque_binds[i].bindCount; -- -- for (uint32_t i = 0; i < info->image_bind_count; ++i) -- sparse_memory_image_bind_entry_count += info->image_binds[i].bindCount; -- - struct vk_queue_submit *submit = - vk_queue_submit_alloc(queue, info->wait_count, - info->command_buffer_count, -@@ -1181,7 +1172,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- VkResult result = vk_queue_submit(queue, &info, perf_pass_index, mem_sync); -+ VkResult result = vk_queue_submit(queue, &info, perf_pass_index, mem_sync, 0, 0); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1283,7 +1274,21 @@ vk_common_QueueBindSparse(VkQueue _queue, - .image_binds = pBindInfo[i].pImageBinds, - .fence = i == bindInfoCount - 1 ? fence : NULL - }; -- VkResult result = vk_queue_submit(queue, &info, 0, NULL); -+ uint32_t sparse_memory_bind_entry_count = 0; -+ uint32_t sparse_memory_image_bind_entry_count = 0; -+ -+ for (uint32_t i = 0; i < info.buffer_bind_count; ++i) -+ sparse_memory_bind_entry_count += info.buffer_binds[i].bindCount; -+ -+ for (uint32_t i = 0; i < info.image_opaque_bind_count; ++i) -+ sparse_memory_bind_entry_count += info.image_opaque_binds[i].bindCount; -+ -+ for (uint32_t i = 0; i < info.image_bind_count; ++i) -+ sparse_memory_image_bind_entry_count += info.image_binds[i].bindCount; -+ -+ VkResult result = vk_queue_submit(queue, &info, 0, NULL, -+ sparse_memory_bind_entry_count, -+ sparse_memory_image_bind_entry_count); - - STACK_ARRAY_FINISH(wait_semaphore_infos); - STACK_ARRAY_FINISH(signal_semaphore_infos); --- -GitLab - - -From 005352375cc7e6ef7539c57df56cb537fd13d320 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 10:38:13 -0400 -Subject: [PATCH 04/17] vk/queue: move vk_queue_submit allocation up - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 68 +++++++++++++++++++++-------------- - 1 file changed, 42 insertions(+), 26 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 45a2de1dcaf38..02b98e83ca032 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -595,30 +595,16 @@ struct vulkan_submit_info { - static VkResult - vk_queue_submit(struct vk_queue *queue, - const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit, - uint32_t perf_pass_index, - struct vk_sync *mem_sync, -- uint32_t sparse_memory_bind_entry_count, -- uint32_t sparse_memory_image_bind_entry_count) -+ VkSparseMemoryBind *sparse_memory_bind_entries, -+ VkSparseImageMemoryBind *sparse_memory_image_bind_entries) - { - struct vk_device *device = queue->base.device; - VkResult result; -- VkSparseMemoryBind *sparse_memory_bind_entries = NULL; -- VkSparseImageMemoryBind *sparse_memory_image_bind_entries = NULL; -- -- struct vk_queue_submit *submit = -- vk_queue_submit_alloc(queue, info->wait_count, -- info->command_buffer_count, -- info->buffer_bind_count, -- info->image_opaque_bind_count, -- info->image_bind_count, -- sparse_memory_bind_entry_count, -- sparse_memory_image_bind_entry_count, -- info->signal_count + -- (mem_sync != NULL) + (info->fence != NULL), -- &sparse_memory_bind_entries, -- &sparse_memory_image_bind_entries); -- if (unlikely(submit == NULL)) -- return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); -+ uint32_t sparse_memory_bind_entry_count = 0; -+ uint32_t sparse_memory_image_bind_entry_count = 0; - - submit->perf_pass_index = perf_pass_index; - -@@ -689,9 +675,6 @@ vk_queue_submit(struct vk_queue *queue, - submit->command_buffers[i] = cmd_buffer; - } - -- sparse_memory_bind_entry_count = 0; -- sparse_memory_image_bind_entry_count = 0; -- - if (info->buffer_binds) - typed_memcpy(submit->buffer_binds, info->buffer_binds, info->buffer_bind_count); - -@@ -1172,7 +1155,22 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- VkResult result = vk_queue_submit(queue, &info, perf_pass_index, mem_sync, 0, 0); -+ struct vk_queue_submit *submit = -+ vk_queue_submit_alloc(queue, info.wait_count, -+ info.command_buffer_count, -+ info.buffer_bind_count, -+ info.image_opaque_bind_count, -+ info.image_bind_count, -+ 0, -+ 0, -+ info.signal_count + -+ (mem_sync != NULL) + (info.fence != NULL), -+ NULL, -+ NULL); -+ if (unlikely(submit == NULL)) -+ return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); -+ -+ VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, 0, 0); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1286,9 +1284,27 @@ vk_common_QueueBindSparse(VkQueue _queue, - for (uint32_t i = 0; i < info.image_bind_count; ++i) - sparse_memory_image_bind_entry_count += info.image_binds[i].bindCount; - -- VkResult result = vk_queue_submit(queue, &info, 0, NULL, -- sparse_memory_bind_entry_count, -- sparse_memory_image_bind_entry_count); -+ VkSparseMemoryBind *sparse_memory_bind_entries = NULL; -+ VkSparseImageMemoryBind *sparse_memory_image_bind_entries = NULL; -+ -+ struct vk_queue_submit *submit = -+ vk_queue_submit_alloc(queue, info.wait_count, -+ info.command_buffer_count, -+ info.buffer_bind_count, -+ info.image_opaque_bind_count, -+ info.image_bind_count, -+ sparse_memory_bind_entry_count, -+ sparse_memory_image_bind_entry_count, -+ info.signal_count + -+ (info.fence != NULL), -+ &sparse_memory_bind_entries, -+ &sparse_memory_image_bind_entries); -+ if (unlikely(submit == NULL)) -+ return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); -+ -+ VkResult result = vk_queue_submit(queue, &info, submit, 0, NULL, -+ sparse_memory_bind_entries, -+ sparse_memory_image_bind_entries); - - STACK_ARRAY_FINISH(wait_semaphore_infos); - STACK_ARRAY_FINISH(signal_semaphore_infos); --- -GitLab - - -From 390c5a8f7bf383a197d8e9fa8c3b93496dc8bb1e Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:09:16 -0400 -Subject: [PATCH 05/17] vk/queue: break out submit wait parsing - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 39 +++++++++++++++++++++-------------- - 1 file changed, 24 insertions(+), 15 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 02b98e83ca032..7df848c75b5f3 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -592,22 +592,11 @@ struct vulkan_submit_info { - struct vk_fence *fence; - }; - --static VkResult --vk_queue_submit(struct vk_queue *queue, -- const struct vulkan_submit_info *info, -- struct vk_queue_submit *submit, -- uint32_t perf_pass_index, -- struct vk_sync *mem_sync, -- VkSparseMemoryBind *sparse_memory_bind_entries, -- VkSparseImageMemoryBind *sparse_memory_image_bind_entries) -+static bool -+vk_queue_parse_waits(struct vk_device *device, -+ const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit) - { -- struct vk_device *device = queue->base.device; -- VkResult result; -- uint32_t sparse_memory_bind_entry_count = 0; -- uint32_t sparse_memory_image_bind_entry_count = 0; -- -- submit->perf_pass_index = perf_pass_index; -- - bool has_binary_permanent_semaphore_wait = false; - for (uint32_t i = 0; i < info->wait_count; i++) { - VK_FROM_HANDLE(vk_semaphore, semaphore, -@@ -655,6 +644,26 @@ vk_queue_submit(struct vk_queue *queue, - .wait_value = wait_value, - }; - } -+ return has_binary_permanent_semaphore_wait; -+} -+ -+static VkResult -+vk_queue_submit(struct vk_queue *queue, -+ const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit, -+ uint32_t perf_pass_index, -+ struct vk_sync *mem_sync, -+ VkSparseMemoryBind *sparse_memory_bind_entries, -+ VkSparseImageMemoryBind *sparse_memory_image_bind_entries) -+{ -+ struct vk_device *device = queue->base.device; -+ VkResult result; -+ uint32_t sparse_memory_bind_entry_count = 0; -+ uint32_t sparse_memory_image_bind_entry_count = 0; -+ -+ submit->perf_pass_index = perf_pass_index; -+ -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(device, info, submit); - - for (uint32_t i = 0; i < info->command_buffer_count; i++) { - VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, --- -GitLab - - -From 443864152ac4977d72d3268ef1b3ade36f32f1ad Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:12:45 -0400 -Subject: [PATCH 06/17] vk/queue: break out cmdbuf parsing - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 42 +++++++++++++++++++++-------------- - 1 file changed, 25 insertions(+), 17 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 7df848c75b5f3..0bd8942dd0586 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -647,24 +647,11 @@ vk_queue_parse_waits(struct vk_device *device, - return has_binary_permanent_semaphore_wait; - } - --static VkResult --vk_queue_submit(struct vk_queue *queue, -- const struct vulkan_submit_info *info, -- struct vk_queue_submit *submit, -- uint32_t perf_pass_index, -- struct vk_sync *mem_sync, -- VkSparseMemoryBind *sparse_memory_bind_entries, -- VkSparseImageMemoryBind *sparse_memory_image_bind_entries) -+static void -+vk_queue_parse_cmdbufs(struct vk_queue *queue, -+ const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit) - { -- struct vk_device *device = queue->base.device; -- VkResult result; -- uint32_t sparse_memory_bind_entry_count = 0; -- uint32_t sparse_memory_image_bind_entry_count = 0; -- -- submit->perf_pass_index = perf_pass_index; -- -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(device, info, submit); -- - for (uint32_t i = 0; i < info->command_buffer_count; i++) { - VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, - info->command_buffers[i].commandBuffer); -@@ -683,6 +670,27 @@ vk_queue_submit(struct vk_queue *queue, - - submit->command_buffers[i] = cmd_buffer; - } -+} -+ -+static VkResult -+vk_queue_submit(struct vk_queue *queue, -+ const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit, -+ uint32_t perf_pass_index, -+ struct vk_sync *mem_sync, -+ VkSparseMemoryBind *sparse_memory_bind_entries, -+ VkSparseImageMemoryBind *sparse_memory_image_bind_entries) -+{ -+ struct vk_device *device = queue->base.device; -+ VkResult result; -+ uint32_t sparse_memory_bind_entry_count = 0; -+ uint32_t sparse_memory_image_bind_entry_count = 0; -+ -+ submit->perf_pass_index = perf_pass_index; -+ -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(device, info, submit); -+ -+ vk_queue_parse_cmdbufs(queue, info, submit); - - if (info->buffer_binds) - typed_memcpy(submit->buffer_binds, info->buffer_binds, info->buffer_bind_count); --- -GitLab - - -From 11d5e2d0c1493d07ad48f61fcdf5b4093708f005 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:16:32 -0400 -Subject: [PATCH 07/17] vk/queue: move wait parsing up - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 0bd8942dd0586..f5190e1c0aff4 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -678,6 +678,7 @@ vk_queue_submit(struct vk_queue *queue, - struct vk_queue_submit *submit, - uint32_t perf_pass_index, - struct vk_sync *mem_sync, -+ bool has_binary_permanent_semaphore_wait, - VkSparseMemoryBind *sparse_memory_bind_entries, - VkSparseImageMemoryBind *sparse_memory_image_bind_entries) - { -@@ -688,8 +689,6 @@ vk_queue_submit(struct vk_queue *queue, - - submit->perf_pass_index = perf_pass_index; - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(device, info, submit); -- - vk_queue_parse_cmdbufs(queue, info, submit); - - if (info->buffer_binds) -@@ -1187,7 +1186,9 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, 0, 0); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, &info, submit); -+ -+ VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1319,7 +1320,10 @@ vk_common_QueueBindSparse(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, &info, submit); -+ - VkResult result = vk_queue_submit(queue, &info, submit, 0, NULL, -+ has_binary_permanent_semaphore_wait, - sparse_memory_bind_entries, - sparse_memory_image_bind_entries); - --- -GitLab - - -From 681dd67e6fecf820258fe1872a13f6339e4c6fff Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:17:14 -0400 -Subject: [PATCH 08/17] vk/queue: move cmdbuf parsing up - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index f5190e1c0aff4..82c9b3e843696 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -689,8 +689,6 @@ vk_queue_submit(struct vk_queue *queue, - - submit->perf_pass_index = perf_pass_index; - -- vk_queue_parse_cmdbufs(queue, info, submit); -- - if (info->buffer_binds) - typed_memcpy(submit->buffer_binds, info->buffer_binds, info->buffer_bind_count); - -@@ -1187,6 +1185,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - - bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, &info, submit); -+ vk_queue_parse_cmdbufs(queue, &info, submit); - - VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); - if (unlikely(result != VK_SUCCESS)) --- -GitLab - - -From 2c3bdfe4effa72c7aadad05875ec3da6231bec50 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:46:59 -0400 -Subject: [PATCH 09/17] vk/queue: break out binary semaphore waiting for - threaded queues - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 178 ++++++++++++++++++---------------- - 1 file changed, 95 insertions(+), 83 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 82c9b3e843696..04974e340db60 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -672,6 +672,98 @@ vk_queue_parse_cmdbufs(struct vk_queue *queue, - } - } - -+static VkResult -+vk_queue_handle_threaded_waits(struct vk_queue *queue, -+ const struct vulkan_submit_info *info, -+ struct vk_queue_submit *submit) -+{ -+ assert(queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED); -+ for (uint32_t i = 0; i < info->wait_count; i++) { -+ VK_FROM_HANDLE(vk_semaphore, semaphore, -+ info->waits[i].semaphore); -+ -+ if (semaphore->type != VK_SEMAPHORE_TYPE_BINARY) -+ continue; -+ -+ /* From the Vulkan 1.2.194 spec: -+ * -+ * "When a batch is submitted to a queue via a queue -+ * submission, and it includes semaphores to be waited on, -+ * it defines a memory dependency between prior semaphore -+ * signal operations and the batch, and defines semaphore -+ * wait operations. -+ * -+ * Such semaphore wait operations set the semaphores -+ * created with a VkSemaphoreType of -+ * VK_SEMAPHORE_TYPE_BINARY to the unsignaled state." -+ * -+ * For threaded submit, we depend on tracking the unsignaled -+ * state of binary semaphores to determine when we can safely -+ * submit. The VK_SYNC_WAIT_PENDING check above as well as the -+ * one in the sumbit thread depend on all binary semaphores -+ * being reset when they're not in active use from the point -+ * of view of the client's CPU timeline. This means we need to -+ * reset them inside vkQueueSubmit and cannot wait until the -+ * actual submit which happens later in the thread. -+ * -+ * We've already stolen temporary semaphore payloads above as -+ * part of basic semaphore processing. We steal permanent -+ * semaphore payloads here by way of vk_sync_move. For shared -+ * semaphores, this can be a bit expensive (sync file import -+ * and export) but, for non-shared semaphores, it can be made -+ * fairly cheap. Also, we only do this semaphore swapping in -+ * the case where you have real timelines AND the client is -+ * using timeline semaphores with wait-before-signal (that's -+ * the only way to get a submit thread) AND mixing those with -+ * waits on binary semaphores AND said binary semaphore is -+ * using its permanent payload. In other words, this code -+ * should basically only ever get executed in CTS tests. -+ */ -+ if (submit->_wait_temps[i] != NULL) -+ continue; -+ -+ assert(submit->waits[i].sync == &semaphore->permanent); -+ -+ /* From the Vulkan 1.2.194 spec: -+ * -+ * VUID-vkQueueSubmit-pWaitSemaphores-03238 -+ * -+ * "All elements of the pWaitSemaphores member of all -+ * elements of pSubmits created with a VkSemaphoreType of -+ * VK_SEMAPHORE_TYPE_BINARY must reference a semaphore -+ * signal operation that has been submitted for execution -+ * and any semaphore signal operations on which it depends -+ * (if any) must have also been submitted for execution." -+ * -+ * Therefore, we can safely do a blocking wait here and it -+ * won't actually block for long. This ensures that the -+ * vk_sync_move below will succeed. -+ */ -+ VkResult result = vk_sync_wait(queue->base.device, -+ submit->waits[i].sync, 0, -+ VK_SYNC_WAIT_PENDING, UINT64_MAX); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ -+ result = vk_sync_create(queue->base.device, -+ semaphore->permanent.type, -+ 0 /* flags */, -+ 0 /* initial value */, -+ &submit->_wait_temps[i]); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ -+ result = vk_sync_move(queue->base.device, -+ submit->_wait_temps[i], -+ &semaphore->permanent); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ -+ submit->waits[i].sync = submit->_wait_temps[i]; -+ } -+ return VK_SUCCESS; -+} -+ - static VkResult - vk_queue_submit(struct vk_queue *queue, - const struct vulkan_submit_info *info, -@@ -865,89 +957,9 @@ vk_queue_submit(struct vk_queue *queue, - - case VK_QUEUE_SUBMIT_MODE_THREADED: - if (has_binary_permanent_semaphore_wait) { -- for (uint32_t i = 0; i < info->wait_count; i++) { -- VK_FROM_HANDLE(vk_semaphore, semaphore, -- info->waits[i].semaphore); -- -- if (semaphore->type != VK_SEMAPHORE_TYPE_BINARY) -- continue; -- -- /* From the Vulkan 1.2.194 spec: -- * -- * "When a batch is submitted to a queue via a queue -- * submission, and it includes semaphores to be waited on, -- * it defines a memory dependency between prior semaphore -- * signal operations and the batch, and defines semaphore -- * wait operations. -- * -- * Such semaphore wait operations set the semaphores -- * created with a VkSemaphoreType of -- * VK_SEMAPHORE_TYPE_BINARY to the unsignaled state." -- * -- * For threaded submit, we depend on tracking the unsignaled -- * state of binary semaphores to determine when we can safely -- * submit. The VK_SYNC_WAIT_PENDING check above as well as the -- * one in the sumbit thread depend on all binary semaphores -- * being reset when they're not in active use from the point -- * of view of the client's CPU timeline. This means we need to -- * reset them inside vkQueueSubmit and cannot wait until the -- * actual submit which happens later in the thread. -- * -- * We've already stolen temporary semaphore payloads above as -- * part of basic semaphore processing. We steal permanent -- * semaphore payloads here by way of vk_sync_move. For shared -- * semaphores, this can be a bit expensive (sync file import -- * and export) but, for non-shared semaphores, it can be made -- * fairly cheap. Also, we only do this semaphore swapping in -- * the case where you have real timelines AND the client is -- * using timeline semaphores with wait-before-signal (that's -- * the only way to get a submit thread) AND mixing those with -- * waits on binary semaphores AND said binary semaphore is -- * using its permanent payload. In other words, this code -- * should basically only ever get executed in CTS tests. -- */ -- if (submit->_wait_temps[i] != NULL) -- continue; -- -- assert(submit->waits[i].sync == &semaphore->permanent); -- -- /* From the Vulkan 1.2.194 spec: -- * -- * VUID-vkQueueSubmit-pWaitSemaphores-03238 -- * -- * "All elements of the pWaitSemaphores member of all -- * elements of pSubmits created with a VkSemaphoreType of -- * VK_SEMAPHORE_TYPE_BINARY must reference a semaphore -- * signal operation that has been submitted for execution -- * and any semaphore signal operations on which it depends -- * (if any) must have also been submitted for execution." -- * -- * Therefore, we can safely do a blocking wait here and it -- * won't actually block for long. This ensures that the -- * vk_sync_move below will succeed. -- */ -- result = vk_sync_wait(queue->base.device, -- submit->waits[i].sync, 0, -- VK_SYNC_WAIT_PENDING, UINT64_MAX); -- if (unlikely(result != VK_SUCCESS)) -- goto fail; -- -- result = vk_sync_create(queue->base.device, -- semaphore->permanent.type, -- 0 /* flags */, -- 0 /* initial value */, -- &submit->_wait_temps[i]); -- if (unlikely(result != VK_SUCCESS)) -- goto fail; -- -- result = vk_sync_move(queue->base.device, -- submit->_wait_temps[i], -- &semaphore->permanent); -- if (unlikely(result != VK_SUCCESS)) -- goto fail; -- -- submit->waits[i].sync = submit->_wait_temps[i]; -- } -+ result = vk_queue_handle_threaded_waits(queue, info, submit); -+ if (unlikely(result != VK_SUCCESS)) -+ goto fail; - } - - vk_queue_push_submit(queue, submit); --- -GitLab - - -From c79eba5ce9f94c5d7f00a294d78e412169ec961d Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:51:23 -0400 -Subject: [PATCH 10/17] vk/queue: pass waits directly to - vk_queue_handle_threaded_waits() - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 04974e340db60..c9278a814f85e 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -674,13 +674,14 @@ vk_queue_parse_cmdbufs(struct vk_queue *queue, - - static VkResult - vk_queue_handle_threaded_waits(struct vk_queue *queue, -- const struct vulkan_submit_info *info, -+ uint32_t wait_count, -+ const VkSemaphoreSubmitInfo *waits, - struct vk_queue_submit *submit) - { - assert(queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED); -- for (uint32_t i = 0; i < info->wait_count; i++) { -+ for (uint32_t i = 0; i < wait_count; i++) { - VK_FROM_HANDLE(vk_semaphore, semaphore, -- info->waits[i].semaphore); -+ waits[i].semaphore); - - if (semaphore->type != VK_SEMAPHORE_TYPE_BINARY) - continue; -@@ -957,7 +958,7 @@ vk_queue_submit(struct vk_queue *queue, - - case VK_QUEUE_SUBMIT_MODE_THREADED: - if (has_binary_permanent_semaphore_wait) { -- result = vk_queue_handle_threaded_waits(queue, info, submit); -+ result = vk_queue_handle_threaded_waits(queue, info->wait_count, info->waits, submit); - if (unlikely(result != VK_SUCCESS)) - goto fail; - } --- -GitLab - - -From ae75a3cb85500f73b07e7d466760abe8217c2b0b Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:58:10 -0400 -Subject: [PATCH 11/17] vk/queue: pass wait info directly to - vk_queue_parse_waits() - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index c9278a814f85e..3b3f331ab0c24 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -594,13 +594,14 @@ struct vulkan_submit_info { - - static bool - vk_queue_parse_waits(struct vk_device *device, -- const struct vulkan_submit_info *info, -+ uint32_t wait_count, -+ const VkSemaphoreSubmitInfo *waits, - struct vk_queue_submit *submit) - { - bool has_binary_permanent_semaphore_wait = false; -- for (uint32_t i = 0; i < info->wait_count; i++) { -+ for (uint32_t i = 0; i < wait_count; i++) { - VK_FROM_HANDLE(vk_semaphore, semaphore, -- info->waits[i].semaphore); -+ waits[i].semaphore); - - /* From the Vulkan 1.2.194 spec: - * -@@ -636,11 +637,11 @@ vk_queue_parse_waits(struct vk_device *device, - } - - uint64_t wait_value = semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE ? -- info->waits[i].value : 0; -+ waits[i].value : 0; - - submit->waits[i] = (struct vk_sync_wait) { - .sync = sync, -- .stage_mask = info->waits[i].stageMask, -+ .stage_mask = waits[i].stageMask, - .wait_value = wait_value, - }; - } -@@ -1197,7 +1198,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, &info, submit); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); - vk_queue_parse_cmdbufs(queue, &info, submit); - - VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); -@@ -1332,7 +1333,7 @@ vk_common_QueueBindSparse(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, &info, submit); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pBindInfo[i].waitSemaphoreCount, wait_semaphore_infos, submit); - - VkResult result = vk_queue_submit(queue, &info, submit, 0, NULL, - has_binary_permanent_semaphore_wait, --- -GitLab - - -From 1e517e9e81478cc63f841d4cf4eceb2150f22804 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 11:58:40 -0400 -Subject: [PATCH 12/17] vk/queue: pass cmdbuf info directly to - vk_queue_parse_cmdbufs() - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 3b3f331ab0c24..54f9c41820bfd 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -650,14 +650,15 @@ vk_queue_parse_waits(struct vk_device *device, - - static void - vk_queue_parse_cmdbufs(struct vk_queue *queue, -- const struct vulkan_submit_info *info, -+ uint32_t command_buffer_count, -+ const VkCommandBufferSubmitInfo *command_buffers, - struct vk_queue_submit *submit) - { -- for (uint32_t i = 0; i < info->command_buffer_count; i++) { -+ for (uint32_t i = 0; i < command_buffer_count; i++) { - VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, -- info->command_buffers[i].commandBuffer); -- assert(info->command_buffers[i].deviceMask == 0 || -- info->command_buffers[i].deviceMask == 1); -+ command_buffers[i].commandBuffer); -+ assert(command_buffers[i].deviceMask == 0 || -+ command_buffers[i].deviceMask == 1); - assert(cmd_buffer->pool->queue_family_index == queue->queue_family_index); - - /* Some drivers don't call vk_command_buffer_begin/end() yet and, for -@@ -1199,7 +1200,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - - bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); -- vk_queue_parse_cmdbufs(queue, &info, submit); -+ vk_queue_parse_cmdbufs(queue, pSubmits[i].commandBufferInfoCount, pSubmits[i].pCommandBufferInfos, submit); - - VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); - if (unlikely(result != VK_SUCCESS)) --- -GitLab - - -From 968f0c66b7f1dd29941626516d2bd0b74a8b5aa9 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 12:01:08 -0400 -Subject: [PATCH 13/17] vk/queue: move vk_queue_handle_threaded_waits() calls - up - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 34 +++++++++++++++++++++++----------- - 1 file changed, 23 insertions(+), 11 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 54f9c41820bfd..1e49cdbbf216a 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -959,12 +959,6 @@ vk_queue_submit(struct vk_queue *queue, - return vk_device_flush(queue->base.device); - - case VK_QUEUE_SUBMIT_MODE_THREADED: -- if (has_binary_permanent_semaphore_wait) { -- result = vk_queue_handle_threaded_waits(queue, info->wait_count, info->waits, submit); -- if (unlikely(result != VK_SUCCESS)) -- goto fail; -- } -- - vk_queue_push_submit(queue, submit); - - if (mem_sync) { -@@ -1164,6 +1158,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - } - - for (uint32_t i = 0; i < submitCount; i++) { -+ VkResult result = VK_SUCCESS; - struct vulkan_submit_info info = { - .pNext = pSubmits[i].pNext, - .command_buffer_count = pSubmits[i].commandBufferInfoCount, -@@ -1202,7 +1197,15 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); - vk_queue_parse_cmdbufs(queue, pSubmits[i].commandBufferInfoCount, pSubmits[i].pCommandBufferInfos, submit); - -- VkResult result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); -+ if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -+ result = vk_queue_handle_threaded_waits(queue, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); -+ if (unlikely(result != VK_SUCCESS)) { -+ vk_queue_submit_destroy(queue, submit); -+ return result; -+ } -+ } -+ -+ result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); - if (unlikely(result != VK_SUCCESS)) - return result; - } -@@ -1231,6 +1234,7 @@ vk_common_QueueBindSparse(VkQueue _queue, - } - - for (uint32_t i = 0; i < bindInfoCount; i++) { -+ VkResult result = VK_SUCCESS; - const VkTimelineSemaphoreSubmitInfo *timeline_info = - vk_find_struct_const(pBindInfo[i].pNext, TIMELINE_SEMAPHORE_SUBMIT_INFO); - const uint64_t *wait_values = NULL; -@@ -1336,11 +1340,19 @@ vk_common_QueueBindSparse(VkQueue _queue, - - bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pBindInfo[i].waitSemaphoreCount, wait_semaphore_infos, submit); - -- VkResult result = vk_queue_submit(queue, &info, submit, 0, NULL, -- has_binary_permanent_semaphore_wait, -- sparse_memory_bind_entries, -- sparse_memory_image_bind_entries); -+ if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -+ result = vk_queue_handle_threaded_waits(queue, pBindInfo[i].waitSemaphoreCount, wait_semaphore_infos, submit); -+ if (unlikely(result != VK_SUCCESS)) { -+ vk_queue_submit_destroy(queue, submit); -+ goto fail; -+ } -+ } - -+ result = vk_queue_submit(queue, &info, submit, 0, NULL, -+ has_binary_permanent_semaphore_wait, -+ sparse_memory_bind_entries, -+ sparse_memory_image_bind_entries); -+fail: - STACK_ARRAY_FINISH(wait_semaphore_infos); - STACK_ARRAY_FINISH(signal_semaphore_infos); - --- -GitLab - - -From 0f428de58525cad8e1ebd3c75c1503b10cbaf389 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 12:01:44 -0400 -Subject: [PATCH 14/17] vk/queue: remove wait and cmdbuf info from - vulkan_submit_info - -these are no longer used ---- - src/vulkan/runtime/vk_queue.c | 35 ++++++++++++++--------------------- - 1 file changed, 14 insertions(+), 21 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 1e49cdbbf216a..328b9abf44386 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -571,12 +571,6 @@ vk_queue_enable_submit_thread(struct vk_queue *queue) - struct vulkan_submit_info { - const void *pNext; - -- uint32_t command_buffer_count; -- const VkCommandBufferSubmitInfo *command_buffers; -- -- uint32_t wait_count; -- const VkSemaphoreSubmitInfo *waits; -- - uint32_t signal_count; - const VkSemaphoreSubmitInfo *signals; - -@@ -1159,12 +1153,12 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - - for (uint32_t i = 0; i < submitCount; i++) { - VkResult result = VK_SUCCESS; -+ uint32_t wait_count = pSubmits[i].waitSemaphoreInfoCount; -+ const VkSemaphoreSubmitInfo *wait_semaphore_infos = pSubmits[i].pWaitSemaphoreInfos; -+ uint32_t cmdbuf_count = pSubmits[i].commandBufferInfoCount; -+ const VkCommandBufferSubmitInfo *cmdbufs = pSubmits[i].pCommandBufferInfos; - struct vulkan_submit_info info = { - .pNext = pSubmits[i].pNext, -- .command_buffer_count = pSubmits[i].commandBufferInfoCount, -- .command_buffers = pSubmits[i].pCommandBufferInfos, -- .wait_count = pSubmits[i].waitSemaphoreInfoCount, -- .waits = pSubmits[i].pWaitSemaphoreInfos, - .signal_count = pSubmits[i].signalSemaphoreInfoCount, - .signals = pSubmits[i].pSignalSemaphoreInfos, - .fence = i == submitCount - 1 ? fence : NULL -@@ -1180,8 +1174,8 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - - struct vk_queue_submit *submit = -- vk_queue_submit_alloc(queue, info.wait_count, -- info.command_buffer_count, -+ vk_queue_submit_alloc(queue, wait_count, -+ cmdbuf_count, - info.buffer_bind_count, - info.image_opaque_bind_count, - info.image_bind_count, -@@ -1194,11 +1188,11 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); -- vk_queue_parse_cmdbufs(queue, pSubmits[i].commandBufferInfoCount, pSubmits[i].pCommandBufferInfos, submit); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); -+ vk_queue_parse_cmdbufs(queue, cmdbuf_count, cmdbufs, submit); - - if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -- result = vk_queue_handle_threaded_waits(queue, pSubmits[i].waitSemaphoreInfoCount, pSubmits[i].pWaitSemaphoreInfos, submit); -+ result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); - if (unlikely(result != VK_SUCCESS)) { - vk_queue_submit_destroy(queue, submit); - return result; -@@ -1268,6 +1262,7 @@ vk_common_QueueBindSparse(VkQueue _queue, - signal_values = timeline_info->pSignalSemaphoreValues; - } - -+ uint32_t wait_count = pBindInfo[i].waitSemaphoreCount; - STACK_ARRAY(VkSemaphoreSubmitInfo, wait_semaphore_infos, - pBindInfo[i].waitSemaphoreCount); - STACK_ARRAY(VkSemaphoreSubmitInfo, signal_semaphore_infos, -@@ -1296,8 +1291,6 @@ vk_common_QueueBindSparse(VkQueue _queue, - } - struct vulkan_submit_info info = { - .pNext = pBindInfo[i].pNext, -- .wait_count = pBindInfo[i].waitSemaphoreCount, -- .waits = wait_semaphore_infos, - .signal_count = pBindInfo[i].signalSemaphoreCount, - .signals = signal_semaphore_infos, - .buffer_bind_count = pBindInfo[i].bufferBindCount, -@@ -1324,8 +1317,8 @@ vk_common_QueueBindSparse(VkQueue _queue, - VkSparseImageMemoryBind *sparse_memory_image_bind_entries = NULL; - - struct vk_queue_submit *submit = -- vk_queue_submit_alloc(queue, info.wait_count, -- info.command_buffer_count, -+ vk_queue_submit_alloc(queue, pBindInfo[i].waitSemaphoreCount, -+ 0, - info.buffer_bind_count, - info.image_opaque_bind_count, - info.image_bind_count, -@@ -1338,10 +1331,10 @@ vk_common_QueueBindSparse(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, pBindInfo[i].waitSemaphoreCount, wait_semaphore_infos, submit); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); - - if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -- result = vk_queue_handle_threaded_waits(queue, pBindInfo[i].waitSemaphoreCount, wait_semaphore_infos, submit); -+ result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); - if (unlikely(result != VK_SUCCESS)) { - vk_queue_submit_destroy(queue, submit); - goto fail; --- -GitLab - - -From 683694ee2d0beb22191e779b5e7eea1e58fc016f Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 12:40:00 -0400 -Subject: [PATCH 15/17] vk/queue: split out allocation+submission for - QueueSubmit2KHR - -no functional changes ---- - src/vulkan/runtime/vk_queue.c | 83 +++++++++++++++++++++-------------- - 1 file changed, 50 insertions(+), 33 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 328b9abf44386..d2a7fbd76b742 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -1114,6 +1114,52 @@ vk_queue_finish(struct vk_queue *queue) - vk_object_base_finish(&queue->base); - } - -+static VkResult -+vk_queue_submit_flush(struct vk_queue *queue, const VkSubmitInfo2 *pSubmit, -+ uint32_t wait_count, const VkSemaphoreSubmitInfo *wait_semaphore_infos, -+ uint32_t cmdbuf_count, const VkCommandBufferSubmitInfo *cmdbufs, -+ uint32_t perf_pass_index, struct vk_sync *mem_sync, struct vk_fence *fence) -+{ -+ VkResult result = VK_SUCCESS; -+ struct vulkan_submit_info info = { -+ .pNext = pSubmit->pNext, -+ .signal_count = pSubmit->signalSemaphoreInfoCount, -+ .signals = pSubmit->pSignalSemaphoreInfos, -+ .fence = fence -+ }; -+ -+ struct vk_queue_submit *submit = -+ vk_queue_submit_alloc(queue, wait_count, -+ cmdbuf_count, -+ info.buffer_bind_count, -+ info.image_opaque_bind_count, -+ info.image_bind_count, -+ 0, -+ 0, -+ info.signal_count + -+ (mem_sync != NULL) + (info.fence != NULL), -+ NULL, -+ NULL); -+ if (unlikely(submit == NULL)) -+ return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); -+ -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); -+ vk_queue_parse_cmdbufs(queue, cmdbuf_count, cmdbufs, submit); -+ -+ if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -+ result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); -+ if (unlikely(result != VK_SUCCESS)) { -+ vk_queue_submit_destroy(queue, submit); -+ goto fail; -+ } -+ } -+ -+ result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); -+fail: -+ vk_queue_submit_destroy(queue, submit); -+ return result; -+} -+ - VKAPI_ATTR VkResult VKAPI_CALL - vk_common_QueueSubmit2KHR(VkQueue _queue, - uint32_t submitCount, -@@ -1157,12 +1203,6 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - const VkSemaphoreSubmitInfo *wait_semaphore_infos = pSubmits[i].pWaitSemaphoreInfos; - uint32_t cmdbuf_count = pSubmits[i].commandBufferInfoCount; - const VkCommandBufferSubmitInfo *cmdbufs = pSubmits[i].pCommandBufferInfos; -- struct vulkan_submit_info info = { -- .pNext = pSubmits[i].pNext, -- .signal_count = pSubmits[i].signalSemaphoreInfoCount, -- .signals = pSubmits[i].pSignalSemaphoreInfos, -- .fence = i == submitCount - 1 ? fence : NULL -- }; - - /* From the Vulkan 1.2.194 spec: - * -@@ -1173,33 +1213,10 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- struct vk_queue_submit *submit = -- vk_queue_submit_alloc(queue, wait_count, -- cmdbuf_count, -- info.buffer_bind_count, -- info.image_opaque_bind_count, -- info.image_bind_count, -- 0, -- 0, -- info.signal_count + -- (mem_sync != NULL) + (info.fence != NULL), -- NULL, -- NULL); -- if (unlikely(submit == NULL)) -- return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); -- -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); -- vk_queue_parse_cmdbufs(queue, cmdbuf_count, cmdbufs, submit); -- -- if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -- result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); -- if (unlikely(result != VK_SUCCESS)) { -- vk_queue_submit_destroy(queue, submit); -- return result; -- } -- } -- -- result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); -+ result = vk_queue_submit_flush(queue, &pSubmits[i], -+ wait_count, wait_semaphore_infos, -+ cmdbuf_count, cmdbufs, -+ perf_pass_index, mem_sync, i == submitCount - 1 ? fence : NULL); - if (unlikely(result != VK_SUCCESS)) - return result; - } --- -GitLab - - -From cd84beeccd14986b30faf154a0d371a93c94242f Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 12:47:12 -0400 -Subject: [PATCH 16/17] vk/queue: add a count param to vk_queue_submit_flush - -not currently used ---- - src/vulkan/runtime/vk_queue.c | 74 +++++++++++++++++++---------------- - 1 file changed, 41 insertions(+), 33 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index d2a7fbd76b742..20d28dfaba821 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -590,6 +590,7 @@ static bool - vk_queue_parse_waits(struct vk_device *device, - uint32_t wait_count, - const VkSemaphoreSubmitInfo *waits, -+ uint32_t offset, - struct vk_queue_submit *submit) - { - bool has_binary_permanent_semaphore_wait = false; -@@ -618,7 +619,7 @@ vk_queue_parse_waits(struct vk_device *device, - struct vk_sync *sync; - if (semaphore->temporary) { - assert(semaphore->type == VK_SEMAPHORE_TYPE_BINARY); -- sync = submit->_wait_temps[i] = semaphore->temporary; -+ sync = submit->_wait_temps[i + offset] = semaphore->temporary; - semaphore->temporary = NULL; - } else { - if (semaphore->type == VK_SEMAPHORE_TYPE_BINARY) { -@@ -633,7 +634,7 @@ vk_queue_parse_waits(struct vk_device *device, - uint64_t wait_value = semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE ? - waits[i].value : 0; - -- submit->waits[i] = (struct vk_sync_wait) { -+ submit->waits[i + offset] = (struct vk_sync_wait) { - .sync = sync, - .stage_mask = waits[i].stageMask, - .wait_value = wait_value, -@@ -646,6 +647,7 @@ static void - vk_queue_parse_cmdbufs(struct vk_queue *queue, - uint32_t command_buffer_count, - const VkCommandBufferSubmitInfo *command_buffers, -+ uint32_t offset, - struct vk_queue_submit *submit) - { - for (uint32_t i = 0; i < command_buffer_count; i++) { -@@ -664,7 +666,7 @@ vk_queue_parse_cmdbufs(struct vk_queue *queue, - cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_PENDING); - cmd_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_PENDING; - -- submit->command_buffers[i] = cmd_buffer; -+ submit->command_buffers[i + offset] = cmd_buffer; - } - } - -@@ -672,6 +674,7 @@ static VkResult - vk_queue_handle_threaded_waits(struct vk_queue *queue, - uint32_t wait_count, - const VkSemaphoreSubmitInfo *waits, -+ unsigned offset, - struct vk_queue_submit *submit) - { - assert(queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED); -@@ -716,10 +719,10 @@ vk_queue_handle_threaded_waits(struct vk_queue *queue, - * using its permanent payload. In other words, this code - * should basically only ever get executed in CTS tests. - */ -- if (submit->_wait_temps[i] != NULL) -+ if (submit->_wait_temps[i + offset] != NULL) - continue; - -- assert(submit->waits[i].sync == &semaphore->permanent); -+ assert(submit->waits[i + offset].sync == &semaphore->permanent); - - /* From the Vulkan 1.2.194 spec: - * -@@ -746,17 +749,17 @@ vk_queue_handle_threaded_waits(struct vk_queue *queue, - semaphore->permanent.type, - 0 /* flags */, - 0 /* initial value */, -- &submit->_wait_temps[i]); -+ &submit->_wait_temps[i + offset]); - if (unlikely(result != VK_SUCCESS)) - return result; - - result = vk_sync_move(queue->base.device, -- submit->_wait_temps[i], -+ submit->_wait_temps[i + offset], - &semaphore->permanent); - if (unlikely(result != VK_SUCCESS)) - return result; - -- submit->waits[i].sync = submit->_wait_temps[i]; -+ submit->waits[i + offset].sync = submit->_wait_temps[i + offset]; - } - return VK_SUCCESS; - } -@@ -1115,16 +1118,16 @@ vk_queue_finish(struct vk_queue *queue) - } - - static VkResult --vk_queue_submit_flush(struct vk_queue *queue, const VkSubmitInfo2 *pSubmit, -- uint32_t wait_count, const VkSemaphoreSubmitInfo *wait_semaphore_infos, -- uint32_t cmdbuf_count, const VkCommandBufferSubmitInfo *cmdbufs, -+vk_queue_submit_flush(struct vk_queue *queue, const VkSubmitInfo2 *pSubmits, unsigned submit_count, -+ uint32_t wait_count, -+ uint32_t cmdbuf_count, - uint32_t perf_pass_index, struct vk_sync *mem_sync, struct vk_fence *fence) - { - VkResult result = VK_SUCCESS; - struct vulkan_submit_info info = { -- .pNext = pSubmit->pNext, -- .signal_count = pSubmit->signalSemaphoreInfoCount, -- .signals = pSubmit->pSignalSemaphoreInfos, -+ .pNext = pSubmits->pNext, -+ .signal_count = pSubmits[submit_count - 1].signalSemaphoreInfoCount, -+ .signals = pSubmits[submit_count - 1].pSignalSemaphoreInfos, - .fence = fence - }; - -@@ -1143,21 +1146,28 @@ vk_queue_submit_flush(struct vk_queue *queue, const VkSubmitInfo2 *pSubmit, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); -- vk_queue_parse_cmdbufs(queue, cmdbuf_count, cmdbufs, submit); -- -- if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -- result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); -- if (unlikely(result != VK_SUCCESS)) { -- vk_queue_submit_destroy(queue, submit); -- goto fail; -+ uint32_t wait_counter = 0; -+ uint32_t cmdbuf_counter = 0; -+ bool has_binary_permanent_semaphore_wait = false; -+ for (unsigned i = 0; i < submit_count; i++) { -+ uint32_t cur_wait_count = pSubmits[i].waitSemaphoreInfoCount; -+ const VkSemaphoreSubmitInfo *wait_semaphore_infos = pSubmits[i].pWaitSemaphoreInfos; -+ uint32_t cur_cmdbuf_count = pSubmits[i].commandBufferInfoCount; -+ const VkCommandBufferSubmitInfo *cmdbufs = pSubmits[i].pCommandBufferInfos; -+ has_binary_permanent_semaphore_wait |= vk_queue_parse_waits(queue->base.device, cur_wait_count, wait_semaphore_infos, wait_counter, submit); -+ vk_queue_parse_cmdbufs(queue, cur_cmdbuf_count, cmdbufs, cmdbuf_counter, submit); -+ if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -+ result = vk_queue_handle_threaded_waits(queue, cur_wait_count, wait_semaphore_infos, wait_counter, submit); -+ if (unlikely(result != VK_SUCCESS)) { -+ vk_queue_submit_destroy(queue, submit); -+ return result; -+ } - } -+ wait_counter += cur_wait_count; -+ cmdbuf_counter += cur_cmdbuf_count; - } - -- result = vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); --fail: -- vk_queue_submit_destroy(queue, submit); -- return result; -+ return vk_queue_submit(queue, &info, submit, perf_pass_index, mem_sync, has_binary_permanent_semaphore_wait, 0, 0); - } - - VKAPI_ATTR VkResult VKAPI_CALL -@@ -1200,9 +1210,7 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - for (uint32_t i = 0; i < submitCount; i++) { - VkResult result = VK_SUCCESS; - uint32_t wait_count = pSubmits[i].waitSemaphoreInfoCount; -- const VkSemaphoreSubmitInfo *wait_semaphore_infos = pSubmits[i].pWaitSemaphoreInfos; - uint32_t cmdbuf_count = pSubmits[i].commandBufferInfoCount; -- const VkCommandBufferSubmitInfo *cmdbufs = pSubmits[i].pCommandBufferInfos; - - /* From the Vulkan 1.2.194 spec: - * -@@ -1213,9 +1221,9 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- result = vk_queue_submit_flush(queue, &pSubmits[i], -- wait_count, wait_semaphore_infos, -- cmdbuf_count, cmdbufs, -+ result = vk_queue_submit_flush(queue, &pSubmits[i], 1, -+ wait_count, -+ cmdbuf_count, - perf_pass_index, mem_sync, i == submitCount - 1 ? fence : NULL); - if (unlikely(result != VK_SUCCESS)) - return result; -@@ -1348,10 +1356,10 @@ vk_common_QueueBindSparse(VkQueue _queue, - if (unlikely(submit == NULL)) - return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); - -- bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, submit); -+ bool has_binary_permanent_semaphore_wait = vk_queue_parse_waits(queue->base.device, wait_count, wait_semaphore_infos, 0, submit); - - if (has_binary_permanent_semaphore_wait && queue->submit.mode == VK_QUEUE_SUBMIT_MODE_THREADED) { -- result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, submit); -+ result = vk_queue_handle_threaded_waits(queue, wait_count, wait_semaphore_infos, 0, submit); - if (unlikely(result != VK_SUCCESS)) { - vk_queue_submit_destroy(queue, submit); - goto fail; --- -GitLab - - -From e2c84bbbfec5cd618909ad0ec98d3304ab7f05f2 Mon Sep 17 00:00:00 2001 -From: Mike Blumenkrantz -Date: Thu, 21 Sep 2023 13:12:14 -0400 -Subject: [PATCH 17/17] vk/queue: merge queue submissions when possible - -given various conditions, it's possible to merge queue submits into a -single submission to reduce synchronization overhead ---- - src/vulkan/runtime/vk_queue.c | 89 +++++++++++++++++++++++++++++++---- - 1 file changed, 79 insertions(+), 10 deletions(-) - -diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c -index 20d28dfaba821..ebe412a0024fe 100644 ---- a/src/vulkan/runtime/vk_queue.c -+++ b/src/vulkan/runtime/vk_queue.c -@@ -1117,6 +1117,21 @@ vk_queue_finish(struct vk_queue *queue) - vk_object_base_finish(&queue->base); - } - -+static bool -+filter_pnexts(const void *pNext) -+{ -+ vk_foreach_struct_const(s, pNext) { -+ switch (s->sType) { -+ /* can possibly be merged */ -+ case VK_STRUCTURE_TYPE_PERFORMANCE_QUERY_SUBMIT_INFO_KHR: -+ break; -+ default: -+ return false; -+ } -+ } -+ return true; -+} -+ - static VkResult - vk_queue_submit_flush(struct vk_queue *queue, const VkSubmitInfo2 *pSubmits, unsigned submit_count, - uint32_t wait_count, -@@ -1207,11 +1222,14 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - } - } - -+ uint32_t prev_perf_pass_index = 0; -+ bool iterate = true; -+ bool has_perf_info = false; -+ bool has_signals = false; -+ bool needs_last = false; -+ uint32_t first = 0, last = 0; -+ uint32_t wait_count = 0, cmdbuf_count = 0; - for (uint32_t i = 0; i < submitCount; i++) { -- VkResult result = VK_SUCCESS; -- uint32_t wait_count = pSubmits[i].waitSemaphoreInfoCount; -- uint32_t cmdbuf_count = pSubmits[i].commandBufferInfoCount; -- - /* From the Vulkan 1.2.194 spec: - * - * "If the VkSubmitInfo::pNext chain does not include this structure, -@@ -1221,12 +1239,63 @@ vk_common_QueueSubmit2KHR(VkQueue _queue, - vk_find_struct_const(pSubmits[i].pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); - uint32_t perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; - -- result = vk_queue_submit_flush(queue, &pSubmits[i], 1, -- wait_count, -- cmdbuf_count, -- perf_pass_index, mem_sync, i == submitCount - 1 ? fence : NULL); -- if (unlikely(result != VK_SUCCESS)) -- return result; -+ /* determine when to split the submits -+ * - split if unhandled pNext is in chain -+ * - split if perf counterPassIndex changes or is added/omitted -+ * - split if signal ordering would be disrupted -+ */ -+ if (!filter_pnexts(pSubmits[i].pNext)) -+ iterate = false; -+ if (i && (!!perf_info != has_perf_info || (has_perf_info && perf_pass_index != prev_perf_pass_index))) -+ iterate = false; -+ if (has_signals) -+ iterate = false; -+ if (i == submitCount - 1) { -+ /* always flush on last submit*/ -+ if (iterate || !i) { -+ /* include last submit for flush if it can be included */ -+ wait_count += pSubmits[i].waitSemaphoreInfoCount; -+ cmdbuf_count += pSubmits[i].commandBufferInfoCount; -+ last = i; -+ } else { -+ needs_last = true; -+ } -+ iterate = false; -+ } -+ -+ if (!iterate) { -+ /* submits must split: flush pending but NOT current (unless last submit) */ -+ VkResult result = vk_queue_submit_flush(queue, &pSubmits[first], last - first + 1, -+ wait_count, -+ cmdbuf_count, -+ perf_pass_index, mem_sync, i == submitCount - 1 ? fence : NULL); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ wait_count = 0; -+ cmdbuf_count = 0; -+ first = last = i; -+ iterate = true; -+ } -+ -+ /* always keep accumulating */ -+ wait_count += pSubmits[i].waitSemaphoreInfoCount; -+ cmdbuf_count += pSubmits[i].commandBufferInfoCount; -+ last = i; -+ -+ has_perf_info = perf_info != NULL; -+ prev_perf_pass_index = perf_pass_index; -+ has_signals = pSubmits[i].signalSemaphoreInfoCount > 0; -+ if (needs_last) { -+ /* catch the last submit if it couldn't be merged above */ -+ assert(first == last); -+ assert(first == submitCount - 1); -+ VkResult result = vk_queue_submit_flush(queue, &pSubmits[first], last - first + 1, -+ wait_count, -+ cmdbuf_count, -+ perf_pass_index, mem_sync, i == submitCount - 1 ? fence : NULL); -+ if (unlikely(result != VK_SUCCESS)) -+ return result; -+ } - } - - return VK_SUCCESS; --- -GitLab - - diff --git a/spec_files/mesa/25576.patch b/spec_files/mesa/25576.patch new file mode 100644 index 00000000..5cc938c9 --- /dev/null +++ b/spec_files/mesa/25576.patch @@ -0,0 +1,1120 @@ +From cc598b60cac90742e3a714748d13d418efa81016 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 16:36:10 -0500 +Subject: [PATCH 1/7] vulkan/queue: Don't use vk_semaphore in threaded payload + stealing + +--- + src/vulkan/runtime/vk_queue.c | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index c8b55b58b0a3a..64d4003184d85 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -895,11 +895,8 @@ vk_queue_submit(struct vk_queue *queue, + + case VK_QUEUE_SUBMIT_MODE_THREADED: + if (has_binary_permanent_semaphore_wait) { +- for (uint32_t i = 0; i < info->wait_count; i++) { +- VK_FROM_HANDLE(vk_semaphore, semaphore, +- info->waits[i].semaphore); +- +- if (semaphore->type != VK_SEMAPHORE_TYPE_BINARY) ++ for (uint32_t i = 0; i < submit->wait_count; i++) { ++ if (submit->waits[i].sync->flags & VK_SYNC_IS_TIMELINE) + continue; + + /* From the Vulkan 1.2.194 spec: +@@ -939,8 +936,6 @@ vk_queue_submit(struct vk_queue *queue, + if (submit->_wait_temps[i] != NULL) + continue; + +- assert(submit->waits[i].sync == &semaphore->permanent); +- + /* From the Vulkan 1.2.194 spec: + * + * VUID-vkQueueSubmit-pWaitSemaphores-03238 +@@ -963,7 +958,7 @@ vk_queue_submit(struct vk_queue *queue, + goto fail; + + result = vk_sync_create(queue->base.device, +- semaphore->permanent.type, ++ submit->waits[i].sync->type, + 0 /* flags */, + 0 /* initial value */, + &submit->_wait_temps[i]); +@@ -972,7 +967,7 @@ vk_queue_submit(struct vk_queue *queue, + + result = vk_sync_move(queue->base.device, + submit->_wait_temps[i], +- &semaphore->permanent); ++ submit->waits[i].sync); + if (unlikely(result != VK_SUCCESS)) + goto fail; + +-- +GitLab + + +From e6c990c780650b911f1945ad364776285a350c44 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 16:38:32 -0500 +Subject: [PATCH 2/7] vulkan/queue: Move has_binary_permanent_semaphore_wait + into the sumbit struct + +--- + src/vulkan/runtime/vk_queue.c | 7 +++---- + src/vulkan/runtime/vk_queue.h | 1 + + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index 64d4003184d85..91c9968fdbdbf 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -642,7 +642,6 @@ vk_queue_submit(struct vk_queue *queue, + vk_find_struct_const(info->pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); + submit->perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; + +- bool has_binary_permanent_semaphore_wait = false; + for (uint32_t i = 0; i < info->wait_count; i++) { + VK_FROM_HANDLE(vk_semaphore, semaphore, + info->waits[i].semaphore); +@@ -674,7 +673,7 @@ vk_queue_submit(struct vk_queue *queue, + if (semaphore->type == VK_SEMAPHORE_TYPE_BINARY) { + if (vk_device_supports_threaded_submit(device)) + assert(semaphore->permanent.type->move); +- has_binary_permanent_semaphore_wait = true; ++ submit->_has_binary_permanent_semaphore_wait = true; + } + + sync = &semaphore->permanent; +@@ -863,7 +862,7 @@ vk_queue_submit(struct vk_queue *queue, + * operation. If we don't signal the vk_sync, then we need to reset it. + */ + if (vk_device_supports_threaded_submit(device) && +- has_binary_permanent_semaphore_wait) { ++ submit->_has_binary_permanent_semaphore_wait) { + for (uint32_t i = 0; i < submit->wait_count; i++) { + if ((submit->waits[i].sync->flags & VK_SYNC_IS_TIMELINE) || + submit->_wait_temps[i] != NULL) +@@ -894,7 +893,7 @@ vk_queue_submit(struct vk_queue *queue, + return vk_device_flush(queue->base.device); + + case VK_QUEUE_SUBMIT_MODE_THREADED: +- if (has_binary_permanent_semaphore_wait) { ++ if (submit->_has_binary_permanent_semaphore_wait) { + for (uint32_t i = 0; i < submit->wait_count; i++) { + if (submit->waits[i].sync->flags & VK_SYNC_IS_TIMELINE) + continue; +diff --git a/src/vulkan/runtime/vk_queue.h b/src/vulkan/runtime/vk_queue.h +index 814f9fefcdd17..23e10d9365925 100644 +--- a/src/vulkan/runtime/vk_queue.h ++++ b/src/vulkan/runtime/vk_queue.h +@@ -237,6 +237,7 @@ struct vk_queue_submit { + uint32_t perf_pass_index; + + /* Used internally; should be ignored by drivers */ ++ bool _has_binary_permanent_semaphore_wait; + struct vk_sync **_wait_temps; + struct vk_sync *_mem_signal_temp; + struct vk_sync_timeline_point **_wait_points; +-- +GitLab + + +From 35127c3b88267952db73f8ec395e578043b72d1a Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 16:45:01 -0500 +Subject: [PATCH 3/7] vulkan/queue: Use _mem_signal_temp instead of + signal_mem_sync + +The two checks should be equivalent. This just lets us use data in +struct vk_queue_submit rather than a local boolean. +--- + src/vulkan/runtime/vk_queue.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index 91c9968fdbdbf..19bf55965a694 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -976,7 +976,7 @@ vk_queue_submit(struct vk_queue *queue, + + vk_queue_push_submit(queue, submit); + +- if (signal_mem_sync) { ++ if (submit->_mem_signal_temp != NULL) { + /* If we're signaling a memory object, we have to ensure that + * vkQueueSubmit does not return until the kernel submission has + * happened. Otherwise, we may get a race between this process +-- +GitLab + + +From 491f788180e331c0de493d7047c973b3fc60c788 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 17:02:00 -0500 +Subject: [PATCH 4/7] vulkan,nvk: Add a vk_queue_submit_has_bind() helper + +--- + src/nouveau/vulkan/nvk_queue_drm_nouveau.c | 4 +--- + src/vulkan/runtime/vk_queue.h | 8 ++++++++ + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c +index a0087df592a49..17c1323fc4068 100644 +--- a/src/nouveau/vulkan/nvk_queue_drm_nouveau.c ++++ b/src/nouveau/vulkan/nvk_queue_drm_nouveau.c +@@ -594,9 +594,7 @@ nvk_queue_submit_drm_nouveau(struct nvk_queue *queue, + if (result != VK_SUCCESS) + return result; + +- const bool is_vmbind = submit->buffer_bind_count > 0 || +- submit->image_bind_count > 0 || +- submit->image_opaque_bind_count > 0; ++ const bool is_vmbind = vk_queue_submit_has_bind(submit); + push_builder_init(queue, &pb, is_vmbind); + + if (!is_vmbind && upload_time_point > 0) +diff --git a/src/vulkan/runtime/vk_queue.h b/src/vulkan/runtime/vk_queue.h +index 23e10d9365925..7d96a4c559d35 100644 +--- a/src/vulkan/runtime/vk_queue.h ++++ b/src/vulkan/runtime/vk_queue.h +@@ -244,6 +244,14 @@ struct vk_queue_submit { + struct vk_sync_timeline_point **_signal_points; + }; + ++static inline bool ++vk_queue_submit_has_bind(const struct vk_queue_submit *submit) ++{ ++ return submit->buffer_bind_count > 0 || ++ submit->image_opaque_bind_count > 0 || ++ submit->image_bind_count > 0; ++} ++ + #ifdef __cplusplus + } + #endif +-- +GitLab + + +From bd5c69333175224fa3605b5a7b4a92443cd2f052 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 18:48:03 -0500 +Subject: [PATCH 5/7] vulkan/queue: Use a builder pattern for vk_queue_submit + +--- + src/vulkan/runtime/vk_queue.c | 445 +++++++++++++++++++--------------- + src/vulkan/runtime/vk_queue.h | 5 + + 2 files changed, 258 insertions(+), 192 deletions(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index 19bf55965a694..229c68a1abd83 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -147,9 +147,7 @@ vk_queue_submit_alloc(struct vk_queue *queue, + uint32_t image_bind_count, + uint32_t bind_entry_count, + uint32_t image_bind_entry_count, +- uint32_t signal_count, +- VkSparseMemoryBind **bind_entries, +- VkSparseImageMemoryBind **image_bind_entries) ++ uint32_t signal_count) + { + VK_MULTIALLOC(ma); + VK_MULTIALLOC_DECL(&ma, struct vk_queue_submit, submit, 1); +@@ -163,8 +161,8 @@ vk_queue_submit_alloc(struct vk_queue *queue, + VK_MULTIALLOC_DECL(&ma, VkSparseImageMemoryBindInfo, image_binds, + image_bind_count); + VK_MULTIALLOC_DECL(&ma, VkSparseMemoryBind, +- bind_entries_local, bind_entry_count); +- VK_MULTIALLOC_DECL(&ma, VkSparseImageMemoryBind, image_bind_entries_local, ++ bind_entries, bind_entry_count); ++ VK_MULTIALLOC_DECL(&ma, VkSparseImageMemoryBind, image_bind_entries, + image_bind_entry_count); + VK_MULTIALLOC_DECL(&ma, struct vk_sync_signal, signals, signal_count); + VK_MULTIALLOC_DECL(&ma, struct vk_sync *, wait_temps, wait_count); +@@ -181,29 +179,19 @@ vk_queue_submit_alloc(struct vk_queue *queue, + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE)) + return NULL; + +- submit->wait_count = wait_count; +- submit->command_buffer_count = command_buffer_count; +- submit->signal_count = signal_count; +- submit->buffer_bind_count = buffer_bind_count; +- submit->image_opaque_bind_count = image_opaque_bind_count; +- submit->image_bind_count = image_bind_count; +- + submit->waits = waits; + submit->command_buffers = command_buffers; + submit->signals = signals; + submit->buffer_binds = buffer_binds; + submit->image_opaque_binds = image_opaque_binds; + submit->image_binds = image_binds; ++ ++ submit->_bind_entries = bind_entries; ++ submit->_image_bind_entries = image_bind_entries; + submit->_wait_temps = wait_temps; + submit->_wait_points = wait_points; + submit->_signal_points = signal_points; + +- if (bind_entries) +- *bind_entries = bind_entries_local; +- +- if (image_bind_entries) +- *image_bind_entries = image_bind_entries_local; +- + return submit; + } + +@@ -253,6 +241,228 @@ vk_queue_submit_destroy(struct vk_queue *queue, + vk_queue_submit_free(queue, submit); + } + ++static void ++vk_queue_submit_add_semaphore_wait(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkSemaphoreSubmitInfo *wait_info) ++{ ++ VK_FROM_HANDLE(vk_semaphore, semaphore, wait_info->semaphore); ++ ++ /* From the Vulkan 1.2.194 spec: ++ * ++ * "Applications can import a semaphore payload into an existing ++ * semaphore using an external semaphore handle. The effects of the ++ * import operation will be either temporary or permanent, as ++ * specified by the application. If the import is temporary, the ++ * implementation must restore the semaphore to its prior permanent ++ * state after submitting the next semaphore wait operation." ++ * ++ * and ++ * ++ * VUID-VkImportSemaphoreFdInfoKHR-flags-03323 ++ * ++ * "If flags contains VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the ++ * VkSemaphoreTypeCreateInfo::semaphoreType field of the semaphore ++ * from which handle or name was exported must not be ++ * VK_SEMAPHORE_TYPE_TIMELINE" ++ */ ++ struct vk_sync *sync; ++ if (semaphore->temporary) { ++ assert(semaphore->type == VK_SEMAPHORE_TYPE_BINARY); ++ sync = submit->_wait_temps[submit->wait_count] = semaphore->temporary; ++ semaphore->temporary = NULL; ++ } else { ++ if (semaphore->type == VK_SEMAPHORE_TYPE_BINARY) { ++ if (vk_device_supports_threaded_submit(queue->base.device)) ++ assert(semaphore->permanent.type->move); ++ submit->_has_binary_permanent_semaphore_wait = true; ++ } ++ ++ sync = &semaphore->permanent; ++ } ++ ++ uint64_t wait_value = semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE ? ++ wait_info->value : 0; ++ ++ submit->waits[submit->wait_count] = (struct vk_sync_wait) { ++ .sync = sync, ++ .stage_mask = wait_info->stageMask, ++ .wait_value = wait_value, ++ }; ++ ++ submit->wait_count++; ++} ++ ++static VkResult MUST_CHECK ++vk_queue_submit_add_semaphore_signal(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkSemaphoreSubmitInfo *signal_info) ++{ ++ VK_FROM_HANDLE(vk_semaphore, semaphore, signal_info->semaphore); ++ VkResult result; ++ ++ struct vk_sync *sync = vk_semaphore_get_active_sync(semaphore); ++ uint64_t signal_value = signal_info->value; ++ if (semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE) { ++ if (signal_value == 0) { ++ return vk_queue_set_lost(queue, ++ "Tried to signal a timeline with value 0"); ++ } ++ } else { ++ signal_value = 0; ++ } ++ ++ /* For emulated timelines, we need to associate a binary vk_sync with ++ * each time point and pass the binary vk_sync to the driver. We could ++ * do this in vk_queue_submit_final but it might require doing memory ++ * allocation and we don't want to to add extra failure paths there. ++ * Instead, allocate and replace the driver-visible vk_sync now and ++ * we'll insert it into the timeline in vk_queue_submit_final. The ++ * insert step is guaranteed to not fail. ++ */ ++ struct vk_sync_timeline *timeline = vk_sync_as_timeline(sync); ++ if (timeline) { ++ assert(queue->base.device->timeline_mode == ++ VK_DEVICE_TIMELINE_MODE_EMULATED); ++ struct vk_sync_timeline_point **signal_point = ++ &submit->_signal_points[submit->signal_count]; ++ result = vk_sync_timeline_alloc_point(queue->base.device, timeline, ++ signal_value, signal_point); ++ if (unlikely(result != VK_SUCCESS)) ++ return result; ++ ++ sync = &(*signal_point)->sync; ++ signal_value = 0; ++ } ++ ++ submit->signals[submit->signal_count] = (struct vk_sync_signal) { ++ .sync = sync, ++ .stage_mask = signal_info->stageMask, ++ .signal_value = signal_value, ++ }; ++ ++ submit->signal_count++; ++ ++ return VK_SUCCESS; ++} ++ ++static void ++vk_queue_submit_add_sync_signal(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ struct vk_sync *sync, ++ uint64_t signal_value) ++{ ++ submit->signals[submit->signal_count++] = (struct vk_sync_signal) { ++ .sync = sync, ++ .stage_mask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, ++ .signal_value = signal_value, ++ }; ++} ++ ++static VkResult MUST_CHECK ++vk_queue_submit_add_mem_signal(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ VkDeviceMemory memory) ++{ ++ assert(submit->_mem_signal_temp == NULL); ++ VkResult result; ++ ++ struct vk_sync *mem_sync; ++ result = queue->base.device->create_sync_for_memory(queue->base.device, ++ memory, true, ++ &mem_sync); ++ if (unlikely(result != VK_SUCCESS)) ++ return result; ++ ++ submit->_mem_signal_temp = mem_sync; ++ ++ vk_queue_submit_add_sync_signal(queue, submit, mem_sync, 0); ++ ++ return VK_SUCCESS; ++} ++ ++static void ++vk_queue_submit_add_fence_signal(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ struct vk_fence *fence) ++{ ++ vk_queue_submit_add_sync_signal(queue, submit, ++ vk_fence_get_active_sync(fence), 0); ++} ++ ++static void ++vk_queue_submit_add_command_buffer(struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkCommandBufferSubmitInfo *info) ++{ ++ VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, info->commandBuffer); ++ ++ assert(info->deviceMask == 0 || info->deviceMask == 1); ++ assert(cmd_buffer->pool->queue_family_index == queue->queue_family_index); ++ ++ /* Some drivers don't call vk_command_buffer_begin/end() yet and, for ++ * those, we'll see initial layout. However, this is enough to catch ++ * command buffers which get submitted without calling EndCommandBuffer. ++ */ ++ assert(cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_INITIAL || ++ cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_EXECUTABLE || ++ cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_PENDING); ++ cmd_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_PENDING; ++ ++ submit->command_buffers[submit->command_buffer_count++] = cmd_buffer; ++} ++ ++static void ++vk_queue_submit_add_buffer_bind( ++ struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkSparseBufferMemoryBindInfo *info) ++{ ++ VkSparseMemoryBind *entries = submit->_bind_entries + ++ submit->_bind_entry_count; ++ submit->_bind_entry_count += info->bindCount; ++ ++ typed_memcpy(entries, info->pBinds, info->bindCount); ++ ++ VkSparseBufferMemoryBindInfo info_tmp = *info; ++ info_tmp.pBinds = entries; ++ submit->buffer_binds[submit->buffer_bind_count++] = info_tmp; ++} ++ ++static void ++vk_queue_submit_add_image_opaque_bind( ++ struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkSparseImageOpaqueMemoryBindInfo *info) ++{ ++ VkSparseMemoryBind *entries = submit->_bind_entries + ++ submit->_bind_entry_count; ++ submit->_bind_entry_count += info->bindCount; ++ ++ typed_memcpy(entries, info->pBinds, info->bindCount); ++ ++ VkSparseImageOpaqueMemoryBindInfo info_tmp = *info; ++ info_tmp.pBinds = entries; ++ submit->image_opaque_binds[submit->image_opaque_bind_count++] = info_tmp; ++} ++ ++static void ++vk_queue_submit_add_image_bind( ++ struct vk_queue *queue, ++ struct vk_queue_submit *submit, ++ const VkSparseImageMemoryBindInfo *info) ++{ ++ VkSparseImageMemoryBind *entries = submit->_image_bind_entries + ++ submit->_image_bind_entry_count; ++ submit->_image_bind_entry_count += info->bindCount; ++ ++ typed_memcpy(entries, info->pBinds, info->bindCount); ++ ++ VkSparseImageMemoryBindInfo info_tmp = *info; ++ info_tmp.pBinds = entries; ++ submit->image_binds[submit->image_bind_count++] = info_tmp; ++} ++ + static void + vk_queue_push_submit(struct vk_queue *queue, + struct vk_queue_submit *submit) +@@ -600,8 +810,6 @@ vk_queue_submit(struct vk_queue *queue, + VkResult result; + uint32_t sparse_memory_bind_entry_count = 0; + uint32_t sparse_memory_image_bind_entry_count = 0; +- VkSparseMemoryBind *sparse_memory_bind_entries = NULL; +- VkSparseImageMemoryBind *sparse_memory_image_bind_entries = NULL; + + for (uint32_t i = 0; i < info->buffer_bind_count; ++i) + sparse_memory_bind_entry_count += info->buffer_binds[i].bindCount; +@@ -618,6 +826,10 @@ vk_queue_submit(struct vk_queue *queue, + mem_signal->memory != VK_NULL_HANDLE && + queue->base.device->create_sync_for_memory != NULL; + ++ uint32_t signal_count = info->signal_count + ++ signal_mem_sync + ++ (info->fence != NULL); ++ + struct vk_queue_submit *submit = + vk_queue_submit_alloc(queue, info->wait_count, + info->command_buffer_count, +@@ -626,10 +838,7 @@ vk_queue_submit(struct vk_queue *queue, + info->image_bind_count, + sparse_memory_bind_entry_count, + sparse_memory_image_bind_entry_count, +- info->signal_count + +- signal_mem_sync + (info->fence != NULL), +- &sparse_memory_bind_entries, +- &sparse_memory_image_bind_entries); ++ signal_count); + if (unlikely(submit == NULL)) + return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); + +@@ -642,185 +851,41 @@ vk_queue_submit(struct vk_queue *queue, + vk_find_struct_const(info->pNext, PERFORMANCE_QUERY_SUBMIT_INFO_KHR); + submit->perf_pass_index = perf_info ? perf_info->counterPassIndex : 0; + +- for (uint32_t i = 0; i < info->wait_count; i++) { +- VK_FROM_HANDLE(vk_semaphore, semaphore, +- info->waits[i].semaphore); +- +- /* From the Vulkan 1.2.194 spec: +- * +- * "Applications can import a semaphore payload into an existing +- * semaphore using an external semaphore handle. The effects of the +- * import operation will be either temporary or permanent, as +- * specified by the application. If the import is temporary, the +- * implementation must restore the semaphore to its prior permanent +- * state after submitting the next semaphore wait operation." +- * +- * and +- * +- * VUID-VkImportSemaphoreFdInfoKHR-flags-03323 +- * +- * "If flags contains VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, the +- * VkSemaphoreTypeCreateInfo::semaphoreType field of the semaphore +- * from which handle or name was exported must not be +- * VK_SEMAPHORE_TYPE_TIMELINE" +- */ +- struct vk_sync *sync; +- if (semaphore->temporary) { +- assert(semaphore->type == VK_SEMAPHORE_TYPE_BINARY); +- sync = submit->_wait_temps[i] = semaphore->temporary; +- semaphore->temporary = NULL; +- } else { +- if (semaphore->type == VK_SEMAPHORE_TYPE_BINARY) { +- if (vk_device_supports_threaded_submit(device)) +- assert(semaphore->permanent.type->move); +- submit->_has_binary_permanent_semaphore_wait = true; +- } +- +- sync = &semaphore->permanent; +- } +- +- uint64_t wait_value = semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE ? +- info->waits[i].value : 0; +- +- submit->waits[i] = (struct vk_sync_wait) { +- .sync = sync, +- .stage_mask = info->waits[i].stageMask, +- .wait_value = wait_value, +- }; +- } ++ for (uint32_t i = 0; i < info->wait_count; i++) ++ vk_queue_submit_add_semaphore_wait(queue, submit, &info->waits[i]); + + for (uint32_t i = 0; i < info->command_buffer_count; i++) { +- VK_FROM_HANDLE(vk_command_buffer, cmd_buffer, +- info->command_buffers[i].commandBuffer); +- assert(info->command_buffers[i].deviceMask == 0 || +- info->command_buffers[i].deviceMask == 1); +- assert(cmd_buffer->pool->queue_family_index == queue->queue_family_index); +- +- /* Some drivers don't call vk_command_buffer_begin/end() yet and, for +- * those, we'll see initial layout. However, this is enough to catch +- * command buffers which get submitted without calling EndCommandBuffer. +- */ +- assert(cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_INITIAL || +- cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_EXECUTABLE || +- cmd_buffer->state == MESA_VK_COMMAND_BUFFER_STATE_PENDING); +- cmd_buffer->state = MESA_VK_COMMAND_BUFFER_STATE_PENDING; +- +- submit->command_buffers[i] = cmd_buffer; ++ vk_queue_submit_add_command_buffer(queue, submit, ++ &info->command_buffers[i]); + } + +- sparse_memory_bind_entry_count = 0; +- sparse_memory_image_bind_entry_count = 0; +- +- if (info->buffer_binds) +- typed_memcpy(submit->buffer_binds, info->buffer_binds, info->buffer_bind_count); +- +- for (uint32_t i = 0; i < info->buffer_bind_count; ++i) { +- VkSparseMemoryBind *binds = sparse_memory_bind_entries + +- sparse_memory_bind_entry_count; +- submit->buffer_binds[i].pBinds = binds; +- typed_memcpy(binds, info->buffer_binds[i].pBinds, +- info->buffer_binds[i].bindCount); +- +- sparse_memory_bind_entry_count += info->buffer_binds[i].bindCount; +- } +- +- if (info->image_opaque_binds) +- typed_memcpy(submit->image_opaque_binds, info->image_opaque_binds, +- info->image_opaque_bind_count); ++ for (uint32_t i = 0; i < info->buffer_bind_count; ++i) ++ vk_queue_submit_add_buffer_bind(queue, submit, &info->buffer_binds[i]); + + for (uint32_t i = 0; i < info->image_opaque_bind_count; ++i) { +- VkSparseMemoryBind *binds = sparse_memory_bind_entries + +- sparse_memory_bind_entry_count; +- submit->image_opaque_binds[i].pBinds = binds; +- typed_memcpy(binds, info->image_opaque_binds[i].pBinds, +- info->image_opaque_binds[i].bindCount); +- +- sparse_memory_bind_entry_count += info->image_opaque_binds[i].bindCount; ++ vk_queue_submit_add_image_opaque_bind(queue, submit, ++ &info->image_opaque_binds[i]); + } + +- if (info->image_binds) +- typed_memcpy(submit->image_binds, info->image_binds, info->image_bind_count); +- +- for (uint32_t i = 0; i < info->image_bind_count; ++i) { +- VkSparseImageMemoryBind *binds = sparse_memory_image_bind_entries + +- sparse_memory_image_bind_entry_count; +- submit->image_binds[i].pBinds = binds; +- typed_memcpy(binds, info->image_binds[i].pBinds, +- info->image_binds[i].bindCount); +- +- sparse_memory_image_bind_entry_count += info->image_binds[i].bindCount; +- } ++ for (uint32_t i = 0; i < info->image_bind_count; ++i) ++ vk_queue_submit_add_image_bind(queue, submit, &info->image_binds[i]); + + for (uint32_t i = 0; i < info->signal_count; i++) { +- VK_FROM_HANDLE(vk_semaphore, semaphore, +- info->signals[i].semaphore); +- +- struct vk_sync *sync = vk_semaphore_get_active_sync(semaphore); +- uint64_t signal_value = info->signals[i].value; +- if (semaphore->type == VK_SEMAPHORE_TYPE_TIMELINE) { +- if (signal_value == 0) { +- result = vk_queue_set_lost(queue, +- "Tried to signal a timeline with value 0"); +- goto fail; +- } +- } else { +- signal_value = 0; +- } +- +- /* For emulated timelines, we need to associate a binary vk_sync with +- * each time point and pass the binary vk_sync to the driver. We could +- * do this in vk_queue_submit_final but it might require doing memory +- * allocation and we don't want to to add extra failure paths there. +- * Instead, allocate and replace the driver-visible vk_sync now and +- * we'll insert it into the timeline in vk_queue_submit_final. The +- * insert step is guaranteed to not fail. +- */ +- struct vk_sync_timeline *timeline = vk_sync_as_timeline(sync); +- if (timeline) { +- assert(queue->base.device->timeline_mode == +- VK_DEVICE_TIMELINE_MODE_EMULATED); +- result = vk_sync_timeline_alloc_point(queue->base.device, timeline, +- signal_value, +- &submit->_signal_points[i]); +- if (unlikely(result != VK_SUCCESS)) +- goto fail; +- +- sync = &submit->_signal_points[i]->sync; +- signal_value = 0; +- } +- +- submit->signals[i] = (struct vk_sync_signal) { +- .sync = sync, +- .stage_mask = info->signals[i].stageMask, +- .signal_value = signal_value, +- }; ++ result = vk_queue_submit_add_semaphore_signal(queue, submit, ++ &info->signals[i]); ++ if (unlikely(result != VK_SUCCESS)) ++ goto fail; + } + +- uint32_t signal_count = info->signal_count; + if (signal_mem_sync) { +- struct vk_sync *mem_sync; +- result = queue->base.device->create_sync_for_memory(queue->base.device, +- mem_signal->memory, +- true, &mem_sync); ++ result = vk_queue_submit_add_mem_signal(queue, submit, ++ mem_signal->memory); + if (unlikely(result != VK_SUCCESS)) + goto fail; +- +- submit->_mem_signal_temp = mem_sync; +- +- assert(submit->signals[signal_count].sync == NULL); +- submit->signals[signal_count++] = (struct vk_sync_signal) { +- .sync = mem_sync, +- .stage_mask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, +- }; + } + +- if (info->fence != NULL) { +- assert(submit->signals[signal_count].sync == NULL); +- submit->signals[signal_count++] = (struct vk_sync_signal) { +- .sync = vk_fence_get_active_sync(info->fence), +- .stage_mask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, +- }; +- } ++ if (info->fence != NULL) ++ vk_queue_submit_add_fence_signal(queue, submit, info->fence); + + assert(signal_count == submit->signal_count); + +@@ -1074,15 +1139,11 @@ vk_queue_signal_sync(struct vk_queue *queue, + uint32_t signal_value) + { + struct vk_queue_submit *submit = vk_queue_submit_alloc(queue, 0, 0, 0, 0, 0, +- 0, 0, 1, NULL, NULL); ++ 0, 0, 1); + if (unlikely(submit == NULL)) + return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY); + +- submit->signals[0] = (struct vk_sync_signal) { +- .sync = sync, +- .stage_mask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, +- .signal_value = signal_value, +- }; ++ vk_queue_submit_add_sync_signal(queue, submit, sync, signal_value); + + VkResult result; + switch (queue->submit.mode) { +diff --git a/src/vulkan/runtime/vk_queue.h b/src/vulkan/runtime/vk_queue.h +index 7d96a4c559d35..f6efd19c5a464 100644 +--- a/src/vulkan/runtime/vk_queue.h ++++ b/src/vulkan/runtime/vk_queue.h +@@ -237,6 +237,11 @@ struct vk_queue_submit { + uint32_t perf_pass_index; + + /* Used internally; should be ignored by drivers */ ++ uint32_t _bind_entry_count; ++ uint32_t _image_bind_entry_count; ++ VkSparseMemoryBind *_bind_entries; ++ VkSparseImageMemoryBind *_image_bind_entries; ++ + bool _has_binary_permanent_semaphore_wait; + struct vk_sync **_wait_temps; + struct vk_sync *_mem_signal_temp; +-- +GitLab + + +From a78e07d371e82fe2f2b14bfad596eb59bc70c0a1 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 18:59:35 -0500 +Subject: [PATCH 6/7] vulkan/queue: Split vk_queue_submit into create and + submit + +--- + src/vulkan/runtime/vk_queue.c | 34 +++++++++++++++++++++++++++++----- + 1 file changed, 29 insertions(+), 5 deletions(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index 229c68a1abd83..14423601baf32 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -803,10 +803,10 @@ struct vulkan_submit_info { + }; + + static VkResult +-vk_queue_submit(struct vk_queue *queue, +- const struct vulkan_submit_info *info) ++vk_queue_submit_create(struct vk_queue *queue, ++ const struct vulkan_submit_info *info, ++ struct vk_queue_submit **submit_out) + { +- struct vk_device *device = queue->base.device; + VkResult result; + uint32_t sparse_memory_bind_entry_count = 0; + uint32_t sparse_memory_image_bind_entry_count = 0; +@@ -889,6 +889,22 @@ vk_queue_submit(struct vk_queue *queue, + + assert(signal_count == submit->signal_count); + ++ *submit_out = submit; ++ ++ return VK_SUCCESS; ++ ++fail: ++ vk_queue_submit_destroy(queue, submit); ++ return result; ++} ++ ++static VkResult ++vk_queue_submit(struct vk_queue *queue, ++ struct vk_queue_submit *submit) ++{ ++ struct vk_device *device = queue->base.device; ++ VkResult result; ++ + /* If this device supports threaded submit, we can't rely on the client + * ordering requirements to ensure submits happen in the right order. Even + * if this queue doesn't have a submit thread, another queue (possibly in a +@@ -1231,7 +1247,12 @@ vk_common_QueueSubmit2(VkQueue _queue, + .signals = pSubmits[i].pSignalSemaphoreInfos, + .fence = i == submitCount - 1 ? fence : NULL + }; +- VkResult result = vk_queue_submit(queue, &info); ++ struct vk_queue_submit *submit; ++ VkResult result = vk_queue_submit_create(queue, &info, &submit); ++ if (unlikely(result != VK_SUCCESS)) ++ return result; ++ ++ result = vk_queue_submit(queue, submit); + if (unlikely(result != VK_SUCCESS)) + return result; + } +@@ -1333,7 +1354,10 @@ vk_common_QueueBindSparse(VkQueue _queue, + .image_binds = pBindInfo[i].pImageBinds, + .fence = i == bindInfoCount - 1 ? fence : NULL + }; +- VkResult result = vk_queue_submit(queue, &info); ++ struct vk_queue_submit *submit; ++ VkResult result = vk_queue_submit_create(queue, &info, &submit); ++ if (likely(result == VK_SUCCESS)) ++ result = vk_queue_submit(queue, submit); + + STACK_ARRAY_FINISH(wait_semaphore_infos); + STACK_ARRAY_FINISH(signal_semaphore_infos); +-- +GitLab + + +From cad7e59ecd7fa0ebdda08ae6cb8e9a2806927837 Mon Sep 17 00:00:00 2001 +From: Faith Ekstrand +Date: Thu, 5 Oct 2023 19:04:10 -0500 +Subject: [PATCH 7/7] vulkan/queue: Merge submits when possible + +--- + src/vulkan/runtime/vk_queue.c | 182 +++++++++++++++++++++++++++++++++- + 1 file changed, 178 insertions(+), 4 deletions(-) + +diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c +index 14423601baf32..f1d0332f0624f 100644 +--- a/src/vulkan/runtime/vk_queue.c ++++ b/src/vulkan/runtime/vk_queue.c +@@ -463,6 +463,135 @@ vk_queue_submit_add_image_bind( + submit->image_binds[submit->image_bind_count++] = info_tmp; + } + ++/* Attempts to merge two submits into one. If the merge succeeds, the merged ++ * submit is return and the two submits passed in are destroyed. ++ */ ++static struct vk_queue_submit * ++vk_queue_submits_merge(struct vk_queue *queue, ++ struct vk_queue_submit *first, ++ struct vk_queue_submit *second) ++{ ++ /* Don't merge if there are signals in between: see 'Signal operation order' */ ++ if (first->signal_count > 0 && ++ (second->command_buffer_count || ++ second->buffer_bind_count || ++ second->image_opaque_bind_count || ++ second->image_bind_count || ++ second->wait_count)) ++ return NULL; ++ ++ if (vk_queue_submit_has_bind(first) != vk_queue_submit_has_bind(second)) ++ return NULL; ++ ++ if (first->_mem_signal_temp) ++ return NULL; ++ ++ if (first->perf_pass_index != second->perf_pass_index) ++ return NULL; ++ ++ /* noop submits can always do a no-op merge */ ++ if (!second->command_buffer_count && ++ !second->buffer_bind_count && ++ !second->image_opaque_bind_count && ++ !second->image_bind_count && ++ !second->wait_count && ++ !second->signal_count) { ++ vk_queue_submit_destroy(queue, second); ++ return first; ++ } ++ if (!first->command_buffer_count && ++ !first->buffer_bind_count && ++ !first->image_opaque_bind_count && ++ !first->image_bind_count && ++ !first->wait_count && ++ !first->signal_count) { ++ vk_queue_submit_destroy(queue, first); ++ return second; ++ } ++ ++ struct vk_queue_submit *merged = vk_queue_submit_alloc(queue, ++ first->wait_count + second->wait_count, ++ first->command_buffer_count + second->command_buffer_count, ++ first->buffer_bind_count + second->buffer_bind_count, ++ first->image_opaque_bind_count + second->image_opaque_bind_count, ++ first->image_bind_count + second->image_bind_count, ++ first->_bind_entry_count + second->_bind_entry_count, ++ first->_image_bind_entry_count + second->_image_bind_entry_count, ++ first->signal_count + second->signal_count); ++ if (merged == NULL) ++ return NULL; ++ ++ merged->wait_count = first->wait_count + second->wait_count; ++ typed_memcpy(merged->waits, first->waits, first->wait_count); ++ typed_memcpy(&merged->waits[first->wait_count], second->waits, second->wait_count); ++ ++ merged->command_buffer_count = first->command_buffer_count + ++ second->command_buffer_count; ++ typed_memcpy(merged->command_buffers, ++ first->command_buffers, first->command_buffer_count); ++ typed_memcpy(&merged->command_buffers[first->command_buffer_count], ++ second->command_buffers, second->command_buffer_count); ++ ++ merged->signal_count = first->signal_count + second->signal_count; ++ typed_memcpy(merged->signals, first->signals, first->signal_count); ++ typed_memcpy(&merged->signals[first->signal_count], second->signals, second->signal_count); ++ ++ for (uint32_t i = 0; i < first->buffer_bind_count; i++) ++ vk_queue_submit_add_buffer_bind(queue, first, &first->buffer_binds[i]); ++ for (uint32_t i = 0; i < second->buffer_bind_count; i++) ++ vk_queue_submit_add_buffer_bind(queue, second, &first->buffer_binds[i]); ++ ++ for (uint32_t i = 0; i < first->image_opaque_bind_count; i++) { ++ vk_queue_submit_add_image_opaque_bind(queue, first, ++ &first->image_opaque_binds[i]); ++ } ++ for (uint32_t i = 0; i < second->image_opaque_bind_count; i++) { ++ vk_queue_submit_add_image_opaque_bind(queue, second, ++ &first->image_opaque_binds[i]); ++ } ++ ++ for (uint32_t i = 0; i < first->image_bind_count; i++) ++ vk_queue_submit_add_image_bind(queue, first, &first->image_binds[i]); ++ for (uint32_t i = 0; i < second->image_bind_count; i++) ++ vk_queue_submit_add_image_bind(queue, second, &first->image_binds[i]); ++ ++ merged->perf_pass_index = first->perf_pass_index; ++ assert(second->perf_pass_index == merged->perf_pass_index); ++ ++ assert(merged->_bind_entry_count == ++ first->_bind_entry_count + second->_bind_entry_count); ++ assert(merged->_image_bind_entry_count == ++ first->_image_bind_entry_count + second->_image_bind_entry_count); ++ ++ merged->_has_binary_permanent_semaphore_wait = ++ first->_has_binary_permanent_semaphore_wait; ++ ++ typed_memcpy(merged->_wait_temps, first->_wait_temps, first->wait_count); ++ typed_memcpy(&merged->_wait_temps[first->wait_count], second->_wait_temps, second->wait_count); ++ ++ assert(first->_mem_signal_temp == NULL); ++ merged->_mem_signal_temp = second->_mem_signal_temp; ++ ++ if (queue->base.device->timeline_mode == VK_DEVICE_TIMELINE_MODE_EMULATED) { ++ typed_memcpy(merged->_wait_points, ++ first->_wait_points, first->wait_count); ++ typed_memcpy(&merged->_wait_points[first->wait_count], ++ second->_wait_points, second->wait_count); ++ ++ typed_memcpy(merged->_signal_points, ++ first->_signal_points, first->signal_count); ++ typed_memcpy(&merged->_signal_points[first->signal_count], ++ second->_signal_points, second->signal_count); ++ } else { ++ assert(first->_wait_points == NULL && second->_wait_points == NULL); ++ assert(first->_signal_points == NULL && second->_signal_points == NULL); ++ } ++ vk_queue_submit_free(queue, first); ++ vk_queue_submit_free(queue, second); ++ ++ return merged; ++} ++ + static void + vk_queue_push_submit(struct vk_queue *queue, + struct vk_queue_submit *submit) +@@ -1084,6 +1213,35 @@ fail: + return result; + } + ++static VkResult ++vk_queue_merge_submit(struct vk_queue *queue, ++ struct vk_queue_submit **last_submit, ++ struct vk_queue_submit *submit) ++{ ++ if (*last_submit == NULL) { ++ *last_submit = submit; ++ return VK_SUCCESS; ++ } ++ ++ struct vk_queue_submit *merged = ++ vk_queue_submits_merge(queue, *last_submit, submit); ++ if (merged != NULL) { ++ *last_submit = merged; ++ return VK_SUCCESS; ++ } ++ ++ VkResult result = vk_queue_submit(queue, *last_submit); ++ *last_submit = NULL; ++ ++ if (likely(result == VK_SUCCESS)) { ++ *last_submit = submit; ++ } else { ++ vk_queue_submit_destroy(queue, submit); ++ } ++ ++ return result; ++} ++ + VkResult + vk_queue_wait_before_present(struct vk_queue *queue, + const VkPresentInfoKHR *pPresentInfo) +@@ -1224,6 +1382,7 @@ vk_common_QueueSubmit2(VkQueue _queue, + { + VK_FROM_HANDLE(vk_queue, queue, _queue); + VK_FROM_HANDLE(vk_fence, fence, _fence); ++ VkResult result; + + if (vk_device_is_lost(queue->base.device)) + return VK_ERROR_DEVICE_LOST; +@@ -1236,6 +1395,7 @@ vk_common_QueueSubmit2(VkQueue _queue, + } + } + ++ struct vk_queue_submit *last_submit = NULL; + for (uint32_t i = 0; i < submitCount; i++) { + struct vulkan_submit_info info = { + .pNext = pSubmits[i].pNext, +@@ -1248,11 +1408,17 @@ vk_common_QueueSubmit2(VkQueue _queue, + .fence = i == submitCount - 1 ? fence : NULL + }; + struct vk_queue_submit *submit; +- VkResult result = vk_queue_submit_create(queue, &info, &submit); ++ result = vk_queue_submit_create(queue, &info, &submit); ++ if (unlikely(result != VK_SUCCESS)) ++ return result; ++ ++ result = vk_queue_merge_submit(queue, &last_submit, submit); + if (unlikely(result != VK_SUCCESS)) + return result; ++ } + +- result = vk_queue_submit(queue, submit); ++ if (last_submit != NULL) { ++ result = vk_queue_submit(queue, last_submit); + if (unlikely(result != VK_SUCCESS)) + return result; + } +@@ -1268,6 +1434,7 @@ vk_common_QueueBindSparse(VkQueue _queue, + { + VK_FROM_HANDLE(vk_queue, queue, _queue); + VK_FROM_HANDLE(vk_fence, fence, _fence); ++ VkResult result; + + if (vk_device_is_lost(queue->base.device)) + return VK_ERROR_DEVICE_LOST; +@@ -1280,6 +1447,7 @@ vk_common_QueueBindSparse(VkQueue _queue, + } + } + ++ struct vk_queue_submit *last_submit = NULL; + for (uint32_t i = 0; i < bindInfoCount; i++) { + const VkTimelineSemaphoreSubmitInfo *timeline_info = + vk_find_struct_const(pBindInfo[i].pNext, TIMELINE_SEMAPHORE_SUBMIT_INFO); +@@ -1355,9 +1523,9 @@ vk_common_QueueBindSparse(VkQueue _queue, + .fence = i == bindInfoCount - 1 ? fence : NULL + }; + struct vk_queue_submit *submit; +- VkResult result = vk_queue_submit_create(queue, &info, &submit); ++ result = vk_queue_submit_create(queue, &info, &submit); + if (likely(result == VK_SUCCESS)) +- result = vk_queue_submit(queue, submit); ++ result = vk_queue_merge_submit(queue, &last_submit, submit); + + STACK_ARRAY_FINISH(wait_semaphore_infos); + STACK_ARRAY_FINISH(signal_semaphore_infos); +@@ -1366,6 +1534,12 @@ vk_common_QueueBindSparse(VkQueue _queue, + return result; + } + ++ if (last_submit != NULL) { ++ result = vk_queue_submit(queue, last_submit); ++ if (unlikely(result != VK_SUCCESS)) ++ return result; ++ } ++ + return VK_SUCCESS; + } + +-- +GitLab + diff --git a/spec_files/mesa/29979.patch b/spec_files/mesa/29979.patch deleted file mode 100644 index 1898e1c9..00000000 --- a/spec_files/mesa/29979.patch +++ /dev/null @@ -1,75 +0,0 @@ -From cbd19e09d1e293b6b34a30312aac3c865f42b244 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Michel=20D=C3=A4nzer?= -Date: Mon, 1 Jul 2024 10:05:52 +0200 -Subject: [PATCH] dri: Go back to hard-coded list of RGBA formats - -Catching these programmatically without false positives / negatives is -surprisingly tricky, go back to the known-working list for now. - -Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11398 -Fixes: ad0edea53a73 ("st/dri: Check format properties from format helpers") -Fixes: 5ca85d75c05d ("dri: Fix BGR format exclusion") - -v2: -* Also put back lima fails removed by 9eeaa4618f8a ("egl/gbm: Enable - RGBA configs"), as those tests are now failing again. - -Part-of: ---- - src/gallium/drivers/lima/ci/lima-fails.txt | 2 ++ - src/gallium/frontends/dri/dri_screen.c | 25 +++++++++------------- - 2 files changed, 12 insertions(+), 15 deletions(-) - -diff --git a/src/gallium/drivers/lima/ci/lima-fails.txt b/src/gallium/drivers/lima/ci/lima-fails.txt -index 155498dbb5679..d6c4edbb5ef5e 100644 ---- a/src/gallium/drivers/lima/ci/lima-fails.txt -+++ b/src/gallium/drivers/lima/ci/lima-fails.txt -@@ -55,7 +55,9 @@ wayland-dEQP-EGL.functional.wide_color.window_888_colorspace_srgb,Fail - - x11-dEQP-EGL.functional.create_context.no_config,Fail - x11-dEQP-EGL.functional.image.modify.renderbuffer_depth16_renderbuffer_clear_depth,Fail -+x11-dEQP-EGL.functional.render.multi_context.gles2.rgb888_window,Fail - x11-dEQP-EGL.functional.render.multi_context.gles2.rgba8888_pbuffer,Fail -+x11-dEQP-EGL.functional.render.multi_thread.gles2.rgb888_window,Fail - x11-dEQP-EGL.functional.render.multi_thread.gles2.rgba8888_pbuffer,Fail - x11-dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_srgb,Fail - x11-dEQP-EGL.functional.wide_color.window_8888_colorspace_srgb,Fail -diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c -index 2e9ce01147a89..15dde5152b837 100644 ---- a/src/gallium/frontends/dri/dri_screen.c -+++ b/src/gallium/frontends/dri/dri_screen.c -@@ -386,21 +386,16 @@ dri_fill_in_modes(struct dri_screen *screen) - uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES]; - - /* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */ -- if (!allow_rgba_ordering) { -- unsigned sh_ax = util_format_get_component_shift(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 3); -- unsigned sh_b = util_format_get_component_shift(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 2); --#if UTIL_ARCH_BIG_ENDIAN -- unsigned sz_b = util_format_get_component_bits(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 2); -- -- if (sz_b + sh_b == sh_ax) -- continue; --#else -- unsigned sz_ax = util_format_get_component_bits(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 3); -- -- if (sz_ax + sh_ax == sh_b) -- continue; --#endif -- } -+ if (!allow_rgba_ordering && -+ (pipe_formats[f] == PIPE_FORMAT_RGBA8888_UNORM || -+ pipe_formats[f] == PIPE_FORMAT_RGBX8888_UNORM || -+ pipe_formats[f] == PIPE_FORMAT_RGBA8888_SRGB || -+ pipe_formats[f] == PIPE_FORMAT_RGBX8888_SRGB || -+ pipe_formats[f] == PIPE_FORMAT_R5G5B5A1_UNORM || -+ pipe_formats[f] == PIPE_FORMAT_R5G5B5X1_UNORM || -+ pipe_formats[f] == PIPE_FORMAT_R4G4B4A4_UNORM || -+ pipe_formats[f] == PIPE_FORMAT_R4G4B4X4_UNORM)) -+ continue; - - if (!allow_rgb10 && - util_format_get_component_bits(pipe_formats[f], --- -GitLab - diff --git a/spec_files/mesa/fix-egl-on-s390x.patch b/spec_files/mesa/fix-egl-on-s390x.patch deleted file mode 100644 index 38b8362f..00000000 --- a/spec_files/mesa/fix-egl-on-s390x.patch +++ /dev/null @@ -1,131 +0,0 @@ -From 5ca85d75c05de9df7c3170122dfdb04bc795b43a Mon Sep 17 00:00:00 2001 -From: Daniel Stone -Date: Fri, 21 Jun 2024 11:24:31 +0100 -Subject: [PATCH 1/3] dri: Fix BGR format exclusion - -The check we had for BGR vs. RGB formats was testing completely the -wrong thing. Fix it so we can restore the previous set of configs we -expose to the frontend, which also fixes surfaceless platform on s390x. - -Signed-off-by: Daniel Stone -Fixes: ad0edea53a73 ("st/dri: Check format properties from format helpers") -Closes: mesa/mesa#11360 -Part-of: ---- - src/gallium/frontends/dri/dri_screen.c | 20 ++++++++++++-------- - 1 file changed, 12 insertions(+), 8 deletions(-) - -diff --git a/src/gallium/frontends/dri/dri_screen.c b/src/gallium/frontends/dri/dri_screen.c -index 97d11f324ee0b..2e9ce01147a89 100644 ---- a/src/gallium/frontends/dri/dri_screen.c -+++ b/src/gallium/frontends/dri/dri_screen.c -@@ -386,17 +386,21 @@ dri_fill_in_modes(struct dri_screen *screen) - uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES]; - - /* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */ -- if (!allow_rgba_ordering && -- util_format_get_component_shift(pipe_formats[f], -- UTIL_FORMAT_COLORSPACE_RGB, 0) -+ if (!allow_rgba_ordering) { -+ unsigned sh_ax = util_format_get_component_shift(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 3); -+ unsigned sh_b = util_format_get_component_shift(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 2); - #if UTIL_ARCH_BIG_ENDIAN -- > -+ unsigned sz_b = util_format_get_component_bits(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 2); -+ -+ if (sz_b + sh_b == sh_ax) -+ continue; - #else -- < -+ unsigned sz_ax = util_format_get_component_bits(pipe_formats[f], UTIL_FORMAT_COLORSPACE_RGB, 3); -+ -+ if (sz_ax + sh_ax == sh_b) -+ continue; - #endif -- util_format_get_component_shift(pipe_formats[f], -- UTIL_FORMAT_COLORSPACE_RGB, 2)) -- continue; -+ } - - if (!allow_rgb10 && - util_format_get_component_bits(pipe_formats[f], --- -GitLab - - -From 94e15d0f64a3a5ca6b86a3e02343cac0d453aed6 Mon Sep 17 00:00:00 2001 -From: Daniel Stone -Date: Fri, 21 Jun 2024 14:19:06 +0100 -Subject: [PATCH 2/3] egl/surfaceless: Enable RGBA configs - -Doing this is harmless since we operate on an allowlist of pipe_configs -anyway. - -Signed-off-by: Daniel Stone -Part-of: ---- - src/egl/drivers/dri2/platform_surfaceless.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c -index 0668ec9285ff3..4b69874d3f60a 100644 ---- a/src/egl/drivers/dri2/platform_surfaceless.c -+++ b/src/egl/drivers/dri2/platform_surfaceless.c -@@ -190,6 +190,8 @@ surfaceless_get_capability(void *loaderPrivate, enum dri_loader_cap cap) - switch (cap) { - case DRI_LOADER_CAP_FP16: - return 1; -+ case DRI_LOADER_CAP_RGBA_ORDERING: -+ return 1; - default: - return 0; - } --- -GitLab - - -From 9eeaa4618f8a7bc8215ac3f195ced7f8eae4342e Mon Sep 17 00:00:00 2001 -From: Daniel Stone -Date: Fri, 21 Jun 2024 14:19:06 +0100 -Subject: [PATCH 3/3] egl/gbm: Enable RGBA configs - -Doing this is harmless since we operate on an allowlist of pipe_configs -anyway. - -Signed-off-by: Daniel Stone -Part-of: ---- - src/gallium/drivers/lima/ci/lima-fails.txt | 2 -- - src/gbm/backends/dri/gbm_dri.c | 2 ++ - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/gallium/drivers/lima/ci/lima-fails.txt b/src/gallium/drivers/lima/ci/lima-fails.txt -index d6c4edbb5ef5e..155498dbb5679 100644 ---- a/src/gallium/drivers/lima/ci/lima-fails.txt -+++ b/src/gallium/drivers/lima/ci/lima-fails.txt -@@ -55,9 +55,7 @@ wayland-dEQP-EGL.functional.wide_color.window_888_colorspace_srgb,Fail - - x11-dEQP-EGL.functional.create_context.no_config,Fail - x11-dEQP-EGL.functional.image.modify.renderbuffer_depth16_renderbuffer_clear_depth,Fail --x11-dEQP-EGL.functional.render.multi_context.gles2.rgb888_window,Fail - x11-dEQP-EGL.functional.render.multi_context.gles2.rgba8888_pbuffer,Fail --x11-dEQP-EGL.functional.render.multi_thread.gles2.rgb888_window,Fail - x11-dEQP-EGL.functional.render.multi_thread.gles2.rgba8888_pbuffer,Fail - x11-dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_srgb,Fail - x11-dEQP-EGL.functional.wide_color.window_8888_colorspace_srgb,Fail -diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c -index 0526f4f8dc16f..6cc2d5d8197f5 100644 ---- a/src/gbm/backends/dri/gbm_dri.c -+++ b/src/gbm/backends/dri/gbm_dri.c -@@ -108,6 +108,8 @@ dri_get_capability(void *loaderPrivate, enum dri_loader_cap cap) - switch (cap) { - case DRI_LOADER_CAP_FP16: - return 1; -+ case DRI_LOADER_CAP_RGBA_ORDERING: -+ return 1; - default: - return 0; - } --- -GitLab - diff --git a/spec_files/mesa/mesa-28923.patch b/spec_files/mesa/mesa-28923.patch deleted file mode 100644 index 315b045e..00000000 --- a/spec_files/mesa/mesa-28923.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 8561958ccfd9b3a742a8742cc5931e9a6f6a7814 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= -Date: Thu, 25 Apr 2024 11:47:31 +0200 -Subject: [PATCH] meson: Disable proc_macro2 unestable features -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -proc-macro2 >= 1.0.80 uses proc_macro_byte_character [1] and -proc_macro_c_str_literals [2]. -Disable them until they are available. - -[1] https://github.com/rust-lang/rust/issues/115268 -[2] https://github.com/rust-lang/rust/issues/119750 -Signed-off-by: José Expósito ---- - subprojects/packagefiles/proc-macro2/meson.build | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/subprojects/packagefiles/proc-macro2/meson.build b/subprojects/packagefiles/proc-macro2/meson.build -index b39d76e80c825..5bd635c80a389 100644 ---- a/subprojects/packagefiles/proc-macro2/meson.build -+++ b/subprojects/packagefiles/proc-macro2/meson.build -@@ -41,6 +41,12 @@ endif - if rc.version().version_compare('< 1.57') - rust_args += ['--cfg', 'no_is_available'] - endif -+if rc.version().version_compare('< 1.79') -+ rust_args += [ -+ '--cfg', 'no_literal_byte_character', -+ '--cfg', 'no_literal_c_string', -+ ] -+endif - - u_ind = subproject('unicode-ident').get_variable('lib') - --- -GitLab - diff --git a/spec_files/mesa/mesa.spec b/spec_files/mesa/mesa.spec index 8c2de733..b0d74ab1 100644 --- a/spec_files/mesa/mesa.spec +++ b/spec_files/mesa/mesa.spec @@ -64,7 +64,7 @@ Name: mesa Summary: Mesa graphics libraries -%global ver 24.1.2 +%global ver 24.1.3 Version: %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)} Release: 101.bazzite.{{{ git_dir_version }}} License: MIT AND BSD-3-Clause AND SGI-B-2.0 @@ -76,18 +76,14 @@ Source0: https://archive.mesa3d.org/mesa-%{ver}.tar.xz # Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD. Source1: Mesa-MLAA-License-Clarification-Email.txt -Patch10: gnome-shell-glthread-disable.patch -Patch11: 0001-llvmpipe-Init-eglQueryDmaBufModifiersEXT-num_modifie.patch -Patch12: 0001-Revert-ac-radeonsi-remove-has_syncobj-has_fence_to_h.patch +Patch0: gnome-shell-glthread-disable.patch -# s390x only -Patch100: fix-egl-on-s390x.patch - -# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29979 -Patch150: 29979.patch +# Performance bump +# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25576 +Patch4: 25576.patch # https://gitlab.com/evlaV/mesa/ -Patch200: valve.patch +Patch5: valve.patch BuildRequires: meson >= 1.3.0 BuildRequires: gcc diff --git a/spec_files/mesa/valve.patch b/spec_files/mesa/valve.patch index d1441eab..2e9788c4 100644 --- a/spec_files/mesa/valve.patch +++ b/spec_files/mesa/valve.patch @@ -1,5 +1,46 @@ +From 4aa431b174c37b3bc0748ddc9bd2ca9c808881e2 Mon Sep 17 00:00:00 2001 +From: Bas Nieuwenhuizen +Date: Fri, 14 Jan 2022 15:58:45 +0100 +Subject: [PATCH 5/8] STEAMOS: radv: min image count override for FH5 + +Otherwise in combination with the vblank time reservation in +gamescope the game could get stuck in low power states. +--- + src/util/00-radv-defaults.conf | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/util/00-radv-defaults.conf b/src/util/00-radv-defaults.conf +index 9434dba1e3f..3c3ae562eb9 100644 +--- a/src/util/00-radv-defaults.conf ++++ b/src/util/00-radv-defaults.conf +@@ -186,5 +186,9 @@ Application bugs worked around in this file: + + ++ ++ ++ + + +-- +2.42.0 + + +From 88327ee8507a323f48e43eeb87cf1f102d04f174 Mon Sep 17 00:00:00 2001 +From: Bas Nieuwenhuizen +Date: Mon, 21 Feb 2022 18:43:54 +0100 +Subject: [PATCH 6/8] STEAMOS: Dynamic swapchain override for gamescope limiter + +--- + src/loader/loader_dri3_helper.c | 42 +++++++++++++++++++++++++++++++-- + src/loader/loader_dri3_helper.h | 1 + + src/loader/meson.build | 2 +- + src/vulkan/wsi/wsi_common_x11.c | 38 +++++++++++++++++++++++++++++ + 4 files changed, 80 insertions(+), 3 deletions(-) + diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c -index dc1db4fa8be..38e55dc23ae 100644 +index 32135770e9d..abc79dda97e 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -289,6 +289,30 @@ dri3_update_max_num_back(struct loader_dri3_drawable *draw) @@ -61,7 +102,7 @@ index dc1db4fa8be..38e55dc23ae 100644 dri3_update_max_num_back(draw); /* Create a new drawable */ -@@ -1085,6 +1117,12 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw, +@@ -1092,6 +1124,12 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw, if (draw->type == LOADER_DRI3_DRAWABLE_WINDOW) { dri3_fence_reset(draw->conn, back); @@ -75,7 +116,7 @@ index dc1db4fa8be..38e55dc23ae 100644 * successful MSC and adding in a swap interval for each outstanding swap * request. target_msc=divisor=remainder=0 means "Use glXSwapBuffers() diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h -index cc2362dd599..fe73b3f329c 100644 +index 1fd340bd145..b8f5eaaf190 100644 --- a/src/loader/loader_dri3_helper.h +++ b/src/loader/loader_dri3_helper.h @@ -178,6 +178,7 @@ struct loader_dri3_drawable { @@ -87,7 +128,7 @@ index cc2362dd599..fe73b3f329c 100644 struct loader_dri3_extensions *ext; const struct loader_dri3_vtable *vtable; diff --git a/src/loader/meson.build b/src/loader/meson.build -index 043cc852112..8391ff38936 100644 +index 35f9991ba2f..154cf809a69 100644 --- a/src/loader/meson.build +++ b/src/loader/meson.build @@ -29,7 +29,7 @@ if with_platform_x11 and with_dri3 @@ -99,19 +140,6 @@ index 043cc852112..8391ff38936 100644 ], build_by_default : false, ) -diff --git a/src/util/00-radv-defaults.conf b/src/util/00-radv-defaults.conf -index 3fa2d074ff5..e1faad8a731 100644 ---- a/src/util/00-radv-defaults.conf -+++ b/src/util/00-radv-defaults.conf -@@ -201,6 +201,11 @@ Application bugs worked around in this file: - - -+ -+ -+ -+ - - +-- +2.42.0 +