mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
vulkan/wsi: Move a couple of dma-buf sync checks
In14b4160792("vulkan/wsi: Only test for dma-buf sync file support once"), I moved the dma-buf sync file import/export check earlier. This is fine for hardware implementations where we have real dma-buf import/export but it broke lavapipe because the check itself ignored whether or not we actually have dma-buf import/export. Add a couple more checks to wsi_drm_check_dma_buf_sync_file_import_export() so it's safe even for SW drivers. Also, in wsi_create_sync_for_dma_buf_wait(), check if we actually have a dma-buf. Fixes:14b4160792("vulkan/wsi: Only test for dma-buf sync file support once") Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37033>
This commit is contained in:
parent
49141ad5f2
commit
e4d9650e21
1 changed files with 20 additions and 9 deletions
|
|
@ -102,6 +102,23 @@ wsi_drm_check_dma_buf_sync_file_import_export(const struct wsi_device *wsi,
|
|||
if (likely(cached_result != 0))
|
||||
return (VkResult) (cached_result + 1);
|
||||
|
||||
/* If we don't have dma-buf export, we don't have dma-buf sync, either */
|
||||
VkResult result;
|
||||
if (wsi->GetMemoryFdKHR == NULL) {
|
||||
result = VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* If semaphores don't support sync FD or if the kernel doesn't support
|
||||
* sync file import/export, then WSI will fall back to requesting BO-based
|
||||
* implicit sync from the driver.
|
||||
*/
|
||||
if (!(wsi->semaphore_export_handle_types &
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT)) {
|
||||
result = VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
struct VkExportMemoryAllocateInfo export_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
|
||||
|
|
@ -110,7 +127,6 @@ wsi_drm_check_dma_buf_sync_file_import_export(const struct wsi_device *wsi,
|
|||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
|
||||
.allocationSize = 4096,
|
||||
.pNext = (void *)&export_info};
|
||||
VkResult result;
|
||||
VkDeviceMemory mem;
|
||||
result = wsi->AllocateMemory(device, &mem_info, NULL, &mem);
|
||||
if (result != VK_SUCCESS) {
|
||||
|
|
@ -223,6 +239,9 @@ wsi_create_sync_for_dma_buf_wait(const struct wsi_swapchain *chain,
|
|||
VK_FROM_HANDLE(vk_device, device, chain->device);
|
||||
VkResult result;
|
||||
|
||||
if (image->dma_buf_fd < 0)
|
||||
return VK_ERROR_FEATURE_NOT_PRESENT;
|
||||
|
||||
/* First, check if we even have the feature */
|
||||
result = wsi_drm_check_dma_buf_sync_file_import_export(chain->wsi,
|
||||
chain->device);
|
||||
|
|
@ -356,14 +375,6 @@ wsi_drm_init_swapchain_implicit_sync(struct wsi_swapchain *chain)
|
|||
if (chain->image_info.explicit_sync)
|
||||
return VK_SUCCESS;
|
||||
|
||||
/* If semaphores don't support sync FD or if the kernel doesn't support
|
||||
* sync file import/export, then WSI will fall back to requesting BO-based
|
||||
* implicit sync from the driver.
|
||||
*/
|
||||
if (!(chain->wsi->semaphore_export_handle_types &
|
||||
VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT))
|
||||
return VK_SUCCESS;
|
||||
|
||||
VkResult result =
|
||||
wsi_drm_check_dma_buf_sync_file_import_export(chain->wsi, chain->device);
|
||||
if (result == VK_ERROR_FEATURE_NOT_PRESENT)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue