agx: Tease apart some sample_mask packing magic
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 30 Mar 2023 01:58:59 +0000 (21:58 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Apr 2023 03:23:04 +0000 (03:23 +0000)
There's a second instruction here, and a second source in the first instruction.
applegpu has known about the encodings for a while but I never updated the
packing code. We will need to stop hardcoding this for multisampling support, as
preparation tease apart the magic pieces.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22353>

src/asahi/compiler/agx_pack.c

index 9f7fe3e..3f81059 100644 (file)
@@ -500,11 +500,27 @@ agx_pack_instr(struct util_dynarray *emission, struct util_dynarray *fixups,
 
    case AGX_OPCODE_SAMPLE_MASK: {
       unsigned S = agx_pack_sample_mask_src(I->src[0]);
-      uint64_t raw = 0x7fc1 | ((S & 0xff) << 16) | (0x3 << 24) |
-                     ((S >> 8) << 26) | (0x158ull << 32);
+      unsigned T = 0xFF;
+      bool Tt = true /* immediate */;
+      uint32_t raw = 0xc1 | (Tt ? BITFIELD_BIT(8) : 0) |
+                     ((T & BITFIELD_MASK(6)) << 9) | ((S & 0xff) << 16) |
+                     ((T >> 6) << 24) | ((S >> 8) << 26);
 
-      unsigned size = 8;
+      unsigned size = 4;
       memcpy(util_dynarray_grow_bytes(emission, 1, size), &raw, size);
+
+      {
+         /* This is actually a separate instruction.
+          *
+          *    signal_pix 1, 0
+          *
+          * We don't model this correctly yet, but we should.
+          */
+         uint32_t raw = 0x158;
+         unsigned size = 4;
+         memcpy(util_dynarray_grow_bytes(emission, 1, size), &raw, size);
+      }
+
       break;
    }