Merge vk-gl-cts/vulkan-cts-1.2.2 into vk-gl-cts/vulkan-cts-1.2.3

Change-Id: I9b3cd47707fa2f7d56cc3fc1037c3fb556c20f90
diff --git a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStackTests.cpp b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStackTests.cpp
index 3e9b105..d712068 100644
--- a/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStackTests.cpp
+++ b/external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStackTests.cpp
@@ -96,7 +96,7 @@
 
 private:
 	de::MovePtr<tcu::Texture2D>	createTestTexture2D	(void);
-	tcu::TestStatus				validateResult		(vk::VkImage			image,
+	bool						validateResult		(vk::VkImage			image,
 													 vk::VkImageLayout imageLayout,
 													 const tcu::Texture2D&	texture2D,
 													 const tcu::Sampler&	refSampler);
@@ -141,7 +141,7 @@
 	// Function p() returns specified protected memory element from the variable allocated on stack.
 	// Function u() returns specified protected memory element from the global variable.
 	// Values returned by p() and u() should be same.
-	// Test is repeated several times (16) to avoid coincidental matches.
+	// Test is repeated 2 times () in shader to avoid coincidental matches.
 	// In case of any mismatches it is signalized to inherited verifier function by setting 0 in result store image.
 	// Each invocation validates particular element (bytes) on stack.
 	// Number of invocations matches stack size specified in test parameters.
@@ -175,7 +175,7 @@
 		"    int checked_ndx = gy * w + gx;\n"
 		"    vec4 outColor;\n"
 		"\n"
-		"    for (int j = 0; j < 16; j++)\n"
+		"    for (int j = 0; j < 2; j++)\n"
 		"    {\n"
 		"        for (int i = 0; i < n; i++)\n"
 		"        {\n"
@@ -324,7 +324,14 @@
 		updateBuilder.update(vk, device);
 	}
 
+	// Calculate reference image
+	calculateRef(*texture2D);
+
+	bool result = true;
+
 	// Create compute commands & submit
+	// Command buffer load is repeated 8 times () to avoid coincidental matches.
+	for (int i = 0; (i < 8) && (result == true); i++)
 	{
 		const vk::Unique<vk::VkFence>		fence		(vk::createFence(vk, device));
 		vk::Unique<vk::VkPipeline>			pipeline	(makeComputePipeline(vk, device, *pipelineLayout, *computeShader, DE_NULL));
@@ -337,14 +344,18 @@
 		vk.cmdDispatch(*cmdBuffer, 1u, 1u, 1u);
 		endCommandBuffer(vk, *cmdBuffer);
 
+
 		VK_CHECK(queueSubmit(ctx, PROTECTION_ENABLED, queue, *cmdBuffer, *fence, ~0ull));
+
+		VK_CHECK(vk.waitForFences(device, 1u, &*fence, VK_TRUE, ~0ull));
+
+	    result = validateResult(**imageDst, vk::VK_IMAGE_LAYOUT_GENERAL, *texture2D, refSampler);
 	}
 
-	// Calculate reference image
-	calculateRef(*texture2D);
-
-	// Validate result
-	return validateResult(**imageDst, vk::VK_IMAGE_LAYOUT_GENERAL, *texture2D, refSampler);
+	if (result == true)
+		return tcu::TestStatus::pass("Pass");
+	else
+		return tcu::TestStatus::fail("Result validation failed");
 }
 
 void StackTestInstance::calculateRef (tcu::Texture2D& texture2D)
@@ -357,7 +368,7 @@
 		reference.setPixel(zero, x, y);
 }
 
-tcu::TestStatus StackTestInstance::validateResult (vk::VkImage image, vk::VkImageLayout imageLayout, const tcu::Texture2D& texture2D, const tcu::Sampler& refSampler)
+bool StackTestInstance::validateResult (vk::VkImage image, vk::VkImageLayout imageLayout, const tcu::Texture2D& texture2D, const tcu::Sampler& refSampler)
 {
 	de::Random			rnd			(getSeedValue(m_params));
 	ValidationData		refData;
@@ -373,9 +384,9 @@
 	}
 
 	if (!m_validator.validateImage(m_protectedContext, refData, image, vk::VK_FORMAT_R8G8B8A8_UNORM, imageLayout))
-		return tcu::TestStatus::fail("Result validation failed");
+		return false;
 	else
-		return tcu::TestStatus::pass("Pass");
+		return true;
 }
 
 } // anonymous
diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp
index f147b40..6d70ecf 100644
--- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp
+++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.cpp
@@ -1599,6 +1599,47 @@
 	return features.shaderTessellationAndGeometryPointSize ? true : false;
 }
 
+bool vkt::subgroups::is16BitUBOStorageSupported(Context& context) {
+	VkPhysicalDevice16BitStorageFeatures storage16bit;
+	deMemset(&storage16bit, 0, sizeof(storage16bit));
+	storage16bit.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR;
+	storage16bit.pNext = DE_NULL;
+
+	VkPhysicalDeviceFeatures2 features2;
+	deMemset(&features2, 0, sizeof(features2));
+	features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+	features2.pNext = &storage16bit;
+
+	const PlatformInterface&		platformInterface = context.getPlatformInterface();
+	const VkInstance				instance = context.getInstance();
+	const InstanceDriver			instanceDriver(platformInterface, instance);
+
+	instanceDriver.getPhysicalDeviceFeatures2(context.getPhysicalDevice(), &features2);
+	return bool(storage16bit.uniformAndStorageBuffer16BitAccess);
+}
+
+
+bool vkt::subgroups::is8BitUBOStorageSupported(Context& context) {
+
+	VkPhysicalDevice8BitStorageFeatures storage8bit;
+	deMemset(&storage8bit, 0, sizeof(storage8bit));
+	storage8bit.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR;
+	storage8bit.pNext = DE_NULL;
+
+	VkPhysicalDeviceFeatures2 features2;
+	deMemset(&features2, 0, sizeof(features2));
+	features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+	features2.pNext = &storage8bit;
+
+
+	const PlatformInterface&		platformInterface = context.getPlatformInterface();
+	const VkInstance				instance = context.getInstance();
+	const InstanceDriver			instanceDriver(platformInterface, instance);
+
+	instanceDriver.getPhysicalDeviceFeatures2(context.getPhysicalDevice(), &features2);
+	return bool(storage8bit.uniformAndStorageBuffer8BitAccess);
+}
+
 bool vkt::subgroups::isFormatSupportedForDevice(Context& context, vk::VkFormat format)
 {
 	VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures subgroupExtendedTypesFeatures;
@@ -1998,6 +2039,46 @@
 	}
 }
 
