[Mesa-dev] [PATCH v2 06/18] framebuffer: add _mesa_get_read_renderbuffer

Jordan Justen jordan.l.justen at intel.com
Sat Jan 12 20:10:56 PST 2013


This returns the current read renderbuffer for the specified
format type.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/framebuffer.c |   21 +++++++++++++++++++++
 src/mesa/main/framebuffer.h |    5 +++++
 2 files changed, 26 insertions(+)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 13887f8..8cbfbd6 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -42,6 +42,7 @@
 #include "framebuffer.h"
 #include "renderbuffer.h"
 #include "texobj.h"
+#include "glformats.h"
 
 
 
@@ -899,6 +900,26 @@ _mesa_get_color_read_type(struct gl_context *ctx)
 
 
 /**
+ * Returns the read renderbuffer for the specified format.
+ */
+struct gl_renderbuffer *
+_mesa_get_read_renderbuffer_for_format(struct gl_context *ctx,
+                                       GLenum format)
+{
+   struct gl_framebuffer *rfb = ctx->ReadBuffer;
+
+   if (_mesa_is_color_format(format)) {
+      return rfb->Attachment[rfb->_ColorReadBufferIndex].Renderbuffer;
+   } else if (_mesa_is_depth_format(format) ||
+              _mesa_is_depthstencil_format(format)) {
+      return rfb->Attachment[BUFFER_DEPTH].Renderbuffer;
+   } else {
+      return rfb->Attachment[BUFFER_STENCIL].Renderbuffer;
+   }
+}
+
+
+/**
  * Print framebuffer info to stderr, for debugging.
  */
 void
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index ad53d8c..06db049 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -30,6 +30,7 @@
 
 struct gl_config;
 struct gl_context;
+struct gl_renderbuffer;
 
 extern struct gl_framebuffer *
 _mesa_create_framebuffer(const struct gl_config *visual);
@@ -96,6 +97,10 @@ _mesa_get_color_read_type(struct gl_context *ctx);
 extern GLenum
 _mesa_get_color_read_format(struct gl_context *ctx);
 
+extern struct gl_renderbuffer *
+_mesa_get_read_renderbuffer_for_format(struct gl_context *ctx,
+                                       GLenum format);
+
 extern void
 _mesa_print_framebuffer(const struct gl_framebuffer *fb);
 
-- 
1.7.10.4



More information about the mesa-dev mailing list