mesa/swrast/st: add ARB_occlusion_query2 support.
authorDave Airlie <airlied@redhat.com>
Sat, 11 Sep 2010 20:31:30 +0000 (06:31 +1000)
committerDave Airlie <airlied@redhat.com>
Sat, 18 Dec 2010 07:33:25 +0000 (17:33 +1000)
This gets my vote for most pointless extension of all time, I'm guessing
some driver could possibly optimise for this instead of counting it might
just get a true/false, but I'm not really sure.

need this to eventually advertise 3.3 despite its total uselessness.

Signed-off-by: Dave Airlie <airlied@redhat.com>
docs/GL3.txt
src/mesa/main/extensions.c
src/mesa/main/queryobj.c
src/mesa/state_tracker/st_extensions.c

index fb22739b6c7c779fe18bc8d4fa2a29b776063a51..9106f439a17b7cb9a4ecb6983e6ec84a10eaf8be 100644 (file)
@@ -71,7 +71,7 @@ GL 3.3:
 GLSL 3.30                                             not started
 GL_ARB_blend_func_extended                            not started
 GL_ARB_explicit_attrib_location                       DONE (swrast, i915, i965)
-GL_ARB_occlusion_query2                               not started
+GL_ARB_occlusion_query2                               DONE (swrast, gallium)
 GL_ARB_sampler_objects                                not started
 GL_ARB_texture_rgb10_a2ui                             not started
 GL_ARB_texture_swizzle                                DONE (same as EXT version)
index f3bf5cb164b794a8a3b042885b6e8d4c91ddafce..fd5b4e915cd20afe7ffee3b0b454419fce62277a 100644 (file)
@@ -259,6 +259,7 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
    ctx->Extensions.ARB_multitexture = GL_TRUE;
 #if FEATURE_queryobj
    ctx->Extensions.ARB_occlusion_query = GL_TRUE;
+   ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
 #endif
    ctx->Extensions.ARB_point_sprite = GL_TRUE;
 #if FEATURE_ARB_shader_objects
index 8874397720633fe65e36118388fd84b878ff07f8..ca829b09bd122c45ef1d4b0d7adc043de9dde8cd 100644 (file)
@@ -143,6 +143,11 @@ get_query_binding_point(struct gl_context *ctx, GLenum target)
          return &ctx->Query.CurrentOcclusionObject;
       else
          return NULL;
+   case GL_ANY_SAMPLES_PASSED:
+      if (ctx->Extensions.ARB_occlusion_query2)
+         return &ctx->Query.CurrentOcclusionObject;
+      else
+         return NULL;
    case GL_TIME_ELAPSED_EXT:
       if (ctx->Extensions.EXT_timer_query)
          return &ctx->Query.CurrentTimerObject;
@@ -378,12 +383,19 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
          if (!q->Ready)
             ctx->Driver.WaitQuery(ctx, q);
          /* if result is too large for returned type, clamp to max value */
-         if (q->Result > 0x7fffffff) {
-            *params = 0x7fffffff;
-         }
-         else {
-            *params = (GLint)q->Result;
-         }
+        if (q->Target == GL_ANY_SAMPLES_PASSED) {
+           if (q->Result)
+              *params = GL_TRUE;
+           else
+              *params = GL_FALSE;
+        } else {
+           if (q->Result > 0x7fffffff) {
+              *params = 0x7fffffff;
+           }
+           else {
+              *params = (GLint)q->Result;
+           }
+        }
          break;
       case GL_QUERY_RESULT_AVAILABLE_ARB:
         if (!q->Ready)
@@ -418,12 +430,19 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
          if (!q->Ready)
             ctx->Driver.WaitQuery(ctx, q);
          /* if result is too large for returned type, clamp to max value */
-         if (q->Result > 0xffffffff) {
-            *params = 0xffffffff;
-         }
-         else {
-            *params = (GLuint)q->Result;
-         }
+        if (q->Target == GL_ANY_SAMPLES_PASSED) {
+           if (q->Result)
+              *params = GL_TRUE;
+           else
+              *params = GL_FALSE;
+        } else {
+           if (q->Result > 0xffffffff) {
+              *params = 0xffffffff;
+           }
+           else {
+              *params = (GLuint)q->Result;
+           }
+        }
          break;
       case GL_QUERY_RESULT_AVAILABLE_ARB:
         if (!q->Ready)
index 51a45a7d51120d2e74e4bf58952756723283f020..62c9ce7273d613ec73de7c8a09f9e6f646855f3b 100644 (file)
@@ -343,6 +343,7 @@ void st_init_extensions(struct st_context *st)
 
    if (screen->get_param(screen, PIPE_CAP_OCCLUSION_QUERY)) {
       ctx->Extensions.ARB_occlusion_query = GL_TRUE;
+      ctx->Extensions.ARB_occlusion_query2 = GL_TRUE;
    }
    if (screen->get_param(screen, PIPE_CAP_TIMER_QUERY)) {
      ctx->Extensions.EXT_timer_query = GL_TRUE;