Commit 2a35741b by Bryan Bernhart (Intel Americas Inc) Committed by Commit Bot

WebGLCompatibility: Disable ES format extensions by default.

Prevents format validation errors with WebGL context. BUG=angleproject:1523 Change-Id: Iddc525eeb467de0139e166dad0893f3bea3ef35f Reviewed-on: https://chromium-review.googlesource.com/650807 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent aa9c396b
...@@ -618,7 +618,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -618,7 +618,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_packed_depth_stencil"] = esOnlyExtension(&Extensions::packedDepthStencil); map["GL_OES_packed_depth_stencil"] = esOnlyExtension(&Extensions::packedDepthStencil);
map["GL_OES_get_program_binary"] = esOnlyExtension(&Extensions::getProgramBinary); map["GL_OES_get_program_binary"] = esOnlyExtension(&Extensions::getProgramBinary);
map["GL_OES_rgb8_rgba8"] = esOnlyExtension(&Extensions::rgb8rgba8); map["GL_OES_rgb8_rgba8"] = esOnlyExtension(&Extensions::rgb8rgba8);
map["GL_EXT_texture_format_BGRA8888"] = esOnlyExtension(&Extensions::textureFormatBGRA8888); map["GL_EXT_texture_format_BGRA8888"] = enableableExtension(&Extensions::textureFormatBGRA8888);
map["GL_EXT_read_format_bgra"] = esOnlyExtension(&Extensions::readFormatBGRA); map["GL_EXT_read_format_bgra"] = esOnlyExtension(&Extensions::readFormatBGRA);
map["GL_NV_pixel_buffer_object"] = enableableExtension(&Extensions::pixelBufferObject); map["GL_NV_pixel_buffer_object"] = enableableExtension(&Extensions::pixelBufferObject);
map["GL_OES_mapbuffer"] = enableableExtension(&Extensions::mapBuffer); map["GL_OES_mapbuffer"] = enableableExtension(&Extensions::mapBuffer);
...@@ -628,7 +628,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -628,7 +628,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_texture_half_float_linear"] = enableableExtension(&Extensions::textureHalfFloatLinear); map["GL_OES_texture_half_float_linear"] = enableableExtension(&Extensions::textureHalfFloatLinear);
map["GL_OES_texture_float"] = enableableExtension(&Extensions::textureFloat); map["GL_OES_texture_float"] = enableableExtension(&Extensions::textureFloat);
map["GL_OES_texture_float_linear"] = enableableExtension(&Extensions::textureFloatLinear); map["GL_OES_texture_float_linear"] = enableableExtension(&Extensions::textureFloatLinear);
map["GL_EXT_texture_rg"] = esOnlyExtension(&Extensions::textureRG); map["GL_EXT_texture_rg"] = enableableExtension(&Extensions::textureRG);
map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1); map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1);
map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3); map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3);
map["GL_ANGLE_texture_compression_dxt5"] = esOnlyExtension(&Extensions::textureCompressionDXT5); map["GL_ANGLE_texture_compression_dxt5"] = esOnlyExtension(&Extensions::textureCompressionDXT5);
...@@ -636,7 +636,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -636,7 +636,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_KHR_texture_compression_astc_hdr"] = esOnlyExtension(&Extensions::textureCompressionASTCHDR); map["GL_KHR_texture_compression_astc_hdr"] = esOnlyExtension(&Extensions::textureCompressionASTCHDR);
map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR); map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR);
map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture); map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture);
map["GL_EXT_sRGB"] = esOnlyExtension(&Extensions::sRGB); map["GL_EXT_sRGB"] = enableableExtension(&Extensions::sRGB);
map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextures); map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextures);
map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32); map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32);
map["GL_EXT_texture_storage"] = esOnlyExtension(&Extensions::textureStorage); map["GL_EXT_texture_storage"] = esOnlyExtension(&Extensions::textureStorage);
......
...@@ -184,8 +184,8 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -184,8 +184,8 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
InsertFormatMapping(&map, GL_SRGB_ALPHA, VersionOrExts(2, 1, "GL_EXT_texture_sRGB"), AlwaysSupported(), VersionOrExts(2, 1, "GL_EXT_texture_sRGB"), ExtsOnly("GL_EXT_sRGB"), AlwaysSupported(), NeverSupported() ); InsertFormatMapping(&map, GL_SRGB_ALPHA, VersionOrExts(2, 1, "GL_EXT_texture_sRGB"), AlwaysSupported(), VersionOrExts(2, 1, "GL_EXT_texture_sRGB"), ExtsOnly("GL_EXT_sRGB"), AlwaysSupported(), NeverSupported() );
// From GL_EXT_texture_format_BGRA8888 // From GL_EXT_texture_format_BGRA8888
InsertFormatMapping(&map, GL_BGRA8_EXT, VersionOrExts(1, 2, "GL_EXT_bgra"), AlwaysSupported(), VersionOrExts(1, 2, "GL_EXT_bgra"), ExtsOnly("GL_EXT_texture_format_BGRA8888"), AlwaysSupported(), NeverSupported() ); InsertFormatMapping(&map, GL_BGRA8_EXT, VersionOrExts(1, 2, "GL_EXT_bgra"), AlwaysSupported(), VersionOrExts(1, 2, "GL_EXT_bgra"), ExtsOnly("GL_EXT_texture_format_BGRA8888"), AlwaysSupported(), VersionOrExts(2, 0, "GL_EXT_texture_format_BGRA8888"));
InsertFormatMapping(&map, GL_BGRA_EXT, VersionOrExts(1, 2, "GL_EXT_bgra"), AlwaysSupported(), VersionOrExts(1, 2, "GL_EXT_bgra"), ExtsOnly("GL_EXT_texture_format_BGRA8888"), AlwaysSupported(), NeverSupported() ); InsertFormatMapping(&map, GL_BGRA_EXT, VersionOrExts(1, 2, "GL_EXT_bgra"), AlwaysSupported(), VersionOrExts(1, 2, "GL_EXT_bgra"), ExtsOnly("GL_EXT_texture_format_BGRA8888"), AlwaysSupported(), VersionOrExts(2, 0, "GL_EXT_texture_format_BGRA8888"));
// Floating point formats // Floating point formats
// Note that GL_EXT_texture_shared_exponent and GL_ARB_color_buffer_float suggest that RGB9_E5 // Note that GL_EXT_texture_shared_exponent and GL_ARB_color_buffer_float suggest that RGB9_E5
......
...@@ -1010,6 +1010,10 @@ void GenerateCaps(const FunctionsGL *functions, ...@@ -1010,6 +1010,10 @@ void GenerateCaps(const FunctionsGL *functions,
// framebuffer with GL_FRAMEBUFFER_SRGB enabled and then reading back returns the same value. // framebuffer with GL_FRAMEBUFFER_SRGB enabled and then reading back returns the same value.
// Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction. // Disabling GL_FRAMEBUFFER_SRGB will then convert in the wrong direction.
extensions->sRGBWriteControl = false; extensions->sRGBWriteControl = false;
// BGRA formats do not appear to be accepted by the Nexus 5X driver dispite the extension being
// exposed.
extensions->textureFormatBGRA8888 = false;
#endif #endif
// EXT_discard_framebuffer can be implemented as long as glDiscardFramebufferEXT or // EXT_discard_framebuffer can be implemented as long as glDiscardFramebufferEXT or
......
...@@ -1285,8 +1285,14 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1285,8 +1285,14 @@ bool ValidateES2TexImageParameters(Context *context,
switch (type) switch (type)
{ {
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
break;
case GL_FLOAT: case GL_FLOAT:
case GL_HALF_FLOAT_OES: case GL_HALF_FLOAT_OES:
if (!context->getExtensions().textureFloat)
{
context->handleError(InvalidEnum());
return false;
}
break; break;
default: default:
ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat); ANGLE_VALIDATION_ERR(context, InvalidOperation(), MismatchedTypeAndFormat);
...@@ -1321,6 +1327,11 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -1321,6 +1327,11 @@ bool ValidateES2TexImageParameters(Context *context,
} }
break; break;
case GL_BGRA_EXT: case GL_BGRA_EXT:
if (!context->getExtensions().textureFormatBGRA8888)
{
context->handleError(InvalidEnum());
return false;
}
switch (type) switch (type)
{ {
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
......
...@@ -256,10 +256,8 @@ TEST_P(CopyTextureTest, InternalFormat) ...@@ -256,10 +256,8 @@ TEST_P(CopyTextureTest, InternalFormat)
// Test to ensure that the destination texture is redefined if the properties are different. // Test to ensure that the destination texture is redefined if the properties are different.
TEST_P(CopyTextureTest, RedefineDestinationTexture) TEST_P(CopyTextureTest, RedefineDestinationTexture)
{ {
if (!checkExtensions()) ANGLE_SKIP_TEST_IF(!checkExtensions());
{ ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_format_BGRA8888"));
return;
}
GLColor pixels[4] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red}; GLColor pixels[4] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red};
......
...@@ -227,6 +227,9 @@ class WebGLCompatibilityTest : public ANGLETest ...@@ -227,6 +227,9 @@ class WebGLCompatibilityTest : public ANGLETest
const std::array<GLenum, 2> &drawBuffers, const std::array<GLenum, 2> &drawBuffers,
GLenum expectedError); GLenum expectedError);
// Called from InvalidTextureFormat
void validateTexImageExtensionFormat(GLenum format, const std::string &extName);
PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE = nullptr; PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE = nullptr;
}; };
...@@ -3553,6 +3556,51 @@ TEST_P(WebGLCompatibilityTest, GenerateMipmapSizedFloatingPointTexture) ...@@ -3553,6 +3556,51 @@ TEST_P(WebGLCompatibilityTest, GenerateMipmapSizedFloatingPointTexture)
} }
} }
// Verify that a texture format is only allowed with extension enabled.
void WebGLCompatibilityTest::validateTexImageExtensionFormat(GLenum format,
const std::string &extName)
{
// Verify texture format fails by default.
glTexImage2D(GL_TEXTURE_2D, 0, format, 1, 1, 0, format, GL_UNSIGNED_BYTE, nullptr);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
if (extensionRequestable(extName))
{
// Verify texture format is allowed once extension is enabled.
glRequestExtensionANGLE(extName.c_str());
EXPECT_TRUE(extensionEnabled(extName));
glTexImage2D(GL_TEXTURE_2D, 0, format, 1, 1, 0, format, GL_UNSIGNED_BYTE, nullptr);
ASSERT_GL_NO_ERROR();
}
}
// Verify that only valid texture formats are allowed.
TEST_P(WebGLCompatibilityTest, InvalidTextureFormat)
{
ANGLE_SKIP_TEST_IF(getClientMajorVersion() != 2);
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture.get());
// Verify valid format is allowed.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
ASSERT_GL_NO_ERROR();
// Verify invalid format fails.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 1, 1, 0, GL_RGBA32F, GL_UNSIGNED_BYTE, nullptr);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
// Verify formats from enableable extensions.
if (!IsAndroid())
{
validateTexImageExtensionFormat(GL_RED_EXT, "GL_EXT_texture_rg");
}
validateTexImageExtensionFormat(GL_SRGB_EXT, "GL_EXT_texture_sRGB");
validateTexImageExtensionFormat(GL_BGRA_EXT, "GL_EXT_texture_format_BGRA8888");
}
// Linking should fail when corresponding vertex/fragment uniform blocks have different precision // Linking should fail when corresponding vertex/fragment uniform blocks have different precision
// qualifiers. // qualifiers.
TEST_P(WebGL2CompatibilityTest, UniformBlockPrecisionMismatch) TEST_P(WebGL2CompatibilityTest, UniformBlockPrecisionMismatch)
......
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