driver->CheckQuery = _mesa_check_query;
}
+static struct gl_query_object **
+get_pipe_stats_binding_point(struct gl_context *ctx,
+ GLenum target)
+{
+ const int which = target - GL_VERTICES_SUBMITTED_ARB;
+ assert(which < MAX_PIPELINE_STATISTICS);
+
+ if (!_mesa_is_desktop_gl(ctx) ||
+ !ctx->Extensions.ARB_pipeline_statistics_query)
+ return NULL;
+
+ return &ctx->Query.pipeline_stats[which];
+}
/**
- * 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:
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;
+
+ case GL_VERTICES_SUBMITTED_ARB:
+ case GL_PRIMITIVES_SUBMITTED_ARB:
+ case GL_VERTEX_SHADER_INVOCATIONS_ARB:
+ case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
+ case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
+ case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
+ return get_pipe_stats_binding_point(ctx, target);
+
+ case GL_GEOMETRY_SHADER_INVOCATIONS:
+ /* GL_GEOMETRY_SHADER_INVOCATIONS is defined in a non-sequential order */
+ target = GL_VERTICES_SUBMITTED_ARB + MAX_PIPELINE_STATISTICS - 1;
+ /* fallthrough */
+ case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
+ if (_mesa_has_geometry_shaders(ctx))
+ return get_pipe_stats_binding_point(ctx, target);
else
return NULL;
+
+ case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
+ case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
+ if (ctx->Extensions.ARB_tessellation_shader)
+ return get_pipe_stats_binding_point(ctx, target);
+ else
+ return NULL;
+
+ case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
+ if (_mesa_has_compute_shaders(ctx))
+ return get_pipe_stats_binding_point(ctx, target);
+ else
+ return NULL;
+
default:
return NULL;
}
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;
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;
"glBeginQuery{Indexed}(query already active)");
return;
}
+
+ /* Section 2.14 Asynchronous Queries, page 84 of the OpenGL ES 3.0.4
+ * spec states:
+ *
+ * "BeginQuery generates an INVALID_OPERATION error if any of the
+ * following conditions hold: [...] id is the name of an
+ * existing query object whose type does not match target; [...]
+ *
+ * Similar wording exists in the OpenGL 4.5 spec, section 4.2. QUERY
+ * OBJECTS AND ASYNCHRONOUS QUERIES, page 43.
+ */
+ if (q->EverBound && q->Target != target) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginQuery{Indexed}(target mismatch)");
+ return;
+ }
}
q->Target = target;
q->Result = 0;
q->Ready = GL_FALSE;
q->EverBound = GL_TRUE;
+ q->Stream = index;
/* XXX should probably refcount query objects */
*bindpt = q;
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;
}
}
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;
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
*params = ctx->Const.QueryCounterBits.PrimitivesWritten;
break;
+ case GL_VERTICES_SUBMITTED_ARB:
+ *params = ctx->Const.QueryCounterBits.VerticesSubmitted;
+ break;
+ case GL_PRIMITIVES_SUBMITTED_ARB:
+ *params = ctx->Const.QueryCounterBits.PrimitivesSubmitted;
+ break;
+ case GL_VERTEX_SHADER_INVOCATIONS_ARB:
+ *params = ctx->Const.QueryCounterBits.VsInvocations;
+ break;
+ case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
+ *params = ctx->Const.QueryCounterBits.TessPatches;
+ break;
+ case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
+ *params = ctx->Const.QueryCounterBits.TessInvocations;
+ break;
+ case GL_GEOMETRY_SHADER_INVOCATIONS:
+ *params = ctx->Const.QueryCounterBits.GsInvocations;
+ break;
+ case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
+ *params = ctx->Const.QueryCounterBits.GsPrimitives;
+ break;
+ case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
+ *params = ctx->Const.QueryCounterBits.FsInvocations;
+ break;
+ case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
+ *params = ctx->Const.QueryCounterBits.ComputeInvocations;
+ break;
+ case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
+ *params = ctx->Const.QueryCounterBits.ClInPrimitives;
+ break;
+ case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
+ *params = ctx->Const.QueryCounterBits.ClOutPrimitives;
+ break;
default:
_mesa_problem(ctx,
"Unknown target in glGetQueryIndexediv(target = %s)",
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectivARB(id=%d is invalid or active)", id);
return;
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectuivARB(id=%d is invalid or active)", id);
return;
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectui64vARB(id=%d is invalid or active)", id);
return;
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectuui64vARB(id=%d is invalid or active)", id);
return;
ctx->Const.QueryCounterBits.Timestamp = 64;
ctx->Const.QueryCounterBits.PrimitivesGenerated = 64;
ctx->Const.QueryCounterBits.PrimitivesWritten = 64;
+
+ ctx->Const.QueryCounterBits.VerticesSubmitted = 64;
+ ctx->Const.QueryCounterBits.PrimitivesSubmitted = 64;
+ ctx->Const.QueryCounterBits.VsInvocations = 64;
+ ctx->Const.QueryCounterBits.TessPatches = 64;
+ ctx->Const.QueryCounterBits.TessInvocations = 64;
+ ctx->Const.QueryCounterBits.GsInvocations = 64;
+ ctx->Const.QueryCounterBits.GsPrimitives = 64;
+ ctx->Const.QueryCounterBits.FsInvocations = 64;
+ ctx->Const.QueryCounterBits.ComputeInvocations = 64;
+ ctx->Const.QueryCounterBits.ClInPrimitives = 64;
+ ctx->Const.QueryCounterBits.ClOutPrimitives = 64;
}