amdgpu: Add new function to get fd.

Dual purpose:
 - The drm fd dedupe functionality confuses the radeonsi
   amdgpu winsys if radeonsi isn't the first thing opening
   the device. By exposing the fd we can detect this case.
 - For a common mesa Vulkan sync objects implementation
   with syncobj. (notable: no buffer allocation)

Both shouldn't interferece with libdrm_amdgpu functionality
though it does somewhat piece the abstraction of the library.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3424
Gitlab: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5630
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
main
Bas Nieuwenhuizen 2021-11-16 01:41:49 +01:00
parent b40d0a7d6c
commit f70e8ae835
3 changed files with 19 additions and 0 deletions

View File

@ -53,6 +53,7 @@ amdgpu_cs_syncobj_wait
amdgpu_cs_wait_fences
amdgpu_cs_wait_semaphore
amdgpu_device_deinitialize
amdgpu_device_get_fd
amdgpu_device_initialize
amdgpu_find_bo_by_cpu_mapping
amdgpu_get_marketing_name

View File

@ -546,6 +546,19 @@ int amdgpu_device_initialize(int fd,
*/
int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
/**
*
* /param device_handle - \c [in] Device handle.
* See #amdgpu_device_initialize()
*
* \return Returns the drm fd used for operations on this
* device. This is still owned by the library and hence
* should not be closed. Guaranteed to be valid until
* #amdgpu_device_deinitialize gets called.
*
*/
int amdgpu_device_get_fd(amdgpu_device_handle device_handle);
/*
* Memory Management
*

View File

@ -285,6 +285,11 @@ drm_public int amdgpu_device_deinitialize(amdgpu_device_handle dev)
return 0;
}
drm_public int amdgpu_device_get_fd(amdgpu_device_handle device_handle)
{
return device_handle->fd;
}
drm_public const char *amdgpu_get_marketing_name(amdgpu_device_handle dev)
{
return dev->marketing_name;