From: Urja Rannikko Date: Tue, 22 Oct 2019 12:05:07 +0000 (+0000) Subject: panfrost: allocate bo for occlusion query results X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dff99ce7d57f6d6d10b2089afacbcdc7660b1423;p=mesa.git panfrost: allocate bo for occlusion query results This memory needs to still be available after all the drawing is done and forgotten about, so cannot be transient. Also clear the result so that no rendering returns a zero. Signed-off-by: Urja Rannikko Reviewed-by: Alyssa Rosenzweig --- diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index bb605280c36..37b3858242c 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -931,7 +931,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) if (ctx->occlusion_query) { ctx->payloads[PIPE_SHADER_FRAGMENT].gl_enables |= MALI_OCCLUSION_QUERY | MALI_OCCLUSION_PRECISE; - ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.occlusion_counter = ctx->occlusion_query->transfer.gpu; + ctx->payloads[PIPE_SHADER_FRAGMENT].postfix.occlusion_counter = ctx->occlusion_query->bo->gpu; } panfrost_patch_shader_state_compute(ctx, PIPE_SHADER_VERTEX, true); @@ -2451,6 +2451,13 @@ panfrost_create_query(struct pipe_context *pipe, static void panfrost_destroy_query(struct pipe_context *pipe, struct pipe_query *q) { + struct panfrost_query *query = (struct panfrost_query *) q; + + if (query->bo) { + panfrost_bo_unreference(query->bo); + query->bo = NULL; + } + ralloc_free(q); } @@ -2459,14 +2466,20 @@ panfrost_begin_query(struct pipe_context *pipe, struct pipe_query *q) { struct panfrost_context *ctx = pan_context(pipe); struct panfrost_query *query = (struct panfrost_query *) q; - struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx); switch (query->type) { case PIPE_QUERY_OCCLUSION_COUNTER: case PIPE_QUERY_OCCLUSION_PREDICATE: case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE: - /* Allocate a word for the query results to be stored */ - query->transfer = panfrost_allocate_transient(batch, sizeof(unsigned)); + /* Allocate a bo for the query results to be stored */ + if (!query->bo) { + query->bo = panfrost_bo_create( + pan_screen(ctx->base.screen), + sizeof(unsigned), 0); + } + + unsigned *result = (unsigned *)query->bo->cpu; + *result = 0; /* Default to 0 if nothing at all drawn. */ ctx->occlusion_query = query; break; @@ -2529,7 +2542,7 @@ panfrost_get_query_result(struct pipe_context *pipe, panfrost_flush_all_batches(ctx, true); /* Read back the query results */ - unsigned *result = (unsigned *) query->transfer.cpu; + unsigned *result = (unsigned *) query->bo->cpu; unsigned passed = *result; if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) { diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index d50ed57d5d8..8460b8a9738 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -80,16 +80,14 @@ struct panfrost_query { unsigned type; unsigned index; - union { - /* For computed queries. 64-bit to prevent overflow */ - struct { - uint64_t start; - uint64_t end; - }; - - /* Memory for the GPU to writeback the value of the query */ - struct panfrost_transfer transfer; + /* For computed queries. 64-bit to prevent overflow */ + struct { + uint64_t start; + uint64_t end; }; + + /* Memory for the GPU to writeback the value of the query */ + struct panfrost_bo *bo; }; struct panfrost_fence {