Merge vk-gl-cts/vulkan-cts-1.0.2 into vk-gl-cts/vulkan-cts-1.1.0

Change-Id: I8c2317b97955bbee922af624b91287071fbc7661
diff --git a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
index 516b408..bc98091 100644
--- a/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
+++ b/external/vulkancts/modules/vulkan/api/vktApiExternalMemoryTests.cpp
@@ -511,6 +511,71 @@
 	VK_CHECK(vkd.queueSubmit(queue, 1, &submit, (vk::VkFence)0u));
 }
 
+void submitDummySignalAndGetSemaphoreNative (	const vk::DeviceInterface&						vk,
+												vk::VkDevice									device,
+												vk::VkQueue										queue,
+												deUint32										queueFamilyIndex,
+												vk::VkSemaphore									semaphore,
+												vk::VkExternalSemaphoreHandleTypeFlagBits		externalType,
+												NativeHandle&									nativeHandle)
+{
+	const vk::Unique<vk::VkCommandPool>		cmdPool(createCommandPool(vk, device, vk::VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex, DE_NULL));
+	const vk::Unique<vk::VkCommandBuffer>	cmdBuffer(allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+
+	const vk::VkEventCreateInfo eventCreateInfo =
+	{
+		vk::VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
+		DE_NULL,
+		0u
+	};
+
+	const vk::Unique<vk::VkEvent> event(createEvent(vk, device, &eventCreateInfo, DE_NULL));
+
+	const vk::VkCommandBufferBeginInfo cmdBufferBeginInfo =
+	{
+		vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+		DE_NULL,
+		vk::VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
+		DE_NULL,
+	};
+
+	VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
+	/*
+		The submitDummySignal function calls vkQueueSubmit with an empty VkSubmitInfo structure and a
+		VkSemaphore to be signalled when the work is finished. Because there is no work in the submission, vkQueueSubmit
+		may signal the semaphore immediately. When a semaphore's file descriptor is obtained using vkGetFenceFdKHR, if the
+		handle type is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR, vkGetFenceFdKHR is allowed to return -1 if the fence
+		is already signalled, instead of a file descriptor, . In order to make sure that a valid file descriptor is returned
+		we use vkCmdWaitEvents to make sure that vkQueueSubmit doesn't signal the fence.
+	*/
+	vk.cmdWaitEvents(*cmdBuffer, 1, &event.get(), vk::VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, DE_NULL, 0, DE_NULL, 0, DE_NULL);
+	vk.endCommandBuffer(*cmdBuffer);
+
+	const vk::VkSubmitInfo submit =
+	{
+		vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,
+		DE_NULL,
+
+		0u,
+		DE_NULL,
+		DE_NULL,
+
+		1u,
+		&cmdBuffer.get(),
+
+		1u,
+		&semaphore
+	};
+
+	VK_CHECK(vk.queueSubmit(queue, 1, &submit, (vk::VkFence)0u));
+
+	getSemaphoreNative(vk, device, semaphore, externalType, nativeHandle);
+
+	VK_CHECK(vk.setEvent(device, *event));
+
+	VK_CHECK(vk.queueWaitIdle(queue));
+}
+
 void submitDummyWait (const vk::DeviceInterface&	vkd,
 					  vk::VkQueue					queue,
 					  vk::VkSemaphore				semaphore)
@@ -558,6 +623,71 @@
 	VK_CHECK(vkd.queueSubmit(queue, 1, &submit, fence));
 }
 
