}
}
+bool
+intel_is_front_buffer_reading(struct gl_framebuffer *fb)
+{
+ if (!fb || _mesa_is_user_fbo(fb))
+ return false;
+
+ return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT;
+}
+
+bool
+intel_is_front_buffer_drawing(struct gl_framebuffer *fb)
+{
+ if (!fb || _mesa_is_user_fbo(fb))
+ return false;
+
+ return (fb->_NumColorDrawBuffers >= 1 &&
+ fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT);
+}
+
static void
intelDrawBuffer(struct gl_context * ctx, GLenum mode)
{
- if (ctx->DrawBuffer && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ if (intel_is_front_buffer_drawing(ctx->DrawBuffer)) {
struct intel_context *const intel = intel_context(ctx);
- const bool was_front_buffer_rendering =
- intel->is_front_buffer_rendering;
- intel->is_front_buffer_rendering = (mode == GL_FRONT_LEFT)
- || (mode == GL_FRONT) || (mode == GL_FRONT_AND_BACK);
-
- /* If we weren't front-buffer rendering before but we are now,
- * invalidate our DRI drawable so we'll ask for new buffers
+ /* If we might be front-buffer rendering on this buffer for the first
+ * time, invalidate our DRI drawable so we'll ask for new buffers
* (including the fake front) before we start rendering again.
*/
- if (!was_front_buffer_rendering && intel->is_front_buffer_rendering)
- dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
+ dri2InvalidateDrawable(intel->driContext->driDrawablePriv);
}
intel_draw_buffer(ctx);
static void
intelReadBuffer(struct gl_context * ctx, GLenum mode)
{
- if (ctx->ReadBuffer && _mesa_is_winsys_fbo(ctx->ReadBuffer)) {
+ if (intel_is_front_buffer_reading(ctx->ReadBuffer)) {
struct intel_context *const intel = intel_context(ctx);
- const bool was_front_buffer_reading =
- intel->is_front_buffer_reading;
-
- intel->is_front_buffer_reading = (mode == GL_FRONT_LEFT)
- || (mode == GL_FRONT);
- /* If we weren't front-buffer reading before but we are now,
- * invalidate our DRI drawable so we'll ask for new buffers
+ /* If we might be front-buffer reading on this buffer for the first
+ * time, invalidate our DRI drawable so we'll ask for new buffers
* (including the fake front) before we start reading again.
*/
- if (!was_front_buffer_reading && intel->is_front_buffer_reading)
- dri2InvalidateDrawable(intel->driContext->driReadablePriv);
+ dri2InvalidateDrawable(intel->driContext->driReadablePriv);
}
}
* that will happen next will probably dirty the front buffer. So
* mark it as dirty here.
*/
- if (intel->is_front_buffer_rendering)
+ if (intel_is_front_buffer_drawing(intel->ctx.DrawBuffer))
intel->front_buffer_dirty = true;
/* Wait for the swapbuffers before the one we just emitted, so we
intel_flush(ctx);
intel_flush_front(ctx);
- if (intel->is_front_buffer_rendering)
+ if (intel_is_front_buffer_drawing(ctx->DrawBuffer))
intel->need_throttle = true;
}
back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
memset(attachments, 0, sizeof(attachments));
- if ((intel->is_front_buffer_rendering ||
- intel->is_front_buffer_reading ||
+ if ((intel_is_front_buffer_drawing(fb) ||
+ intel_is_front_buffer_reading(fb) ||
!back_rb) && front_rb) {
/* If a fake front buffer is in use, then querying for
* __DRI_BUFFER_FRONT_LEFT will cause the server to copy the image from
else
return;
- if ((intel->is_front_buffer_rendering || intel->is_front_buffer_reading || !back_rb) && front_rb)
+ if (front_rb && (intel_is_front_buffer_drawing(fb) ||
+ intel_is_front_buffer_reading(fb) || !back_rb)) {
buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
+ }
if (back_rb)
buffer_mask |= __DRI_IMAGE_BUFFER_BACK;