Mesa (gallium-0.2): mesa: check frambuffer complete status before rendering

Alan Hourihane alanh at kemper.freedesktop.org
Thu Jan 15 11:52:58 UTC 2009


Module: Mesa
Branch: gallium-0.2
Commit: 263b96e160606975285154c4b8b610fcb8f4c930
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=263b96e160606975285154c4b8b610fcb8f4c930

Author: Alan Hourihane <alanh at vmware.com>
Date:   Thu Jan 15 11:51:39 2009 +0000

mesa: check frambuffer complete status before rendering

---

 src/mesa/main/api_validate.c |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index bbc5933..5c8955d 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -78,6 +78,23 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
    return max;
 }
 
+static GLboolean
+check_valid_to_render(GLcontext *ctx, char *function)
+{
+   if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+                  "glDraw%s(incomplete framebuffer)", function);
+      return GL_FALSE;
+   }
+
+   /* Always need vertex positions, unless a vertex program is in use */
+   if (!ctx->VertexProgram._Current &&
+       !ctx->Array.ArrayObj->Vertex.Enabled &&
+       !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
+      return GL_FALSE;
+
+   return GL_TRUE;
+}
 
 GLboolean
 _mesa_validate_DrawElements(GLcontext *ctx,
@@ -108,10 +125,7 @@ _mesa_validate_DrawElements(GLcontext *ctx,
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
-   /* Always need vertex positions, unless a vertex program is in use */
-   if (!ctx->VertexProgram._Current &&
-       !ctx->Array.ArrayObj->Vertex.Enabled &&
-       !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
+   if (!check_valid_to_render(ctx, "Elements"))
       return GL_FALSE;
 
    /* Vertex buffer object tests */
@@ -161,7 +175,6 @@ _mesa_validate_DrawElements(GLcontext *ctx,
    return GL_TRUE;
 }
 
-
 GLboolean
 _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
 				 GLuint start, GLuint end,
@@ -196,10 +209,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
-   /* Always need vertex positions, unless a vertex program is in use */
-   if (!ctx->VertexProgram._Current &&
-       !ctx->Array.ArrayObj->Vertex.Enabled &&
-       !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
+   if (!check_valid_to_render(ctx, "RangeElements"))
       return GL_FALSE;
 
    /* Vertex buffer object tests */
@@ -267,10 +277,7 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
    if (ctx->NewState)
       _mesa_update_state(ctx);
 
-   /* Always need vertex positions, unless a vertex program is in use */
-   if (!ctx->VertexProgram._Current &&
-       !ctx->Array.ArrayObj->Vertex.Enabled &&
-       !ctx->Array.ArrayObj->VertexAttrib[0].Enabled)
+   if (!check_valid_to_render(ctx, "Arrays"))
       return GL_FALSE;
 
    if (ctx->Const.CheckArrayBounds) {




More information about the mesa-commit mailing list