}
static VkResult
-x11_present_to_x11(struct x11_swapchain *chain, uint32_t image_index,
- uint32_t target_msc)
+x11_present_to_x11_dri3(struct x11_swapchain *chain, uint32_t image_index,
+ uint32_t target_msc)
{
struct x11_image *image = &chain->images[image_index];
return x11_swapchain_result(chain, VK_SUCCESS);
}
+static VkResult
+x11_present_to_x11_sw(struct x11_swapchain *chain, uint32_t image_index,
+ uint32_t target_msc)
+{
+ struct x11_image *image = &chain->images[image_index];
+
+ xcb_void_cookie_t cookie;
+ void *myptr;
+ chain->base.wsi->MapMemory(chain->base.device,
+ image->base.memory,
+ 0, 0, 0, &myptr);
+
+ cookie = xcb_put_image(chain->conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
+ chain->window,
+ chain->gc,
+ image->base.row_pitches[0] / 4,
+ chain->extent.height,
+ 0,0,0,24,
+ image->base.row_pitches[0] * chain->extent.height,
+ myptr);
+
+ chain->base.wsi->UnmapMemory(chain->base.device, image->base.memory);
+ xcb_discard_reply(chain->conn, cookie.sequence);
+ xcb_flush(chain->conn);
+ return x11_swapchain_result(chain, VK_SUCCESS);
+}
+static VkResult
+x11_present_to_x11(struct x11_swapchain *chain, uint32_t image_index,
+ uint32_t target_msc)
+{
+ if (chain->base.wsi->sw)
+ return x11_present_to_x11_sw(chain, image_index, target_msc);
+ return x11_present_to_x11_dri3(chain, image_index, target_msc);
+}
+
static VkResult
x11_acquire_next_image(struct wsi_swapchain *anv_chain,
const VkAcquireNextImageInfoKHR *info,
if (chain->status < 0)
return chain->status;
+ if (chain->base.wsi->sw) {
+ *image_index = 0;
+ return VK_SUCCESS;
+ }
if (chain->has_acquire_queue) {
return x11_acquire_next_image_from_queue(chain, image_index, timeout);
} else {
if (result < 0)
return result;
+ if (chain->base.wsi->sw) {
+ image->busy = false;
+ return VK_SUCCESS;
+ }
image->pixmap = xcb_generate_id(chain->conn);
#ifdef HAVE_DRI3_MODIFIERS
{
xcb_void_cookie_t cookie;
- cookie = xcb_sync_destroy_fence(chain->conn, image->sync_fence);
- xcb_discard_reply(chain->conn, cookie.sequence);
- xshmfence_unmap_shm(image->shm_fence);
+ if (!chain->base.wsi->sw) {
+ cookie = xcb_sync_destroy_fence(chain->conn, image->sync_fence);
+ xcb_discard_reply(chain->conn, cookie.sequence);
+ xshmfence_unmap_shm(image->shm_fence);
- cookie = xcb_free_pixmap(chain->conn, image->pixmap);
- xcb_discard_reply(chain->conn, cookie.sequence);
+ cookie = xcb_free_pixmap(chain->conn, image->pixmap);
+ xcb_discard_reply(chain->conn, cookie.sequence);
+ }
wsi_destroy_image(&chain->base, &image->base);
}
else
chain->last_present_mode = XCB_PRESENT_COMPLETE_MODE_COPY;
- if (!wsi_x11_check_dri3_compatible(wsi_device, conn))
- chain->base.use_prime_blit = true;
+ if (!wsi_device->sw)
+ if (!wsi_x11_check_dri3_compatible(wsi_device, conn))
+ chain->base.use_prime_blit = true;
chain->event_id = xcb_generate_id(chain->conn);
xcb_present_select_input(chain->conn, chain->event_id, chain->window,
goto fail_init_images;
}
- if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR ||
- chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) {
+ if ((chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR ||
+ chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) && !chain->base.wsi->sw) {
chain->has_present_queue = true;
/* Initialize our queues. We make them base.image_count + 1 because we will