From 5eda9f5832105bea0b3f75bcc866c760dd801718 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 17 Sep 2018 08:53:24 -0700 Subject: [PATCH] glsl_types: Add function to get an unsigned base type from a signed type Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- src/compiler/glsl_types.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 76a6fd2..28d4ad4 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -196,6 +196,27 @@ glsl_base_type_get_bit_size(const enum glsl_base_type base_type) return 0; } +static inline enum glsl_base_type +glsl_unsigned_base_type_of(enum glsl_base_type type) +{ + switch (type) { + case GLSL_TYPE_INT: + return GLSL_TYPE_UINT; + case GLSL_TYPE_INT8: + return GLSL_TYPE_UINT8; + case GLSL_TYPE_INT16: + return GLSL_TYPE_UINT16; + case GLSL_TYPE_INT64: + return GLSL_TYPE_UINT64; + default: + assert(type == GLSL_TYPE_UINT || + type == GLSL_TYPE_UINT8 || + type == GLSL_TYPE_UINT16 || + type == GLSL_TYPE_UINT64); + return type; + } +} + enum glsl_sampler_dim { GLSL_SAMPLER_DIM_1D = 0, GLSL_SAMPLER_DIM_2D, -- 2.7.4