Merge vk-gl-cts/vulkan-cts-1.3.5 into vk-gl-cts/vulkan-cts-1.3.6

Change-Id: I15e89356eb9701f1e6967f60ed8baae359388989
diff --git a/external/vulkancts/modules/vulkan/api/vktApiPipelineTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiPipelineTests.cpp
index cdc7899..969c583 100644
--- a/external/vulkancts/modules/vulkan/api/vktApiPipelineTests.cpp
+++ b/external/vulkancts/modules/vulkan/api/vktApiPipelineTests.cpp
@@ -1679,7 +1679,6 @@
 	if (isGraphics)
 	{
 		shaderModules.push_back(createShaderModule(vk, device, context.getBinaryCollection().get("vertex"), 0));
-		shaderModules.push_back(createShaderModule(vk, device, context.getBinaryCollection().get("fragment"), 0));
 
 		const VkPipelineShaderStageCreateInfo	shaderStageCreateInfos[]	=
 		{
@@ -1691,15 +1690,6 @@
 				shaderModules[0].get(),									// VkShaderModule                      shader;
 				"main",													// const char*                         pName;
 				DE_NULL,												// const VkSpecializationInfo*         pSpecializationInfo;
-			},
-			{
-				VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,	// VkStructureType                     sType;
-				DE_NULL,												// const void*                         pNext;
-				(VkPipelineShaderStageCreateFlags)0,					// VkPipelineShaderStageCreateFlags    flags;
-				VK_SHADER_STAGE_FRAGMENT_BIT,							// VkShaderStageFlagBits               stage;
-				shaderModules[1].get(),									// VkShaderModule                      shader;
-				"main",													// const char*                         pName;
-				DE_NULL,												// const VkSpecializationInfo*         pSpecializationInfo;
 			}
 		};
 
diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryDeviceMemoryReportTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryDeviceMemoryReportTests.cpp
index 035226f..7d276e5 100644
--- a/external/vulkancts/modules/vulkan/memory/vktMemoryDeviceMemoryReportTests.cpp
+++ b/external/vulkancts/modules/vulkan/memory/vktMemoryDeviceMemoryReportTests.cpp
@@ -1875,13 +1875,14 @@
 	const deUint32							testTypeIndex		= 0;
 	const deUint32							testHeapIndex		= memoryProperties.memoryTypes[testTypeIndex].heapIndex;
 	const VkDeviceSize						testSize			= memoryProperties.memoryHeaps[testHeapIndex].size;
+	const deUint32							testNumAlloc		= 10;
 
 	{
-		recorder.setCallbackMarker(MARKER_ALLOCATION_FAILED);
+		recorder.setCallbackMarker(MARKER_UNKNOWN);
 
-		VkDeviceMemory			memory1 = DE_NULL;
-		VkDeviceMemory			memory2 = DE_NULL;
-		VkMemoryAllocateInfo	memoryAllocateInfo
+		std::vector<VkDeviceMemory>	memories;
+		VkResult					result				= VK_SUCCESS;
+		VkMemoryAllocateInfo		memoryAllocateInfo	=
 		{
 			VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,	// VkStructureType	sType;
 			DE_NULL,								// const void*		pNext;
@@ -1889,27 +1890,44 @@
 			testTypeIndex,							// uint32_t			memoryTypeIndex;
 		};
 
-		// first do a small allocation to prevent LowMemoryKiller on android from culling this app
-		VkResult result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory1);
-		if (result != VK_SUCCESS)
-			TCU_THROW(NotSupportedError, "Unable to do a small allocation");
-
-		// if small allocation succeeded then we can try to trigger an allocation failure by allocating as much memory as there is on the heap
-		memoryAllocateInfo.allocationSize = testSize;
-		result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory2);
-		if (result == VK_SUCCESS)
 		{
-			vkd.freeMemory(*device, memory1, DE_NULL);
-			vkd.freeMemory(*device, memory2, DE_NULL);
-			return tcu::TestStatus::fail(std::string("Should not be able to allocate ") + std::to_string(testSize) + " bytes of memory");
+			VkDeviceMemory	memory	= DE_NULL;
+
+			// first do a small allocation to prevent LowMemoryKiller on android from culling this app
+			result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory);
+			if (result != VK_SUCCESS)
+				TCU_THROW(NotSupportedError, "Unable to do a small allocation");
+
+			memories.emplace_back(memory);
 		}
 
+		// use heap size to trigger allocation failure (up to testNumAlloc times for overallocation)
+		memoryAllocateInfo.allocationSize = testSize;
+		// only mark the range that an allocation failure could occur
+		recorder.setCallbackMarker(MARKER_ALLOCATION_FAILED);
+		for (deUint32 i = 0; i < testNumAlloc; i++)
+		{
+			VkDeviceMemory	memory	= DE_NULL;
+
+			result = vkd.allocateMemory(*device, &memoryAllocateInfo, (const VkAllocationCallbacks*)DE_NULL, &memory);
+			if (result != VK_SUCCESS)
+			{
+				break;
+			}
+
+			memories.emplace_back(memory);
+		}
 		recorder.setCallbackMarker(MARKER_UNKNOWN);
 
