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;
}
q->funcs->destroy_query(fd_context(pctx), q);
}
-static void
+static boolean
fd_begin_query(struct pipe_context *pctx, struct pipe_query *pq)
{
struct fd_query *q = fd_query(pq);
- 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, enum pipe_render_cond_flag mode)
+{
+ struct fd_context *ctx = fd_context(pctx);
+ ctx->cond_query = pq;
+ ctx->cond_cond = condition;
+ ctx->cond_mode = mode;
+}
+
static int
fd_get_driver_query_info(struct pipe_screen *pscreen,
unsigned index, struct pipe_driver_query_info *info)
{
struct pipe_driver_query_info list[] = {
- {"draw-calls", FD_QUERY_DRAW_CALLS, 0},
- {"batches", FD_QUERY_BATCH_TOTAL, 0},
- {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, 0},
- {"batches-gmem", FD_QUERY_BATCH_GMEM, 0},
- {"restores", FD_QUERY_BATCH_RESTORE, 0},
- {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, 0},
+ {"draw-calls", FD_QUERY_DRAW_CALLS, {0}},
+ {"batches", FD_QUERY_BATCH_TOTAL, {0}},
+ {"batches-sysmem", FD_QUERY_BATCH_SYSMEM, {0}},
+ {"batches-gmem", FD_QUERY_BATCH_GMEM, {0}},
+ {"restores", FD_QUERY_BATCH_RESTORE, {0}},
+ {"prims-emitted", PIPE_QUERY_PRIMITIVES_EMITTED, {0}},
};
if (!info)
return 1;
}
+static void
+fd_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
void
fd_query_screen_init(struct pipe_screen *pscreen)
{
pctx->begin_query = fd_begin_query;
pctx->end_query = fd_end_query;
pctx->get_query_result = fd_get_query_result;
+ pctx->set_active_query_state = fd_set_active_query_state;
+ pctx->render_condition = fd_render_condition;
}