Mesa (master): radv: reset semaphores & fences on sync_file export.

Bas Nieuwenhuizen bnieuwenhuizen at kemper.freedesktop.org
Thu Jan 11 21:28:39 UTC 2018


Module: Mesa
Branch: master
Commit: b9f4c615f860b1fb00dec2917fcec4df84f6427e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9f4c615f860b1fb00dec2917fcec4df84f6427e

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Thu Jan  4 02:55:39 2018 +0100

radv: reset semaphores & fences on sync_file export.

Per spec:

"Additionally, exporting a fence payload to a handle with copy transference has the same side effects
on the source fence’s payload as executing a fence reset operation. If the fence was using a
temporarily imported payload, the fence’s prior permanent payload will be restored."

And similar for semaphores:

"Additionally, exporting a semaphore payload to a handle with copy transference has the same side
effects on the source semaphore’s payload as executing a semaphore wait operation. If the
semaphore was using a temporarily imported payload, the semaphore’s prior permanent payload
will be restored."

Fixes: 42bc25a79c "radv: Advertise sync fd import and export."
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_device.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 24aa861780..55ffebb20a 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -3815,6 +3815,14 @@ VkResult radv_GetSemaphoreFdKHR(VkDevice _device,
 		break;
 	case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR:
 		ret = device->ws->export_syncobj_to_sync_file(device->ws, syncobj_handle, pFd);
+		if (!ret) {
+			if (sem->temp_syncobj) {
+				close (sem->temp_syncobj);
+				sem->temp_syncobj = 0;
+			} else {
+				device->ws->reset_syncobj(device->ws, syncobj_handle);
+			}
+		}
 		break;
 	default:
 		unreachable("Unhandled semaphore handle type");
@@ -3896,6 +3904,14 @@ VkResult radv_GetFenceFdKHR(VkDevice _device,
 		break;
 	case VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR:
 		ret = device->ws->export_syncobj_to_sync_file(device->ws, syncobj_handle, pFd);
+		if (!ret) {
+			if (fence->temp_syncobj) {
+				close (fence->temp_syncobj);
+				fence->temp_syncobj = 0;
+			} else {
+				device->ws->reset_syncobj(device->ws, syncobj_handle);
+			}
+		}
 		break;
 	default:
 		unreachable("Unhandled fence handle type");




More information about the mesa-commit mailing list