st_cb_queryobj.c File Reference

Include dependency graph for st_cb_queryobj.c:

Go to the source code of this file.

Data Structures

struct  st_query_object
 glBegin/EndQuery interface to pipe More...

Functions

static struct st_query_objectst_query_object (struct gl_query_object *q)
 Cast wrapper.
static struct gl_query_object * st_NewQueryObject (GLcontext *ctx, GLuint id)
static void st_DeleteQuery (GLcontext *ctx, struct gl_query_object *q)
static void st_BeginQuery (GLcontext *ctx, struct gl_query_object *q)
static void st_EndQuery (GLcontext *ctx, struct gl_query_object *q)
static void st_WaitQuery (GLcontext *ctx, struct gl_query_object *q)
static void st_CheckQuery (GLcontext *ctx, struct gl_query_object *q)
void st_init_query_functions (struct dd_function_table *functions)


Function Documentation

static void st_BeginQuery ( GLcontext *  ctx,
struct gl_query_object *  q 
) [static]

Definition at line 95 of file st_cb_queryobj.c.

References assert, pipe_context::begin_query, pipe_context::create_query, PIPE_QUERY_OCCLUSION_COUNTER, st_query_object::pq, and st_query_object().

00096 {
00097    struct pipe_context *pipe = ctx->st->pipe;
00098    struct st_query_object *stq = st_query_object(q);
00099 
00100    switch (q->Target) {
00101    case GL_SAMPLES_PASSED_ARB:
00102       if (!stq->pq)
00103          stq->pq = pipe->create_query( pipe, PIPE_QUERY_OCCLUSION_COUNTER );
00104       break;
00105    default:
00106       assert(0);
00107       return;
00108    }
00109 
00110    pipe->begin_query(pipe, stq->pq);
00111 }

static void st_CheckQuery ( GLcontext *  ctx,
struct gl_query_object *  q 
) [static]

Definition at line 147 of file st_cb_queryobj.c.

References FALSE, pipe_context::get_query_result, st_query_object::pq, and st_query_object().

00148 {
00149    struct pipe_context *pipe = ctx->st->pipe;
00150    struct st_query_object *stq = st_query_object(q);
00151 
00152    if (!q->Ready) {
00153       q->Ready = pipe->get_query_result(pipe, 
00154                                         stq->pq,
00155                                         FALSE,
00156                                         &q->Result);
00157    }
00158 }

static void st_DeleteQuery ( GLcontext *  ctx,
struct gl_query_object *  q 
) [static]

Definition at line 80 of file st_cb_queryobj.c.

References pipe_context::destroy_query, FREE, st_query_object::pq, and st_query_object().

00081 {
00082    struct pipe_context *pipe = ctx->st->pipe;
00083    struct st_query_object *stq = st_query_object(q);
00084 
00085    if (stq->pq) {
00086       pipe->destroy_query(pipe, stq->pq);
00087       stq->pq = NULL;
00088    }
00089 
00090    FREE(stq);
00091 }

static void st_EndQuery ( GLcontext *  ctx,
struct gl_query_object *  q 
) [static]

Definition at line 115 of file st_cb_queryobj.c.

References pipe_context::end_query, st_query_object::pq, and st_query_object().

00116 {
00117    struct pipe_context *pipe = ctx->st->pipe;
00118    struct st_query_object *stq = st_query_object(q);
00119 
00120    pipe->end_query(pipe, stq->pq);
00121 }

void st_init_query_functions ( struct dd_function_table *  functions  ) 

Definition at line 163 of file st_cb_queryobj.c.

References st_BeginQuery(), st_CheckQuery(), st_DeleteQuery(), st_EndQuery(), st_NewQueryObject(), and st_WaitQuery().

00164 {
00165    functions->NewQueryObject = st_NewQueryObject;
00166    functions->DeleteQuery = st_DeleteQuery;
00167    functions->BeginQuery = st_BeginQuery;
00168    functions->EndQuery = st_EndQuery;
00169    functions->WaitQuery = st_WaitQuery;
00170    functions->CheckQuery = st_CheckQuery;
00171 }

static struct gl_query_object* st_NewQueryObject ( GLcontext *  ctx,
GLuint  id 
) [static, read]

Definition at line 65 of file st_cb_queryobj.c.

References st_query_object::base, CALLOC_STRUCT, and st_query_object::pq.

00066 {
00067    struct st_query_object *stq = CALLOC_STRUCT(st_query_object);
00068    if (stq) {
00069       stq->base.Id = id;
00070       stq->base.Ready = GL_TRUE;
00071       stq->pq = NULL;
00072       return &stq->base;
00073    }
00074    return NULL;
00075 }

static struct st_query_object* st_query_object ( struct gl_query_object *  q  )  [static, read]

Cast wrapper.

Definition at line 58 of file st_cb_queryobj.c.

00059 {
00060    return (struct st_query_object *) q;
00061 }

static void st_WaitQuery ( GLcontext *  ctx,
struct gl_query_object *  q 
) [static]

Definition at line 125 of file st_cb_queryobj.c.

References assert, st_query_object::base, pipe_context::get_query_result, st_query_object::pq, st_query_object(), and TRUE.

00126 {
00127    struct pipe_context *pipe = ctx->st->pipe;
00128    struct st_query_object *stq = st_query_object(q);
00129 
00130    /* this function should only be called if we don't have a ready result */
00131    assert(!stq->base.Ready);
00132 
00133    while (!stq->base.Ready &&
00134           !pipe->get_query_result(pipe, 
00135                                   stq->pq,
00136                                   TRUE,
00137                                   &q->Result))
00138    {
00139       /* nothing */
00140    }
00141                             
00142    q->Ready = GL_TRUE;
00143 }


Generated on Tue Sep 29 06:25:53 2009 for Gallium3D by  doxygen 1.5.4