Fix asserts due to missing texture formats

In has16bitTextureFormat(), we were missing several formats. Also this
function was poorly named, as it made it seem like we were just
duplicating the work of the bytes() function but giving less
informations. What has16bitTextureFormat() is really checking for is if
the texture format is 16 bit Packed. So it's been renamed to
has16bitPackedTextureFormat()

Bug: b/150076646
Change-Id: I8082e8e9d3845cfa3b5c3ec4a269454457d558ce
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/42688
Tested-by: Sean Risser <srisser@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index 2bb87c1..6540c06 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -1496,7 +1496,7 @@
 {
 	Vector4s c;
 
-	if(has16bitTextureFormat())
+	if(has16bitPackedTextureFormat())
 	{
 		c.x = Insert(c.x, Pointer<Short>(buffer)[index[0]], 0);
 		c.x = Insert(c.x, Pointer<Short>(buffer)[index[1]], 1);
@@ -2534,9 +2534,9 @@
 	       (state.textureType == VK_IMAGE_VIEW_TYPE_1D_ARRAY);  // Treated as 2D texture with second coordinate 0. TODO(b/134669567)
 }
 
-bool SamplerCore::has16bitTextureFormat() const
+bool SamplerCore::has16bitPackedTextureFormat() const
 {
-	return state.textureFormat.has16bitTextureFormat();
+	return state.textureFormat.has16bitPackedTextureFormat();
 }
 
 bool SamplerCore::has8bitTextureComponents() const
diff --git a/src/Pipeline/SamplerCore.hpp b/src/Pipeline/SamplerCore.hpp
index 5f00148..1fee321 100644
--- a/src/Pipeline/SamplerCore.hpp
+++ b/src/Pipeline/SamplerCore.hpp
@@ -103,7 +103,7 @@
 	bool hasUnsignedTextureComponent(int component) const;
 	int textureComponentCount() const;
 	bool hasThirdCoordinate() const;
-	bool has16bitTextureFormat() const;
+	bool has16bitPackedTextureFormat() const;
 	bool has8bitTextureComponents() const;
 	bool has16bitTextureComponents() const;
 	bool has32bitIntegerTextureComponents() const;
diff --git a/src/Vulkan/VkFormat.cpp b/src/Vulkan/VkFormat.cpp
index c392fdc..3053716 100644
--- a/src/Vulkan/VkFormat.cpp
+++ b/src/Vulkan/VkFormat.cpp
@@ -2228,66 +2228,30 @@
 	return sw::float4(1.0f, 1.0f, 1.0f, 1.0f);
 }
 
-bool Format::has16bitTextureFormat() const
+bool Format::has16bitPackedTextureFormat() const
 {
+	if(bytes() != 2)
+	{
+		return false;
+	}
+
 	switch(format)
 	{
 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
 			return true;
-		case VK_FORMAT_R8_SNORM:
-		case VK_FORMAT_R8G8_SNORM:
-		case VK_FORMAT_R8G8B8A8_SNORM:
-		case VK_FORMAT_R8_SINT:
-		case VK_FORMAT_R8_UINT:
 		case VK_FORMAT_R8G8_SINT:
 		case VK_FORMAT_R8G8_UINT:
-		case VK_FORMAT_R8G8B8A8_SINT:
-		case VK_FORMAT_R8G8B8A8_UINT:
-		case VK_FORMAT_R32_SINT:
-		case VK_FORMAT_R32_UINT:
-		case VK_FORMAT_R32G32_SINT:
-		case VK_FORMAT_R32G32_UINT:
-		case VK_FORMAT_R32G32B32A32_SINT:
-		case VK_FORMAT_R32G32B32A32_UINT:
 		case VK_FORMAT_R8G8_UNORM:
+		case VK_FORMAT_R8G8_SNORM:
 		case VK_FORMAT_R8G8_SRGB:
-		case VK_FORMAT_B8G8R8_UNORM:
-		case VK_FORMAT_B8G8R8A8_UNORM:
-		case VK_FORMAT_R8G8B8A8_UNORM:
-		case VK_FORMAT_B8G8R8_SRGB:
-		case VK_FORMAT_R8G8B8A8_SRGB:
-		case VK_FORMAT_B8G8R8A8_SRGB:
-		case VK_FORMAT_R32_SFLOAT:
-		case VK_FORMAT_R32G32_SFLOAT:
-		case VK_FORMAT_R32G32B32A32_SFLOAT:
-		case VK_FORMAT_R8_UNORM:
 		case VK_FORMAT_R16_UNORM:
-		case VK_FORMAT_R8_SRGB:
 		case VK_FORMAT_R16_SNORM:
-		case VK_FORMAT_R16G16_UNORM:
-		case VK_FORMAT_R16G16_SNORM:
-		case VK_FORMAT_R16G16B16A16_UNORM:
 		case VK_FORMAT_R16_SINT:
 		case VK_FORMAT_R16_UINT:
 		case VK_FORMAT_R16_SFLOAT:
-		case VK_FORMAT_R16G16_SINT:
-		case VK_FORMAT_R16G16_UINT:
-		case VK_FORMAT_R16G16_SFLOAT:
-		case VK_FORMAT_R16G16B16A16_SINT:
-		case VK_FORMAT_R16G16B16A16_UINT:
-		case VK_FORMAT_R16G16B16A16_SFLOAT:
-		case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
-		case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
-		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
-		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
-		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
-		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
-		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
-		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
 		case VK_FORMAT_D16_UNORM:
-		case VK_FORMAT_S8_UINT:
 			return false;
 		default:
 			UNSUPPORTED("Format: %d", int(format));
diff --git a/src/Vulkan/VkFormat.hpp b/src/Vulkan/VkFormat.hpp
index 6265130..d1334b2 100644
--- a/src/Vulkan/VkFormat.hpp
+++ b/src/Vulkan/VkFormat.hpp
@@ -61,7 +61,7 @@
 	sw::float4 getScale() const;
 
 	// Texture sampling utilities
-	bool has16bitTextureFormat() const;
+	bool has16bitPackedTextureFormat() const;
 	bool has8bitTextureComponents() const;
 	bool has16bitTextureComponents() const;
 	bool has32bitIntegerTextureComponents() const;
@@ -78,4 +78,4 @@
 
 }  // namespace vk
 
-#endif  // VK_FORMAT_HPP_
\ No newline at end of file
+#endif  // VK_FORMAT_HPP_