vulkan/wsi/display: add option for display fence to signal syncobj
To avoid having a separate "wsi_fence" path in the driver, make it so wsi fences can signal a syncobj. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Acked-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6707>
This commit is contained in:

committed by
Marge Bot

parent
32d754825c
commit
4c71cda9ab
@@ -287,7 +287,8 @@ radv_RegisterDeviceEventEXT(VkDevice _device,
|
||||
&device->physical_device->wsi_device,
|
||||
device_event_info,
|
||||
allocator,
|
||||
&fence->permanent.fence_wsi);
|
||||
&fence->permanent.fence_wsi,
|
||||
-1);
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = radv_fence_to_handle(fence);
|
||||
else
|
||||
@@ -319,7 +320,8 @@ radv_RegisterDisplayEventEXT(VkDevice _device,
|
||||
display,
|
||||
display_event_info,
|
||||
allocator,
|
||||
&(fence->permanent.fence_wsi));
|
||||
&fence->permanent.fence_wsi,
|
||||
-1);
|
||||
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = radv_fence_to_handle(fence);
|
||||
|
@@ -281,7 +281,8 @@ tu_RegisterDeviceEventEXT(VkDevice _device,
|
||||
&device->physical_device->wsi_device,
|
||||
device_event_info,
|
||||
allocator,
|
||||
&fence->fence_wsi);
|
||||
&fence->fence_wsi,
|
||||
-1);
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = tu_fence_to_handle(fence);
|
||||
else
|
||||
@@ -313,7 +314,8 @@ tu_RegisterDisplayEventEXT(VkDevice _device,
|
||||
display,
|
||||
display_event_info,
|
||||
allocator,
|
||||
&fence->fence_wsi);
|
||||
&fence->fence_wsi,
|
||||
-1);
|
||||
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = tu_fence_to_handle(fence);
|
||||
|
@@ -266,7 +266,8 @@ anv_RegisterDeviceEventEXT(VkDevice _device,
|
||||
&device->physical->wsi_device,
|
||||
device_event_info,
|
||||
allocator,
|
||||
&fence->permanent.fence_wsi);
|
||||
&fence->permanent.fence_wsi,
|
||||
-1);
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = anv_fence_to_handle(fence);
|
||||
else
|
||||
@@ -294,7 +295,7 @@ anv_RegisterDisplayEventEXT(VkDevice _device,
|
||||
|
||||
ret = wsi_register_display_event(
|
||||
_device, &device->physical->wsi_device,
|
||||
display, display_event_info, allocator, &(fence->permanent.fence_wsi));
|
||||
display, display_event_info, allocator, &fence->permanent.fence_wsi, -1);
|
||||
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = anv_fence_to_handle(fence);
|
||||
|
@@ -137,6 +137,7 @@ struct wsi_display_fence {
|
||||
struct wsi_fence base;
|
||||
bool event_received;
|
||||
bool destroyed;
|
||||
uint32_t syncobj; /* syncobj to signal on event */
|
||||
uint64_t sequence;
|
||||
};
|
||||
|
||||
@@ -1527,6 +1528,14 @@ wsi_display_fence_check_free(struct wsi_display_fence *fence)
|
||||
|
||||
static void wsi_display_fence_event_handler(struct wsi_display_fence *fence)
|
||||
{
|
||||
struct wsi_display *wsi =
|
||||
(struct wsi_display *) fence->base.wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
|
||||
|
||||
if (fence->syncobj) {
|
||||
(void) drmSyncobjSignal(wsi->fd, &fence->syncobj, 1);
|
||||
(void) drmSyncobjDestroy(wsi->fd, fence->syncobj);
|
||||
}
|
||||
|
||||
fence->event_received = true;
|
||||
wsi_display_fence_check_free(fence);
|
||||
}
|
||||
@@ -1545,7 +1554,8 @@ static struct wsi_display_fence *
|
||||
wsi_display_fence_alloc(VkDevice device,
|
||||
const struct wsi_device *wsi_device,
|
||||
VkDisplayKHR display,
|
||||
const VkAllocationCallbacks *allocator)
|
||||
const VkAllocationCallbacks *allocator,
|
||||
int sync_fd)
|
||||
{
|
||||
struct wsi_display *wsi =
|
||||
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
|
||||
@@ -1556,6 +1566,14 @@ wsi_display_fence_alloc(VkDevice device,
|
||||
if (!fence)
|
||||
return NULL;
|
||||
|
||||
if (sync_fd >= 0) {
|
||||
int ret = drmSyncobjFDToHandle(wsi->fd, sync_fd, &fence->syncobj);
|
||||
if (ret) {
|
||||
vk_free2(wsi->alloc, allocator, fence);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fence->base.device = device;
|
||||
fence->base.display = display;
|
||||
fence->base.wsi_device = wsi_device;
|
||||
@@ -2499,7 +2517,8 @@ wsi_register_device_event(VkDevice device,
|
||||
struct wsi_device *wsi_device,
|
||||
const VkDeviceEventInfoEXT *device_event_info,
|
||||
const VkAllocationCallbacks *allocator,
|
||||
struct wsi_fence **fence_p)
|
||||
struct wsi_fence **fence_p,
|
||||
int sync_fd)
|
||||
{
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
}
|
||||
@@ -2510,7 +2529,8 @@ wsi_register_display_event(VkDevice device,
|
||||
VkDisplayKHR display,
|
||||
const VkDisplayEventInfoEXT *display_event_info,
|
||||
const VkAllocationCallbacks *allocator,
|
||||
struct wsi_fence **fence_p)
|
||||
struct wsi_fence **fence_p,
|
||||
int sync_fd)
|
||||
{
|
||||
struct wsi_display *wsi =
|
||||
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
|
||||
@@ -2520,7 +2540,7 @@ wsi_register_display_event(VkDevice device,
|
||||
switch (display_event_info->displayEvent) {
|
||||
case VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT:
|
||||
|
||||
fence = wsi_display_fence_alloc(device, wsi_device, display, allocator);
|
||||
fence = wsi_display_fence_alloc(device, wsi_device, display, allocator, sync_fd);
|
||||
|
||||
if (!fence)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
@@ -2528,10 +2548,16 @@ wsi_register_display_event(VkDevice device,
|
||||
ret = wsi_register_vblank_event(fence, wsi_device, display,
|
||||
DRM_CRTC_SEQUENCE_RELATIVE, 1, NULL);
|
||||
|
||||
if (ret == VK_SUCCESS)
|
||||
*fence_p = &fence->base;
|
||||
else if (fence != NULL)
|
||||
if (ret == VK_SUCCESS) {
|
||||
if (fence_p)
|
||||
*fence_p = &fence->base;
|
||||
else
|
||||
fence->base.destroy(&fence->base);
|
||||
} else if (fence != NULL) {
|
||||
if (fence->syncobj)
|
||||
drmSyncobjDestroy(wsi->fd, fence->syncobj);
|
||||
vk_free2(wsi->alloc, allocator, fence);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@@ -143,7 +143,8 @@ wsi_register_device_event(VkDevice device,
|
||||
struct wsi_device *wsi_device,
|
||||
const VkDeviceEventInfoEXT *device_event_info,
|
||||
const VkAllocationCallbacks *allocator,
|
||||
struct wsi_fence **fence);
|
||||
struct wsi_fence **fence,
|
||||
int sync_fd);
|
||||
|
||||
VkResult
|
||||
wsi_register_display_event(VkDevice device,
|
||||
@@ -151,7 +152,8 @@ wsi_register_display_event(VkDevice device,
|
||||
VkDisplayKHR display,
|
||||
const VkDisplayEventInfoEXT *display_event_info,
|
||||
const VkAllocationCallbacks *allocator,
|
||||
struct wsi_fence **fence);
|
||||
struct wsi_fence **fence,
|
||||
int sync_fd);
|
||||
|
||||
VkResult
|
||||
wsi_get_swapchain_counter(VkDevice device,
|
||||
|
Reference in New Issue
Block a user