+void submitDummySignalAndGetFenceNative (	const vk::DeviceInterface&					vk,
+											vk::VkDevice								device,
+											vk::VkQueue									queue,
+											deUint32									queueFamilyIndex,
+											vk::VkFence									fence,
+											vk::VkExternalFenceHandleTypeFlagBits		externalType,
+											NativeHandle&								nativeHandle)
+{
+	const vk::Unique<vk::VkCommandPool>		cmdPool(createCommandPool(vk, device, vk::VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, queueFamilyIndex, DE_NULL));
+	const vk::Unique<vk::VkCommandBuffer>	cmdBuffer(allocateCommandBuffer(vk, device, *cmdPool, vk::VK_COMMAND_BUFFER_LEVEL_PRIMARY));
+
+	const vk::VkEventCreateInfo eventCreateInfo =
+	{
+		vk::VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
+		DE_NULL,
+		0u
+	};
+
+	const vk::Unique<vk::VkEvent> event(createEvent(vk, device, &eventCreateInfo, DE_NULL));
+
+	const vk::VkCommandBufferBeginInfo cmdBufferBeginInfo =
+	{
+		vk::VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
+		DE_NULL,
+		vk::VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
+		DE_NULL,
+	};
+
+	VK_CHECK(vk.beginCommandBuffer(*cmdBuffer, &cmdBufferBeginInfo));
+	/*
+		The submitDummySignal function calls vkQueueSubmit with an empty VkSubmitInfo structure and a
+		VkFence to be signalled when the work is finished. Because there is no work in the submission, vkQueueSubmit
+		could signal the fence immediately. When a fence's file descriptor is obtained using vkGetFenceFdKHR, if the
+		handle type is VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR, vkGetFenceFdKHR is allowed to return -1 instead of a
+		file descriptor, if the fence is already signalled. In order to make sure that a valid file descriptor is returned
+		we use vkCmdWaitEvents to make sure that vkQueueSubmit doesn't signal the fence.
+	*/
+	vk.cmdWaitEvents(*cmdBuffer, 1, &event.get(), vk::VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, vk::VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, DE_NULL, 0, DE_NULL, 0, DE_NULL);
+	vk.endCommandBuffer(*cmdBuffer);
+
+	const vk::VkSubmitInfo submit =
+	{
+		vk::VK_STRUCTURE_TYPE_SUBMIT_INFO,
+		DE_NULL,
+
+		0u,
+		DE_NULL,
+		DE_NULL,
+
+		1u,
+		&cmdBuffer.get(),
+
+		0u,
+		DE_NULL
+	};
+
+	VK_CHECK(vk.queueSubmit(queue, 1, &submit, fence));
+
+	getFenceNative(vk, device, fence, externalType, nativeHandle);
+
+	VK_CHECK(vk.setEvent(device, *event));
+
+	VK_CHECK(vk.queueWaitIdle(queue));
+}
+
 tcu::TestStatus testSemaphoreQueries (Context& context, vk::VkExternalSemaphoreHandleTypeFlagBits externalType)
 {
 	const vk::PlatformInterface&		vkp				(context.getPlatformInterface());
@@ -693,12 +823,12 @@
 		const vk::DeviceDriver				vkd				(vki, *device);
 		const vk::VkQueue					queue			(getQueue(vkd, *device, queueFamilyIndex));
 		const vk::Unique<vk::VkSemaphore>	semaphore		(createExportableSemaphore(vkd, *device, config.externalType));
+		NativeHandle						handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphore);
-
-		NativeHandle						handleA;
-		getSemaphoreNative(vkd, *device, *semaphore, config.externalType, handleA);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphore, config.externalType, handleA);
+		else
+			getSemaphoreNative(vkd, *device, *semaphore, config.externalType, handleA);
 
 		{
 			NativeHandle						handleB		(handleA);
@@ -741,12 +871,12 @@
 		const vk::VkQueue					queue			(getQueue(vkd, *device, queueFamilyIndex));
 
 		const vk::Unique<vk::VkSemaphore>	semaphoreA		(createExportableSemaphore(vkd, *device, config.externalType));
+		NativeHandle						handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphoreA);
-
-		NativeHandle						handleA;
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handleA);
+		else
+			getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
 
 		NativeHandle						handleB		(handleA);
 		const vk::VkSemaphoreImportFlags	flags		= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
@@ -786,13 +916,10 @@
 		const vk::DeviceDriver				vkd					(vki, *device);
 		const vk::VkQueue					queue				(getQueue(vkd, *device, queueFamilyIndex));
 		const vk::Unique<vk::VkSemaphore>	semaphoreA			(createExportableSemaphore(vkd, *device, config.externalType));
-
-		submitDummySignal(vkd, queue, *semaphoreA);
-
 		{
 			NativeHandle	handle;
 
-			getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
 
 			{
 				const vk::VkSemaphoreImportFlags	flags		= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
@@ -865,7 +992,7 @@
 		const vk::Unique<vk::VkSemaphore>	semaphoreA	(createExportableSemaphore(vkd, *device, config.externalType));
 		NativeHandle						handle;
 
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+		submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
 
 		const vk::Unique<vk::VkSemaphore>	semaphoreB	(createAndImportSemaphore(vkd, *device, config.externalType, handle, flags));
 
@@ -904,9 +1031,9 @@
 		VK_CHECK(vkd.queueWaitIdle(queue));
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphoreA);
-
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
+		else
+			getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
 
 		importSemaphore(vkd, *device, *semaphoreB, config.externalType, handle, flags);
 
@@ -949,9 +1076,9 @@
 		NativeHandle						handle;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphoreA);
