zink: lower discard/demote depending on derivatives

This should fix rendering in some games that incorrectly expect discard
to have demote behavior.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18272>
This commit is contained in:
Erik Faye-Lund 2022-08-26 13:24:28 +02:00 committed by Marge Bot
parent 9909eff0c8
commit 0511713af7
3 changed files with 8 additions and 0 deletions

View file

@ -3019,6 +3019,12 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
NIR_PASS_V(nir, lower_baseinstance);
NIR_PASS_V(nir, lower_sparse);
if (screen->info.have_EXT_shader_demote_to_helper_invocation) {
NIR_PASS_V(nir, nir_lower_discard_or_demote,
screen->driconf.glsl_correct_derivatives_after_discard ||
nir->info.use_legacy_math_rules);
}
if (screen->need_2D_zs)
NIR_PASS_V(nir, lower_1d_shadow, screen);

View file

@ -2202,6 +2202,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
driParseConfigFiles(config->options, config->options_info, 0, "zink",
NULL, NULL, NULL, 0, NULL, 0);
screen->driconf.dual_color_blend_by_location = driQueryOptionb(config->options, "dual_color_blend_by_location");
screen->driconf.glsl_correct_derivatives_after_discard = driQueryOptionb(config->options, "glsl_correct_derivatives_after_discard");
//screen->driconf.inline_uniforms = driQueryOptionb(config->options, "radeonsi_inline_uniforms");
screen->instance_info.disable_xcb_surface = driQueryOptionb(config->options, "disable_xcb_surface");
}

View file

@ -1112,6 +1112,7 @@ struct zink_screen {
struct {
bool dual_color_blend_by_location;
bool glsl_correct_derivatives_after_discard;
bool inline_uniforms;
} driconf;