zink: use EXT_color_write_enable to mask out primgen+rasterizer_discard output

by disabling color and depth write, the side effects of force-disabling discard can
be mitigated

fixes:
KHR-GL46.tessellation_shader.single.isolines_tessellation
KHR-GL46.tessellation_shader.tessellation_control_to_tessellation_evaluation.data_pass_through
KHR-GL46.tessellation_shader.tessellation_invariance.invariance_rule3
KHR-GL46.tessellation_shader.tessellation_shader_point_mode.points_verification
KHR-GL46.tessellation_shader.tessellation_shader_quads_tessellation.degenerate_case
KHR-GL46.tessellation_shader.tessellation_shader_quads_tessellation.inner_tessellation_level_rounding
KHR-GL46.tessellation_shader.tessellation_shader_tessellation.gl_InvocationID_PatchVerticesIn_PrimitiveID
KHR-GL46.tessellation_shader.vertex.vertex_spacing

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:51:54 -05:00
parent 3892c13381
commit 9153fb7fbe
5 changed files with 22 additions and 6 deletions

View file

@ -2574,13 +2574,23 @@ zink_set_color_write_enables(struct zink_context *ctx)
const VkBool32 enables[PIPE_MAX_COLOR_BUFS] = {1, 1, 1, 1, 1, 1, 1, 1};
const VkBool32 disables[PIPE_MAX_COLOR_BUFS] = {0};
const unsigned max_att = MIN2(PIPE_MAX_COLOR_BUFS, zink_screen(ctx->base.screen)->info.props.limits.maxColorAttachments);
bool disable_color_writes = ctx->rast_state && ctx->rast_state->base.rasterizer_discard && ctx->primitives_generated_active;
if (ctx->disable_color_writes == disable_color_writes)
return;
ctx->disable_color_writes = disable_color_writes;
if (zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing) {
/* use dummy color buffers instead of the more sane option */
zink_end_render_pass(ctx);
update_framebuffer_state(ctx, ctx->fb_state.width, ctx->fb_state.height);
} else {
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, enables);
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, disable_color_writes ? disables : enables);
}
if (!zink_screen(ctx->base.screen)->info.have_EXT_extended_dynamic_state) {
/* TODO: maybe pipeline variants for this */
return;
}
if (ctx->dsa_state)
VKCTX(CmdSetDepthWriteEnableEXT)(ctx->batch.state->cmdbuf, disable_color_writes ? VK_FALSE : ctx->dsa_state->hw_state.depth_write);
}
static void

View file

@ -1131,15 +1131,16 @@ zink_program_init(struct zink_context *ctx)
ctx->base.delete_compute_state = zink_delete_shader_state;
}
void
bool
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;
return false;
if (!zink_screen(ctx->base.screen)->info.have_EXT_extended_dynamic_state2)
ctx->gfx_pipeline_state.dirty |= true;
ctx->rasterizer_discard_changed = true;
return true;
}

View file

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

View file

@ -706,7 +706,8 @@ begin_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_quer
_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);
if (zink_set_rasterizer_discard(ctx, true))
zink_set_color_write_enables(ctx);
}
}
@ -777,7 +778,8 @@ end_query(struct zink_context *ctx, struct zink_batch *batch, struct zink_query
update_query_id(ctx, q);
if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED) {
ctx->primitives_generated_active = false;
zink_set_rasterizer_discard(ctx, false);
if (zink_set_rasterizer_discard(ctx, false))
zink_set_color_write_enables(ctx);
}
}

View file

@ -681,6 +681,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
bool pv_last = ctx->rast_state ? ctx->rast_state->hw_state.pv_last : false;
bool force_persample_interp = ctx->rast_state ? ctx->rast_state->hw_state.force_persample_interp : false;
bool clip_halfz = ctx->rast_state ? ctx->rast_state->hw_state.clip_halfz : false;
bool rasterizer_discard = ctx->rast_state ? ctx->rast_state->base.rasterizer_discard : false;
ctx->rast_state = cso;
if (ctx->rast_state) {
@ -710,6 +711,8 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
}
if (!ctx->primitives_generated_active)
zink_set_rasterizer_discard(ctx, false);
else if (rasterizer_discard != ctx->rast_state->base.rasterizer_discard)
zink_set_color_write_enables(ctx);
if (ctx->rast_state->base.point_quad_rasterization != point_quad_rasterization)
zink_set_fs_point_coord_key(ctx);