#include "tr_context.h"
+struct trace_query
+{
+ unsigned type;
+
+ struct pipe_query *query;
+};
+
+
+static INLINE struct trace_query *
+trace_query(struct pipe_query *query) {
+ return (struct trace_query *)query;
+}
+
+static INLINE struct pipe_query *
+trace_query_unwrap(struct pipe_query *query)
+{
+ if (query) {
+ return trace_query(query)->query;
+ } else {
+ return NULL;
+ }
+}
static INLINE struct pipe_resource *
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_query *result;
+ struct pipe_query *query;
trace_dump_call_begin("pipe_context", "create_query");
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, query_type);
- result = pipe->create_query(pipe, query_type);
+ query = pipe->create_query(pipe, query_type);
- trace_dump_ret(ptr, result);
+ trace_dump_ret(ptr, query);
trace_dump_call_end();
- return result;
+ /* Wrap query object. */
+ if (query) {
+ struct trace_query *tr_query = CALLOC_STRUCT(trace_query);
+ if (tr_query) {
+ tr_query->type = query_type;
+ tr_query->query = query;
+ query = (struct pipe_query *)tr_query;
+ } else {
+ pipe->destroy_query(pipe, query);
+ query = NULL;
+ }
+ }
+
+ return query;
}
static INLINE void
trace_context_destroy_query(struct pipe_context *_pipe,
- struct pipe_query *query)
+ struct pipe_query *_query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ struct trace_query *tr_query = trace_query(_query);
+ struct pipe_query *query = tr_query->query;
+
+ FREE(tr_query);
trace_dump_call_begin("pipe_context", "destroy_query");
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ query = trace_query_unwrap(query);
+
trace_dump_call_begin("pipe_context", "begin_query");
trace_dump_arg(ptr, pipe);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
+ query = trace_query_unwrap(query);
+
trace_dump_call_begin("pipe_context", "end_query");
trace_dump_arg(ptr, pipe);
static INLINE boolean
trace_context_get_query_result(struct pipe_context *_pipe,
- struct pipe_query *query,
+ struct pipe_query *_query,
boolean wait,
- union pipe_query_result *presult)
+ union pipe_query_result *result)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- uint64_t result;
- boolean _result;
+ struct trace_query *tr_query = trace_query(_query);
+ struct pipe_query *query = tr_query->query;
+ boolean ret;
trace_dump_call_begin("pipe_context", "get_query_result");
trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
- _result = pipe->get_query_result(pipe, query, wait, presult);
- /* XXX this depends on the query type */
- result = *((uint64_t*)presult);
+ ret = pipe->get_query_result(pipe, query, wait, result);
- trace_dump_arg(uint, result);
- trace_dump_ret(bool, _result);
+ trace_dump_arg_begin("result");
+ if (ret) {
+ trace_dump_query_result(tr_query->type, result);
+ } else {
+ trace_dump_null();
+ }
+ trace_dump_arg_end();
+
+ trace_dump_ret(bool, ret);
trace_dump_call_end();
- return _result;
+ return ret;
}
struct trace_context *tr_context = trace_context(_context);
struct pipe_context *context = tr_context->pipe;
+ query = trace_query_unwrap(query);
+
trace_dump_call_begin("pipe_context", "render_condition");
trace_dump_arg(ptr, context);
trace_dump_struct_end();
}
+
+void
+trace_dump_query_result(unsigned query_type,
+ const union pipe_query_result *result)
+{
+ if (!trace_dumping_enabled_locked())
+ return;
+
+ if (!result) {
+ trace_dump_null();
+ return;
+ }
+
+ switch (query_type) {
+ case PIPE_QUERY_OCCLUSION_PREDICATE:
+ case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+ case PIPE_QUERY_GPU_FINISHED:
+ trace_dump_bool(result->b);
+ break;
+
+ case PIPE_QUERY_OCCLUSION_COUNTER:
+ case PIPE_QUERY_TIMESTAMP:
+ case PIPE_QUERY_TIME_ELAPSED:
+ case PIPE_QUERY_PRIMITIVES_GENERATED:
+ case PIPE_QUERY_PRIMITIVES_EMITTED:
+ trace_dump_uint(result->u64);
+ break;
+
+ case PIPE_QUERY_SO_STATISTICS:
+ trace_dump_struct_begin("pipe_query_data_so_statistics");
+ trace_dump_member(uint, &result->so_statistics, num_primitives_written);
+ trace_dump_member(uint, &result->so_statistics, primitives_storage_needed);
+ trace_dump_struct_end();
+ break;
+
+ case PIPE_QUERY_TIMESTAMP_DISJOINT:
+ trace_dump_struct_begin("pipe_query_data_timestamp_disjoint");
+ trace_dump_member(uint, &result->timestamp_disjoint, frequency);
+ trace_dump_member(bool, &result->timestamp_disjoint, disjoint);
+ trace_dump_struct_end();
+ break;
+
+ case PIPE_QUERY_PIPELINE_STATISTICS:
+ trace_dump_struct_begin("pipe_query_data_pipeline_statistics");
+ trace_dump_member(uint, &result->pipeline_statistics, ia_vertices);
+ trace_dump_member(uint, &result->pipeline_statistics, ia_primitives);
+ trace_dump_member(uint, &result->pipeline_statistics, vs_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, gs_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, gs_primitives);
+ trace_dump_member(uint, &result->pipeline_statistics, c_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, c_primitives);
+ trace_dump_member(uint, &result->pipeline_statistics, ps_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, hs_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, ds_invocations);
+ trace_dump_member(uint, &result->pipeline_statistics, cs_invocations);
+ trace_dump_struct_end();
+ break;
+
+ default:
+ assert(query_type >= PIPE_QUERY_DRIVER_SPECIFIC);
+ trace_dump_uint(result->u64);
+ break;
+ }
+}