Mesa (main): asahi: Update viewport descriptor depth fields

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun May 30 23:42:26 UTC 2021


Module: Mesa
Branch: main
Commit: 6fbc1cb52a06a6cc67fff57eab5235ec4ef3d992
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6fbc1cb52a06a6cc67fff57eab5235ec4ef3d992

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Mon May 31 02:13:19 2021 +0530

asahi: Update viewport descriptor depth fields

Acts like a translate/scale pair more generally, not specific to near/far
planes.

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

---

 src/asahi/lib/cmdbuf.xml              | 11 +++++++++--
 src/gallium/drivers/asahi/agx_state.c |  4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml
index 6059a9c2c22..83e793b092d 100644
--- a/src/asahi/lib/cmdbuf.xml
+++ b/src/asahi/lib/cmdbuf.xml
@@ -153,8 +153,15 @@
     <field name="Scale X" size="32" start="5:0" type="float"/>
     <field name="Translate Y" size="32" start="6:0" type="float"/>
     <field name="Scale Y" size="32" start="7:0" type="float"/>
-    <field name="Near Z" size="32" start="8:0" type="float"/>
-    <field name="Z Range" size="32" start="9:0" type="float"/>
+
+    <!-- Specifies an affine transformation from clip coordinates to viewport
+    depth coordinates. For APIs with clip coordinates [0, 1], this cooresponds
+    to near z and (far z - near z) respectively. In general, given clip
+    coordinate z_in, the viewport depth is given as (z_in * scale_z) +
+    translate_z.  For example, the default [0, 1] depth buffer in OpenGL with
+    [-1, +1] clip coordinates is specified as scale = 1/2, bias = 1/2 -->
+    <field name="Translate Z" size="32" start="8:0" type="float"/>
+    <field name="Scale Z" size="32" start="9:0" type="float"/>
   </struct>
 
   <!--- Pointed to from the command buffer -->
diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c
index feabe48cccf..f84c9f32a60 100644
--- a/src/gallium/drivers/asahi/agx_state.c
+++ b/src/gallium/drivers/asahi/agx_state.c
@@ -477,8 +477,8 @@ agx_upload_viewport(struct agx_pool *pool,
       cfg.translate_y = vp->translate[1];
       cfg.scale_x = vp->scale[0];
       cfg.scale_y = vp->scale[1];
-      cfg.near_z = near_z;
-      cfg.z_range = far_z - near_z;
+      cfg.translate_z = near_z;
+      cfg.scale_z = far_z - near_z;
    };
 
    return T.gpu;



More information about the mesa-commit mailing list