aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2020-07-14 21:23:17 +0200
committerMarge Bot <[email protected]>2020-07-16 21:04:37 +0000
commit56395a8b6d6aa042fb9a984c1ca91b9596331f8d (patch)
tree7d1dc3157e9080478471739d4ddeaa110cad17e0
parent3b7cd734e8a11a9af0cbc4c2445c7103044fc4a0 (diff)
radv: optimize creating signaled syncobj with amdgpu_cs_create_syncobj2()
This creates a syncobj and sets it as signaled with one ioctl instead of two. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5921>
-rw-r--r--src/amd/vulkan/radv_device.c34
-rw-r--r--src/amd/vulkan/radv_radeon_winsys.h3
-rw-r--r--src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c8
3 files changed, 29 insertions, 16 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 5a1a67288d3..00f87ebdf52 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -5204,14 +5204,16 @@ VkResult radv_CreateFence(
fence->fence_wsi = NULL;
fence->temp_syncobj = 0;
if (device->always_use_syncobj || handleTypes) {
- int ret = device->ws->create_syncobj(device->ws, &fence->syncobj);
+ bool create_signaled = false;
+ if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT)
+ create_signaled = true;
+
+ int ret = device->ws->create_syncobj(device->ws, create_signaled,
+ &fence->syncobj);
if (ret) {
radv_destroy_fence(device, pAllocator, fence);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
- if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT) {
- device->ws->signal_syncobj(device->ws, fence->syncobj);
- }
fence->fence = NULL;
} else {
fence->fence = device->ws->create_fence();
@@ -5539,7 +5541,7 @@ radv_timeline_add_point_locked(struct radv_device *device,
if (list_is_empty(&timeline->free_points)) {
ret = malloc(sizeof(struct radv_timeline_point));
- device->ws->create_syncobj(device->ws, &ret->syncobj);
+ device->ws->create_syncobj(device->ws, false, &ret->syncobj);
} else {
ret = list_first_entry(&timeline->free_points, struct radv_timeline_point, list);
list_del(&ret->list);
@@ -5680,7 +5682,8 @@ VkResult radv_CreateSemaphore(
sem->permanent.kind = RADV_SEMAPHORE_TIMELINE;
} else if (device->always_use_syncobj || handleTypes) {
assert (device->physical_device->rad_info.has_syncobj);
- int ret = device->ws->create_syncobj(device->ws, &sem->permanent.syncobj);
+ int ret = device->ws->create_syncobj(device->ws, false,
+ &sem->permanent.syncobj);
if (ret) {
radv_destroy_semaphore(device, pAllocator, sem);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -7062,23 +7065,26 @@ static VkResult radv_import_sync_fd(struct radv_device *device,
* leave a syncobj in an undetermined state in the fence. */
uint32_t syncobj_handle = *syncobj;
if (!syncobj_handle) {
- int ret = device->ws->create_syncobj(device->ws, &syncobj_handle);
+ bool create_signaled = fd == -1 ? true : false;
+
+ int ret = device->ws->create_syncobj(device->ws, create_signaled,
+ &syncobj_handle);
if (ret) {
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
}
+ } else {
+ if (fd == -1)
+ device->ws->signal_syncobj(device->ws, syncobj_handle);
}
- if (fd == -1) {
- device->ws->signal_syncobj(device->ws, syncobj_handle);
- } else {
+ if (fd != -1) {
int ret = device->ws->import_syncobj_from_sync_file(device->ws, syncobj_handle, fd);
- if (ret != 0)
- return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
+ if (ret)
+ return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
+ close(fd);
}
*syncobj = syncobj_handle;
- if (fd != -1)
- close(fd);
return VK_SUCCESS;
}
diff --git a/src/amd/vulkan/radv_radeon_winsys.h b/src/amd/vulkan/radv_radeon_winsys.h
index 802dbdb1783..2cf68dc8edb 100644
--- a/src/amd/vulkan/radv_radeon_winsys.h
+++ b/src/amd/vulkan/radv_radeon_winsys.h
@@ -320,7 +320,8 @@ struct radeon_winsys {
void (*destroy_sem)(struct radeon_winsys_sem *sem);
/* new shareable sync objects */
- int (*create_syncobj)(struct radeon_winsys *ws, uint32_t *handle);
+ int (*create_syncobj)(struct radeon_winsys *ws, bool create_signaled,
+ uint32_t *handle);
void (*destroy_syncobj)(struct radeon_winsys *ws, uint32_t handle);
void (*reset_syncobj)(struct radeon_winsys *ws, uint32_t handle);
diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
index 74ba56ccb46..daebdf9cc5f 100644
--- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
+++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c
@@ -1600,10 +1600,16 @@ error_out:
}
static int radv_amdgpu_create_syncobj(struct radeon_winsys *_ws,
+ bool create_signaled,
uint32_t *handle)
{
struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
- return amdgpu_cs_create_syncobj(ws->dev, handle);
+ uint32_t flags = 0;
+
+ if (create_signaled)
+ flags |= DRM_SYNCOBJ_CREATE_SIGNALED;
+
+ return amdgpu_cs_create_syncobj2(ws->dev, flags, handle);
}
static void radv_amdgpu_destroy_syncobj(struct radeon_winsys *_ws,