radv: use syncobj for wsi fence
Note: this also fixes vk_object_base_init() not being called for the wsi fences, now that it goes through radv_CreateFence(). Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6846>
This commit is contained in:
@@ -5650,9 +5650,6 @@ radv_destroy_fence_part(struct radv_device *device,
|
||||
case RADV_FENCE_SYNCOBJ:
|
||||
device->ws->destroy_syncobj(device->ws, part->syncobj);
|
||||
break;
|
||||
case RADV_FENCE_WSI:
|
||||
part->fence_wsi->destroy(part->fence_wsi);
|
||||
break;
|
||||
default:
|
||||
unreachable("Invalid fence type");
|
||||
}
|
||||
@@ -5876,12 +5873,6 @@ VkResult radv_WaitForFences(
|
||||
timeout))
|
||||
return VK_TIMEOUT;
|
||||
break;
|
||||
case RADV_FENCE_WSI: {
|
||||
VkResult result = part->fence_wsi->wait(part->fence_wsi, timeout);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
unreachable("Invalid fence type");
|
||||
}
|
||||
@@ -5953,15 +5944,6 @@ VkResult radv_GetFenceStatus(VkDevice _device, VkFence _fence)
|
||||
return VK_NOT_READY;
|
||||
break;
|
||||
}
|
||||
case RADV_FENCE_WSI: {
|
||||
VkResult result = part->fence_wsi->wait(part->fence_wsi, 0);
|
||||
if (result != VK_SUCCESS) {
|
||||
if (result == VK_TIMEOUT)
|
||||
return VK_NOT_READY;
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
unreachable("Invalid fence type");
|
||||
}
|
||||
|
@@ -125,7 +125,7 @@ EXTENSIONS = [
|
||||
Extension('VK_EXT_conservative_rasterization', 1, 'device->rad_info.chip_class >= GFX9'),
|
||||
Extension('VK_EXT_custom_border_color', 12, True),
|
||||
Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
|
||||
Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'),
|
||||
Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR && device->rad_info.has_syncobj_wait_for_submit'),
|
||||
Extension('VK_EXT_debug_report', 9, True),
|
||||
Extension('VK_EXT_depth_clip_enable', 1, True),
|
||||
Extension('VK_EXT_depth_range_unrestricted', 1, True),
|
||||
|
@@ -2418,7 +2418,6 @@ typedef enum {
|
||||
RADV_FENCE_NONE,
|
||||
RADV_FENCE_WINSYS,
|
||||
RADV_FENCE_SYNCOBJ,
|
||||
RADV_FENCE_WSI,
|
||||
} radv_fence_kind;
|
||||
|
||||
struct radv_fence_part {
|
||||
@@ -2430,9 +2429,6 @@ struct radv_fence_part {
|
||||
|
||||
/* DRM syncobj handle for syncobj-based fences. */
|
||||
uint32_t syncobj;
|
||||
|
||||
/* WSI fence. */
|
||||
struct wsi_fence *fence_wsi;
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -273,26 +273,38 @@ radv_RegisterDeviceEventEXT(VkDevice _device,
|
||||
VkFence *_fence)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||
struct radv_fence *fence;
|
||||
VkResult ret;
|
||||
VkResult ret;
|
||||
int fd;
|
||||
|
||||
fence = vk_zalloc2(&device->instance->alloc, allocator, sizeof (*fence),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (!fence)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
ret = radv_CreateFence(_device, &(VkFenceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||
.pNext = &(VkExportFenceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT,
|
||||
},
|
||||
}, allocator, _fence);
|
||||
if (ret != VK_SUCCESS)
|
||||
return ret;
|
||||
|
||||
fence->permanent.kind = RADV_FENCE_WSI;
|
||||
RADV_FROM_HANDLE(radv_fence, fence, *_fence);
|
||||
|
||||
assert(fence->permanent.kind = RADV_FENCE_SYNCOBJ);
|
||||
|
||||
if (device->ws->export_syncobj(device->ws, fence->permanent.syncobj, &fd)) {
|
||||
ret = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} else {
|
||||
ret = wsi_register_device_event(_device,
|
||||
&device->physical_device->wsi_device,
|
||||
device_event_info,
|
||||
allocator,
|
||||
NULL,
|
||||
fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if (ret != VK_SUCCESS)
|
||||
radv_DestroyFence(_device, *_fence, allocator);
|
||||
|
||||
ret = wsi_register_device_event(_device,
|
||||
&device->physical_device->wsi_device,
|
||||
device_event_info,
|
||||
allocator,
|
||||
&fence->permanent.fence_wsi,
|
||||
-1);
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = radv_fence_to_handle(fence);
|
||||
else
|
||||
vk_free2(&device->instance->alloc, allocator, fence);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -304,29 +316,39 @@ radv_RegisterDisplayEventEXT(VkDevice _device,
|
||||
VkFence *_fence)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||
VkResult ret;
|
||||
int fd;
|
||||
|
||||
struct radv_fence *fence;
|
||||
VkResult ret;
|
||||
ret = radv_CreateFence(_device, &(VkFenceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||
.pNext = &(VkExportFenceCreateInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT,
|
||||
},
|
||||
}, allocator, _fence);
|
||||
if (ret != VK_SUCCESS)
|
||||
return ret;
|
||||
|
||||
fence = vk_zalloc2(&device->instance->alloc, allocator, sizeof (*fence),
|
||||
8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (!fence)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
RADV_FROM_HANDLE(radv_fence, fence, *_fence);
|
||||
|
||||
fence->permanent.kind = RADV_FENCE_WSI;
|
||||
assert(fence->permanent.kind = RADV_FENCE_SYNCOBJ);
|
||||
|
||||
ret = wsi_register_display_event(_device,
|
||||
&device->physical_device->wsi_device,
|
||||
display,
|
||||
display_event_info,
|
||||
allocator,
|
||||
&fence->permanent.fence_wsi,
|
||||
-1);
|
||||
if (device->ws->export_syncobj(device->ws, fence->permanent.syncobj, &fd)) {
|
||||
ret = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
} else {
|
||||
ret = wsi_register_display_event(_device,
|
||||
&device->physical_device->wsi_device,
|
||||
display,
|
||||
display_event_info,
|
||||
allocator,
|
||||
NULL,
|
||||
fd);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
if (ret != VK_SUCCESS)
|
||||
radv_DestroyFence(_device, *_fence, allocator);
|
||||
|
||||
if (ret == VK_SUCCESS)
|
||||
*_fence = radv_fence_to_handle(fence);
|
||||
else
|
||||
vk_free2(&device->instance->alloc, allocator, fence);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user