Commit 3e92206b by Geoff Lang Committed by Commit Bot

Allow querying of all draw buffer states on the default framebuffer.

Because the default framebuffer isn't tied to a specific context, its drawbuffer state vector was only of size 1. It is still valid to query up to GL_MAX_DRAW_BUFFERS through so a special case is added when the drawbuffer is larger than the state vector. BUG=angleproject:2965 Change-Id: Ib49570df67e59e93932a7e916fe72f2e71c29939 Reviewed-on: https://chromium-review.googlesource.com/c/1337453Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 872f6ebd
...@@ -2216,10 +2216,15 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params) ...@@ -2216,10 +2216,15 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params)
{ {
if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT) if (pname >= GL_DRAW_BUFFER0_EXT && pname <= GL_DRAW_BUFFER15_EXT)
{ {
unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0_EXT); size_t drawBuffer = (pname - GL_DRAW_BUFFER0_EXT);
ASSERT(colorAttachment < mMaxDrawBuffers); ASSERT(drawBuffer < mMaxDrawBuffers);
Framebuffer *framebuffer = mDrawFramebuffer; Framebuffer *framebuffer = mDrawFramebuffer;
*params = framebuffer->getDrawBufferState(colorAttachment); // The default framebuffer may have fewer draw buffer states than a user-created one. The
// user is always allowed to query up to GL_MAX_DRAWBUFFERS so just return GL_NONE here if
// the draw buffer is out of range for this framebuffer.
*params = drawBuffer < framebuffer->getDrawbufferStateCount()
? framebuffer->getDrawBufferState(drawBuffer)
: GL_NONE;
return NoError(); return NoError();
} }
......
...@@ -352,6 +352,20 @@ TEST_P(DrawBuffersTest, FirstHalfNULL) ...@@ -352,6 +352,20 @@ TEST_P(DrawBuffersTest, FirstHalfNULL)
glDeleteProgram(program); glDeleteProgram(program);
} }
// Test that non-zero draw buffers can be queried on the default framebuffer
TEST_P(DrawBuffersTest, DefaultFramebufferDrawBufferQuery)
{
ANGLE_SKIP_TEST_IF(!setupTest());
glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLint drawbuffer = 0;
glGetIntegerv(GL_DRAW_BUFFER1, &drawbuffer);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(GL_NONE, drawbuffer);
}
// Tests masking out some of the draw buffers by not writing to them in the program. // Tests masking out some of the draw buffers by not writing to them in the program.
TEST_P(DrawBuffersWebGL2Test, SomeProgramOutputsDisabled) TEST_P(DrawBuffersWebGL2Test, SomeProgramOutputsDisabled)
{ {
......
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