From 8e3f81ccc4006426f833d91ce591e18e7d8416af Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 5 Jul 2021 19:26:20 -0400 Subject: [PATCH] asahi: Add XML for the attachment structure We need a lot more control over these magic structures to get Z/S attachments working correctly. This is an early start. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/cmdbuf.xml | 19 +++++++++++++++++++ src/gallium/drivers/asahi/magic.c | 18 +++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml index 4b2adf24fb7..8ffae47b2d3 100644 --- a/src/asahi/lib/cmdbuf.xml +++ b/src/asahi/lib/cmdbuf.xml @@ -458,4 +458,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/gallium/drivers/asahi/magic.c b/src/gallium/drivers/asahi/magic.c index e09b28798f9..742306d5f8c 100644 --- a/src/gallium/drivers/asahi/magic.c +++ b/src/gallium/drivers/asahi/magic.c @@ -2,7 +2,8 @@ #include "agx_state.h" #include "magic.h" -/* magic code lifted from ./demo ... a lot more reveng needed */ +/* The structures managed in this file appear to be software defined (either in + * the macOS kernel driver or in the AGX firmware) */ struct cmdbuf { uint32_t *map; @@ -229,13 +230,16 @@ demo_cmdbuf(uint64_t *buf, size_t size, EMIT32(cmdbuf, 0x1); // number of attachments (includes depth/stencil) stored to /* A single attachment follows, depth/stencil have their own attachments */ - { - EMIT64(cmdbuf, 0x100 | (rt0 << 16)); - EMIT32(cmdbuf, 0xa0000); - EMIT32(cmdbuf, 0x4c000000); // 80000000 also observed, and 8c000 and.. offset into the tilebuffer I imagine - EMIT32(cmdbuf, 0x0c001d); // C0020 also observed - EMIT32(cmdbuf, 0x640000); + agx_pack((cmdbuf->map + cmdbuf->offset), IOGPU_ATTACHMENT, cfg) { + cfg.address = rt0; + cfg.type = AGX_IOGPU_ATTACHMENT_TYPE_COLOUR; + cfg.unk_1 = 0x4c000000; + cfg.unk_2 = 0x5; + cfg.bytes_per_pixel = 3; + cfg.percent = 100; } + + cmdbuf->offset += (AGX_IOGPU_ATTACHMENT_LENGTH / 4); } static struct agx_map_header