-		if (!!memory1)
-			vkd.freeMemory(*device, memory1, DE_NULL);
-		if (!!memory2)
-			vkd.freeMemory(*device, memory2, DE_NULL);
+		for (auto memory : memories)
+		{
+			vkd.freeMemory(*device, memory, DE_NULL);
+		}
+
+		if (result == VK_SUCCESS)
+		{
+			return tcu::TestStatus::fail(std::string("Should not be able to allocate ") + std::to_string(testNumAlloc * testSize) + " bytes of memory");
+		}
 	}
 
 	deBool	allocationFailedEvent	= false;
diff --git a/external/vulkancts/modules/vulkan/vktCustomInstancesDevices.cpp b/external/vulkancts/modules/vulkan/vktCustomInstancesDevices.cpp
index a7abd2f..610d706 100644
--- a/external/vulkancts/modules/vulkan/vktCustomInstancesDevices.cpp
+++ b/external/vulkancts/modules/vulkan/vktCustomInstancesDevices.cpp
@@ -208,7 +208,7 @@
 	, m_instance	(instance)
 #ifndef CTS_USES_VULKANSC
 	, m_driver((m_instance != DE_NULL) ? new InstanceDriver(context.getPlatformInterface(), m_instance) : nullptr)
-	, m_callback	(m_recorder ? m_recorder->createCallback(*m_driver, m_instance) : Move<VkDebugReportCallbackEXT>())
+	, m_callback	((m_driver && m_recorder) ? m_recorder->createCallback(*m_driver, m_instance) : Move<VkDebugReportCallbackEXT>())
 #else
 	, m_driver((m_instance != DE_NULL) ? new InstanceDriverSC(context.getPlatformInterface(), m_instance, context.getTestContext().getCommandLine(), context.getResourceInterface()) : nullptr)
 #endif // CTS_USES_VULKANSC
@@ -225,6 +225,7 @@
 	if (m_instance != DE_NULL)
 	{
 #ifndef CTS_USES_VULKANSC
+		m_callback.~Move<vk::VkDebugReportCallbackEXT>();
 		m_recorder.reset(nullptr);
 #endif // CTS_USES_VULKANSC
 		m_driver->destroyInstance(m_instance, m_allocator);
@@ -425,7 +426,6 @@
 	const bool								addLayers				= (validationEnabled && allowLayers);
 #ifndef CTS_USES_VULKANSC
 	std::unique_ptr<DebugReportRecorder>	recorder;
-	VkDebugReportCallbackCreateInfoEXT		callbackInfo;
 #endif // CTS_USES_VULKANSC
 
 	if (addLayers)
@@ -444,11 +444,10 @@
 		createInfo.ppEnabledExtensionNames = enabledExtensions.data();
 
 #ifndef CTS_USES_VULKANSC
-		// Prepare debug report recorder also for instance creation.
 		recorder.reset(new DebugReportRecorder(printValidationErrors));
-		callbackInfo		= recorder->makeCreateInfo();
-		callbackInfo.pNext	= createInfo.pNext;
-		createInfo.pNext	= &callbackInfo;
+		// No need to add VkDebugReportCallbackCreateInfoEXT to VkInstanceCreateInfo since we
+		// don't want to check for errors at instance creation. This is intended since we use
+		// UncheckedInstance to try to create invalid instances for driver stability
 #endif // CTS_USES_VULKANSC
 	}
 
diff --git a/external/vulkancts/modules/vulkan/vktInfoTests.cpp b/external/vulkancts/modules/vulkan/vktInfoTests.cpp
index 6fab27e..b42fac6 100644
--- a/external/vulkancts/modules/vulkan/vktInfoTests.cpp
+++ b/external/vulkancts/modules/vulkan/vktInfoTests.cpp
@@ -191,7 +191,7 @@
 
 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_units); ++ndx)
 	{
-		DE_ASSERT(ndx == DE_LENGTH_OF_ARRAY(s_units) ||
+		DE_ASSERT(ndx == (DE_LENGTH_OF_ARRAY(s_units) - 1) ||
 		          s_units[ndx].value > s_units[ndx + 1].value);
 		if (value >= s_units[ndx].value)
 			return &s_units[ndx];
diff --git a/external/vulkancts/modules/vulkan/ycbcr/vktYCbCrViewTests.cpp b/external/vulkancts/modules/vulkan/ycbcr/vktYCbCrViewTests.cpp
index 156a0f9..4e272b1 100644
--- a/external/vulkancts/modules/vulkan/ycbcr/vktYCbCrViewTests.cpp
+++ b/external/vulkancts/modules/vulkan/ycbcr/vktYCbCrViewTests.cpp
@@ -424,14 +424,18 @@
 }
 
 Vec4 castResult(Vec4 result, VkFormat f) {
+	union {
+		Vec4 vec;
+		IVec4 ivec;
+		UVec4 uvec;
+	} cast = { result };
+
 	if (isIntFormat(f)) {
-		IVec4* result_ptr = reinterpret_cast<IVec4*>(&result);
-		IVec4 ivec = *(result_ptr);
+		IVec4 ivec = cast.ivec;
 		return Vec4((float)ivec.x(), (float)ivec.y(), (float)ivec.z(), (float)ivec.w());
 	}
 	else if (isUintFormat(f)) {
-		UVec4* result_ptr = reinterpret_cast<UVec4*>(&result);
-		UVec4 uvec = *(result_ptr);
+		UVec4 uvec = cast.uvec;
 		return Vec4((float)uvec.x(), (float)uvec.y(), (float)uvec.z(), (float)uvec.w());
 	}
 	else {