From ce830a364e0aec8c9769729162bfe7501feb028b Mon Sep 17 00:00:00 2001 From: Rafael Antognolli Date: Wed, 6 Mar 2019 16:59:44 -0800 Subject: [PATCH] iris: Add iris_resolve_conditional_render(). This function can be used to stall on the CPU and resolve the predicate for the conditional render. It will convert ice->state.predicate from IRIS_PREDICATE_STATE_USE_BIT to either IRIS_PREDICATE_STATE_RENDER or IRIS_PREDICATE_STATE_DONT_RENDER, depending on the result of the query. v2: - return void (Ken) - update the stored condition (Ken) - simplify the code leading to resolve the predicate (Ken) Reviewed-by: Kenneth Graunke --- src/gallium/drivers/iris/iris_context.h | 6 ++++++ src/gallium/drivers/iris/iris_query.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 8f91d28446f..f3a5bdb7eb8 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -514,6 +514,11 @@ struct iris_context { struct iris_bo *scratch_bos[1 << 4][MESA_SHADER_STAGES]; } shaders; + struct { + struct iris_query *query; + bool condition; + } condition; + struct { uint64_t dirty; uint64_t dirty_for_nos[IRIS_NOS_COUNT]; @@ -781,6 +786,7 @@ void iris_math_div32_gpr0(struct iris_context *ice, uint64_t iris_timebase_scale(const struct gen_device_info *devinfo, uint64_t gpu_timestamp); +void iris_resolve_conditional_render(struct iris_context *ice); /* iris_resolve.c */ diff --git a/src/gallium/drivers/iris/iris_query.c b/src/gallium/drivers/iris/iris_query.c index ec9050b6390..76816a7c0fd 100644 --- a/src/gallium/drivers/iris/iris_query.c +++ b/src/gallium/drivers/iris/iris_query.c @@ -1069,6 +1069,8 @@ iris_render_condition(struct pipe_context *ctx, /* The old condition isn't relevant; we'll update it if necessary */ ice->state.compute_predicate = NULL; + ice->condition.query = q; + ice->condition.condition = condition; if (!q) { ice->state.predicate = IRIS_PREDICATE_STATE_RENDER; @@ -1089,6 +1091,23 @@ iris_render_condition(struct pipe_context *ctx, } } +void +iris_resolve_conditional_render(struct iris_context *ice) +{ + struct pipe_context *ctx = (void *) ice; + struct iris_query *q = ice->condition.query; + struct pipe_query *query = (void *) q; + union pipe_query_result result; + + if (ice->state.predicate != IRIS_PREDICATE_STATE_USE_BIT) + return; + + assert(q); + + iris_get_query_result(ctx, query, true, &result); + set_predicate_enable(ice, (q->result != 0) ^ ice->condition.condition); +} + void iris_init_query_functions(struct pipe_context *ctx) { -- 2.30.2