r300: fcsel_ge lowering from lowered ftrunc

The fcsel lowering for R3xx happens already in the main loop, here we
only do it for the fcsel_ge that comes from the frunc.

No change in shader-db

Reviewed-by: Filip Gawin <filip.gawin@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26816>
This commit is contained in:
Pavel Ondračka 2023-12-15 17:13:35 +01:00
parent 6167f6e096
commit 77f429e1a5
3 changed files with 16 additions and 0 deletions

View file

@ -2448,9 +2448,15 @@ const void *nir_to_rc_options(struct nir_shader *s,
!options->lower_cmp && !options->lower_fabs);
/* bool_to_float generates MOVs for b2f32 that we want to clean up. */
NIR_PASS_V(s, nir_copy_prop);
/* At this point we need to clean;
* a) fcsel_gt that come from the ftrunc lowering on R300,
* b) all flavours of fcsels that read three different temp sources on R500.
*/
if (s->info.stage == MESA_SHADER_VERTEX) {
if (is_r500)
NIR_PASS_V(s, r300_nir_lower_fcsel_r500);
else
NIR_PASS_V(s, r300_nir_lower_fcsel_r300);
NIR_PASS_V(s, r300_nir_lower_flrp);
}
NIR_PASS_V(s, nir_opt_dce);

View file

@ -83,6 +83,8 @@ extern bool r300_nir_post_integer_lowering(struct nir_shader *shader);
extern bool r300_nir_lower_fcsel_r500(nir_shader *shader);
extern bool r300_nir_lower_fcsel_r300(nir_shader *shader);
extern bool r300_nir_lower_flrp(nir_shader *shader);
#endif /* R300_NIR_H */

View file

@ -99,6 +99,11 @@ r300_nir_lower_flrp = [
(('flrp', a, b, c), ('ffma', b, c, ('ffma', ('fneg', a), c, a)))
]
# Lower fcsel_ge from ftrunc on r300
r300_nir_lower_fcsel_r300 = [
(('fcsel_ge', a, b, c), ('flrp', c, b, ('sge', a, 0.0)))
]
r300_nir_post_integer_lowering = [
# If ffloor result is used only for indirect constant load, we can get rid of it
# completelly as ntt emits ARL by default which already does the flooring.
@ -168,5 +173,8 @@ def main():
f.write(nir_algebraic.AlgebraicPass("r300_nir_lower_flrp",
r300_nir_lower_flrp).render())
f.write(nir_algebraic.AlgebraicPass("r300_nir_lower_fcsel_r300",
r300_nir_lower_fcsel_r300).render())
if __name__ == '__main__':
main()