-
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
+		else
+			getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
 
 		submitDummySignal(vkd, queue, *semaphoreB);
 		submitDummyWait(vkd, queue, *semaphoreB);
@@ -1000,9 +1127,9 @@
 			NativeHandle handle;
 
 			if (transference == TRANSFERENCE_COPY)
-				submitDummySignal(vkd, queue, *semaphore);
-
-			getSemaphoreNative(vkd, *device, *semaphore, config.externalType, handle);
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphore, config.externalType, handle);
+			else
+				getSemaphoreNative(vkd, *device, *semaphore, config.externalType, handle);
 		}
 
 		submitDummySignal(vkd, queue, *semaphore);
@@ -1036,9 +1163,9 @@
 		NativeHandle						handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphoreA);
-
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handleA);
+		else
+			getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handleA);
 
 		for (size_t importNdx = 0; importNdx < importCount; importNdx++)
 		{
@@ -1086,9 +1213,7 @@
 		const vk::Unique<vk::VkSemaphore>	semaphoreA	(createExportableSemaphore(vkd, *device, config.externalType));
 		NativeHandle						handle;
 
-		submitDummySignal(vkd, queue, *semaphoreA);
-
-		getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, handle);
+		submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, handle);
 
 		{
 			const vk::Unique<vk::VkSemaphore>	semaphoreB			(createAndImportSemaphore(vkd, *device, config.externalType, handle, flags));
@@ -1181,11 +1306,14 @@
 		TestLog&							log			= context.getTestContext().getLog();
 		const vk::Unique<vk::VkSemaphore>	semaphoreA	(createExportableSemaphore(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphoreA);
-
 		{
-			const NativeHandle	fd		(getSemaphoreFd(vkd, *device, *semaphoreA, config.externalType));
+			NativeHandle		fd;
+
+			if (transference == TRANSFERENCE_COPY)
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, fd);
+			else
+				getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, fd);
+
 			NativeHandle		newFd	(dup(fd.getFd()));
 
 			if (newFd.getFd() < 0)
@@ -1242,15 +1370,20 @@
 		const vk::Unique<vk::VkSemaphore>	semaphoreA	(createExportableSemaphore(vkd, *device, config.externalType));
 		const vk::Unique<vk::VkSemaphore>	semaphoreB	(createExportableSemaphore(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
 		{
-			submitDummySignal(vkd, queue, *semaphoreA);
-			submitDummySignal(vkd, queue, *semaphoreB);
-		}
+			NativeHandle		fd, secondFd;
 
-		{
-			const NativeHandle	fd			(getSemaphoreFd(vkd, *device, *semaphoreA, config.externalType));
-			NativeHandle		secondFd	(getSemaphoreFd(vkd, *device, *semaphoreB, config.externalType));
+			if (transference == TRANSFERENCE_COPY)
+			{
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, fd);
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreB, config.externalType, secondFd);
+			}
+			else
+			{
+				getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, fd);
+				getSemaphoreNative(vkd, *device, *semaphoreB, config.externalType, secondFd);
+			}
+
 			int					newFd		(dup2(fd.getFd(), secondFd.getFd()));
 
 			if (newFd < 0)
@@ -1306,16 +1439,21 @@
 		const vk::Unique<vk::VkSemaphore>	semaphoreA	(createExportableSemaphore(vkd, *device, config.externalType));
 		const vk::Unique<vk::VkSemaphore>	semaphoreB	(createExportableSemaphore(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
 		{
-			submitDummySignal(vkd, queue, *semaphoreA);
-			submitDummySignal(vkd, queue, *semaphoreB);
-		}
+			NativeHandle						fd, secondFd;
 
-		{
+			if (transference == TRANSFERENCE_COPY)
+			{
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreA, config.externalType, fd);
+				submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphoreB, config.externalType, secondFd);
+			}
+			else
+			{
+				getSemaphoreNative(vkd, *device, *semaphoreA, config.externalType, fd);
+				getSemaphoreNative(vkd, *device, *semaphoreB, config.externalType, secondFd);
+			}
+
 			const vk::VkSemaphoreImportFlags	flags		= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_SEMAPHORE_IMPORT_TEMPORARY_BIT : (vk::VkSemaphoreImportFlagBits)0u;
-			const NativeHandle					fd			(getSemaphoreFd(vkd, *device, *semaphoreA, config.externalType));
-			NativeHandle						secondFd	(getSemaphoreFd(vkd, *device, *semaphoreB, config.externalType));
 			const int							newFd		(dup3(fd.getFd(), secondFd.getFd(), 0));
 
 			if (newFd < 0)
@@ -1369,11 +1507,12 @@
 
 		TestLog&							log			= context.getTestContext().getLog();
 		const vk::Unique<vk::VkSemaphore>	semaphore	(createExportableSemaphore(vkd, *device, config.externalType));
+		NativeHandle						fd;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *semaphore);
-
-		const NativeHandle	fd	(getSemaphoreFd(vkd, *device, *semaphore, config.externalType));
+			submitDummySignalAndGetSemaphoreNative(vkd, *device, queue, queueFamilyIndex, *semaphore, config.externalType, fd);
+		else
+			getSemaphoreNative(vkd, *device, *semaphore, config.externalType, fd);
 
 		{
 			int sv[2];
@@ -1624,12 +1763,12 @@
 		const vk::DeviceDriver			vkd			(vki, *device);
 		const vk::VkQueue				queue		(getQueue(vkd, *device, queueFamilyIndex));
 		const vk::Unique<vk::VkFence>	fence		(createExportableFence(vkd, *device, config.externalType));
+		NativeHandle					handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fence);
-
-		NativeHandle						handleA;
-		getFenceNative(vkd, *device, *fence, config.externalType, handleA);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fence, config.externalType, handleA);
+		else
+			getFenceNative(vkd, *device, *fence, config.externalType, handleA);
 
 		{
 			NativeHandle					handleB	(handleA);
@@ -1672,12 +1811,12 @@
 		const vk::VkQueue				queue	(getQueue(vkd, *device, queueFamilyIndex));
 
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
+		NativeHandle					handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fenceA);
-
-		NativeHandle					handleA;
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handleA);
+		else
+			getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
 
 		NativeHandle					handleB	(handleA);
 		const vk::VkFenceImportFlags	flags	= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
