Mesa (main): asahi: Add XML for the attachment structure
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 6 13:55:47 UTC 2021
Module: Mesa
Branch: main
Commit: 8e3f81ccc4006426f833d91ce591e18e7d8416af
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8e3f81ccc4006426f833d91ce591e18e7d8416af
Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date: Mon Jul 5 19:26:20 2021 -0400
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 <alyssa at rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11730>
---
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 @@
<field name="Local size Z" size="32" start="7:0" type="uint"/>
<field name="Unk" size="32" start="8:0" type="hex" default="0x60000160"/>
</struct>
+
+ <!--- The rest of this file is likely software defined by macOS kernel -->
+ <enum name="IOGPU Attachment Type">
+ <value name="Colour" value="0xA"/>
+ <value name="Depth" value="0xC"/>
+ </enum>
+
+ <struct name="IOGPU Attachment" size="24">
+ <field name="Unk 0" start="0:0" size="16" default="0x100" type="hex"/>
+ <field name="Address" start="0:16" size="48" type="address"/>
+ <field name="Type" start="2:16" size="16" type="IOGPU Attachment Type"/>
+ <field name="Unk 1" start="3:0" size="32" type="hex"/>
+ <field name="Unk 2" start="4:0" size="3" type="hex"/>
+ <field name="Bytes per pixel" start="4:3" size="5" type="uint"/>
+ <field name="Unk 3" start="4:16" size="4" type="hex" default="0xC"/>
+ <!-- Percent of total attachment space used for this attachment, expressed
+ in a decimal percentage [0, 100] <field name="Percent" start="5:16" -->
+ <field name="Percent" start="5:16" size="16" type="uint"/>
+ </struct>
</agxml>
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
More information about the mesa-commit
mailing list