diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-27 11:59:20 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-31 18:28:35 +0200 |
commit | 5482c344c034efe0b363837b9b8724b29e3f3983 (patch) | |
tree | d165ea5ddca8042db6d4b7a829ef675b31d71e03 | |
parent | 9ac3042a5bfdb080f552e7e1c990f83bd35da214 (diff) |
ddebug: handle get_query_result_resource as a GPU call
-rw-r--r-- | src/gallium/drivers/ddebug/dd_context.c | 32 | ||||
-rw-r--r-- | src/gallium/drivers/ddebug/dd_draw.c | 64 | ||||
-rw-r--r-- | src/gallium/drivers/ddebug/dd_pipe.h | 28 |
3 files changed, 92 insertions, 32 deletions
diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c index 6b1ddc9d46..5b0b27e006 100644 --- a/src/gallium/drivers/ddebug/dd_context.c +++ b/src/gallium/drivers/ddebug/dd_context.c @@ -45,22 +45,6 @@ safe_memcpy(void *dst, const void *src, size_t size) * queries */ -static struct dd_query * -dd_query(struct pipe_query *query) -{ - return (struct dd_query *)query; -} - -static struct pipe_query * -dd_query_unwrap(struct pipe_query *query) -{ - if (query) { - return dd_query(query)->query; - } else { - return NULL; - } -} - static struct pipe_query * dd_context_create_query(struct pipe_context *_pipe, unsigned query_type, unsigned index) @@ -151,21 +135,6 @@ dd_context_get_query_result(struct pipe_context *_pipe, } static void -dd_context_get_query_result_resource(struct pipe_context *_pipe, - struct pipe_query *query, - boolean wait, - enum pipe_query_value_type result_type, - int index, - struct pipe_resource *resource, - unsigned offset) -{ - struct pipe_context *pipe = dd_context(_pipe)->pipe; - - pipe->get_query_result_resource(pipe, dd_query_unwrap(query), wait, - result_type, index, resource, offset); -} - -static void dd_context_set_active_query_state(struct pipe_context *_pipe, boolean enable) { struct pipe_context *pipe = dd_context(_pipe)->pipe; @@ -847,7 +816,6 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe) CTX_INIT(begin_query); CTX_INIT(end_query); CTX_INIT(get_query_result); - CTX_INIT(get_query_result_resource); CTX_INIT(set_active_query_state); CTX_INIT(create_blend_state); CTX_INIT(bind_blend_state); diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c index 81a796873f..ae8f99bf2b 100644 --- a/src/gallium/drivers/ddebug/dd_draw.c +++ b/src/gallium/drivers/ddebug/dd_draw.c @@ -154,6 +154,12 @@ util_dump_uint(FILE *f, unsigned i) } static void +util_dump_int(FILE *f, int i) +{ + fprintf(f, "%d", i); +} + +static void util_dump_hex(FILE *f, unsigned i) { fprintf(f, "0x%x", i); @@ -419,6 +425,18 @@ dd_dump_generate_mipmap(struct dd_draw_state *dstate, FILE *f) } static void +dd_dump_get_query_result_resource(struct call_get_query_result_resource *info, FILE *f) +{ + fprintf(f, "%s:\n", __func__ + 8); + DUMP_M(query_type, info, query_type); + DUMP_M(uint, info, wait); + DUMP_M(query_value_type, info, result_type); + DUMP_M(int, info, index); + DUMP_M(resource, info, resource); + DUMP_M(uint, info, offset); +} + +static void dd_dump_flush_resource(struct dd_draw_state *dstate, struct pipe_resource *res, FILE *f) { @@ -525,6 +543,9 @@ dd_dump_call(FILE *f, struct dd_draw_state *state, struct dd_call *call) case CALL_GENERATE_MIPMAP: dd_dump_generate_mipmap(state, f); break; + case CALL_GET_QUERY_RESULT_RESOURCE: + dd_dump_get_query_result_resource(&call->info.get_query_result_resource, f); + break; } } @@ -648,6 +669,9 @@ dd_unreference_copy_of_call(struct dd_call *dst) case CALL_GENERATE_MIPMAP: pipe_resource_reference(&dst->info.generate_mipmap.res, NULL); break; + case CALL_GET_QUERY_RESULT_RESOURCE: + pipe_resource_reference(&dst->info.get_query_result_resource.resource, NULL); + break; } } @@ -725,6 +749,12 @@ dd_copy_call(struct dd_call *dst, struct dd_call *src) src->info.generate_mipmap.res); dst->info.generate_mipmap = src->info.generate_mipmap; break; + case CALL_GET_QUERY_RESULT_RESOURCE: + pipe_resource_reference(&dst->info.get_query_result_resource.resource, + src->info.get_query_result_resource.resource); + dst->info.get_query_result_resource = src->info.get_query_result_resource; + dst->info.get_query_result_resource.query = NULL; + break; } } @@ -1287,6 +1317,39 @@ dd_context_generate_mipmap(struct pipe_context *_pipe, } static void +dd_context_get_query_result_resource(struct pipe_context *_pipe, + struct pipe_query *query, + boolean wait, + enum pipe_query_value_type result_type, + int index, + struct pipe_resource *resource, + unsigned offset) +{ + struct dd_context *dctx = dd_context(_pipe); + struct dd_query *dquery = dd_query(query); + struct pipe_context *pipe = dctx->pipe; + struct dd_call call; + + call.type = CALL_GET_QUERY_RESULT_RESOURCE; + call.info.get_query_result_resource.query = query; + call.info.get_query_result_resource.wait = wait; + call.info.get_query_result_resource.result_type = result_type; + call.info.get_query_result_resource.index = index; + call.info.get_query_result_resource.resource = resource; + call.info.get_query_result_resource.offset = offset; + + /* In pipelined mode, the query may be deleted by the time we need to + * print it. + */ + call.info.get_query_result_resource.query_type = dquery->type; + + dd_before_draw(dctx); + pipe->get_query_result_resource(pipe, dquery->query, wait, + result_type, index, resource, offset); + dd_after_draw(dctx, &call); +} + +static void dd_context_flush_resource(struct pipe_context *_pipe, struct pipe_resource *resource) { @@ -1416,4 +1479,5 @@ dd_init_draw_functions(struct dd_context *dctx) CTX_INIT(clear_texture); CTX_INIT(flush_resource); CTX_INIT(generate_mipmap); + CTX_INIT(get_query_result_resource); } diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h index caad45b723..e21b5fee08 100644 --- a/src/gallium/drivers/ddebug/dd_pipe.h +++ b/src/gallium/drivers/ddebug/dd_pipe.h @@ -66,6 +66,7 @@ enum call_type CALL_CLEAR_RENDER_TARGET, CALL_CLEAR_DEPTH_STENCIL, CALL_GENERATE_MIPMAP, + CALL_GET_QUERY_RESULT_RESOURCE, }; struct call_resource_copy_region @@ -109,6 +110,16 @@ struct call_draw_info { struct pipe_draw_indirect_info indirect; }; +struct call_get_query_result_resource { + struct pipe_query *query; + enum pipe_query_type query_type; + boolean wait; + enum pipe_query_value_type result_type; + int index; + struct pipe_resource *resource; + unsigned offset; +}; + struct dd_call { enum call_type type; @@ -122,6 +133,7 @@ struct dd_call struct call_clear clear; struct call_clear_buffer clear_buffer; struct call_generate_mipmap generate_mipmap; + struct call_get_query_result_resource get_query_result_resource; } info; }; @@ -272,6 +284,22 @@ dd_screen(struct pipe_screen *screen) return (struct dd_screen*)screen; } +static inline struct dd_query * +dd_query(struct pipe_query *query) +{ + return (struct dd_query *)query; +} + +static inline struct pipe_query * +dd_query_unwrap(struct pipe_query *query) +{ + if (query) { + return dd_query(query)->query; + } else { + return NULL; + } +} + #define CTX_INIT(_member) \ dctx->base._member = dctx->pipe->_member ? dd_context_##_member : NULL |