close(image->dma_buf_fd);
#endif
+ if (image->cpu_map != NULL)
+ wsi->UnmapMemory(chain->device, image->memory);
+
if (image->buffer.blit_cmd_buffers) {
int cmd_buffer_count =
chain->buffer_blit_queue != VK_NULL_HANDLE ? 1 : wsi->queue_family_count;
if (result != VK_SUCCESS)
return result;
+ result = wsi->MapMemory(chain->device, image->memory,
+ 0, VK_WHOLE_SIZE, 0, &image->cpu_map);
+ if (result != VK_SUCCESS)
+ return result;
+
image->num_planes = 1;
image->sizes[0] = reqs.size;
image->row_pitches[0] = layout.rowPitch;
#ifndef _WIN32
int dma_buf_fd;
#endif
+ void *cpu_map;
};
struct wsi_swapchain {
if (chain->display->sw) {
struct wsi_wl_image *image = &chain->images[image_index];
- void *dptr = image->data_ptr;
- void *sptr;
- chain->base.wsi->MapMemory(chain->base.device,
- image->base.memory,
- 0, VK_WHOLE_SIZE, 0, &sptr);
-
- memcpy(dptr, sptr, image->base.row_pitches[0] * chain->extent.height);
-
- chain->base.wsi->UnmapMemory(chain->base.device,
- image->base.memory);
-
+ memcpy(image->data_ptr, image->base.cpu_map,
+ image->base.row_pitches[0] * chain->extent.height);
}
if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {
while (!chain->fifo_ready) {
struct x11_image *image = &chain->images[image_index];
xcb_void_cookie_t cookie;
- void *myptr;
+ void *myptr = image->base.cpu_map;
size_t hdr_len = sizeof(xcb_put_image_request_t);
int stride_b = image->base.row_pitches[0];
size_t size = (hdr_len + stride_b * chain->extent.height) >> 2;
uint64_t max_req_len = xcb_get_maximum_request_length(chain->conn);
- chain->base.wsi->MapMemory(chain->base.device,
- image->base.memory,
- 0, VK_WHOLE_SIZE, 0, &myptr);
-
if (size < max_req_len) {
cookie = xcb_put_image(chain->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
chain->window,
chain->extent.height,
0,0,0,24,
image->base.row_pitches[0] * chain->extent.height,
- myptr);
+ image->base.cpu_map);
xcb_discard_reply(chain->conn, cookie.sequence);
} else {
int num_lines = ((max_req_len << 2) - hdr_len) / stride_b;
}
}
- chain->base.wsi->UnmapMemory(chain->base.device, image->base.memory);
xcb_flush(chain->conn);
return x11_swapchain_result(chain, VK_SUCCESS);
}