tu: KGSL backend rewrite
This commit rewrites the KGSL backend to utilize vk common wherever possible to bring the codebase in line with DRM while implicitly fixing minor API bugs that may have occurred as a result of manually implementing VK functions. As a part of moving to vk common, KGSL sync is now implemented atop vk common sync and vastly expanded in terms of functionality such as: * Import/Export of sync FDs - A required capability for properly supporting the Android WSI and as these functions were stubbed when a presentation operation used semaphores, it would cause a leak of FDs that were imported due to the expectation that the driver would close them. As well as causing UB around due to ignoring the imported FD or not exporting a valid FD. * Supporting pre-signalled fences - Vulkan allows fences to be created in a signalled state which was stubbed prior and can lead to UB. * Timeline semaphore support - As a result of utilizing vk common as the backbone for synchronization, its timeline semaphore emulation has been utilized to provide support for them without needing kernel support. (Note: On newer versions of KGSL, timeline semaphores can be implemented natively rather than using emulation as they support wait-before-signal) Fixes freezes due to semaphore usage with presentation on: * Genshin Impact * Skyline Emulator Signed-off-by: Mark Collins <mark@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21651>
This commit is contained in:
@@ -193,7 +193,7 @@ get_device_extensions(const struct tu_physical_device *device,
|
||||
"vk_khr_present_wait") ||
|
||||
wsi_common_vk_instance_supports_present_wait(
|
||||
&device->instance->vk)),
|
||||
.KHR_timeline_semaphore = !is_kgsl(device->instance),
|
||||
.KHR_timeline_semaphore = true,
|
||||
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
|
||||
.EXT_display_control = true,
|
||||
#endif
|
||||
@@ -1682,15 +1682,14 @@ tu_queue_init(struct tu_device *device,
|
||||
return result;
|
||||
|
||||
queue->device = device;
|
||||
if (!is_kgsl(device->instance))
|
||||
queue->vk.driver_submit = tu_queue_submit;
|
||||
queue->vk.driver_submit = tu_queue_submit;
|
||||
|
||||
int ret = tu_drm_submitqueue_new(device, priority, &queue->msm_queue_id);
|
||||
if (ret)
|
||||
return vk_startup_errorf(device->instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"submitqueue create failed");
|
||||
|
||||
queue->fence = -1;
|
||||
queue->last_submit_timestamp = -1;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@@ -1699,8 +1698,6 @@ static void
|
||||
tu_queue_finish(struct tu_queue *queue)
|
||||
{
|
||||
vk_queue_finish(&queue->vk);
|
||||
if (queue->fence >= 0)
|
||||
close(queue->fence);
|
||||
tu_drm_submitqueue_close(queue->device, queue->msm_queue_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,8 @@ struct tu_queue
|
||||
struct tu_device *device;
|
||||
|
||||
uint32_t msm_queue_id;
|
||||
int fence;
|
||||
|
||||
int64_t last_submit_timestamp; /* timestamp of the last queue submission for kgsl */
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(tu_queue, vk.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
||||
|
||||
|
||||
+741
-447
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user