mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
render/vulkan: vkMapMemory stage spans up front
We always need these mapped for CPU access, so map it up front instead of duplicating lazy mapping at each site of use.
This commit is contained in:
parent
bf0246e50c
commit
bf67eb342b
@ -822,13 +822,6 @@ static bool create_3d_lut_image(struct wlr_vk_renderer *renderer,
|
||||
goto fail_imageview;
|
||||
}
|
||||
|
||||
if (!span.buffer->cpu_mapping) {
|
||||
res = vkMapMemory(dev, span.buffer->memory, 0, VK_WHOLE_SIZE, 0, &span.buffer->cpu_mapping);
|
||||
if (res != VK_SUCCESS) {
|
||||
wlr_vk_error("vkMapMemory", res);
|
||||
goto fail_imageview;
|
||||
}
|
||||
}
|
||||
char *map = (char*)span.buffer->cpu_mapping + span.alloc.start;
|
||||
float *dst = (float*)map;
|
||||
size_t dim_len = lut_3d->dim_len;
|
||||
|
@ -309,6 +309,12 @@ struct wlr_vk_buffer_span vulkan_get_stage_span(struct wlr_vk_renderer *r,
|
||||
goto error;
|
||||
}
|
||||
|
||||
res = vkMapMemory(r->dev->dev, buf->memory, 0, VK_WHOLE_SIZE, 0, &buf->cpu_mapping);
|
||||
if (res != VK_SUCCESS) {
|
||||
wlr_vk_error("vkMapMemory", res);
|
||||
goto error;
|
||||
}
|
||||
|
||||
struct wlr_vk_allocation *a = wl_array_add(&buf->allocs, sizeof(*a));
|
||||
if (a == NULL) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
|
@ -41,9 +41,7 @@ static bool write_pixels(struct wlr_vk_texture *texture,
|
||||
uint32_t stride, const pixman_region32_t *region, const void *vdata,
|
||||
VkImageLayout old_layout, VkPipelineStageFlags src_stage,
|
||||
VkAccessFlags src_access) {
|
||||
VkResult res;
|
||||
struct wlr_vk_renderer *renderer = texture->renderer;
|
||||
VkDevice dev = texture->renderer->dev->dev;
|
||||
|
||||
const struct wlr_pixel_format_info *format_info = drm_get_pixel_format_info(texture->format->drm);
|
||||
assert(format_info);
|
||||
@ -79,15 +77,6 @@ static bool write_pixels(struct wlr_vk_texture *texture,
|
||||
free(copies);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!span.buffer->cpu_mapping) {
|
||||
res = vkMapMemory(dev, span.buffer->memory, 0, VK_WHOLE_SIZE, 0, &span.buffer->cpu_mapping);
|
||||
if (res != VK_SUCCESS) {
|
||||
wlr_vk_error("vkMapMemory", res);
|
||||
free(copies);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
char *map = (char*)span.buffer->cpu_mapping + span.alloc.start;
|
||||
|
||||
// upload data
|
||||
|
Loading…
Reference in New Issue
Block a user