+bool vkt::subgroups::isFormat8bitTy(VkFormat format)
+{
+	switch (format)
+	{
+	default:
+		return false;
+	case VK_FORMAT_R8_SINT:
+	case VK_FORMAT_R8G8_SINT:
+	case VK_FORMAT_R8G8B8_SINT:
+	case VK_FORMAT_R8G8B8A8_SINT:
+	case VK_FORMAT_R8_UINT:
+	case VK_FORMAT_R8G8_UINT:
+	case VK_FORMAT_R8G8B8_UINT:
+	case VK_FORMAT_R8G8B8A8_UINT:
+		return true;
+	}
+}
+
+bool vkt::subgroups::isFormat16BitTy(VkFormat format)
+{
+	switch (format)
+	{
+	default:
+		return false;
+	case VK_FORMAT_R16_SFLOAT:
+	case VK_FORMAT_R16G16_SFLOAT:
+	case VK_FORMAT_R16G16B16_SFLOAT:
+	case VK_FORMAT_R16G16B16A16_SFLOAT:
+	case VK_FORMAT_R16_SINT:
+	case VK_FORMAT_R16G16_SINT:
+	case VK_FORMAT_R16G16B16_SINT:
+	case VK_FORMAT_R16G16B16A16_SINT:
+	case VK_FORMAT_R16_UINT:
+	case VK_FORMAT_R16G16_UINT:
+	case VK_FORMAT_R16G16B16_UINT:
+	case VK_FORMAT_R16G16B16A16_UINT:
+		return true;
+	}
+}
+
 void vkt::subgroups::setVertexShaderFrameBuffer (SourceCollections& programCollection)
 {
 	/*
diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp
index 9cb4d54..167d42c 100644
--- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp
+++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsTestsUtils.hpp
@@ -141,6 +141,10 @@
 
 bool isTessellationAndGeometryPointSizeSupported(Context& context);
 
+bool is16BitUBOStorageSupported(Context& context);
+
+bool is8BitUBOStorageSupported(Context& context);
+
 bool isSubgroupBroadcastDynamicIdSupported(Context& context);
 
 std::string getFormatNameForGLSL (vk::VkFormat format);
@@ -153,6 +157,8 @@
 bool isFormatUnsigned (vk::VkFormat format);
 bool isFormatFloat (vk::VkFormat format);
 bool isFormatBool (vk::VkFormat format);
+bool isFormat8bitTy(vk::VkFormat format);
+bool isFormat16BitTy(vk::VkFormat format);
 
 void addGeometryShadersFromTemplate (const std::string& glslTemplate, const vk::ShaderBuildOptions& options, vk::GlslSourceCollection& collection);
 void addGeometryShadersFromTemplate (const std::string& spirvTemplate, const vk::SpirVAsmBuildOptions& options, vk::SpirVAsmCollection& collection);
diff --git a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp
index 0416791..2228170 100755
--- a/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp
+++ b/external/vulkancts/modules/vulkan/subgroups/vktSubgroupsVoteTests.cpp
@@ -120,6 +120,8 @@
 	VkFormat			format;
 	de::SharedPtr<bool>	geometryPointSizeSupported;
 	deBool				requiredSubgroupSize;
+	deBool              requires8BitUniformBuffer;
+	deBool              requires16BitUniformBuffer;
 };
 
 bool fmtIsBoolean(VkFormat format)
@@ -621,6 +623,22 @@
 	if (!subgroups::isFormatSupportedForDevice(context, caseDef.format))
 		TCU_THROW(NotSupportedError, "Device does not support the specified format in subgroup operations");
 
+	if (caseDef.requires16BitUniformBuffer)
+	{
+		if (!subgroups::is16BitUBOStorageSupported(context))
+		{
+			TCU_THROW(NotSupportedError, "Device does not support the specified format in subgroup operations");
+		}
+	}
+
+	if (caseDef.requires8BitUniformBuffer)
+	{
+		if (!subgroups::is8BitUBOStorageSupported(context))
+		{
+			TCU_THROW(NotSupportedError, "Device does not support the specified format in subgroup operations");
+		}
+	}
+
 	if (caseDef.opType > OPTYPE_LAST_NON_ARB)
 	{
 		context.requireDeviceFunctionality("VK_EXT_shader_subgroup_vote");
@@ -860,7 +878,7 @@
 			const std::string op = de::toLower(getOpTypeName(opTypeIndex));
 
 			{
-				CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_COMPUTE_BIT, format, de::SharedPtr<bool>(new bool), DE_FALSE};
+				CaseDefinition caseDef = { opTypeIndex, VK_SHADER_STAGE_COMPUTE_BIT, format, de::SharedPtr<bool>(new bool), DE_FALSE, deBool(false),deBool(false) };
 				if (opTypeIndex < OPTYPE_LAST_NON_ARB)
 				{
 					addFunctionCaseWithPrograms(computeGroup.get(),
@@ -884,7 +902,7 @@
 			}
 
 			{
-				const CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_ALL_GRAPHICS, format, de::SharedPtr<bool>(new bool), DE_FALSE};
+				const CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_ALL_GRAPHICS, format, de::SharedPtr<bool>(new bool), DE_FALSE, deBool(false),deBool(false) };
 				if (opTypeIndex < OPTYPE_LAST_NON_ARB)
 				{
 					addFunctionCaseWithPrograms(graphicGroup.get(),
@@ -901,7 +919,7 @@
 
 			for (int stageIndex = 0; stageIndex < DE_LENGTH_OF_ARRAY(stages); ++stageIndex)
 			{
-				const CaseDefinition caseDef = {opTypeIndex, stages[stageIndex], format, de::SharedPtr<bool>(new bool), DE_FALSE};
+				const CaseDefinition caseDef = {opTypeIndex, stages[stageIndex], format, de::SharedPtr<bool>(new bool), DE_FALSE, deBool(false),deBool(false) };
 				if (opTypeIndex < OPTYPE_LAST_NON_ARB)
 				{
 					addFunctionCaseWithPrograms(framebufferGroup.get(),
@@ -920,7 +938,9 @@
 				}
 			}
 
-			const CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_FRAGMENT_BIT, format, de::SharedPtr<bool>(new bool), DE_FALSE};
+			bool needs8BitUBOStorage = isFormat8bitTy(format);
+			bool needs16BitUBOStorage = isFormat16BitTy(format);
+			const CaseDefinition caseDef = {opTypeIndex, VK_SHADER_STAGE_FRAGMENT_BIT, format, de::SharedPtr<bool>(new bool), DE_FALSE, deBool(needs8BitUBOStorage),deBool(needs16BitUBOStorage) };
 			if (opTypeIndex < OPTYPE_LAST_NON_ARB)
 			{
 				addFunctionCaseWithPrograms(fragHelperGroup.get(),