Fix custom device creation for synchronization2

Some synchronization tests created custom device without
enabling all used features. This change fixes that.

Components: Vulkan

VK-GL-CTS issue: 2734

Affects:
dEQP-VK.synchronization*.basic.*.multi_queu*
dEQP-VK.synchronization*.op.multi_queue.*
dEQP-VK.synchronization*.cross_instance.*

Change-Id: Ib2c062967608c5348e5b0a5edabd310574900632
diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationBasicSemaphoreTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationBasicSemaphoreTests.cpp
index 4aec177..124ec52 100644
--- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationBasicSemaphoreTests.cpp
+++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationBasicSemaphoreTests.cpp
@@ -56,8 +56,6 @@
 
 Move<VkSemaphore> createTestSemaphore(Context& context, const DeviceInterface& vk, const VkDevice device, const TestConfig& config)
 {
-	Move<VkSemaphore> semaphore;
-
 	if (config.semaphoreType == VK_SEMAPHORE_TYPE_TIMELINE_KHR && !context.getTimelineSemaphoreFeatures().timelineSemaphore)
 		TCU_THROW(NotSupportedError, "Timeline semaphore not supported");
 
@@ -324,13 +322,30 @@
 	deMemset(&deviceInfo, 0, sizeof(deviceInfo));
 	instance.getPhysicalDeviceFeatures(physicalDevice, &deviceFeatures);
 
+	VkPhysicalDeviceFeatures2					createPhysicalFeature		{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, DE_NULL, deviceFeatures };
+	VkPhysicalDeviceTimelineSemaphoreFeatures	timelineSemaphoreFeatures	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, DE_NULL, DE_TRUE };
+	VkPhysicalDeviceSynchronization2FeaturesKHR	synchronization2Features	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR, DE_NULL, DE_TRUE };
+	void**										nextPtr						= &createPhysicalFeature.pNext;
+
+	std::vector<const char*> deviceExtensions;
+	if (isTimelineSemaphore)
+	{
+		deviceExtensions.push_back("VK_KHR_timeline_semaphore");
+		addToChainVulkanStructure(&nextPtr, timelineSemaphoreFeatures);
+	}
+	if (config.type == SynchronizationType::SYNCHRONIZATION2)
+	{
+		deviceExtensions.push_back("VK_KHR_synchronization2");
+		addToChainVulkanStructure(&nextPtr, synchronization2Features);
+	}
+
 	deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
-	deviceInfo.pNext = DE_NULL;
-	deviceInfo.enabledExtensionCount = 0u;
-	deviceInfo.ppEnabledExtensionNames = DE_NULL;
+	deviceInfo.pNext = &createPhysicalFeature;
+	deviceInfo.enabledExtensionCount = static_cast<deUint32>(deviceExtensions.size());
+	deviceInfo.ppEnabledExtensionNames = deviceExtensions.empty() ? DE_NULL : deviceExtensions.data();
 	deviceInfo.enabledLayerCount = 0u;
 	deviceInfo.ppEnabledLayerNames = DE_NULL;
-	deviceInfo.pEnabledFeatures = &deviceFeatures;
+	deviceInfo.pEnabledFeatures = 0u;
 	deviceInfo.queueCreateInfoCount = (queues[FIRST].queueFamilyIndex == queues[SECOND].queueFamilyIndex) ? 1 : COUNT;
 	deviceInfo.pQueueCreateInfos = queueInfos;
 
@@ -460,6 +475,9 @@
 
 void checkSupport(Context& context, TestConfig config)
 {
+	if (config.semaphoreType == VK_SEMAPHORE_TYPE_TIMELINE_KHR)
+		context.requireDeviceFunctionality("VK_KHR_timeline_semaphore");
+
 	if (config.type == SynchronizationType::SYNCHRONIZATION2)
 		context.requireDeviceFunctionality("VK_KHR_synchronization2");
 }
diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp
index 336731d..8e3d305 100644
--- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp
+++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp
@@ -325,10 +325,15 @@
 										 const vk::InstanceInterface&	vki,
 										 const vk::VkPhysicalDevice		physicalDevice)
 {
-	const bool										validationEnabled		= context.getTestContext().getCommandLine().isValidationEnabled();
-	const float										priority				= 0.0f;
-	const std::vector<vk::VkQueueFamilyProperties>	queueFamilyProperties	= vk::getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
-	std::vector<deUint32>							queueFamilyIndices		(queueFamilyProperties.size(), 0xFFFFFFFFu);
+	const bool										validationEnabled			= context.getTestContext().getCommandLine().isValidationEnabled();
+	const float										priority					= 0.0f;
+	const std::vector<vk::VkQueueFamilyProperties>	queueFamilyProperties		= vk::getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
+	std::vector<deUint32>							queueFamilyIndices			(queueFamilyProperties.size(), 0xFFFFFFFFu);
+
+	VkPhysicalDeviceFeatures2						createPhysicalFeature		{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, DE_NULL, context.getDeviceFeatures() };
+	VkPhysicalDeviceTimelineSemaphoreFeatures		timelineSemaphoreFeatures	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, DE_NULL, DE_TRUE };
+	VkPhysicalDeviceSynchronization2FeaturesKHR		synchronization2Features	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR, DE_NULL, DE_TRUE };
+	void**											nextPtr						= &createPhysicalFeature.pNext;
 	std::vector<const char*>						extensions;
 
 	if (context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation"))
@@ -356,9 +361,15 @@
 		extensions.push_back("VK_KHR_external_memory_win32");
 
 	if (context.isDeviceFunctionalitySupported("VK_KHR_timeline_semaphore"))
+	{
 		extensions.push_back("VK_KHR_timeline_semaphore");
+		addToChainVulkanStructure(&nextPtr, timelineSemaphoreFeatures);
+	}
 	if (context.isDeviceFunctionalitySupported("VK_KHR_synchronization2"))
+	{
 		extensions.push_back("VK_KHR_synchronization2");
+		addToChainVulkanStructure(&nextPtr, synchronization2Features);
+	}
 
 	try
 	{
@@ -380,12 +391,6 @@
 			queues.push_back(createInfo);
 		}
 
-		const vk::VkPhysicalDeviceFeatures2	createPhysicalFeature	=
-		{
-			vk::VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
-			DE_NULL,
-			context.getDeviceFeatures(),
-		};
 		const vk::VkDeviceCreateInfo		createInfo				=
 		{
 			vk::VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperationMultiQueueTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperationMultiQueueTests.cpp
index c29f64b..6e10bed 100644
--- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperationMultiQueueTests.cpp
+++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationOperationMultiQueueTests.cpp
@@ -141,16 +141,27 @@
 		}
 
 		{
+			VkPhysicalDeviceFeatures2					createPhysicalFeature		{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, DE_NULL, context.getDeviceFeatures() };
+			VkPhysicalDeviceTimelineSemaphoreFeatures	timelineSemaphoreFeatures	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, DE_NULL, DE_TRUE };
+			VkPhysicalDeviceSynchronization2FeaturesKHR	synchronization2Features	{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR, DE_NULL, DE_TRUE };
+			void**										nextPtr						= &createPhysicalFeature.pNext;
+
 			std::vector<const char*> deviceExtensions;
 			if (timelineSemaphore)
+			{
 				deviceExtensions.push_back("VK_KHR_timeline_semaphore");
+				addToChainVulkanStructure(&nextPtr, timelineSemaphoreFeatures);
+			}
 			if (type == SynchronizationType::SYNCHRONIZATION2)
+			{
 				deviceExtensions.push_back("VK_KHR_synchronization2");
+				addToChainVulkanStructure(&nextPtr, synchronization2Features);
+			}
 
 			const VkDeviceCreateInfo deviceInfo =
 			{
 				VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,							//VkStructureType					sType;
-				DE_NULL,														//const void*						pNext;
+				&createPhysicalFeature,											//const void*						pNext;
 				0u,																//VkDeviceCreateFlags				flags;
 				static_cast<deUint32>(queueInfos.size()),						//deUint32							queueCreateInfoCount;
 				&queueInfos[0],													//const VkDeviceQueueCreateInfo*	pQueueCreateInfos;
@@ -158,7 +169,7 @@
 				DE_NULL,														//const char* const*				ppEnabledLayerNames;
 				static_cast<deUint32>(deviceExtensions.size()),					//deUint32							enabledExtensionCount;
 				deviceExtensions.empty() ? DE_NULL : &deviceExtensions[0],		//const char* const*				ppEnabledExtensionNames;
-				&context.getDeviceFeatures()									//const VkPhysicalDeviceFeatures*	pEnabledFeatures;
+				DE_NULL															//const VkPhysicalDeviceFeatures*	pEnabledFeatures;
 			};
 
 			m_logicalDevice	= createCustomDevice(context.getTestContext().getCommandLine().isValidationEnabled(), context.getPlatformInterface(), context.getInstance(), instance, physicalDevice, &deviceInfo);