From bc828357568f98fb8ab3a851c93bdbdf18be9950 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Wed, 26 Jun 2024 13:14:07 +0200 Subject: [PATCH] render/vulkan: Use new span map handling for 3dlut The use of stage spans for 3dluts was missed when the new cached mappings were introduced, meaning that it would try to map and unmap memory that might already have a cached mapping. Vulkan does not support mapping memory multiple times, so make sure the 3dlut code also uses the cached mapping to avoid segfaults after unmap. --- render/vulkan/pass.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/render/vulkan/pass.c b/render/vulkan/pass.c index 7ea15684..464cdbc1 100644 --- a/render/vulkan/pass.c +++ b/render/vulkan/pass.c @@ -821,14 +821,15 @@ static bool create_3d_lut_image(struct wlr_vk_renderer *renderer, goto fail_imageview; } - void *data; - res = vkMapMemory(dev, span.buffer->memory, span.alloc.start, size, 0, &data); - if (res != VK_SUCCESS) { - wlr_vk_error("vkMapMemory", res); - goto fail_imageview; + if (!span.buffer->cpu_mapping) { + res = vkMapMemory(dev, span.buffer->memory, span.alloc.start, size, 0, &span.buffer->cpu_mapping); + if (res != VK_SUCCESS) { + wlr_vk_error("vkMapMemory", res); + goto fail_imageview; + } } - float *dst = data; + float *dst = span.buffer->cpu_mapping; size_t dim_len = lut_3d->dim_len; for (size_t b_index = 0; b_index < dim_len; b_index++) { for (size_t g_index = 0; g_index < dim_len; g_index++) { @@ -844,8 +845,6 @@ static bool create_3d_lut_image(struct wlr_vk_renderer *renderer, } } - vkUnmapMemory(dev, span.buffer->memory); - VkCommandBuffer cb = vulkan_record_stage_cb(renderer); vulkan_change_layout(cb, *image, VK_IMAGE_LAYOUT_UNDEFINED, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0,