asahi: Identify CDM block types
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 13 Sep 2022 02:22:56 +0000 (22:22 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 18 Sep 2022 14:34:25 +0000 (10:34 -0400)
Same enum as PowerVR CDM, annoyingly different from the VDM block types.
Split out the stream link / terminate structs (both observed with Metal
for copious amounts of compute), in preparation for decoding "properly".

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

src/asahi/lib/cmdbuf.xml
src/asahi/lib/decode.c
src/gallium/drivers/asahi/agx_state.c

index b459a1e..66aaa38 100644 (file)
   <!-- Conditional branching and function calls may be supported, see the
        STREAM_LINK0 struct in mesa/src/imagination/csbgen/rogue_vdm.xml for a
        probable dfinition -->
-  <struct name="Stream Link" size="8">
+  <struct name="VDM Stream Link" size="8">
     <field name="Target hi" size="8" start="0" type="hex"/>
     <field name="Block Type" size="3" start="29" type="VDM Block Type" default="Stream Link"/>
     <field name="Target lo" size="32" start="32" type="hex"/>
   </struct>
 
-  <struct name="Stream Terminate" size="8">
+  <struct name="VDM Stream Terminate" size="8">
     <field name="Block Type" size="3" start="29" type="VDM Block Type" default="Stream Terminate"/>
   </struct>
 
   <!-- VDM commands end -->
 
   <!-- CDM commands start -->
+  <enum name="CDM Block Type">
+    <value name="Compute Kernel" value="0"/>
+    <value name="Stream Link" value="1"/>
+    <value name="Stream Terminate" value="2"/>
+  </enum>
 
   <!--- Command to launch a direct compute kernel -->
   <struct name="Launch" size="36">
-    <field name="Command" size="32" start="0:0" type="hex" default="0x1002"/>
+    <field name="Unk 1" size="29" start="0:0" type="hex" default="0x1002"/>
+    <field name="Block Type" size="3" start="29" type="CDM Block Type" default="Compute Kernel"/>
     <field name="Pipeline" size="32" start="1:0" type="address"/>
     <field name="Group count X" size="32" start="2:0" type="uint"/>
     <field name="Group count Y" size="32" start="3:0" type="uint"/>
     <field name="Local size X" size="32" start="5:0" type="uint"/>
     <field name="Local size Y" size="32" start="6:0" type="uint"/>
     <field name="Local size Z" size="32" start="7:0" type="uint"/>
-    <field name="Unk" size="32" start="8:0" type="hex" default="0x60000160"/>
+    <field name="Unk 2" size="32" start="8:0" type="hex" default="0x60000160"/>
+  </struct>
+
+  <struct name="CDM Stream Link" size="8">
+    <field name="Target hi" size="8" start="0" type="hex"/>
+    <field name="Block Type" size="3" start="29" type="CDM Block Type" default="Stream Link"/>
+    <field name="Target lo" size="32" start="32" type="hex"/>
+  </struct>
+
+  <struct name="CDM Stream Terminate" size="8">
+    <field name="Block Type" size="3" start="29" type="CDM Block Type" default="Stream Terminate"/>
   </struct>
 
   <!-- CDM commands end -->
index ce84ea0..728f3a7 100644 (file)
@@ -550,14 +550,14 @@ agxdecode_cmd(const uint8_t *map, uint64_t *link, bool verbose)
    }
 
    case AGX_VDM_BLOCK_TYPE_STREAM_LINK: {
-      agx_unpack(agxdecode_dump_stream, map, STREAM_LINK, hdr);
-      DUMP_UNPACKED(STREAM_LINK, hdr, "Stream Link\n");
+      agx_unpack(agxdecode_dump_stream, map, VDM_STREAM_LINK, hdr);
+      DUMP_UNPACKED(VDM_STREAM_LINK, hdr, "Stream Link\n");
       *link = hdr.target_lo | (((uint64_t) hdr.target_hi) << 32);
       return STATE_LINK;
    }
 
    case AGX_VDM_BLOCK_TYPE_STREAM_TERMINATE: {
-      DUMP_CL(STREAM_TERMINATE, map, "Stream Terminate");
+      DUMP_CL(VDM_STREAM_TERMINATE, map, "Stream Terminate");
       return STATE_DONE;
    }
 
index c887c85..ffeb4ed 100644 (file)
@@ -1792,7 +1792,7 @@ agx_ensure_cmdbuf_has_space(struct agx_batch *batch, size_t space)
    struct agx_ptr T = agx_pool_alloc_aligned(&batch->pool, size, 256);
 
    /* Jump from the old command buffer to the new command buffer */
-   agx_pack(batch->encoder_current, STREAM_LINK, cfg) {
+   agx_pack(batch->encoder_current, VDM_STREAM_LINK, cfg) {
       cfg.target_lo = T.gpu & BITFIELD_MASK(32);
       cfg.target_hi = T.gpu >> 32;
    }