mesa: add _mesa_get_version, a ctx-independent variant of _mesa_compute_version
[mesa.git] / src / mesa / main / condrender.c
index bfd2b08180727494d7cd7d81c3095983a50a5ead..0ad1e5c2aee1e1f8bc9840090496c75567d8afa0 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.8
  *
  * Copyright (C) 2009  VMware, Inc.   All Rights Reserved.
  *
 void GLAPIENTRY
 _mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
 {
-   struct gl_query_object *q;
+   struct gl_query_object *q = NULL;
    GET_CURRENT_CONTEXT(ctx);
 
-   if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery ||
-       queryId == 0) {
+   /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+    *
+    *     "If BeginConditionalRender is called while conditional rendering is
+    *     in progress, or if EndConditionalRender is called while conditional
+    *     rendering is not in progress, the error INVALID_OPERATION is
+    *     generated."
+    */
+   if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
       return;
    }
 
    ASSERT(ctx->Query.CondRenderMode == GL_NONE);
 
+   /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+    *
+    *     "The error INVALID_VALUE is generated if <id> is not the name of an
+    *     existing query object query."
+    */
+   if (queryId != 0)
+      q = _mesa_lookup_query_object(ctx, queryId);
+
+   if (!q) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "glBeginConditionalRender(bad queryId=%u)", queryId);
+      return;
+   }
+   ASSERT(q->Id == queryId);
+
    switch (mode) {
    case GL_QUERY_WAIT:
    case GL_QUERY_NO_WAIT:
@@ -65,15 +85,15 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
       return;
    }
 
-   q = _mesa_lookup_query_object(ctx, queryId);
-   if (!q) {
-      _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glBeginConditionalRender(bad queryId=%u)", queryId);
-      return;
-   }
-   ASSERT(q->Id == queryId);
-
-   if (q->Target != GL_SAMPLES_PASSED || q->Active) {
+   /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+    *
+    *     "The error INVALID_OPERATION is generated if <id> is the name of a
+    *     query object with a target other than SAMPLES_PASSED, or <id> is the
+    *     name of a query currently in progress."
+    */
+   if ((q->Target != GL_SAMPLES_PASSED &&
+        q->Target != GL_ANY_SAMPLES_PASSED &&
+        q->Target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE) || q->Active) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
       return;
    }