Mesa (main): llvmpipe: replace GET_A0() macro w/ inline function

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 14 20:00:37 UTC 2022


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

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Jun  3 09:02:18 2022 -0600

llvmpipe: replace GET_A0() macro w/ inline function

And GET_DADX(), GET_DADY(), GET_PLANES().  This is a bit more
readable, making the expected parameter types explicit.

Signed-off-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17062>

---

 src/gallium/drivers/llvmpipe/lp_rast.h | 41 ++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index 277a3810db7..c8fda61850d 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -188,11 +188,44 @@ struct lp_rast_clear_rb {
 };
 
 
-#define GET_A0(inputs) ((float (*)[4])((inputs)+1))
-#define GET_DADX(inputs) ((float (*)[4])((char *)((inputs) + 1) + (inputs)->stride))
-#define GET_DADY(inputs) ((float (*)[4])((char *)((inputs) + 1) + 2 * (inputs)->stride))
-#define GET_PLANES(tri) ((struct lp_rast_plane *)((char *)(&(tri)->inputs + 1) + 3 * (tri)->inputs.stride))
+/*
+ * Return the address (as float[][4]) of the FS input values which
+ * are immediately after the 'inputs' object.
+ */
+static inline float(*
+GET_A0(const struct lp_rast_shader_inputs *inputs))[4]
+{
+   return (float (*)[4]) (inputs + 1);
+}
+
+/*
+ * Return the address (as float[][4]) of the FS input partial derivatives
+ * (w.r.t. X) which are after the 'inputs' object.
+ */
+static inline float(*
+GET_DADX(const struct lp_rast_shader_inputs *inputs))[4]
+{
+   const uint8_t *p = (const uint8_t *) (inputs + 1);
+   return (float (*)[4]) (p + 1 * inputs->stride);
+}
 
+/*
+ * Return the address (as float[][4]) of the FS input partial derivatives
+ * (w.r.t. Y) which are after the 'inputs' object.
+ */
+static inline float(*
+GET_DADY(const struct lp_rast_shader_inputs *inputs))[4]
+{
+   const uint8_t *p = (const uint8_t *) (inputs + 1);
+   return (float (*)[4]) (p + 2 * inputs->stride);
+}
+
+static inline struct lp_rast_plane *
+GET_PLANES(const struct lp_rast_triangle *tri)
+{
+   const uint8_t *p = (const uint8_t *) (&tri->inputs + 1);
+   return (struct lp_rast_plane *) (p + 3 * tri->inputs.stride);
+}
 
 
 struct lp_rasterizer *



More information about the mesa-commit mailing list