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.
master
Kenny Levinsen 5 months ago
parent 53464074e9
commit bc82835756

@ -821,14 +821,15 @@ static bool create_3d_lut_image(struct wlr_vk_renderer *renderer,
goto fail_imageview; goto fail_imageview;
} }
void *data; if (!span.buffer->cpu_mapping) {
res = vkMapMemory(dev, span.buffer->memory, span.alloc.start, size, 0, &data); res = vkMapMemory(dev, span.buffer->memory, span.alloc.start, size, 0, &span.buffer->cpu_mapping);
if (res != VK_SUCCESS) { if (res != VK_SUCCESS) {
wlr_vk_error("vkMapMemory", res); wlr_vk_error("vkMapMemory", res);
goto fail_imageview; goto fail_imageview;
}
} }
float *dst = data; float *dst = span.buffer->cpu_mapping;
size_t dim_len = lut_3d->dim_len; size_t dim_len = lut_3d->dim_len;
for (size_t b_index = 0; b_index < dim_len; b_index++) { for (size_t b_index = 0; b_index < dim_len; b_index++) {
for (size_t g_index = 0; g_index < dim_len; g_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); VkCommandBuffer cb = vulkan_record_stage_cb(renderer);
vulkan_change_layout(cb, *image, vulkan_change_layout(cb, *image,
VK_IMAGE_LAYOUT_UNDEFINED, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, VK_IMAGE_LAYOUT_UNDEFINED, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0,

Loading…
Cancel
Save