diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 82 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump_state.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump_state.h | 2 |
3 files changed, 133 insertions, 15 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 6a986571e74..d9afb0aba7c 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -40,7 +40,29 @@ #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 * @@ -108,29 +130,46 @@ trace_context_create_query(struct pipe_context *_pipe, { 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"); @@ -150,6 +189,8 @@ trace_context_begin_query(struct pipe_context *_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", "begin_query"); trace_dump_arg(ptr, pipe); @@ -168,6 +209,8 @@ trace_context_end_query(struct pipe_context *_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); @@ -181,29 +224,36 @@ trace_context_end_query(struct pipe_context *_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; } @@ -1408,6 +1458,8 @@ static void trace_context_render_condition(struct pipe_context *_context, 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); diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 374e32fda99..c1e5361254d 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -775,3 +775,67 @@ void trace_dump_blit_info(const struct pipe_blit_info *info) 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; + } +} diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h index 22beffaae67..6151a0a0214 100644 --- a/src/gallium/drivers/trace/tr_dump_state.h +++ b/src/gallium/drivers/trace/tr_dump_state.h @@ -85,5 +85,7 @@ void trace_dump_draw_info(const struct pipe_draw_info *state); void trace_dump_blit_info(const struct pipe_blit_info *); +void trace_dump_query_result(unsigned query_type, + const union pipe_query_result *result); #endif /* TR_STATE_H */ |