[Mesa-dev] [PATCH 3/5] mesa/meta: Add support for storing the current read buffer

Jason Ekstrand jason at jlekstrand.net
Thu Jul 31 11:28:01 PDT 2014


Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
 src/mesa/drivers/common/meta.c      | 13 +++++++++++++
 src/mesa/drivers/common/meta.h      |  4 ++++
 src/mesa/drivers/common/meta_blit.c |  3 ++-
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f1155b4..8c515e0 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -822,6 +822,15 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
       }
    }
 
+   if (state & MESA_META_READ_BUFFER) {
+      int buf_index = ctx->ReadBuffer->_ColorReadBufferIndex;
+
+      if (buf_index == -1)
+         save->ColorReadBuffer = 0;
+      else
+         save->ColorReadBuffer = gl_buffer_index_to_drawbuffers_enum(buf_index);
+   }
+
    /* misc */
    {
       save->Lighting = ctx->Light.Enabled;
@@ -1227,6 +1236,10 @@ _mesa_meta_end(struct gl_context *ctx)
       _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers);
    }
 
+   if (state & MESA_META_READ_BUFFER) {
+      _mesa_ReadBuffer(save->ColorReadBuffer);
+   }
+
    ctx->Meta->SaveStackDepth--;
 
    ctx->API = save->API;
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index f12dc65..cb25b3a 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -60,6 +60,7 @@
 #define MESA_META_OCCLUSION_QUERY      0x400000
 #define MESA_META_DRAW_BUFFERS         0x800000
 #define MESA_META_DITHER              0x1000000
+#define MESA_META_READ_BUFFER         0x2000000
 /**\}*/
 
 /**
@@ -188,6 +189,9 @@ struct save_state
 
    /** MESA_META_DRAW_BUFFERS */
    GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
+
+   /** MESA_META_READ_BUFFER */
+   GLenum ColorReadBuffer;
 };
 
 /**
diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index bbf0c3c..e4c0f07 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -707,7 +707,8 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
    /* Only scissor affects blit, but we're doing to set a custom scissor if
     * necessary anyway, so save/clear state.
     */
-   _mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS);
+   _mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS &
+                    ~MESA_META_READ_BUFFER);
 
    /* If the clipping earlier changed the destination rect at all, then
     * enable the scissor to clip to it.
-- 
2.0.3



More information about the mesa-dev mailing list