* return -1 for an invalid buffer.
*/
static gl_buffer_index
-read_buffer_enum_to_index(GLenum buffer)
+read_buffer_enum_to_index(const struct gl_context *ctx, GLenum buffer)
{
switch (buffer) {
case GL_FRONT:
return BUFFER_FRONT_LEFT;
case GL_BACK:
+ if (_mesa_is_gles(ctx)) {
+ /* In draw_buffer_enum_to_bitmask, when GLES contexts draw to
+ * GL_BACK with a single-buffered configuration, we actually end
+ * up drawing to the sole front buffer in our internal
+ * representation. For consistency, we must read from that
+ * front left buffer too.
+ */
+ if (!ctx->DrawBuffer->Visual.doubleBufferMode)
+ return BUFFER_FRONT_LEFT;
+ }
return BUFFER_BACK_LEFT;
case GL_RIGHT:
return BUFFER_FRONT_RIGHT;
if (_mesa_is_gles3(ctx) && !is_legal_es3_readbuffer_enum(buffer))
srcBuffer = -1;
else
- srcBuffer = read_buffer_enum_to_index(buffer);
+ srcBuffer = read_buffer_enum_to_index(ctx, buffer);
if (srcBuffer == -1) {
_mesa_error(ctx, GL_INVALID_ENUM,
mask |= BUFFER_BIT_FRONT_RIGHT;
break;
case GL_BACK:
+ /* For GLES contexts with a single buffered configuration, we actually
+ * only have a front renderbuffer, so any clear calls to GL_BACK should
+ * affect that buffer. See draw_buffer_enum_to_bitmask for details.
+ */
+ if (_mesa_is_gles(ctx))
+ if (!ctx->DrawBuffer->Visual.doubleBufferMode)
+ if (att[BUFFER_FRONT_LEFT].Renderbuffer)
+ mask |= BUFFER_BIT_FRONT_LEFT;
if (att[BUFFER_BACK_LEFT].Renderbuffer)
mask |= BUFFER_BIT_BACK_LEFT;
if (att[BUFFER_BACK_RIGHT].Renderbuffer)
}
if (!newCtx->ReadBuffer || _mesa_is_winsys_fbo(newCtx->ReadBuffer)) {
_mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
+ /* In _mesa_initialize_window_framebuffer, for single-buffered
+ * visuals, the ColorReadBuffer is set to be GL_FRONT, even with
+ * GLES contexts. When calling read_buffer, we verify we are reading
+ * from GL_BACK in is_legal_es3_readbuffer_enum. But the default is
+ * incorrect, and certain dEQP tests check this. So fix it here.
+ */
+ if (_mesa_is_gles(newCtx) &&
+ !newCtx->ReadBuffer->Visual.doubleBufferMode)
+ if (newCtx->ReadBuffer->ColorReadBuffer == GL_FRONT)
+ newCtx->ReadBuffer->ColorReadBuffer = GL_BACK;
}
/* XXX only set this flag if we're really changing the draw/read