summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2012-12-18 13:26:03 -0800
committerIan Romanick <[email protected]>2013-01-15 14:59:40 -0800
commitfd3891cbbe8f11c297edf0a6bf0580f69024722e (patch)
tree5b0982b00ce32c2a6aa774a19910fc42a1f2df16 /src/mesa
parentd786bf2c2acbafe2ac32e7fd5b8f9a6b09f3d968 (diff)
mesa: Handle GL_BACK correctly for ES 3.0 in glDrawBuffers().
In ES 3.0, when calling glDrawBuffers() on the window system framebuffer, the only valid targets are GL_NONE or GL_BACK. Since there is no stereo rendering in ES 3.0, this is a single buffer, unlike desktop where it may be two (and thus isn't allowed). For single-buffered configs, GL_BACK ironically means the front (and only) buffer. I'm not sure that it matters, however, as ES shouldn't have front buffer rendering in the first place. Fixes es3conform framebuffer_blit_coverage_default_draw_buffer_binding. v2: Update GLES3 spec reference. Signed-off-by: Anuj Phogat <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Signed-off-by: Ian Romanick <[email protected]> [v2] Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> [v1]
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/buffers.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 3dcd46f0180..b4f324c6c91 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -94,7 +94,7 @@ supported_buffer_bitmask(const struct gl_context *ctx,
* GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
*/
static GLbitfield
-draw_buffer_enum_to_bitmask(GLenum buffer)
+draw_buffer_enum_to_bitmask(const struct gl_context *ctx, GLenum buffer)
{
switch (buffer) {
case GL_NONE:
@@ -102,6 +102,21 @@ draw_buffer_enum_to_bitmask(GLenum buffer)
case GL_FRONT:
return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
case GL_BACK:
+ if (_mesa_is_gles3(ctx)) {
+ /* Page 181 (page 192 of the PDF) in section 4.2.1 of the OpenGL
+ * ES 3.0.1 specification says:
+ *
+ * "When draw buffer zero is BACK, color values are written
+ * into the sole buffer for single-buffered contexts, or into
+ * the back buffer for double-buffered contexts."
+ *
+ * Since there is no stereo rendering in ES 3.0, only return the
+ * LEFT bits. This also satisfies the "n must be 1" requirement.
+ */
+ if (ctx->DrawBuffer->Visual.doubleBufferMode)
+ return BUFFER_BIT_BACK_LEFT;
+ return BUFFER_BIT_FRONT_LEFT;
+ }
return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
case GL_RIGHT:
return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
@@ -241,7 +256,7 @@ _mesa_DrawBuffer(GLenum buffer)
else {
const GLbitfield supportedMask
= supported_buffer_bitmask(ctx, ctx->DrawBuffer);
- destMask = draw_buffer_enum_to_bitmask(buffer);
+ destMask = draw_buffer_enum_to_bitmask(ctx, buffer);
if (destMask == BAD_MASK) {
/* totally bogus buffer */
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -321,7 +336,7 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
return;
}
- destMask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ destMask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]);
/* From the OpenGL 3.0 specification, page 258:
* "Each buffer listed in bufs must be one of the values from tables
@@ -451,7 +466,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb);
GLuint output;
for (output = 0; output < n; output++) {
- mask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ mask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]);
ASSERT(mask[output] != BAD_MASK);
mask[output] &= supportedMask;
}