struct fd_query *q;
q = fd_sw_create_query(ctx, query_type);
- if (!q)
- q = fd_hw_create_query(ctx, query_type);
+ if (!q && ctx->create_query)
+ q = ctx->create_query(ctx, query_type);
return (struct pipe_query *) q;
}
fd_begin_query(struct pipe_context *pctx, struct pipe_query *pq)
{
struct fd_query *q = fd_query(pq);
- return q->funcs->begin_query(fd_context(pctx), q);
+ boolean ret;
+
+ if (q->active)
+ return false;
+
+ ret = q->funcs->begin_query(fd_context(pctx), q);
+ q->active = ret;
+
+ return ret;
}
-static void
+static bool
fd_end_query(struct pipe_context *pctx, struct pipe_query *pq)
{
struct fd_query *q = fd_query(pq);
+
+ /* there are a couple special cases, which don't have
+ * a matching ->begin_query():
+ */
+ if (skip_begin_query(q->type) && !q->active)
+ fd_begin_query(pctx, pq);
+
+ if (!q->active)
+ return false;
+
q->funcs->end_query(fd_context(pctx), q);
+ q->active = false;
+
+ return true;
}
static boolean
boolean wait, union pipe_query_result *result)
{
struct fd_query *q = fd_query(pq);
+
+ if (q->active)
+ return false;
+
+ util_query_clear_result(result, q->type);
+
return q->funcs->get_query_result(fd_context(pctx), q, wait, result);
}
static void
fd_render_condition(struct pipe_context *pctx, struct pipe_query *pq,
- boolean condition, uint mode)
+ boolean condition, enum pipe_render_cond_flag mode)
{
struct fd_context *ctx = fd_context(pctx);
ctx->cond_query = pq;