Mesa (master): gallium/util: Add a helper function for point sprite handling.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 29 17:00:13 UTC 2020


Module: Mesa
Branch: master
Commit: 64cb81a3a4ad0b2c794a276ca22c7fd39a1856a8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=64cb81a3a4ad0b2c794a276ca22c7fd39a1856a8

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Dec  3 15:26:29 2019 -0800

gallium/util: Add a helper function for point sprite handling.

Many drivers will need to do the same thing here, so consolidate it.

Reviewed-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2952>

---

 src/gallium/auxiliary/util/u_helpers.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h
index 09a95a7ab70..db7b3efc711 100644
--- a/src/gallium/auxiliary/util/u_helpers.h
+++ b/src/gallium/auxiliary/util/u_helpers.h
@@ -30,6 +30,7 @@
 
 #include "pipe/p_state.h"
 #include "c11/threads.h"
+#include "compiler/shader_enums.h"
 #include <stdio.h>
 
 #ifdef __cplusplus
@@ -56,6 +57,24 @@ bool util_upload_index_buffer(struct pipe_context *pipe,
                               struct pipe_resource **out_buffer,
                               unsigned *out_offset, unsigned alignment);
 
+/* Helper function to determine if the varying should contain the point
+ * coordinates, given the sprite_coord_enable mask.  Requires
+ * PIPE_CAP_TGSI_TEXCOORD to be enabled.
+ */
+static inline bool
+util_varying_is_point_coord(gl_varying_slot slot, uint32_t sprite_coord_enable)
+{
+   if (slot == VARYING_SLOT_PNTC)
+      return true;
+
+   if (slot >= VARYING_SLOT_TEX0 && slot <= VARYING_SLOT_TEX7 &&
+       (sprite_coord_enable & (1 << (slot - VARYING_SLOT_TEX0)))) {
+      return true;
+   }
+
+   return false;
+}
+
 void
 util_pin_driver_threads_to_random_L3(struct pipe_context *ctx,
                                      thrd_t *upper_thread);



More information about the mesa-commit mailing list