Commit 299fcf29 by Geoff Lang

Fix swizzle formats being assigned incorrectly.

* Non-4 component formats cannot be used as swizzle formats. * Unsized formats should not have swizzle formats. BUG=angle:721 Change-Id: Ic4e2642f5dc4c9811768961fbab00f6edd200ce1 Reviewed-on: https://chromium-review.googlesource.com/211241Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 592dbb8e
...@@ -658,43 +658,54 @@ static inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *map, GLenum internal ...@@ -658,43 +658,54 @@ static inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *map, GLenum internal
// Compute the swizzle formats // Compute the swizzle formats
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
if (internalFormat != GL_NONE && (formatInfo.componentCount == 4 || texFormat == DXGI_FORMAT_UNKNOWN || if (internalFormat != GL_NONE && formatInfo.pixelBytes > 0)
srvFormat == DXGI_FORMAT_UNKNOWN || rtvFormat == DXGI_FORMAT_UNKNOWN))
{ {
// Get the maximum sized component if (formatInfo.componentCount != 4 || texFormat == DXGI_FORMAT_UNKNOWN ||
unsigned int maxBits = 1; srvFormat == DXGI_FORMAT_UNKNOWN || rtvFormat == DXGI_FORMAT_UNKNOWN)
if (formatInfo.compressed)
{ {
unsigned int compressedBitsPerBlock = formatInfo.pixelBytes * 8; // Get the maximum sized component
unsigned int blockSize = formatInfo.compressedBlockWidth * formatInfo.compressedBlockHeight; unsigned int maxBits = 1;
maxBits = std::max(compressedBitsPerBlock / blockSize, maxBits); if (formatInfo.compressed)
{
unsigned int compressedBitsPerBlock = formatInfo.pixelBytes * 8;
unsigned int blockSize = formatInfo.compressedBlockWidth * formatInfo.compressedBlockHeight;
maxBits = std::max(compressedBitsPerBlock / blockSize, maxBits);
}
else
{
maxBits = std::max(maxBits, formatInfo.alphaBits);
maxBits = std::max(maxBits, formatInfo.redBits);
maxBits = std::max(maxBits, formatInfo.greenBits);
maxBits = std::max(maxBits, formatInfo.blueBits);
maxBits = std::max(maxBits, formatInfo.luminanceBits);
maxBits = std::max(maxBits, formatInfo.depthBits);
}
maxBits = roundUp(maxBits, 8U);
static const SwizzleInfoMap swizzleMap = BuildSwizzleInfoMap();
SwizzleInfoMap::const_iterator swizzleIter = swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType));
ASSERT(swizzleIter != swizzleMap.end());
const SwizzleFormatInfo &swizzleInfo = swizzleIter->second;
info.swizzleTexFormat = swizzleInfo.mTexFormat;
info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
} }
else else
{ {
maxBits = std::max(maxBits, formatInfo.alphaBits); // The original texture format is suitable for swizzle operations
maxBits = std::max(maxBits, formatInfo.redBits); info.swizzleTexFormat = texFormat;
maxBits = std::max(maxBits, formatInfo.greenBits); info.swizzleSRVFormat = srvFormat;
maxBits = std::max(maxBits, formatInfo.blueBits); info.swizzleRTVFormat = rtvFormat;
maxBits = std::max(maxBits, formatInfo.luminanceBits);
maxBits = std::max(maxBits, formatInfo.depthBits);
} }
maxBits = roundUp(maxBits, 8U);
static const SwizzleInfoMap swizzleMap = BuildSwizzleInfoMap();
SwizzleInfoMap::const_iterator swizzleIter = swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType));
ASSERT(swizzleIter != swizzleMap.end());
const SwizzleFormatInfo &swizzleInfo = swizzleIter->second;
info.swizzleTexFormat = swizzleInfo.mTexFormat;
info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
} }
else else
{ {
info.swizzleTexFormat = texFormat; // Not possible to swizzle with this texture format since it is either unsized or GL_NONE
info.swizzleSRVFormat = srvFormat; info.swizzleTexFormat = DXGI_FORMAT_UNKNOWN;
info.swizzleRTVFormat = rtvFormat; info.swizzleSRVFormat = DXGI_FORMAT_UNKNOWN;
info.swizzleRTVFormat = DXGI_FORMAT_UNKNOWN;
} }
// Check if there is an initialization function for this texture format // Check if there is an initialization function for this texture format
......
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