@@ -1718,12 +1857,10 @@
 		const vk::VkQueue				queue	(getQueue(vkd, *device, queueFamilyIndex));
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
 
-		submitDummySignal(vkd, queue, *fenceA);
-
 		{
 			NativeHandle	handle;
 
-			getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
 
 			{
 				const vk::VkFenceImportFlags	flags	= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
@@ -1835,9 +1972,9 @@
 		VK_CHECK(vkd.queueWaitIdle(queue));
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fenceA);
-
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
+		else
+			getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
 
 		importFence(vkd, *device, *fenceB, config.externalType, handle, flags);
 
@@ -1883,9 +2020,7 @@
 		submitDummySignal(vkd, queue, *fenceB);
 		VK_CHECK(vkd.queueWaitIdle(queue));
 
-		submitDummySignal(vkd, queue, *fenceA);
-
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+		submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
 		{
 			NativeHandle					handleB	(handle);
 			importFence(vkd, *device, *fenceB, config.externalType, handleB, flags);
@@ -1949,9 +2084,9 @@
 		NativeHandle					handle;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fenceA);
-
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
+		else
+			getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
 
 		submitDummySignal(vkd, queue, *fenceB);
 		VK_CHECK(vkd.waitForFences(*device, 1u, &*fenceB, VK_TRUE, ~0ull));
@@ -2000,9 +2135,9 @@
 			NativeHandle handle;
 
 			if (transference == TRANSFERENCE_COPY)
-				submitDummySignal(vkd, queue, *fence);
-
-			getFenceNative(vkd, *device, *fence, config.externalType, handle);
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fence, config.externalType, handle);
+			else
+				getFenceNative(vkd, *device, *fence, config.externalType, handle);
 		}
 
 		submitDummySignal(vkd, queue, *fence);
@@ -2036,9 +2171,9 @@
 		NativeHandle					handleA;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fenceA);
-
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handleA);
+		else
+			getFenceNative(vkd, *device, *fenceA, config.externalType, handleA);
 
 		for (size_t importNdx = 0; importNdx < importCount; importNdx++)
 		{
@@ -2086,9 +2221,7 @@
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
 		NativeHandle					handle;
 
-		submitDummySignal(vkd, queue, *fenceA);
-
-		getFenceNative(vkd, *device, *fenceA, config.externalType, handle);
+		submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, handle);
 
 		{
 			const vk::Unique<vk::VkFence>	fenceB	(createAndImportFence(vkd, *device, config.externalType, handle, flags));
@@ -2187,11 +2320,14 @@
 		TestLog&						log		= context.getTestContext().getLog();
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fenceA);
-
 		{
-			const NativeHandle	fd		(getFenceFd(vkd, *device, *fenceA, config.externalType));
+			NativeHandle		fd;
+
+			if (transference == TRANSFERENCE_COPY)
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, fd);
+			else
+				getFenceNative(vkd, *device, *fenceA, config.externalType, fd);
+
 			NativeHandle		newFd	(dup(fd.getFd()));
 
 			if (newFd.getFd() < 0)
@@ -2248,15 +2384,20 @@
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
 		const vk::Unique<vk::VkFence>	fenceB	(createExportableFence(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
 		{
-			submitDummySignal(vkd, queue, *fenceA);
-			submitDummySignal(vkd, queue, *fenceB);
-		}
+			NativeHandle		fd, secondFd;
 
-		{
-			const NativeHandle	fd			(getFenceFd(vkd, *device, *fenceA, config.externalType));
-			NativeHandle		secondFd	(getFenceFd(vkd, *device, *fenceB, config.externalType));
+			if (transference == TRANSFERENCE_COPY)
+			{
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, fd);
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceB, config.externalType, secondFd);
+			}
+			else
+			{
+				getFenceNative(vkd, *device, *fenceA, config.externalType, fd);
+				getFenceNative(vkd, *device, *fenceB, config.externalType, secondFd);
+			}
+
 			int					newFd		(dup2(fd.getFd(), secondFd.getFd()));
 
 			if (newFd < 0)
@@ -2312,16 +2453,21 @@
 		const vk::Unique<vk::VkFence>	fenceA	(createExportableFence(vkd, *device, config.externalType));
 		const vk::Unique<vk::VkFence>	fenceB	(createExportableFence(vkd, *device, config.externalType));
 
-		if (transference == TRANSFERENCE_COPY)
 		{
-			submitDummySignal(vkd, queue, *fenceA);
-			submitDummySignal(vkd, queue, *fenceB);
-		}
+			NativeHandle					fd, secondFd;
 
-		{
+			if (transference == TRANSFERENCE_COPY)
+			{
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceA, config.externalType, fd);
+				submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fenceB, config.externalType, secondFd);
+			}
+			else
+			{
+				getFenceNative(vkd, *device, *fenceA, config.externalType, fd);
+				getFenceNative(vkd, *device, *fenceB, config.externalType, secondFd);
+			}
+
 			const vk::VkFenceImportFlags	flags		= config.permanence == PERMANENCE_TEMPORARY ? vk::VK_FENCE_IMPORT_TEMPORARY_BIT : (vk::VkFenceImportFlagBits)0u;
-			const NativeHandle				fd			(getFenceFd(vkd, *device, *fenceA, config.externalType));
-			NativeHandle					secondFd	(getFenceFd(vkd, *device, *fenceB, config.externalType));
 			const int						newFd		(dup3(fd.getFd(), secondFd.getFd(), 0));
 
 			if (newFd < 0)
@@ -2375,11 +2521,12 @@
 
 		TestLog&						log		= context.getTestContext().getLog();
 		const vk::Unique<vk::VkFence>	fence	(createExportableFence(vkd, *device, config.externalType));
+		NativeHandle					fd;
 
 		if (transference == TRANSFERENCE_COPY)
-			submitDummySignal(vkd, queue, *fence);
-
-		const NativeHandle	fd	(getFenceFd(vkd, *device, *fence, config.externalType));
+			submitDummySignalAndGetFenceNative(vkd, *device, queue, queueFamilyIndex, *fence, config.externalType, fd);
+		else
+			getFenceNative(vkd, *device, *fence, config.externalType, fd);
 
 		{
 			int sv[2];
diff --git a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp
index 14f03ce..cdd0155 100644
--- a/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp
+++ b/external/vulkancts/modules/vulkan/renderpass/vktRenderPassTests.cpp
@@ -677,7 +677,7 @@
 	const vector<Attachment>&							getAttachments	(void) const { return m_attachments;	}
 	const vector<Subpass>&								getSubpasses	(void) const { return m_subpasses;		}
 	const vector<SubpassDependency>&					getDependencies	(void) const { return m_dependencies;	}
-	const vector<VkInputAttachmentAspectReference>		getInputAspects	(void) const { return m_inputAspects;	}
+	const vector<VkInputAttachmentAspectReference>&		getInputAspects	(void) const { return m_inputAspects;	}
 
 private:
 	const vector<Attachment>							m_attachments;