Rearrange the code related to GL_ARB_occlusion_object to generalize query
objects for future types of queries.
This commit is contained in:
@@ -209,6 +209,10 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
|||||||
driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
|
driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* query objects */
|
||||||
|
driver->BeginQuery = NULL;
|
||||||
|
driver->EndQuery = NULL;
|
||||||
|
|
||||||
/* T&L stuff */
|
/* T&L stuff */
|
||||||
driver->NeedValidate = GL_FALSE;
|
driver->NeedValidate = GL_FALSE;
|
||||||
driver->ValidateTnlModule = NULL;
|
driver->ValidateTnlModule = NULL;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: gld_vb_mesa_render_dx7.c,v 1.5 2005/04/22 22:47:09 keithw Exp $ */
|
/* $Id: gld_vb_mesa_render_dx7.c,v 1.6 2005/08/27 13:56:08 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -153,7 +153,6 @@ do { \
|
|||||||
#define TAG(x) clip_##x##_verts
|
#define TAG(x) clip_##x##_verts
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
#include "tnl/t_vb_rendertmp.h"
|
#include "tnl/t_vb_rendertmp.h"
|
||||||
|
|
||||||
@@ -239,7 +238,6 @@ static void clip_elt_triangles( GLcontext *ctx,
|
|||||||
(void) elt;
|
(void) elt;
|
||||||
|
|
||||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RENDER_TAB_QUALIFIER
|
#define RENDER_TAB_QUALIFIER
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: gld_vb_mesa_render_dx8.c,v 1.5 2005/04/22 22:47:10 keithw Exp $ */
|
/* $Id: gld_vb_mesa_render_dx8.c,v 1.6 2005/08/27 13:56:08 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -153,7 +153,6 @@ do { \
|
|||||||
#define TAG(x) clip_##x##_verts
|
#define TAG(x) clip_##x##_verts
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
#include "tnl/t_vb_rendertmp.h"
|
#include "tnl/t_vb_rendertmp.h"
|
||||||
|
|
||||||
@@ -239,7 +238,6 @@ static void clip_elt_triangles( GLcontext *ctx,
|
|||||||
(void) elt;
|
(void) elt;
|
||||||
|
|
||||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RENDER_TAB_QUALIFIER
|
#define RENDER_TAB_QUALIFIER
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: gld_vb_mesa_render_dx9.c,v 1.5 2005/04/22 22:47:10 keithw Exp $ */
|
/* $Id: gld_vb_mesa_render_dx9.c,v 1.6 2005/08/27 13:56:08 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -148,7 +148,6 @@ do { \
|
|||||||
#define TAG(x) clip_##x##_verts
|
#define TAG(x) clip_##x##_verts
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
#include "tnl/t_vb_rendertmp.h"
|
#include "tnl/t_vb_rendertmp.h"
|
||||||
|
|
||||||
@@ -234,7 +233,6 @@ static void clip_elt_triangles( GLcontext *ctx,
|
|||||||
(void) elt;
|
(void) elt;
|
||||||
|
|
||||||
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
#define RESET_STIPPLE tnl->Driver.Render.ResetLineStipple( ctx )
|
||||||
#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
|
|
||||||
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
|
||||||
#define RENDER_TAB_QUALIFIER
|
#define RENDER_TAB_QUALIFIER
|
||||||
#define PRESERVE_VB_DEFS
|
#define PRESERVE_VB_DEFS
|
||||||
|
@@ -816,6 +816,14 @@ struct dd_function_table {
|
|||||||
/*@}*/
|
/*@}*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name Query objects
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
void (*BeginQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||||
|
void (*EndQuery)(GLcontext *ctx, struct gl_query_object *q);
|
||||||
|
/*@}*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Support for multiple T&L engines
|
* \name Support for multiple T&L engines
|
||||||
|
@@ -1853,7 +1853,7 @@ struct gl_vertex_program_state
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* State for GL_ARB/NV_fragment_program
|
* State for GL_ARB/NV_fragment_program
|
||||||
*/
|
*/
|
||||||
struct gl_fragment_program_state
|
struct gl_fragment_program_state
|
||||||
@@ -1874,8 +1874,9 @@ struct gl_fragment_program_state
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* State for GL_fragment_shader
|
/**
|
||||||
|
* State for GL_ATI_fragment_shader
|
||||||
*/
|
*/
|
||||||
struct gl_ati_fragment_shader_state
|
struct gl_ati_fragment_shader_state
|
||||||
{
|
{
|
||||||
@@ -1886,17 +1887,24 @@ struct gl_ati_fragment_shader_state
|
|||||||
struct ati_fragment_shader *Current;
|
struct ati_fragment_shader *Current;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* State for GL_ARB_occlusion_query
|
struct gl_query_object
|
||||||
*/
|
|
||||||
struct gl_occlusion_state
|
|
||||||
{
|
{
|
||||||
GLboolean Active;
|
GLenum Target;
|
||||||
GLuint CurrentQueryObject;
|
GLuint Id;
|
||||||
GLuint PassedCounter;
|
GLuint Result; /* the counter */
|
||||||
struct _mesa_HashTable *QueryObjects;
|
GLboolean Active; /* inside Begin/EndQuery */
|
||||||
|
GLboolean Ready; /* result is ready */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct gl_query_state
|
||||||
|
{
|
||||||
|
struct _mesa_HashTable *QueryObjects;
|
||||||
|
struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gl2 unique interface identifier.
|
* gl2 unique interface identifier.
|
||||||
* Each gl2 interface has its own interface id used for object queries.
|
* Each gl2 interface has its own interface id used for object queries.
|
||||||
@@ -2802,7 +2810,7 @@ struct __GLcontextRec
|
|||||||
GLboolean _MaintainTexEnvProgram;
|
GLboolean _MaintainTexEnvProgram;
|
||||||
GLboolean _MaintainTnlProgram;
|
GLboolean _MaintainTnlProgram;
|
||||||
|
|
||||||
struct gl_occlusion_state Occlusion; /**< GL_ARB_occlusion_query */
|
struct gl_query_state Query; /**< GL_ARB_occlusion_query */
|
||||||
|
|
||||||
struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
|
struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
@@ -36,29 +36,20 @@
|
|||||||
#include "mtypes.h"
|
#include "mtypes.h"
|
||||||
|
|
||||||
|
|
||||||
struct occlusion_query
|
|
||||||
{
|
|
||||||
GLenum Target;
|
|
||||||
GLuint Id;
|
|
||||||
GLuint PassedCounter;
|
|
||||||
GLboolean Active;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new occlusion query object.
|
* Allocate a new occlusion query object.
|
||||||
* \param target - must be GL_SAMPLES_PASSED_ARB at this time
|
* \param target - must be GL_SAMPLES_PASSED_ARB at this time
|
||||||
* \param id - the object's ID
|
* \param id - the object's ID
|
||||||
* \return pointer to new occlusion_query object or NULL if out of memory.
|
* \return pointer to new query_object object or NULL if out of memory.
|
||||||
*/
|
*/
|
||||||
static struct occlusion_query *
|
static struct gl_query_object *
|
||||||
new_query_object(GLenum target, GLuint id)
|
new_query_object(GLenum target, GLuint id)
|
||||||
{
|
{
|
||||||
struct occlusion_query *q = MALLOC_STRUCT(occlusion_query);
|
struct gl_query_object *q = MALLOC_STRUCT(gl_query_object);
|
||||||
if (q) {
|
if (q) {
|
||||||
q->Target = target;
|
q->Target = target;
|
||||||
q->Id = id;
|
q->Id = id;
|
||||||
q->PassedCounter = 0;
|
q->Result = 0;
|
||||||
q->Active = GL_FALSE;
|
q->Active = GL_FALSE;
|
||||||
}
|
}
|
||||||
return q;
|
return q;
|
||||||
@@ -67,14 +58,24 @@ new_query_object(GLenum target, GLuint id)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an occlusion query object.
|
* Delete an occlusion query object.
|
||||||
|
* Not removed from hash table here.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
delete_query_object(struct occlusion_query *q)
|
delete_query_object(struct gl_query_object *q)
|
||||||
{
|
{
|
||||||
FREE(q);
|
FREE(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct gl_query_object *
|
||||||
|
lookup_query_object(GLcontext *ctx, GLuint id)
|
||||||
|
{
|
||||||
|
return (struct gl_query_object *)
|
||||||
|
_mesa_HashLookup(ctx->Query.QueryObjects, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
|
_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
|
||||||
{
|
{
|
||||||
@@ -87,23 +88,24 @@ _mesa_GenQueriesARB(GLsizei n, GLuint *ids)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Occlusion.Active) {
|
/* No query objects can be active at this time! */
|
||||||
|
if (ctx->Query.CurrentOcclusionObject) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
first = _mesa_HashFindFreeKeyBlock(ctx->Occlusion.QueryObjects, n);
|
first = _mesa_HashFindFreeKeyBlock(ctx->Query.QueryObjects, n);
|
||||||
if (first) {
|
if (first) {
|
||||||
GLsizei i;
|
GLsizei i;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
struct occlusion_query *q = new_query_object(GL_SAMPLES_PASSED_ARB,
|
struct gl_query_object *q = new_query_object(GL_SAMPLES_PASSED_ARB,
|
||||||
first + i);
|
first + i);
|
||||||
if (!q) {
|
if (!q) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ids[i] = first + i;
|
ids[i] = first + i;
|
||||||
_mesa_HashInsert(ctx->Occlusion.QueryObjects, first + i, q);
|
_mesa_HashInsert(ctx->Query.QueryObjects, first + i, q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,17 +123,18 @@ _mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Occlusion.Active) {
|
/* No query objects can be active at this time! */
|
||||||
|
if (ctx->Query.CurrentOcclusionObject) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (ids[i] > 0) {
|
if (ids[i] > 0) {
|
||||||
struct occlusion_query *q = (struct occlusion_query *)
|
struct gl_query_object *q = lookup_query_object(ctx, ids[i]);
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects, ids[i]);
|
|
||||||
if (q) {
|
if (q) {
|
||||||
_mesa_HashRemove(ctx->Occlusion.QueryObjects, ids[i]);
|
ASSERT(!q->Active); /* should be caught earlier */
|
||||||
|
_mesa_HashRemove(ctx->Query.QueryObjects, ids[i]);
|
||||||
delete_query_object(q);
|
delete_query_object(q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +148,7 @@ _mesa_IsQueryARB(GLuint id)
|
|||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
|
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
|
||||||
|
|
||||||
if (id && _mesa_HashLookup(ctx->Occlusion.QueryObjects, id))
|
if (id && lookup_query_object(ctx, id))
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
else
|
else
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@@ -156,7 +159,7 @@ void GLAPIENTRY
|
|||||||
_mesa_BeginQueryARB(GLenum target, GLuint id)
|
_mesa_BeginQueryARB(GLenum target, GLuint id)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
struct occlusion_query *q;
|
struct gl_query_object *q;
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
||||||
@@ -171,31 +174,43 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Occlusion.CurrentQueryObject) {
|
if (ctx->Query.CurrentOcclusionObject) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(target)");
|
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(target)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = (struct occlusion_query *)
|
q = lookup_query_object(ctx, id);
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
|
if (!q) {
|
||||||
if (q && q->Active) {
|
/* create new object */
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!q) {
|
|
||||||
q = new_query_object(target, id);
|
q = new_query_object(target, id);
|
||||||
if (!q) {
|
if (!q) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_mesa_HashInsert(ctx->Occlusion.QueryObjects, id, q);
|
_mesa_HashInsert(ctx->Query.QueryObjects, id, q);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* pre-existing object */
|
||||||
|
if (q->Target != target) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glBeginQueryARB(target mismatch)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (q->Active) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glBeginQueryARB(query already active)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
q->Active = GL_TRUE;
|
q->Active = GL_TRUE;
|
||||||
q->PassedCounter = 0;
|
q->Result = 0;
|
||||||
ctx->Occlusion.Active = GL_TRUE;
|
q->Ready = GL_FALSE;
|
||||||
ctx->Occlusion.CurrentQueryObject = id;
|
ctx->Query.CurrentOcclusionObject = q;
|
||||||
ctx->Occlusion.PassedCounter = 0;
|
|
||||||
|
if (ctx->Driver.BeginQuery) {
|
||||||
|
ctx->Driver.BeginQuery(ctx, q);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -203,29 +218,34 @@ void GLAPIENTRY
|
|||||||
_mesa_EndQueryARB(GLenum target)
|
_mesa_EndQueryARB(GLenum target)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
struct occlusion_query *q = NULL;
|
struct gl_query_object *q;
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
||||||
|
|
||||||
if (target != GL_SAMPLES_PASSED_ARB) {
|
switch (target) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
case GL_SAMPLES_PASSED_ARB:
|
||||||
return;
|
q = ctx->Query.CurrentOcclusionObject;
|
||||||
|
ctx->Query.CurrentOcclusionObject = NULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Occlusion.CurrentQueryObject)
|
|
||||||
q = (struct occlusion_query *)
|
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects,
|
|
||||||
ctx->Occlusion.CurrentQueryObject);
|
|
||||||
if (!q || !q->Active) {
|
if (!q || !q->Active) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glEndQuery with no glBeginQuery");
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glEndQueryARB(no matching glBeginQueryARB)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
q->PassedCounter = ctx->Occlusion.PassedCounter;
|
|
||||||
q->Active = GL_FALSE;
|
q->Active = GL_FALSE;
|
||||||
ctx->Occlusion.Active = GL_FALSE;
|
if (ctx->Driver.EndQuery) {
|
||||||
ctx->Occlusion.CurrentQueryObject = 0;
|
ctx->Driver.EndQuery(ctx, q);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q->Ready = GL_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -233,19 +253,24 @@ void GLAPIENTRY
|
|||||||
_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
|
_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
|
struct gl_query_object *q;
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
if (target != GL_SAMPLES_PASSED_ARB) {
|
switch (target) {
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(target)");
|
case GL_SAMPLES_PASSED_ARB:
|
||||||
return;
|
q = ctx->Query.CurrentOcclusionObject;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(target)");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_QUERY_COUNTER_BITS_ARB:
|
case GL_QUERY_COUNTER_BITS_ARB:
|
||||||
*params = 8 * sizeof(GLuint);
|
*params = 8 * sizeof(q->Result);
|
||||||
break;
|
break;
|
||||||
case GL_CURRENT_QUERY_ARB:
|
case GL_CURRENT_QUERY_ARB:
|
||||||
*params = ctx->Occlusion.CurrentQueryObject;
|
*params = q ? q->Id : 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)");
|
||||||
@@ -258,25 +283,25 @@ void GLAPIENTRY
|
|||||||
_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
|
_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
struct occlusion_query *q = NULL;
|
struct gl_query_object *q = NULL;
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
if (id)
|
if (id)
|
||||||
q = (struct occlusion_query *)
|
q = lookup_query_object(ctx, id);
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
|
|
||||||
|
|
||||||
if (!q || q->Active) {
|
if (!q || q->Active) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectivARB(id=%d)", id);
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glGetQueryObjectivARB(id=%d is active)", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_QUERY_RESULT_ARB:
|
case GL_QUERY_RESULT_ARB:
|
||||||
*params = q->PassedCounter;
|
*params = q->Result;
|
||||||
break;
|
break;
|
||||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||||
/* XXX revisit when we have a hardware implementation! */
|
/* XXX revisit when we have a hardware implementation! */
|
||||||
*params = GL_TRUE;
|
*params = q->Ready;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)");
|
||||||
@@ -289,24 +314,25 @@ void GLAPIENTRY
|
|||||||
_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
|
_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
|
||||||
{
|
{
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
struct occlusion_query *q = NULL;
|
struct gl_query_object *q = NULL;
|
||||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||||
|
|
||||||
if (id)
|
if (id)
|
||||||
q = (struct occlusion_query *)
|
q = lookup_query_object(ctx, id);
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
|
|
||||||
if (!q || q->Active) {
|
if (!q || q->Active) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuivARB(id=%d", id);
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"glGetQueryObjectuivARB(id=%d is active)", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pname) {
|
switch (pname) {
|
||||||
case GL_QUERY_RESULT_ARB:
|
case GL_QUERY_RESULT_ARB:
|
||||||
*params = q->PassedCounter;
|
*params = q->Result;
|
||||||
break;
|
break;
|
||||||
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
case GL_QUERY_RESULT_AVAILABLE_ARB:
|
||||||
/* XXX revisit when we have a hardware implementation! */
|
/* XXX revisit when we have a hardware implementation! */
|
||||||
*params = GL_TRUE;
|
*params = q->Ready;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)");
|
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)");
|
||||||
@@ -323,7 +349,8 @@ void
|
|||||||
_mesa_init_occlude(GLcontext *ctx)
|
_mesa_init_occlude(GLcontext *ctx)
|
||||||
{
|
{
|
||||||
#if FEATURE_ARB_occlusion_query
|
#if FEATURE_ARB_occlusion_query
|
||||||
ctx->Occlusion.QueryObjects = _mesa_NewHashTable();
|
ctx->Query.QueryObjects = _mesa_NewHashTable();
|
||||||
|
ctx->Query.CurrentOcclusionObject = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,17 +362,16 @@ void
|
|||||||
_mesa_free_occlude_data(GLcontext *ctx)
|
_mesa_free_occlude_data(GLcontext *ctx)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
GLuint query = _mesa_HashFirstEntry(ctx->Occlusion.QueryObjects);
|
GLuint id = _mesa_HashFirstEntry(ctx->Query.QueryObjects);
|
||||||
if (query) {
|
if (id) {
|
||||||
struct occlusion_query *q = (struct occlusion_query *)
|
struct gl_query_object *q = lookup_query_object(ctx, id);
|
||||||
_mesa_HashLookup(ctx->Occlusion.QueryObjects, query);
|
|
||||||
ASSERT(q);
|
ASSERT(q);
|
||||||
delete_query_object(q);
|
delete_query_object(q);
|
||||||
_mesa_HashRemove(ctx->Occlusion.QueryObjects, query);
|
_mesa_HashRemove(ctx->Query.QueryObjects, id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_mesa_DeleteHashTable(ctx->Occlusion.QueryObjects);
|
_mesa_DeleteHashTable(ctx->Query.QueryObjects);
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
|
|||||||
rasterMask |= CLIP_BIT;
|
rasterMask |= CLIP_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Occlusion.Active)
|
if (ctx->Query.CurrentOcclusionObject)
|
||||||
rasterMask |= OCCLUSION_BIT;
|
rasterMask |= OCCLUSION_BIT;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -850,11 +850,12 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if FEATURE_ARB_occlusion_query
|
#if FEATURE_ARB_occlusion_query
|
||||||
if (ctx->Occlusion.Active) {
|
if (ctx->Query.CurrentOcclusionObject) {
|
||||||
/* update count of 'passed' fragments */
|
/* update count of 'passed' fragments */
|
||||||
|
struct gl_query_object *q = ctx->Query.CurrentOcclusionObject;
|
||||||
GLuint i;
|
GLuint i;
|
||||||
for (i = 0; i < span->end; i++)
|
for (i = 0; i < span->end; i++)
|
||||||
ctx->Occlusion.PassedCounter += span->array->mask[i];
|
q->Result += span->array->mask[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1215,11 +1216,12 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if FEATURE_ARB_occlusion_query
|
#if FEATURE_ARB_occlusion_query
|
||||||
if (ctx->Occlusion.Active) {
|
if (ctx->Query.CurrentOcclusionObject) {
|
||||||
/* update count of 'passed' fragments */
|
/* update count of 'passed' fragments */
|
||||||
|
struct gl_query_object *q = ctx->Query.CurrentOcclusionObject;
|
||||||
GLuint i;
|
GLuint i;
|
||||||
for (i = 0; i < span->end; i++)
|
for (i = 0; i < span->end; i++)
|
||||||
ctx->Occlusion.PassedCounter += span->array->mask[i];
|
q->Result += span->array->mask[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -904,14 +904,15 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
|
|||||||
*/
|
*/
|
||||||
#define NAME occlusion_zless_triangle
|
#define NAME occlusion_zless_triangle
|
||||||
#define INTERP_Z 1
|
#define INTERP_Z 1
|
||||||
#define SETUP_CODE \
|
#define SETUP_CODE \
|
||||||
struct gl_renderbuffer *rb \
|
struct gl_renderbuffer *rb \
|
||||||
= ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \
|
= ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \
|
||||||
ASSERT(ctx->Depth.Test); \
|
struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; \
|
||||||
ASSERT(!ctx->Depth.Mask); \
|
ASSERT(ctx->Depth.Test); \
|
||||||
ASSERT(ctx->Depth.Func == GL_LESS); \
|
ASSERT(!ctx->Depth.Mask); \
|
||||||
if (!ctx->Occlusion.Active) { \
|
ASSERT(ctx->Depth.Func == GL_LESS); \
|
||||||
return; \
|
if (!q) { \
|
||||||
|
return; \
|
||||||
}
|
}
|
||||||
#define RENDER_SPAN( span ) \
|
#define RENDER_SPAN( span ) \
|
||||||
if (ctx->Visual.depthBits <= 16) { \
|
if (ctx->Visual.depthBits <= 16) { \
|
||||||
@@ -921,7 +922,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
|
|||||||
for (i = 0; i < span.end; i++) { \
|
for (i = 0; i < span.end; i++) { \
|
||||||
GLdepth z = FixedToDepth(span.z); \
|
GLdepth z = FixedToDepth(span.z); \
|
||||||
if (z < zRow[i]) { \
|
if (z < zRow[i]) { \
|
||||||
ctx->Occlusion.PassedCounter++; \
|
q->Result++; \
|
||||||
} \
|
} \
|
||||||
span.z += span.zStep; \
|
span.z += span.zStep; \
|
||||||
} \
|
} \
|
||||||
@@ -932,7 +933,7 @@ fast_persp_span(GLcontext *ctx, struct sw_span *span,
|
|||||||
rb->GetPointer(ctx, rb, span.x, span.y); \
|
rb->GetPointer(ctx, rb, span.x, span.y); \
|
||||||
for (i = 0; i < span.end; i++) { \
|
for (i = 0; i < span.end; i++) { \
|
||||||
if ((GLuint)span.z < zRow[i]) { \
|
if ((GLuint)span.z < zRow[i]) { \
|
||||||
ctx->Occlusion.PassedCounter++; \
|
q->Result++; \
|
||||||
} \
|
} \
|
||||||
span.z += span.zStep; \
|
span.z += span.zStep; \
|
||||||
} \
|
} \
|
||||||
@@ -1055,7 +1056,7 @@ _swrast_choose_triangle( GLcontext *ctx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case for occlusion testing */
|
/* special case for occlusion testing */
|
||||||
if (ctx->Occlusion.Active &&
|
if (ctx->Query.CurrentOcclusionObject &&
|
||||||
ctx->Depth.Test &&
|
ctx->Depth.Test &&
|
||||||
ctx->Depth.Mask == GL_FALSE &&
|
ctx->Depth.Mask == GL_FALSE &&
|
||||||
ctx->Depth.Func == GL_LESS &&
|
ctx->Depth.Func == GL_LESS &&
|
||||||
|
Reference in New Issue
Block a user