zink: force disable rasterization discard if primgen query is active

this query requires rasterization to pass the clipping invocations stage,
which means discard is impossible

Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15392>
This commit is contained in:
Mike Blumenkrantz 2022-03-07 15:32:40 -05:00
parent 795925e0ff
commit 0a80f94de0
5 changed files with 29 additions and 6 deletions

View File

@ -290,6 +290,7 @@ struct zink_context {
struct list_head suspended_queries;
struct list_head primitives_generated_queries;
struct zink_query *vertices_query;
bool primitives_generated_active;
bool queries_disabled, render_condition_active;
struct {
struct zink_query *query;

View File

@ -1130,3 +1130,16 @@ zink_program_init(struct zink_context *ctx)
ctx->base.bind_compute_state = zink_bind_cs_state;
ctx->base.delete_compute_state = zink_delete_shader_state;
}
void
zink_set_rasterizer_discard(struct zink_context *ctx, bool disable)
{
bool value = disable ? false : (ctx->rast_state ? ctx->rast_state->base.rasterizer_discard : false);
bool changed = ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard != value;
ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard = value;
if (!changed)
return;
if (!zink_screen(ctx->base.screen)->info.have_EXT_extended_dynamic_state2)
ctx->gfx_pipeline_state.dirty |= true;
ctx->rasterizer_discard_changed = true;
}

View File

@ -379,6 +379,9 @@ zink_set_fs_point_coord_key(struct zink_context *ctx)
}
}
void
zink_set_rasterizer_discard(struct zink_context *ctx, bool disable);
#ifdef __cplusplus
}
#endif

View File

@ -2,6 +2,7 @@
#include "zink_context.h"
#include "zink_fence.h"
#include "zink_program.h"
#include "zink_resource.h"
#include "zink_screen.h"
@ -703,6 +704,10 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
list_addtail(&q->stats_list, &ctx->primitives_generated_queries);
zink_batch_usage_set(&q->batch_id, batch->state);
_mesa_set_add(batch->state->active_queries, q);
if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED) {
ctx->primitives_generated_active = true;
zink_set_rasterizer_discard(ctx, true);
}
}
static bool
@ -770,6 +775,10 @@ end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query
list_delinit(&q->stats_list);
update_query_id(ctx, q);
if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED) {
ctx->primitives_generated_active = false;
zink_set_rasterizer_discard(ctx, false);
}
}
static bool

View File

@ -708,12 +708,9 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
ctx->gfx_pipeline_state.dyn_state1.front_face = ctx->rast_state->front_face;
ctx->gfx_pipeline_state.dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state;
}
if (ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard != ctx->rast_state->base.rasterizer_discard) {
ctx->gfx_pipeline_state.dyn_state2.rasterizer_discard = ctx->rast_state->base.rasterizer_discard;
ctx->gfx_pipeline_state.dirty |= !zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state2;
if (zink_screen(pctx->screen)->info.have_EXT_extended_dynamic_state2)
ctx->rasterizer_discard_changed = true;
}
if (!ctx->primitives_generated_active)
zink_set_rasterizer_discard(ctx, false);
if (ctx->rast_state->base.point_quad_rasterization != point_quad_rasterization)
zink_set_fs_point_coord_key(ctx);
if (ctx->rast_state->base.scissor != scissor)