Module: Mesa
Branch: main
Commit: 77f429e1a5179b891b58281fcdee856e84cf056b
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=77f429e1a5179b891b58281fcdee856e84cf056b

Author: Pavel Ondračka <pavel.ondra...@gmail.com>
Date:   Fri Dec 15 17:13:35 2023 +0100

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.ga...@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26816>

---

 src/gallium/drivers/r300/compiler/nir_to_rc.c           | 6 ++++++
 src/gallium/drivers/r300/compiler/r300_nir.h            | 2 ++
 src/gallium/drivers/r300/compiler/r300_nir_algebraic.py | 8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/src/gallium/drivers/r300/compiler/nir_to_rc.c 
b/src/gallium/drivers/r300/compiler/nir_to_rc.c
index 1345b99859e..58d37cbfa93 100644
--- a/src/gallium/drivers/r300/compiler/nir_to_rc.c
+++ b/src/gallium/drivers/r300/compiler/nir_to_rc.c
@@ -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);
diff --git a/src/gallium/drivers/r300/compiler/r300_nir.h 
b/src/gallium/drivers/r300/compiler/r300_nir.h
index bf31307fdcc..b4c9bd9968b 100644
--- a/src/gallium/drivers/r300/compiler/r300_nir.h
+++ b/src/gallium/drivers/r300/compiler/r300_nir.h
@@ -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 */
diff --git a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py 
b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
index d2c83cdf56f..1f3514791bc 100644
--- a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
+++ b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py
@@ -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()

Reply via email to