Expose Vulkan 1.3

This CL exposes Vulkan 1.3 in SwiftShader.

Tests: dEQP-VK.*
Bug: b/204169571
Change-Id: I9da0075eb7bf07e266be8769ea1207103df4ece2
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/61988
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/SpirvShaderImage.cpp b/src/Pipeline/SpirvShaderImage.cpp
index 30bc61b..c82d576 100644
--- a/src/Pipeline/SpirvShaderImage.cpp
+++ b/src/Pipeline/SpirvShaderImage.cpp
@@ -238,6 +238,13 @@
 		imageOperands &= ~spv::ImageOperandsVolatileTexelMask;
 	}
 
+	if(imageOperands & spv::ImageOperandsNontemporalMask)
+	{
+		// Hints that the accessed texels are not likely
+		// to be accessed again in the near future.
+		imageOperands &= ~spv::ImageOperandsNontemporalMask;
+	}
+
 	// There should be no remaining image operands.
 	if(imageOperands != 0)
 	{
diff --git a/src/Vulkan/VkConfig.hpp b/src/Vulkan/VkConfig.hpp
index f0816b8..fba81b4 100644
--- a/src/Vulkan/VkConfig.hpp
+++ b/src/Vulkan/VkConfig.hpp
@@ -27,9 +27,9 @@
 #define SWIFTSHADER_DEVICE_NAME "SwiftShader Device"  // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE
 #define SWIFTSHADER_UUID "SwiftShaderUUID"            // Max length: VK_UUID_SIZE (16)
 
-constexpr spv_target_env SPIRV_VERSION = SPV_ENV_VULKAN_1_2;
+constexpr spv_target_env SPIRV_VERSION = SPV_ENV_VULKAN_1_3;
 
-constexpr uint32_t API_VERSION = VK_API_VERSION_1_2;
+constexpr uint32_t API_VERSION = VK_API_VERSION_1_3;
 constexpr uint32_t DRIVER_VERSION = VK_MAKE_VERSION(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION);
 constexpr uint32_t VENDOR_ID = 0x1AE0;  // Google, Inc.: https://pcisig.com/google-inc-1
 constexpr uint32_t DEVICE_ID = 0xC0DE;  // SwiftShader (placeholder)
diff --git a/src/Vulkan/VkGetProcAddress.cpp b/src/Vulkan/VkGetProcAddress.cpp
index a8d4651..c34ffac 100644
--- a/src/Vulkan/VkGetProcAddress.cpp
+++ b/src/Vulkan/VkGetProcAddress.cpp
@@ -103,6 +103,8 @@
 	MAKE_VULKAN_INSTANCE_ENTRY(vkSetDebugUtilsObjectNameEXT),
 	MAKE_VULKAN_INSTANCE_ENTRY(vkSetDebugUtilsObjectTagEXT),
 	MAKE_VULKAN_INSTANCE_ENTRY(vkSubmitDebugUtilsMessageEXT),
+	// VK_EXT_tooling_info
+	MAKE_VULKAN_INSTANCE_ENTRY(vkGetPhysicalDeviceToolProperties),
 #ifndef __ANDROID__
 	// VK_KHR_surface
 	MAKE_VULKAN_INSTANCE_ENTRY(vkDestroySurfaceKHR),
@@ -331,6 +333,50 @@
 	// VK_KHR_draw_indirect_count
 	MAKE_VULKAN_DEVICE_ENTRY(vkCmdDrawIndirectCount),
 	MAKE_VULKAN_DEVICE_ENTRY(vkCmdDrawIndexedIndirectCount),
+	// Vulkan 1.3 Entry point functions
+	// VK_KHR_copy_commands2
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdCopyBuffer2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdCopyImage2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdCopyBufferToImage2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdCopyImageToBuffer2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdBlitImage2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdResolveImage2),
+	// VK_KHR_dynamic_rendering
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdBeginRendering),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdEndRendering),
+	// VK_KHR_maintenance4
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetDeviceBufferMemoryRequirements),
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetDeviceImageMemoryRequirements),
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetDeviceImageSparseMemoryRequirements),
+	// VK_KHR_synchronization2
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetEvent2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdResetEvent2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdWaitEvents2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdPipelineBarrier2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdWriteTimestamp2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkQueueSubmit2),
+	// VK_EXT_extended_dynamic_state
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetCullMode),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetFrontFace),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetPrimitiveTopology),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetViewportWithCount),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetScissorWithCount),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdBindVertexBuffers2),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetDepthTestEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetDepthWriteEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetDepthCompareOp),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetDepthBoundsTestEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetStencilTestEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetStencilOp),
+	// VK_EXT_extended_dynamic_state2 (partial promotion, VKCmdSetLogicOpEXT and VKCmdSetPatchControlPointsEXT are not promoted)
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetRasterizerDiscardEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetDepthBiasEnable),
+	MAKE_VULKAN_DEVICE_ENTRY(vkCmdSetPrimitiveRestartEnable),
+	// VK_EXT_private_data
+	MAKE_VULKAN_DEVICE_ENTRY(vkCreatePrivateDataSlot),
+	MAKE_VULKAN_DEVICE_ENTRY(vkDestroyPrivateDataSlot),
+	MAKE_VULKAN_DEVICE_ENTRY(vkSetPrivateData),
+	MAKE_VULKAN_DEVICE_ENTRY(vkGetPrivateData),
 };
 
 // TODO(b/208256248): Avoid exit-time destructor.
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 5163496..bf7a1fe 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -579,6 +579,10 @@
 		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES:
 			getPhysicalDeviceMaintenance4Features(reinterpret_cast<struct VkPhysicalDeviceMaintenance4Features *>(curExtension));
 			break;
+		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT:
+			// Workaround for a test bug (see https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/3564)
+			reinterpret_cast<struct VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT *>(curExtension)->texelBufferAlignment = VK_TRUE;
+			break;
 		case VK_STRUCTURE_TYPE_MAX_ENUM:  // TODO(b/176893525): This may not be legal. dEQP tests that this value is ignored.
 			break;
 		default:
@@ -1317,6 +1321,8 @@
 {
 	getSubgroupSizeControlProperties(properties);
 	getInlineUniformBlockProperties(properties);
+	properties->maxInlineUniformTotalSize = properties->maxInlineUniformBlockSize *
+	                                        properties->maxDescriptorSetInlineUniformBlocks;
 	getShaderIntegerDotProductProperties(properties);
 	getTexelBufferAlignmentProperties(properties);
 	getMaintenance4Properties(properties);
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index cfc15b8..2019b87 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -1044,6 +1044,10 @@
 		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT:
 		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES:
 		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES:
+		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES:
+			break;
+		case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT:
+			// Workaround for a test bug (see https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/3564)
 			break;
 		default:
 			// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
diff --git a/tests/VulkanUnitTests/BasicTests.cpp b/tests/VulkanUnitTests/BasicTests.cpp
index 9629212..b9e0767 100644
--- a/tests/VulkanUnitTests/BasicTests.cpp
+++ b/tests/VulkanUnitTests/BasicTests.cpp
@@ -62,7 +62,7 @@
 TEST_F(BasicTest, Version)
 {
 	uint32_t apiVersion = 0;
-	uint32_t expectedVersion = static_cast<uint32_t>(VK_API_VERSION_1_2);
+	uint32_t expectedVersion = static_cast<uint32_t>(VK_API_VERSION_1_3);
 	VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion);
 	EXPECT_EQ(apiVersion, expectedVersion);