Mesa (main): freedreno/ir3: Use immediate for flat.b's src1

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 4 03:20:38 UTC 2021


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue Oct 19 12:39:13 2021 -0700

freedreno/ir3: Use immediate for flat.b's src1

According to Jonathan Marek:

  Only one immediate can be decoded in a cat2 instruction (if both srcs
  are immediates, they will use the value of the either the first or
  second one, I don't remember which) - using 2 immediates in a cat2
  instruction is only "correct" if they are both equal.

  The (i,j) in the second src of flat.b is not unused, but behaves as 0
  for any (small) integer because it is a float src. The hack I
  suggested is to set the second src equal to (immediate) first src,
  which seems to work.

This allows us to remove a couple of mov instructions or a bit of extra
constfile usage.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13558>

---

 src/freedreno/ir3/ir3.c              | 5 +++++
 src/freedreno/ir3/ir3_compiler_nir.c | 9 +--------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c
index 04e68c676a3..db116f01017 100644
--- a/src/freedreno/ir3/ir3.c
+++ b/src/freedreno/ir3/ir3.c
@@ -859,6 +859,11 @@ ir3_valid_flags(struct ir3_instruction *instr, unsigned n, unsigned flags)
       if (flags & ~valid_flags)
          return false;
 
+      /* Allow an immediate src1 for flat.b, since it's ignored */
+      if (instr->opc == OPC_FLAT_B &&
+          n == 1 && flags == IR3_REG_IMMED)
+         return true;
+
       if (flags & (IR3_REG_CONST | IR3_REG_IMMED | IR3_REG_SHARED)) {
          unsigned m = n ^ 1;
          /* cannot deal w/ const or shared in both srcs:
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 7b21dfa40d9..abee9638c1e 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -87,14 +87,7 @@ create_frag_input(struct ir3_context *ctx, struct ir3_instruction *coord,
       instr = ir3_BARY_F(block, inloc, 0, coord, 0);
    } else if (ctx->compiler->flat_bypass) {
       if (ctx->compiler->gen >= 6) {
-         struct ir3_instruction *ij[2];
-
-         for (int i = 0; i < 2; i++) {
-            ij[i] = create_immed(block, fui(0.0));
-         }
-
-         instr = ir3_FLAT_B(block, inloc, 0, ir3_create_collect(block, ij, 2), 0);
-         instr->srcs[1]->wrmask = 0x3;
+         instr = ir3_FLAT_B(block, inloc, 0, inloc, 0);
       } else {
          instr = ir3_LDLV(block, inloc, 0, create_immed(block, 1), 0);
          instr->cat6.type = TYPE_U32;



More information about the mesa-commit mailing list