From 64cb81a3a4ad0b2c794a276ca22c7fd39a1856a8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 3 Dec 2019 15:26:29 -0800 Subject: [PATCH] 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 Part-of: --- 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 #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); -- 2.30.2