mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2026-01-01 16:20:12 +01:00
Remove the roundtrip to Wayland when creating wl_buffers for each image
Change the implementation to create wl_buffers immediately on client side and defer the creation of wl_buffers on the server when the first image is presented as that's when all buffered requests will be flushed to the display Additionally remove the swapchain event queue as we no longer need it to dispatch any events Change-Id: Ic0683e7ec457df63638ce0b972c4925ac836b198 Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
This commit is contained in:
parent
96657394ec
commit
92e8614cf9
2 changed files with 5 additions and 61 deletions
|
|
@ -78,7 +78,6 @@ swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCal
|
|||
, m_display(wsi_surface.get_wl_display())
|
||||
, m_surface(wsi_surface.get_wl_surface())
|
||||
, m_wsi_surface(&wsi_surface)
|
||||
, m_swapchain_queue(nullptr)
|
||||
, m_buffer_queue(nullptr)
|
||||
, m_wsi_allocator(nullptr)
|
||||
, m_image_creation_parameters({}, {}, m_allocator, {}, {})
|
||||
|
|
@ -95,10 +94,6 @@ swapchain::~swapchain()
|
|||
wsialloc_delete(m_wsi_allocator);
|
||||
}
|
||||
m_wsi_allocator = nullptr;
|
||||
if (m_swapchain_queue != nullptr)
|
||||
{
|
||||
wl_event_queue_destroy(m_swapchain_queue);
|
||||
}
|
||||
if (m_buffer_queue != nullptr)
|
||||
{
|
||||
wl_event_queue_destroy(m_buffer_queue);
|
||||
|
|
@ -113,14 +108,6 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
|
|||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
m_swapchain_queue = wl_display_create_queue(m_display);
|
||||
|
||||
if (m_swapchain_queue == nullptr)
|
||||
{
|
||||
WSI_LOG_ERROR("Failed to create swapchain wl queue.");
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
m_buffer_queue = wl_display_create_queue(m_display);
|
||||
if (m_buffer_queue == nullptr)
|
||||
{
|
||||
|
|
@ -145,22 +132,6 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VWL_CAPI_CALL(void)
|
||||
create_succeeded(void *data, struct zwp_linux_buffer_params_v1 *params, struct wl_buffer *buffer) VWL_API_POST
|
||||
{
|
||||
auto wayland_buffer = reinterpret_cast<wl_buffer **>(data);
|
||||
*wayland_buffer = buffer;
|
||||
|
||||
zwp_linux_buffer_params_v1_destroy(params);
|
||||
}
|
||||
|
||||
VWL_CAPI_CALL(void) create_failed(void *data, struct zwp_linux_buffer_params_v1 *params)
|
||||
{
|
||||
zwp_linux_buffer_params_v1_destroy(params);
|
||||
}
|
||||
|
||||
static const struct zwp_linux_buffer_params_v1_listener params_listener = { create_succeeded, create_failed };
|
||||
|
||||
VWL_CAPI_CALL(void) buffer_release(void *data, struct wl_buffer *wayl_buffer) VWL_API_POST
|
||||
{
|
||||
auto sc = reinterpret_cast<swapchain *>(data);
|
||||
|
|
@ -590,45 +561,20 @@ VkResult swapchain::create_and_bind_swapchain_image(VkImageCreateInfo image_crea
|
|||
}
|
||||
|
||||
/* create a wl_buffer using the dma_buf protocol */
|
||||
auto dmabuf_interface_proxy = make_proxy_with_queue(m_wsi_surface->get_dmabuf_interface(), m_swapchain_queue);
|
||||
if (dmabuf_interface_proxy == nullptr)
|
||||
{
|
||||
WSI_LOG_ERROR("Failed to allocate dma-buf interface proxy.");
|
||||
destroy_image(image);
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
zwp_linux_buffer_params_v1 *params = zwp_linux_dmabuf_v1_create_params(dmabuf_interface_proxy.get());
|
||||
zwp_linux_buffer_params_v1 *params = zwp_linux_dmabuf_v1_create_params(m_wsi_surface->get_dmabuf_interface());
|
||||
for (uint32_t plane = 0; plane < image_data->num_planes; plane++)
|
||||
{
|
||||
zwp_linux_buffer_params_v1_add(params, image_data->buffer_fd[plane], plane,
|
||||
image_data->offset[plane], image_data->stride[plane], 0, 0);
|
||||
}
|
||||
|
||||
auto res = zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, &image_data->buffer);
|
||||
if (res < 0)
|
||||
{
|
||||
destroy_image(image);
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
const auto fourcc = util::drm::vk_to_drm_format(image_create_info.format);
|
||||
zwp_linux_buffer_params_v1_create(params, image_create_info.extent.width,
|
||||
image_create_info.extent.height, fourcc, 0);
|
||||
|
||||
/* TODO: don't roundtrip - we should be able to send the create request now,
|
||||
* and only wait for it on first present. only do this once, not for all buffers created */
|
||||
res = wl_display_roundtrip_queue(m_display, m_swapchain_queue);
|
||||
if (res < 0)
|
||||
{
|
||||
destroy_image(image);
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
/* should now have a wl_buffer */
|
||||
assert(image_data->buffer);
|
||||
image_data->buffer = zwp_linux_buffer_params_v1_create_immed(params, image_create_info.extent.width,
|
||||
image_create_info.extent.height, fourcc, 0);
|
||||
zwp_linux_buffer_params_v1_destroy(params);
|
||||
|
||||
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(image_data->buffer), m_buffer_queue);
|
||||
res = wl_buffer_add_listener(image_data->buffer, &buffer_listener, this);
|
||||
auto res = wl_buffer_add_listener(image_data->buffer, &buffer_listener, this);
|
||||
if (res < 0)
|
||||
{
|
||||
destroy_image(image);
|
||||
|
|
|
|||
|
|
@ -174,8 +174,6 @@ private:
|
|||
* surface is valid until swapchain is destroyed. */
|
||||
surface *m_wsi_surface;
|
||||
|
||||
/* The queue on which we dispatch the swapchain related events, mostly frame completion */
|
||||
struct wl_event_queue *m_swapchain_queue;
|
||||
/* The queue on which we dispatch buffer related events, mostly buffer_release */
|
||||
struct wl_event_queue *m_buffer_queue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue