[Mesa-dev] [PATCH 4/7] helper-conveniance functions for drivers to implement ARB_framebuffer_no_attachment
kevin.rogovin at intel.com
kevin.rogovin at intel.com
Thu Apr 23 23:59:07 PDT 2015
From: Kevin Rogovin <kevin.rogovin at intel.com>
To assist drivers to implement ARB_framebuffer_no_attachment, provide
a set of convenience functions that check for gl_framebuffer::_HasAttachments
that return the geometry of the gl_framebuffer.
---
src/mesa/main/framebuffer.c | 49 ++++++++++++++++++++++++++++++---------------
src/mesa/main/framebuffer.h | 29 +++++++++++++++++++++++++++
src/mesa/main/mtypes.h | 21 ++++++++++---------
3 files changed, 74 insertions(+), 25 deletions(-)
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4e4d896..7d8921b 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -357,30 +357,20 @@ update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
}
+
/**
- * Calculate the inclusive bounding box for the scissor of a specific viewport
+ * Given a bounding box, intersect the bounding box with the scirros of
+ * a specified vieport.
*
* \param ctx GL context.
- * \param buffer Framebuffer to be checked against
* \param idx Index of the desired viewport
* \param bbox Bounding box for the scissored viewport. Stored as xmin,
* xmax, ymin, ymax.
- *
- * \warning This function assumes that the framebuffer dimensions are up to
- * date (e.g., update_framebuffer_size has been recently called on \c buffer).
- *
- * \sa _mesa_clip_to_region
*/
-void
-_mesa_scissor_bounding_box(const struct gl_context *ctx,
- const struct gl_framebuffer *buffer,
- unsigned idx, int *bbox)
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox)
{
- bbox[0] = 0;
- bbox[2] = 0;
- bbox[1] = buffer->Width;
- bbox[3] = buffer->Height;
-
if (ctx->Scissor.EnableFlags & (1u << idx)) {
if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
bbox[0] = ctx->Scissor.ScissorArray[idx].X;
@@ -402,6 +392,33 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
bbox[2] = bbox[3];
}
}
+}
+
+/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bbox Bounding box for the scissored viewport. Stored as xmin,
+ * xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer,
+ unsigned idx, int *bbox)
+{
+ bbox[0] = 0;
+ bbox[2] = 0;
+ bbox[1] = buffer->Width;
+ bbox[3] = buffer->Height;
+
+ _mesa_intersect_scissor_bounding_box(ctx, idx, bbox);
assert(bbox[0] <= bbox[1]);
assert(bbox[2] <= bbox[3]);
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index a427421..8b84d26 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,35 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ 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);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 38a3817..ac7cdb6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3134,13 +3134,13 @@ struct gl_framebuffer
struct gl_config Visual;
/**
- * size of frame buffer in pixels,
- * no attachments has these values as 0
+ * size of frame buffer in pixels,
+ * no attachments has these values as 0
*/
- GLuint Width, Height;
+ GLuint Width, Height;
/**
- * In the case that the framebuffer has no attachment (i.e.
+ * In the case that the framebuffer has no attachment (i.e.
* GL_ARB_framebuffer_no_attachments) then the geometry of
* the framebuffer is specified by the default values.
*/
@@ -3154,8 +3154,8 @@ struct gl_framebuffer
* (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
*/
/*@{*/
- GLint _Xmin, _Xmax;
- GLint _Ymin, _Ymax;
+ GLint _Xmin, _Xmax;
+ GLint _Ymin, _Ymax;
/*@}*/
/** \name Derived Z buffer stuff */
@@ -3172,13 +3172,16 @@ struct gl_framebuffer
* - one of Attachment has gl_renderbuffer_attachment::Type != GL_NONE
* - _Status is GL_FRAMEBUFFER_COMPLETE_EXT
* NOTE: the values for Width and Height are set to 0 in the
- * case of no attachments, a backend driver supporting
- * GL_ARB_framebuffer_no_attachments must check for
+ * case of no attachments, a backend driver supporting
+ * 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
+ * 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
*/
GLboolean _HasAttachments;
--
1.9.1
More information about the mesa-dev
mailing list