mesa: add helper functions for geometry of gl_framebuffer
authorKevin Rogovin <kevin.rogovin@intel.com>
Wed, 17 Jun 2015 10:29:53 +0000 (13:29 +0300)
committerMartin Peres <martin.peres@linux.intel.com>
Wed, 17 Jun 2015 11:39:03 +0000 (14:39 +0300)
Add convenience helper functions for fetching geometry of gl_framebuffer
that return the geometry of the gl_framebuffer instead of the geometry of
the buffers of the gl_framebuffer when then the gl_framebuffer has no
attachments.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Kevin Rogovin <kevin.rogovin@intel.com>
src/mesa/main/framebuffer.h
src/mesa/main/mtypes.h

index d02b86f20d9b48aa27bb87db1e00d7a8f723f3fa..ca286e9a9927f36914bb6ae56c89769fae951a95 100644 (file)
@@ -76,6 +76,34 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
                            const struct gl_framebuffer *buffer,
                            unsigned idx, int *bbox);
 
+static inline GLuint
+_mesa_geometric_width(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+      buffer->Width : buffer->DefaultGeometry.Width;
+}
+
+static inline GLuint
+_mesa_geometric_height(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+      buffer->Height : buffer->DefaultGeometry.Height;
+}
+
+static inline GLuint
+_mesa_geometric_samples(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+      buffer->Visual.samples : buffer->DefaultGeometry.NumSamples;
+}
+
+static inline GLuint
+_mesa_geometric_layers(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+      buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
+}
+
 extern void 
 _mesa_update_draw_buffer_bounds(struct gl_context *ctx,
                                 struct gl_framebuffer *drawFb);
index e9f70e206129c1b2e0027b5eeea2aaf2eb28d4a9..a10e49434bc2751d40815856a48556dc89452f20 100644 (file)
@@ -3174,7 +3174,13 @@ struct gl_framebuffer
     * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
     * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
     * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
-    * _Ymax do NOT take into account _HasAttachments being false)
+    * _Ymax do NOT take into account _HasAttachments being false). To get the
+    * geometry of the framebuffer, the  helper functions
+    *   _mesa_geometric_width(),
+    *   _mesa_geometric_height(),
+    *   _mesa_geometric_samples() and
+    *   _mesa_geometric_layers()
+    * are available that check _HasAttachments.
     */
    bool _HasAttachments;