#include "r600_cs.h"
#include "util/u_memory.h"
-
struct r600_query_buffer {
/* The buffer where query results are stored. */
struct r600_resource *buf;
};
struct r600_query {
+ struct r600_query_ops *ops;
+
/* The query buffer and how many results are in it. */
struct r600_query_buffer buffer;
/* The type of query */
unsigned stream;
};
+static void r600_do_destroy_query(struct r600_common_context *, struct r600_query *);
+static boolean r600_do_begin_query(struct r600_common_context *, struct r600_query *);
+static void r600_do_end_query(struct r600_common_context *, struct r600_query *);
+static boolean r600_do_get_query_result(struct r600_common_context *,
+ struct r600_query *, boolean wait,
+ union pipe_query_result *result);
+
+static struct r600_query_ops legacy_query_ops = {
+ .destroy = r600_do_destroy_query,
+ .begin = r600_do_begin_query,
+ .end = r600_do_end_query,
+ .get_result = r600_do_get_query_result,
+};
static bool r600_is_timer_query(unsigned type)
{
return NULL;
query->type = query_type;
+ query->ops = &legacy_query_ops;
switch (query_type) {
case PIPE_QUERY_OCCLUSION_COUNTER:
query->result_size = 16 * rctx->max_db;
query->num_cs_dw = 6;
break;
- break;
case PIPE_QUERY_TIME_ELAPSED:
query->result_size = 16;
query->num_cs_dw = 8;
static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *query)
{
- struct r600_query *rquery = (struct r600_query*)query;
+ struct r600_common_context *rctx = (struct r600_common_context *)ctx;
+ struct r600_query *rquery = (struct r600_query *)query;
+
+ rquery->ops->destroy(rctx, rquery);
+}
+
+static void r600_do_destroy_query(struct r600_common_context *rctx,
+ struct r600_query *rquery)
+{
struct r600_query_buffer *prev = rquery->buffer.previous;
/* Release all query buffers. */
}
pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL);
- FREE(query);
+ FREE(rquery);
}
static boolean r600_begin_query(struct pipe_context *ctx,
{
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
+
+ return rquery->ops->begin(rctx, rquery);
+}
+
+static boolean r600_do_begin_query(struct r600_common_context *rctx,
+ struct r600_query *rquery)
+{
struct r600_query_buffer *prev = rquery->buffer.previous;
if (!r600_query_needs_begin(rquery->type)) {
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
+ rquery->ops->end(rctx, rquery);
+}
+
+static void r600_do_end_query(struct r600_common_context *rctx,
+ struct r600_query *rquery)
+{
/* Non-GPU queries. */
switch (rquery->type) {
case PIPE_QUERY_TIMESTAMP_DISJOINT:
return;
case PIPE_QUERY_GPU_FINISHED:
- ctx->flush(ctx, &rquery->fence, 0);
+ rctx->b.flush(&rctx->b, &rquery->fence, 0);
return;
case R600_QUERY_DRAW_CALLS:
rquery->end_result = rctx->num_draw_calls;
}
static boolean r600_get_query_result(struct pipe_context *ctx,
- struct pipe_query *query,
- boolean wait, union pipe_query_result *result)
+ struct pipe_query *query, boolean wait,
+ union pipe_query_result *result)
{
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_query *rquery = (struct r600_query *)query;
+
+ return rquery->ops->get_result(rctx, rquery, wait, result);
+}
+
+static boolean r600_do_get_query_result(struct r600_common_context *rctx,
+ struct r600_query *rquery,
+ boolean wait, union pipe_query_result *result)
+{
struct r600_query_buffer *qbuf;
util_query_clear_result(result, rquery->type);
#include "pipe/p_defines.h"
+struct r600_common_context;
+struct r600_query;
+
#define R600_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)
#define R600_QUERY_REQUESTED_VRAM (PIPE_QUERY_DRIVER_SPECIFIC + 1)
#define R600_QUERY_REQUESTED_GTT (PIPE_QUERY_DRIVER_SPECIFIC + 2)
#define R600_QUERY_NUM_SHADERS_CREATED (PIPE_QUERY_DRIVER_SPECIFIC + 13)
#define R600_QUERY_FIRST_PERFCOUNTER (PIPE_QUERY_DRIVER_SPECIFIC + 100)
+struct r600_query_ops {
+ void (*destroy)(struct r600_common_context *, struct r600_query *);
+ boolean (*begin)(struct r600_common_context *, struct r600_query *);
+ void (*end)(struct r600_common_context *, struct r600_query *);
+ boolean (*get_result)(struct r600_common_context *,
+ struct r600_query *, boolean wait,
+ union pipe_query_result *result);
+};
+
#endif /* R600_QUERY_H */