tu: KGSL backend rewrite
authorMark Collins <mark@igalia.com>
Tue, 28 Feb 2023 11:45:08 +0000 (11:45 +0000)
committerMarge Bot <emma+marge@anholt.net>
Mon, 13 Mar 2023 18:59:50 +0000 (18:59 +0000)
commit9c808043f35005bbf0d1810277f3d8a8f8090f19
tree2f46b9e23d669f9def39e29e95ccd1b87cf54097
parent88989379b1e0d80de1eaac449faff8f2a5ad3892
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>
src/freedreno/vulkan/tu_device.c
src/freedreno/vulkan/tu_device.h
src/freedreno/vulkan/tu_knl_kgsl.c