mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
mesa: improved driver query interface
Brought over from gallium-0.2 branch.
This commit is contained in:
parent
dc8058c337
commit
7ce597508e
7 changed files with 100 additions and 69 deletions
|
|
@ -228,8 +228,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
|||
|
||||
/* query objects */
|
||||
driver->NewQueryObject = _mesa_new_query_object;
|
||||
driver->BeginQuery = NULL;
|
||||
driver->EndQuery = NULL;
|
||||
driver->DeleteQuery = _mesa_delete_query;
|
||||
driver->BeginQuery = _mesa_begin_query;
|
||||
driver->EndQuery = _mesa_end_query;
|
||||
driver->WaitQuery = _mesa_wait_query;
|
||||
|
||||
/* APPLE_vertex_array_object */
|
||||
driver->NewArrayObject = _mesa_new_array_object;
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ intelFinish(GLcontext * ctx)
|
|||
|
||||
#ifdef I915_MMIO_READ
|
||||
static void
|
||||
intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
|
||||
intelBeginQuery(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
struct intel_context *intel = intel_context( ctx );
|
||||
struct drm_i915_mmio io = {
|
||||
|
|
@ -564,7 +564,7 @@ intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
|
|||
}
|
||||
|
||||
static void
|
||||
intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
|
||||
intelEndQuery(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
struct intel_context *intel = intel_context( ctx );
|
||||
GLuint64EXT tmp;
|
||||
|
|
|
|||
|
|
@ -1086,9 +1086,9 @@ xmesa_new_query_object(GLcontext *ctx, GLuint id)
|
|||
|
||||
|
||||
static void
|
||||
xmesa_begin_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
|
||||
xmesa_begin_query(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
if (target == GL_TIME_ELAPSED_EXT) {
|
||||
if (q->Target == GL_TIME_ELAPSED_EXT) {
|
||||
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
|
||||
(void) gettimeofday(&xq->StartTime, NULL);
|
||||
}
|
||||
|
|
@ -1113,9 +1113,9 @@ time_diff(const struct timeval *t0, const struct timeval *t1)
|
|||
|
||||
|
||||
static void
|
||||
xmesa_end_query(GLcontext *ctx, GLenum target, struct gl_query_object *q)
|
||||
xmesa_end_query(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
if (target == GL_TIME_ELAPSED_EXT) {
|
||||
if (q->Target == GL_TIME_ELAPSED_EXT) {
|
||||
struct xmesa_query_object *xq = (struct xmesa_query_object *) q;
|
||||
struct timeval endTime;
|
||||
(void) gettimeofday(&endTime, NULL);
|
||||
|
|
|
|||
|
|
@ -817,9 +817,11 @@ struct dd_function_table {
|
|||
*/
|
||||
/*@{*/
|
||||
struct gl_query_object * (*NewQueryObject)(GLcontext *ctx, GLuint id);
|
||||
void (*BeginQuery)(GLcontext *ctx, GLenum target,
|
||||
struct gl_query_object *q);
|
||||
void (*EndQuery)(GLcontext *ctx, GLenum target, struct gl_query_object *q);
|
||||
void (*DeleteQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||
void (*BeginQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||
void (*EndQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||
void (*CheckQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||
void (*WaitQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2074,10 +2074,11 @@ struct gl_ati_fragment_shader_state
|
|||
*/
|
||||
struct gl_query_object
|
||||
{
|
||||
GLuint Id;
|
||||
GLuint64EXT Result; /* the counter */
|
||||
GLboolean Active; /* inside Begin/EndQuery */
|
||||
GLboolean Ready; /* result is ready */
|
||||
GLenum Target; /**< The query target, when active */
|
||||
GLuint Id; /**< hash table ID/name */
|
||||
GLuint64EXT Result; /**< the counter */
|
||||
GLboolean Active; /**< inside Begin/EndQuery */
|
||||
GLboolean Ready; /**< result is ready? */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5.1
|
||||
* Version: 7.1
|
||||
*
|
||||
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
|
@ -53,15 +53,51 @@ _mesa_new_query_object(GLcontext *ctx, GLuint id)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Begin a query. Software driver fallback.
|
||||
* Called via ctx->Driver.BeginQuery().
|
||||
*/
|
||||
void
|
||||
_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* End a query. Software driver fallback.
|
||||
* Called via ctx->Driver.EndQuery().
|
||||
*/
|
||||
void
|
||||
_mesa_end_query(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
q->Ready = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wait for query to complete. Software driver fallback.
|
||||
* Called via ctx->Driver.WaitQuery().
|
||||
*/
|
||||
void
|
||||
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q)
|
||||
{
|
||||
/* For software drivers, _mesa_end_query() should have completed the query.
|
||||
* For real hardware, implement a proper WaitQuery() driver function.
|
||||
*/
|
||||
assert(q->Ready);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete an occlusion query object.
|
||||
* Not removed from hash table here.
|
||||
* XXX maybe add Delete() method to gl_query_object class and call that instead
|
||||
*/
|
||||
static void
|
||||
delete_query_object(struct gl_query_object *q)
|
||||
void
|
||||
_mesa_delete_query(struct gl_query_object *q)
|
||||
{
|
||||
FREE(q);
|
||||
_mesa_free(q);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -135,7 +171,7 @@ _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
|
|||
if (q) {
|
||||
ASSERT(!q->Active); /* should be caught earlier */
|
||||
_mesa_HashRemove(ctx->Query.QueryObjects, ids[i]);
|
||||
delete_query_object(q);
|
||||
ctx->Driver.DeleteQuery(ctx, q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -216,6 +252,7 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
|
|||
}
|
||||
}
|
||||
|
||||
q->Target = target;
|
||||
q->Active = GL_TRUE;
|
||||
q->Result = 0;
|
||||
q->Ready = GL_FALSE;
|
||||
|
|
@ -229,9 +266,7 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (ctx->Driver.BeginQuery) {
|
||||
ctx->Driver.BeginQuery(ctx, target, q);
|
||||
}
|
||||
ctx->Driver.BeginQuery(ctx, q);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -275,13 +310,7 @@ _mesa_EndQueryARB(GLenum target)
|
|||
}
|
||||
|
||||
q->Active = GL_FALSE;
|
||||
if (ctx->Driver.EndQuery) {
|
||||
ctx->Driver.EndQuery(ctx, target, q);
|
||||
}
|
||||
else {
|
||||
/* if we're using software rendering/querying */
|
||||
q->Ready = GL_TRUE;
|
||||
}
|
||||
ctx->Driver.EndQuery(ctx, q);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -346,23 +375,19 @@ _mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
|
|||
|
||||
switch (pname) {
|
||||
case GL_QUERY_RESULT_ARB:
|
||||
while (!q->Ready) {
|
||||
/* Wait for the query to finish! */
|
||||
/* If using software rendering, the result will always be ready
|
||||
* by time we get here. Otherwise, we must be using hardware!
|
||||
*/
|
||||
ASSERT(ctx->Driver.EndQuery);
|
||||
}
|
||||
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 = q->Result;
|
||||
*params = (GLint)q->Result;
|
||||
}
|
||||
break;
|
||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||
/* XXX revisit when we have a hardware implementation! */
|
||||
if (!q->Ready)
|
||||
ctx->Driver.CheckQuery( ctx, q );
|
||||
*params = q->Ready;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -390,23 +415,19 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
|
|||
|
||||
switch (pname) {
|
||||
case GL_QUERY_RESULT_ARB:
|
||||
while (!q->Ready) {
|
||||
/* Wait for the query to finish! */
|
||||
/* If using software rendering, the result will always be ready
|
||||
* by time we get here. Otherwise, we must be using hardware!
|
||||
*/
|
||||
ASSERT(ctx->Driver.EndQuery);
|
||||
}
|
||||
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 = q->Result;
|
||||
*params = (GLuint)q->Result;
|
||||
}
|
||||
break;
|
||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||
/* XXX revisit when we have a hardware implementation! */
|
||||
if (!q->Ready)
|
||||
ctx->Driver.CheckQuery( ctx, q );
|
||||
*params = q->Ready;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -439,17 +460,13 @@ _mesa_GetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)
|
|||
|
||||
switch (pname) {
|
||||
case GL_QUERY_RESULT_ARB:
|
||||
while (!q->Ready) {
|
||||
/* Wait for the query to finish! */
|
||||
/* If using software rendering, the result will always be ready
|
||||
* by time we get here. Otherwise, we must be using hardware!
|
||||
*/
|
||||
ASSERT(ctx->Driver.EndQuery);
|
||||
}
|
||||
if (!q->Ready)
|
||||
ctx->Driver.WaitQuery(ctx, q);
|
||||
*params = q->Result;
|
||||
break;
|
||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||
/* XXX revisit when we have a hardware implementation! */
|
||||
if (!q->Ready)
|
||||
ctx->Driver.CheckQuery( ctx, q );
|
||||
*params = q->Ready;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -480,17 +497,13 @@ _mesa_GetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
|
|||
|
||||
switch (pname) {
|
||||
case GL_QUERY_RESULT_ARB:
|
||||
while (!q->Ready) {
|
||||
/* Wait for the query to finish! */
|
||||
/* If using software rendering, the result will always be ready
|
||||
* by time we get here. Otherwise, we must be using hardware!
|
||||
*/
|
||||
ASSERT(ctx->Driver.EndQuery);
|
||||
}
|
||||
if (!q->Ready)
|
||||
ctx->Driver.WaitQuery(ctx, q);
|
||||
*params = q->Result;
|
||||
break;
|
||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||
/* XXX revisit when we have a hardware implementation! */
|
||||
if (!q->Ready)
|
||||
ctx->Driver.CheckQuery( ctx, q );
|
||||
*params = q->Ready;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -522,8 +535,8 @@ static void
|
|||
delete_queryobj_cb(GLuint id, void *data, void *userData)
|
||||
{
|
||||
struct gl_query_object *q= (struct gl_query_object *) data;
|
||||
(void) userData;
|
||||
delete_query_object(q);
|
||||
GLcontext *ctx = (GLcontext *)userData;
|
||||
ctx->Driver.DeleteQuery(ctx, q);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 6.5
|
||||
* Version: 7.1
|
||||
*
|
||||
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
|
@ -36,6 +36,19 @@ _mesa_init_query(GLcontext *ctx);
|
|||
extern void
|
||||
_mesa_free_query_data(GLcontext *ctx);
|
||||
|
||||
extern void
|
||||
_mesa_delete_query(struct gl_query_object *q);
|
||||
|
||||
extern void
|
||||
_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q);
|
||||
|
||||
extern void
|
||||
_mesa_end_query(GLcontext *ctx, struct gl_query_object *q);
|
||||
|
||||
extern void
|
||||
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q);
|
||||
|
||||
|
||||
extern void GLAPIENTRY
|
||||
_mesa_GenQueriesARB(GLsizei n, GLuint *ids);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue