mesa: Enable simultaneous queries on different streams.
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 10 Jun 2014 11:50:32 +0000 (13:50 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 30 Jun 2014 06:08:50 +0000 (08:08 +0200)
It should be possible to query the number of primitives written to each
individual stream by a geometry shader in a single draw call. For that
we need to have up to MAX_VERTEX_STREAM separate query objects.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/mtypes.h
src/mesa/main/queryobj.c

index af35ce532c0fc0818c36abea93a805734591be11..de4d7f88f2738c014415767f73eb3b31237de0ce 100644 (file)
@@ -2912,8 +2912,8 @@ struct gl_query_state
    struct gl_query_object *CondRenderQuery;
 
    /** GL_EXT_transform_feedback */
-   struct gl_query_object *PrimitivesGenerated;
-   struct gl_query_object *PrimitivesWritten;
+   struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
+   struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
 
    /** GL_ARB_timer_query */
    struct gl_query_object *TimeElapsed;
index 512f45ab93a499489bfb11c0930024c153a34e15..932359c4e7f2539b3ebb2bb758e6ace46f1f2b85 100644 (file)
@@ -144,11 +144,12 @@ _mesa_init_query_object_functions(struct dd_function_table *driver)
 
 
 /**
- * Return pointer to the query object binding point for the given target.
+ * Return pointer to the query object binding point for the given target and
+ * index.
  * \return NULL if invalid target, else the address of binding point
  */
 static struct gl_query_object **
-get_query_binding_point(struct gl_context *ctx, GLenum target)
+get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index)
 {
    switch (target) {
    case GL_SAMPLES_PASSED_ARB:
@@ -174,12 +175,12 @@ get_query_binding_point(struct gl_context *ctx, GLenum target)
          return NULL;
    case GL_PRIMITIVES_GENERATED:
       if (ctx->Extensions.EXT_transform_feedback)
-         return &ctx->Query.PrimitivesGenerated;
+         return &ctx->Query.PrimitivesGenerated[index];
       else
          return NULL;
    case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
       if (ctx->Extensions.EXT_transform_feedback)
-         return &ctx->Query.PrimitivesWritten;
+         return &ctx->Query.PrimitivesWritten[index];
       else
          return NULL;
    default:
@@ -240,7 +241,7 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
          if (q) {
             if (q->Active) {
                struct gl_query_object **bindpt;
-               bindpt = get_query_binding_point(ctx, q->Target);
+               bindpt = get_query_binding_point(ctx, q->Target, q->Stream);
                assert(bindpt); /* Should be non-null for active q. */
                if (bindpt) {
                   *bindpt = NULL;
@@ -313,7 +314,7 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
 
    FLUSH_VERTICES(ctx, 0);
 
-   bindpt = get_query_binding_point(ctx, target);
+   bindpt = get_query_binding_point(ctx, target, index);
    if (!bindpt) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQuery{Indexed}(target)");
       return;
@@ -391,7 +392,7 @@ _mesa_EndQueryIndexed(GLenum target, GLuint index)
 
    FLUSH_VERTICES(ctx, 0);
 
-   bindpt = get_query_binding_point(ctx, target);
+   bindpt = get_query_binding_point(ctx, target, index);
    if (!bindpt) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glEndQuery{Indexed}(target)");
       return;
@@ -518,7 +519,7 @@ _mesa_GetQueryIndexediv(GLenum target, GLuint index, GLenum pname,
       }
    }
    else {
-      bindpt = get_query_binding_point(ctx, target);
+      bindpt = get_query_binding_point(ctx, target, index);
       if (!bindpt) {
          _mesa_error(ctx, GL_INVALID_ENUM, "glGetQuery{Indexed}iv(target)");
          return;