asahi: Correct alignment for USC Uniform packets
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 4 Feb 2023 03:02:34 +0000 (22:02 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Feb 2023 07:19:29 +0000 (07:19 +0000)
We only need 4 byte alignment, not 8 bytes. This isn't a big difference in
practice, but it probably reduces padding in some cases. More importantly, it
corrects our XML to match what the hardware actually does, which is great.
(There is exactly enough room for a 40-bit address with 4 byte alignment.)

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

src/asahi/lib/cmdbuf.xml
src/gallium/drivers/asahi/agx_nir_lower_sysvals.c

index 606722f..0970eb7 100644 (file)
   <struct name="USC Uniform" size="8">
     <field name="Tag" size="8" start="0:0" type="USC Control" default="Uniform"/>
     <field name="Start (halfs)" size="8" start="0:8" type="uint"/>
-    <!-- Exact split is unknown. -->
     <field name="Size (halfs)" size="6" start="0:20" type="uint" modifier="groups(1)"/>
-    <field name="Buffer" size="36" start="0:27" type="address" modifier="shr(3)"/>
+    <field name="Buffer" size="38" start="0:26" type="address" modifier="shr(2)"/>
   </struct>
 
   <struct name="USC Uniform High" size="8">
     <field name="Tag" size="8" start="0:0" type="USC Control" default="Uniform High"/>
     <field name="Start (halfs)" size="8" start="0:8" type="uint"/>
-    <!-- Exact split is unknown. -->
     <field name="Size (halfs)" size="6" start="0:20" type="uint" modifier="groups(1)"/>
-    <field name="Buffer" size="36" start="0:27" type="address" modifier="shr(3)"/>
+    <field name="Buffer" size="38" start="0:26" type="address" modifier="shr(2)"/>
   </struct>
 
   <struct name="USC Texture" size="8">
index b76a5cd..77568ac 100644 (file)
@@ -141,10 +141,10 @@ lay_out_uniforms(struct agx_compiled_shader *shader, struct state *state)
          assert((shader->push_range_count < ARRAY_SIZE(shader->push)) &&
                 "AGX_MAX_PUSH_RANGES must be an upper bound");
 
-         /* Offsets must be aligned to 8 bytes, this may require pushing a
+         /* Offsets must be aligned to 4 bytes, this may require pushing a
           * little more than intended (otherwise we would need extra copies)
           */
-         range_start = ROUND_DOWN_TO(range_start, 8 / 2);
+         range_start = ROUND_DOWN_TO(range_start, 4 / 2);
 
          shader->push[shader->push_range_count++] = (struct agx_push_range){
             .uniform = uniform,