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 <kenneth@whitecape.org>
This commit is contained in:
Rafael Antognolli 2019-03-06 16:59:44 -08:00
parent 131b42f0aa
commit ce830a364e
2 changed files with 25 additions and 0 deletions

View file

@ -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 */

View file

@ -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)
{