summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/intel_buffers.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-03-03 10:43:10 -0800
committerEric Anholt <eric@anholt.net>2014-03-11 12:47:41 -0700
commitec542d74578bbef6b55125dd6aba1dc7f5079e65 (patch)
tree2afd62c3ded5f3157a502b721c6d022e821e6b7a /src/mesa/drivers/dri/i965/intel_buffers.c
parent66073ef438623f27dbbd01ba25189e5d4f0d9ae0 (diff)
downloadexternal_mesa3d-ec542d74578bbef6b55125dd6aba1dc7f5079e65.zip
external_mesa3d-ec542d74578bbef6b55125dd6aba1dc7f5079e65.tar.gz
external_mesa3d-ec542d74578bbef6b55125dd6aba1dc7f5079e65.tar.bz2
i965: Drop broken front_buffer_reading/drawing optimization.
The flag wasn't getting updated correctly when the ctx->DrawBuffer or ctx->ReadBuffer changed. It usually ended up working out because most apps only have one window system framebuffer, or if they have more than one and they have any front read/drawing, they will have called glReadBuffer()/glDrawBuffer() on it when they get started on the new buffer. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_buffers.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_buffers.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_buffers.c b/src/mesa/drivers/dri/i965/intel_buffers.c
index 1ece875..23d936f 100644
--- a/src/mesa/drivers/dri/i965/intel_buffers.c
+++ b/src/mesa/drivers/dri/i965/intel_buffers.c
@@ -53,22 +53,36 @@ intel_check_front_buffer_rendering(struct brw_context *brw)
}
}
+bool
+brw_is_front_buffer_reading(struct gl_framebuffer *fb)
+{
+ if (!fb || _mesa_is_user_fbo(fb))
+ return false;
+
+ return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT;
+}
+
+bool
+brw_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 (brw_is_front_buffer_drawing(ctx->DrawBuffer)) {
struct brw_context *const brw = brw_context(ctx);
- const bool was_front_buffer_rendering = brw->is_front_buffer_rendering;
- brw->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 && brw->is_front_buffer_rendering)
- dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
+ dri2InvalidateDrawable(brw->driContext->driDrawablePriv);
}
}
@@ -76,18 +90,14 @@ intelDrawBuffer(struct gl_context * ctx, GLenum mode)
static void
intelReadBuffer(struct gl_context * ctx, GLenum mode)
{
- if (ctx->ReadBuffer && _mesa_is_winsys_fbo(ctx->ReadBuffer)) {
+ if (brw_is_front_buffer_reading(ctx->ReadBuffer)) {
struct brw_context *const brw = brw_context(ctx);
- const bool was_front_buffer_reading = brw->is_front_buffer_reading;
-
- brw->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 && brw->is_front_buffer_reading)
- dri2InvalidateDrawable(brw->driContext->driReadablePriv);
+ dri2InvalidateDrawable(brw->driContext->driReadablePriv);
}
}