*/
-#include "main/imports.h"
-#include "main/compiler.h"
+#include "util/imports.h"
+#include "util/compiler.h"
#include "main/context.h"
+#include "main/queryobj.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "st_cb_queryobj.h"
#include "st_cb_bitmap.h"
#include "st_cb_bufferobjects.h"
+#include "st_util.h"
static struct gl_query_object *
free_queries(pipe, stq);
- free(stq);
+ _mesa_delete_query(ctx, q);
}
+static int
+target_to_index(const struct st_context *st, const struct gl_query_object *q)
+{
+ if (q->Target == GL_PRIMITIVES_GENERATED ||
+ q->Target == GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ||
+ q->Target == GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB)
+ return q->Stream;
+
+ if (st->has_single_pipe_stat) {
+ switch (q->Target) {
+ case GL_VERTICES_SUBMITTED_ARB:
+ return PIPE_STAT_QUERY_IA_VERTICES;
+ case GL_PRIMITIVES_SUBMITTED_ARB:
+ return PIPE_STAT_QUERY_IA_PRIMITIVES;
+ case GL_VERTEX_SHADER_INVOCATIONS_ARB:
+ return PIPE_STAT_QUERY_VS_INVOCATIONS;
+ case GL_GEOMETRY_SHADER_INVOCATIONS:
+ return PIPE_STAT_QUERY_GS_INVOCATIONS;
+ case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
+ return PIPE_STAT_QUERY_GS_PRIMITIVES;
+ case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
+ return PIPE_STAT_QUERY_C_INVOCATIONS;
+ case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
+ return PIPE_STAT_QUERY_C_PRIMITIVES;
+ case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
+ return PIPE_STAT_QUERY_PS_INVOCATIONS;
+ case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
+ return PIPE_STAT_QUERY_HS_INVOCATIONS;
+ case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
+ return PIPE_STAT_QUERY_DS_INVOCATIONS;
+ case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
+ return PIPE_STAT_QUERY_CS_INVOCATIONS;
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
static void
st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
- type = PIPE_QUERY_PIPELINE_STATISTICS;
+ type = st->has_single_pipe_stat ? PIPE_QUERY_PIPELINE_STATISTICS_SINGLE
+ : PIPE_QUERY_PIPELINE_STATISTICS;
break;
default:
assert(0 && "unexpected query target in st_BeginQuery()");
ret = pipe->end_query(pipe, stq->pq_begin);
} else {
if (!stq->pq) {
- stq->pq = pipe->create_query(pipe, type, q->Stream);
+ stq->pq = pipe->create_query(pipe, type, target_to_index(st, q));
stq->type = type;
}
if (stq->pq)
return;
}
+ if (stq->type != PIPE_QUERY_TIMESTAMP)
+ st->active_queries++;
+
assert(stq->type == type);
}
static void
st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
{
- struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct st_query_object *stq = st_query_object(q);
bool ret = false;
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glEndQuery");
return;
}
+
+ if (stq->type != PIPE_QUERY_TIMESTAMP)
+ st->active_queries--;
}