Commit 08c24e6e by Jamie Madill Committed by Commit Bot

ES: Don't expose EXT_draw_buffers if extension not present.

Emulation of this extension would potentially require rewriting ESSL 1.00 shaders as 3.00 when the extension is missing, and we're on a GLES 3.0 context. For now, it's easier to disable the extension when native support is lacking. BUG=angleproject:1828 Change-Id: I8eabb8efccc2ddd5fafd3521657ea68cc9e1d1e0 Reviewed-on: https://chromium-review.googlesource.com/436144 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 786ad387
......@@ -794,8 +794,10 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_map_buffer_range");
extensions->textureNPOT = functions->standard == STANDARD_GL_DESKTOP ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_OES_texture_npot");
extensions->drawBuffers = functions->isAtLeastGL(gl::Version(2, 0)) || functions->hasGLExtension("ARB_draw_buffers") ||
functions->isAtLeastGLES(gl::Version(3, 0)) || functions->hasGLESExtension("GL_EXT_draw_buffers");
// TODO(jmadill): Investigate emulating EXT_draw_buffers on ES 3.0's core functionality.
extensions->drawBuffers = functions->isAtLeastGL(gl::Version(2, 0)) ||
functions->hasGLExtension("ARB_draw_buffers") ||
functions->hasGLESExtension("GL_EXT_draw_buffers");
extensions->textureStorage = true;
extensions->textureFilterAnisotropic = functions->hasGLExtension("GL_EXT_texture_filter_anisotropic") || functions->hasGLESExtension("GL_EXT_texture_filter_anisotropic");
extensions->occlusionQueryBoolean = nativegl::SupportsOcclusionQueries(functions);
......
......@@ -24,7 +24,7 @@ class DrawBuffersTest : public ANGLETest
mMaxDrawBuffers = 0;
}
virtual void SetUp()
void SetUp() override
{
ANGLETest::SetUp();
......@@ -54,12 +54,15 @@ class DrawBuffersTest : public ANGLETest
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6, data, GL_STATIC_DRAW);
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &mMaxDrawBuffers);
if (checkSupport())
{
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &mMaxDrawBuffers);
}
ASSERT_GL_NO_ERROR();
}
virtual void TearDown()
void TearDown() override
{
glDeleteFramebuffers(1, &mFBO);
glDeleteTextures(4, mTextures);
......@@ -68,6 +71,27 @@ class DrawBuffersTest : public ANGLETest
ANGLETest::TearDown();
}
// We must call a different DrawBuffers method depending on extension support. Use this
// method instead of calling on directly.
void setDrawBuffers(GLsizei n, const GLenum *drawBufs)
{
if (extensionEnabled("GL_EXT_draw_buffers"))
{
glDrawBuffersEXT(n, drawBufs);
}
else
{
ASSERT_GE(getClientMajorVersion(), 3);
glDrawBuffers(n, drawBufs);
}
}
// Use this method to filter if we can support these tests.
bool checkSupport()
{
return (getClientMajorVersion() >= 3 || extensionEnabled("GL_EXT_draw_buffers"));
}
void setupMRTProgramESSL3(bool bufferEnabled[8], GLuint *programOut)
{
const std::string vertexShaderSource =
......@@ -249,7 +273,7 @@ TEST_P(DrawBuffersTest, VerifyD3DLimits)
TEST_P(DrawBuffersTest, Gaps)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_draw_buffers"))
if (!checkSupport())
{
std::cout << "Test skipped because ES3 or GL_EXT_draw_buffers is not available."
<< std::endl;
......@@ -277,7 +301,7 @@ TEST_P(DrawBuffersTest, Gaps)
GL_COLOR_ATTACHMENT1
};
glUseProgram(program);
glDrawBuffersEXT(2, bufs);
setDrawBuffers(2, bufs);
glDrawArrays(GL_TRIANGLES, 0, 3);
verifyAttachment2D(1, mTextures[0], GL_TEXTURE_2D, 0);
......@@ -287,7 +311,7 @@ TEST_P(DrawBuffersTest, Gaps)
TEST_P(DrawBuffersTest, FirstAndLast)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_draw_buffers"))
if (!checkSupport())
{
std::cout << "Test skipped because ES3 or GL_EXT_draw_buffers is not available."
<< std::endl;
......@@ -321,7 +345,7 @@ TEST_P(DrawBuffersTest, FirstAndLast)
};
glUseProgram(program);
glDrawBuffersEXT(4, bufs);
setDrawBuffers(4, bufs);
glDrawArrays(GL_TRIANGLES, 0, 3);
verifyAttachment2D(0, mTextures[0], GL_TEXTURE_2D, 0);
......@@ -334,7 +358,7 @@ TEST_P(DrawBuffersTest, FirstAndLast)
TEST_P(DrawBuffersTest, FirstHalfNULL)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_draw_buffers"))
if (!checkSupport())
{
std::cout << "Test skipped because ES3 or GL_EXT_draw_buffers is not available."
<< std::endl;
......@@ -365,7 +389,7 @@ TEST_P(DrawBuffersTest, FirstHalfNULL)
setupMRTProgram(flags, &program);
glUseProgram(program);
glDrawBuffersEXT(mMaxDrawBuffers, bufs);
setDrawBuffers(mMaxDrawBuffers, bufs);
glDrawArrays(GL_TRIANGLES, 0, 3);
for (GLuint texIndex = 0; texIndex < halfMaxDrawBuffers; texIndex++)
......@@ -380,7 +404,7 @@ TEST_P(DrawBuffersTest, FirstHalfNULL)
TEST_P(DrawBuffersTest, UnwrittenOutputVariablesShouldNotCrash)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_draw_buffers"))
if (!checkSupport())
{
std::cout << "Test skipped because ES3 or GL_EXT_draw_buffers is not available."
<< std::endl;
......@@ -408,7 +432,7 @@ TEST_P(DrawBuffersTest, UnwrittenOutputVariablesShouldNotCrash)
};
glUseProgram(program);
glDrawBuffersEXT(4, bufs);
setDrawBuffers(4, bufs);
// This call should not crash when we dynamically generate the HLSL code.
glDrawArrays(GL_TRIANGLES, 0, 3);
......@@ -420,15 +444,13 @@ TEST_P(DrawBuffersTest, UnwrittenOutputVariablesShouldNotCrash)
glDeleteProgram(program);
}
// Test that binding multiple layers of a 3D texture works correctly
TEST_P(DrawBuffersTest, 3DTextures)
class DrawBuffersTestES3 : public DrawBuffersTest
{
if (getClientMajorVersion() < 3)
{
std::cout << "Test skipped because ES3 is not available." << std::endl;
return;
}
};
// Test that binding multiple layers of a 3D texture works correctly
TEST_P(DrawBuffersTestES3, 3DTextures)
{
GLTexture texture;
glBindTexture(GL_TEXTURE_3D, texture.get());
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), getWindowWidth(),
......@@ -449,7 +471,7 @@ TEST_P(DrawBuffersTest, 3DTextures)
};
glUseProgram(program);
glDrawBuffersEXT(4, bufs);
glDrawBuffers(4, bufs);
glDrawArrays(GL_TRIANGLES, 0, 3);
......@@ -464,14 +486,8 @@ TEST_P(DrawBuffersTest, 3DTextures)
}
// Test that binding multiple layers of a 2D array texture works correctly
TEST_P(DrawBuffersTest, 2DArrayTextures)
TEST_P(DrawBuffersTestES3, 2DArrayTextures)
{
if (getClientMajorVersion() < 3)
{
std::cout << "Test skipped because ES3 is not available." << std::endl;
return;
}
GLTexture texture;
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, getWindowWidth(), getWindowHeight(),
......@@ -492,7 +508,7 @@ TEST_P(DrawBuffersTest, 2DArrayTextures)
};
glUseProgram(program);
glDrawBuffersEXT(4, bufs);
glDrawBuffers(4, bufs);
glDrawArrays(GL_TRIANGLES, 0, 3);
......@@ -515,3 +531,5 @@ ANGLE_INSTANTIATE_TEST(DrawBuffersTest,
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES());
ANGLE_INSTANTIATE_TEST(DrawBuffersTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
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