venus: require exportable/importable bit for ext semaphores sync fd

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20088>
This commit is contained in:
Juston Li
2022-12-20 14:19:13 -08:00
committed by Marge Bot
parent 31e7471be2
commit f6ffb5ac36
2 changed files with 30 additions and 29 deletions
+5 -1
View File
@@ -965,7 +965,11 @@ vn_physical_device_get_native_extensions(
VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT))
exts->KHR_external_fence_fd = true;
exts->KHR_external_semaphore_fd = true;
if ((physical_dev->renderer_sync_fd_semaphore_features &
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT) &&
(physical_dev->renderer_sync_fd_semaphore_features &
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT))
exts->KHR_external_semaphore_fd = true;
}
#endif
+25 -28
View File
@@ -1551,6 +1551,11 @@ vn_GetSemaphoreFdKHR(VkDevice device,
assert(dev->instance->experimental.globalFencing);
assert(sync_file);
assert((dev->physical_device->renderer_sync_fd_semaphore_features &
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT));
assert((dev->physical_device->renderer_sync_fd_semaphore_features &
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT));
int fd = -1;
if (payload->type == VN_SYNC_TYPE_DEVICE_ONLY) {
VkResult result = vn_create_sync_file(dev, sem->ring_idx, &fd);
@@ -1565,36 +1570,28 @@ vn_GetSemaphoreFdKHR(VkDevice device,
payload->fd = -1;
}
/* required sync_fd features for fixing the host semaphore payload */
static const VkExternalSemaphoreFeatureFlags req_sync_fd_feats =
VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT |
VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT;
if ((dev->physical_device->renderer_sync_fd_semaphore_features &
req_sync_fd_feats) == req_sync_fd_feats) {
/* When payload->type is VN_SYNC_TYPE_IMPORTED_SYNC_FD, the current
* payload is from a prior temporary sync_fd import. The permanent
* payload of the sempahore might be in signaled state. So we do an
* import here to ensure later wait operation is legit. With resourceId
* 0, renderer does a signaled sync_fd -1 payload import on the host
* semaphore.
*/
if (payload->type == VN_SYNC_TYPE_IMPORTED_SYNC_FD) {
const VkImportSemaphoreResourceInfo100000MESA res_info = {
.sType =
VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_RESOURCE_INFO_100000_MESA,
.semaphore = pGetFdInfo->semaphore,
.resourceId = 0,
};
vn_async_vkImportSemaphoreResource100000MESA(dev->instance, device,
&res_info);
}
/* perform wait operation on the host semaphore */
vn_async_vkWaitSemaphoreResource100000MESA(dev->instance, device,
pGetFdInfo->semaphore);
/* When payload->type is VN_SYNC_TYPE_IMPORTED_SYNC_FD, the current
* payload is from a prior temporary sync_fd import. The permanent
* payload of the sempahore might be in signaled state. So we do an
* import here to ensure later wait operation is legit. With resourceId
* 0, renderer does a signaled sync_fd -1 payload import on the host
* semaphore.
*/
if (payload->type == VN_SYNC_TYPE_IMPORTED_SYNC_FD) {
const VkImportSemaphoreResourceInfo100000MESA res_info = {
.sType =
VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_RESOURCE_INFO_100000_MESA,
.semaphore = pGetFdInfo->semaphore,
.resourceId = 0,
};
vn_async_vkImportSemaphoreResource100000MESA(dev->instance, device,
&res_info);
}
/* perform wait operation on the host semaphore */
vn_async_vkWaitSemaphoreResource100000MESA(dev->instance, device,
pGetFdInfo->semaphore);
vn_sync_payload_release(dev, &sem->temporary);
sem->payload = &sem->permanent;