Commit a272a8ac by Alexey Knyazev Committed by Commit Bot

Fix PVRTC1 frontend validation

PVRTC1 texture dimensions must always be powers of two. Moreover, Apple hardware requires them to be squares. Bug: angleproject:5731, angleproject:2634 Change-Id: I5fcdc364b37d17b60cf772c21ba38795272236fd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2741585Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
parent 92b5fccd
...@@ -775,6 +775,9 @@ struct Limitations ...@@ -775,6 +775,9 @@ struct Limitations
// Renderer doesn't support GL_TEXTURE_COMPARE_MODE=GL_NONE on a shadow sampler. // Renderer doesn't support GL_TEXTURE_COMPARE_MODE=GL_NONE on a shadow sampler.
// TODO(http://anglebug.com/5231): add validation code to front-end. // TODO(http://anglebug.com/5231): add validation code to front-end.
bool noShadowSamplerCompareModeNone = false; bool noShadowSamplerCompareModeNone = false;
// PVRTC1 textures must be squares.
bool squarePvrtc1 = false;
}; };
struct TypePrecision struct TypePrecision
......
...@@ -1521,21 +1521,7 @@ bool CompressedFormatRequiresWholeImage(GLenum internalFormat) ...@@ -1521,21 +1521,7 @@ bool CompressedFormatRequiresWholeImage(GLenum internalFormat)
{ {
// List of compressed texture format that require that the sub-image size is equal to texture's // List of compressed texture format that require that the sub-image size is equal to texture's
// respective mip level's size // respective mip level's size
switch (internalFormat) return IsPVRTC1Format(internalFormat);
{
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
return true;
default:
return false;
}
} }
void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType) void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType)
......
...@@ -423,6 +423,25 @@ ANGLE_INLINE bool IsETC2EACFormat(const GLenum format) ...@@ -423,6 +423,25 @@ ANGLE_INLINE bool IsETC2EACFormat(const GLenum format)
} }
} }
ANGLE_INLINE bool IsPVRTC1Format(const GLenum format)
{
switch (format)
{
case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
return true;
default:
return false;
}
}
// Check if an internal format is ever valid in ES3. Makes no checks about support for a specific // Check if an internal format is ever valid in ES3. Makes no checks about support for a specific
// context. // context.
bool ValidES3InternalFormat(GLenum internalFormat); bool ValidES3InternalFormat(GLenum internalFormat);
......
...@@ -264,10 +264,11 @@ const gl::Version &RendererGL::getMaxSupportedESVersion() const ...@@ -264,10 +264,11 @@ const gl::Version &RendererGL::getMaxSupportedESVersion() const
void RendererGL::generateCaps(gl::Caps *outCaps, void RendererGL::generateCaps(gl::Caps *outCaps,
gl::TextureCapsMap *outTextureCaps, gl::TextureCapsMap *outTextureCaps,
gl::Extensions *outExtensions, gl::Extensions *outExtensions,
gl::Limitations * /* outLimitations */) const gl::Limitations *outLimitations) const
{ {
nativegl_gl::GenerateCaps(mFunctions.get(), mFeatures, outCaps, outTextureCaps, outExtensions, nativegl_gl::GenerateCaps(mFunctions.get(), mFeatures, outCaps, outTextureCaps, outExtensions,
&mMaxSupportedESVersion, &mMultiviewImplementationType); outLimitations, &mMaxSupportedESVersion,
&mMultiviewImplementationType);
} }
GLint RendererGL::getGPUDisjoint() GLint RendererGL::getGPUDisjoint()
......
...@@ -541,6 +541,7 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -541,6 +541,7 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps, gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap, gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions, gl::Extensions *extensions,
gl::Limitations *limitations,
gl::Version *maxSupportedESVersion, gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType) MultiviewImplementationTypeGL *multiviewImplementationType)
{ {
...@@ -1667,6 +1668,12 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1667,6 +1668,12 @@ void GenerateCaps(const FunctionsGL *functions,
} }
extensions->yuvTargetEXT = functions->hasGLESExtension("GL_EXT_YUV_target"); extensions->yuvTargetEXT = functions->hasGLESExtension("GL_EXT_YUV_target");
// PVRTC1 textures must be squares on Apple platforms.
if (IsApple())
{
limitations->squarePvrtc1 = true;
}
} }
bool GetSystemInfoVendorIDAndDeviceID(const FunctionsGL *functions, bool GetSystemInfoVendorIDAndDeviceID(const FunctionsGL *functions,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_ #define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
#include "common/debug.h" #include "common/debug.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/Version.h" #include "libANGLE/Version.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
...@@ -101,6 +102,7 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -101,6 +102,7 @@ void GenerateCaps(const FunctionsGL *functions,
gl::Caps *caps, gl::Caps *caps,
gl::TextureCapsMap *textureCapsMap, gl::TextureCapsMap *textureCapsMap,
gl::Extensions *extensions, gl::Extensions *extensions,
gl::Limitations *limitations,
gl::Version *maxSupportedESVersion, gl::Version *maxSupportedESVersion,
MultiviewImplementationTypeGL *multiviewImplementationType); MultiviewImplementationTypeGL *multiviewImplementationType);
......
...@@ -613,6 +613,9 @@ void DisplayMtl::ensureCapsInitialized() const ...@@ -613,6 +613,9 @@ void DisplayMtl::ensureCapsInitialized() const
// Metal doesn't support GL_TEXTURE_COMPARE_MODE=GL_NONE for shadow samplers // Metal doesn't support GL_TEXTURE_COMPARE_MODE=GL_NONE for shadow samplers
mNativeLimitations.noShadowSamplerCompareModeNone = true; mNativeLimitations.noShadowSamplerCompareModeNone = true;
// Apple platforms require PVRTC1 textures to be squares.
mNativeLimitations.squarePvrtc1 = true;
} }
void DisplayMtl::initializeExtensions() const void DisplayMtl::initializeExtensions() const
......
...@@ -1024,6 +1024,23 @@ bool ValidCompressedImageSize(const Context *context, ...@@ -1024,6 +1024,23 @@ bool ValidCompressedImageSize(const Context *context,
return false; return false;
} }
// Only PVRTC1 requires dimensions to be powers of two
if (IsPVRTC1Format(internalFormat))
{
if (!isPow2(width) || !isPow2(height))
{
return false;
}
if (context->getLimitations().squarePvrtc1)
{
if (width != height)
{
return false;
}
}
}
if (CompressedTextureFormatRequiresExactSize(internalFormat)) if (CompressedTextureFormatRequiresExactSize(internalFormat))
{ {
if (!ValidCompressedDimension(width, formatInfo.compressedBlockWidth, level) || if (!ValidCompressedDimension(width, formatInfo.compressedBlockWidth, level) ||
......
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