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,