Commit 58806567 by Bryan Bernhart Committed by Commit Bot

Apply max draw buffer limit for WebGL shaders.

For WebGL, using native caps incorrectly sets gl_MaxDrawBuffers. This change always applys the limit for compatible shaders. BUG=angleproject:1523 Change-Id: Ie956f4b9fdd10bdf9276ae08eaeb49e65690185b Reviewed-on: https://chromium-review.googlesource.com/425477 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c5a2a172
......@@ -594,7 +594,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32);
map["GL_EXT_texture_storage"] = esOnlyExtension(&Extensions::textureStorage);
map["GL_OES_texture_npot"] = enableableExtension(&Extensions::textureNPOT);
map["GL_EXT_draw_buffers"] = esOnlyExtension(&Extensions::drawBuffers);
map["GL_EXT_draw_buffers"] = enableableExtension(&Extensions::drawBuffers);
map["GL_EXT_texture_filter_anisotropic"] = esOnlyExtension(&Extensions::textureFilterAnisotropic);
map["GL_EXT_occlusion_query_boolean"] = esOnlyExtension(&Extensions::occlusionQueryBoolean);
map["GL_NV_fence"] = esOnlyExtension(&Extensions::fence);
......
......@@ -110,6 +110,11 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
mResources.MaxFragmentAtomicCounterBuffers = caps.maxFragmentAtomicCounterBuffers;
mResources.MaxCombinedAtomicCounterBuffers = caps.maxCombinedAtomicCounterBuffers;
mResources.MaxAtomicCounterBufferSize = caps.maxAtomicCounterBufferSize;
if (state.getClientMajorVersion() == 2 && !extensions.drawBuffers)
{
mResources.MaxDrawBuffers = 1;
}
}
Compiler::~Compiler()
......
......@@ -2293,11 +2293,14 @@ void Context::initExtensionStrings()
}
mExtensionString = mergeExtensionStrings(mExtensionStrings);
const gl::Extensions &nativeExtensions = mImplementation->getNativeExtensions();
mRequestableExtensionStrings.clear();
for (const auto &extensionInfo : GetExtensionInfoMap())
{
if (extensionInfo.second.Requestable &&
!(mExtensions.*(extensionInfo.second.ExtensionsMember)))
!(mExtensions.*(extensionInfo.second.ExtensionsMember)) &&
nativeExtensions.*(extensionInfo.second.ExtensionsMember))
{
mRequestableExtensionStrings.push_back(MakeStaticString(extensionInfo.first));
}
......@@ -2370,6 +2373,10 @@ void Context::requestExtension(const char *name)
mExtensions.*(extension.ExtensionsMember) = true;
updateCaps();
initExtensionStrings();
// Re-create the compiler with the requested extensions enabled.
SafeDelete(mCompiler);
mCompiler = new Compiler(mImplementation.get(), mState);
}
size_t Context::getRequestableExtensionStringCount() const
......
......@@ -151,8 +151,6 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign
case GL_MAX_TEXTURE_IMAGE_UNITS:
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
case GL_MAX_RENDERBUFFER_SIZE:
case GL_MAX_COLOR_ATTACHMENTS_EXT:
case GL_MAX_DRAW_BUFFERS_EXT:
case GL_NUM_SHADER_BINARY_FORMATS:
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
case GL_ARRAY_BUFFER_BINDING:
......@@ -214,6 +212,17 @@ bool ValidationContext::getQueryParameterInfo(GLenum pname, GLenum *type, unsign
*numParams = 1;
return true;
}
case GL_MAX_DRAW_BUFFERS_EXT:
case GL_MAX_COLOR_ATTACHMENTS_EXT:
{
if ((getClientMajorVersion() < 3) && !getExtensions().drawBuffers)
{
return false;
}
*type = GL_INT;
*numParams = 1;
return true;
}
case GL_MAX_SAMPLES_ANGLE:
{
if (!getExtensions().framebufferMultisample)
......
......@@ -589,6 +589,44 @@ TEST_P(WebGLCompatibilityTest, TextureCopyingFeedbackLoops)
EXPECT_GL_NO_ERROR();
}
// Test for the max draw buffers and color attachments.
TEST_P(WebGLCompatibilityTest, MaxDrawBuffersAttachmentPoints)
{
// This test only applies to ES2.
if (getClientMajorVersion() != 2)
{
return;
}
GLFramebuffer fbo[2];
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0].get());
// Test that is valid when we bind with a single attachment point.
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture.get());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0);
ASSERT_GL_NO_ERROR();
// Test that enabling the draw buffers extension will allow us to bind with a non-zero
// attachment point.
if (extensionRequestable("GL_EXT_draw_buffers"))
{
glRequestExtensionANGLE("GL_EXT_draw_buffers");
EXPECT_GL_NO_ERROR();
EXPECT_TRUE(extensionEnabled("GL_EXT_draw_buffers"));
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1].get());
GLTexture texture2;
glBindTexture(GL_TEXTURE_2D, texture2.get());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, texture2.get(),
0);
ASSERT_GL_NO_ERROR();
}
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(WebGLCompatibilityTest,
......
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