Commit c9625f16 by Sean Risser

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/+/42688Tested-by: 's avatarSean Risser <srisser@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d748e165
...@@ -1496,7 +1496,7 @@ Vector4s SamplerCore::sampleTexel(UInt index[4], Pointer<Byte> buffer) ...@@ -1496,7 +1496,7 @@ Vector4s SamplerCore::sampleTexel(UInt index[4], Pointer<Byte> buffer)
{ {
Vector4s c; 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[0]], 0);
c.x = Insert(c.x, Pointer<Short>(buffer)[index[1]], 1); c.x = Insert(c.x, Pointer<Short>(buffer)[index[1]], 1);
...@@ -2534,9 +2534,9 @@ bool SamplerCore::hasThirdCoordinate() const ...@@ -2534,9 +2534,9 @@ bool SamplerCore::hasThirdCoordinate() const
(state.textureType == VK_IMAGE_VIEW_TYPE_1D_ARRAY); // Treated as 2D texture with second coordinate 0. TODO(b/134669567) (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 bool SamplerCore::has8bitTextureComponents() const
......
...@@ -103,7 +103,7 @@ private: ...@@ -103,7 +103,7 @@ private:
bool hasUnsignedTextureComponent(int component) const; bool hasUnsignedTextureComponent(int component) const;
int textureComponentCount() const; int textureComponentCount() const;
bool hasThirdCoordinate() const; bool hasThirdCoordinate() const;
bool has16bitTextureFormat() const; bool has16bitPackedTextureFormat() const;
bool has8bitTextureComponents() const; bool has8bitTextureComponents() const;
bool has16bitTextureComponents() const; bool has16bitTextureComponents() const;
bool has32bitIntegerTextureComponents() const; bool has32bitIntegerTextureComponents() const;
......
...@@ -2228,66 +2228,30 @@ sw::float4 Format::getScale() const ...@@ -2228,66 +2228,30 @@ sw::float4 Format::getScale() const
return sw::float4(1.0f, 1.0f, 1.0f, 1.0f); 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) switch(format)
{ {
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_R5G6B5_UNORM_PACK16: case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
return true; 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_SINT:
case VK_FORMAT_R8G8_UINT: 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_UNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8_SRGB: 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_R16_UNORM:
case VK_FORMAT_R8_SRGB:
case VK_FORMAT_R16_SNORM: 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_SINT:
case VK_FORMAT_R16_UINT: case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16_SFLOAT: 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_D16_UNORM:
case VK_FORMAT_S8_UINT:
return false; return false;
default: default:
UNSUPPORTED("Format: %d", int(format)); UNSUPPORTED("Format: %d", int(format));
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
sw::float4 getScale() const; sw::float4 getScale() const;
// Texture sampling utilities // Texture sampling utilities
bool has16bitTextureFormat() const; bool has16bitPackedTextureFormat() const;
bool has8bitTextureComponents() const; bool has8bitTextureComponents() const;
bool has16bitTextureComponents() const; bool has16bitTextureComponents() const;
bool has32bitIntegerTextureComponents() const; bool has32bitIntegerTextureComponents() const;
...@@ -78,4 +78,4 @@ private: ...@@ -78,4 +78,4 @@ private:
} // namespace vk } // namespace vk
#endif // VK_FORMAT_HPP_ #endif // VK_FORMAT_HPP_
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment