diff options
author | Connor Abbott <[email protected]> | 2015-08-14 10:36:15 -0700 |
---|---|---|
committer | Samuel Iglesias Gonsálvez <[email protected]> | 2016-03-17 11:16:33 +0100 |
commit | 3d37de930d04da1d067b40593b55fc248eaf7b3b (patch) | |
tree | 0d14c42128484202c8450ef9dacb4b0abfc051a8 | |
parent | c38a25af2f47c6de093c9b0ac0ccdfa9fe48007e (diff) |
nir/types: add a function to get the bitsize of a base type
v2: fix it for GLSL_TYPE_SUBROUTINE (Iago)
Signed-off-by: Iago Toral Quiroga <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
-rw-r--r-- | src/compiler/nir_types.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index 18d64b768d4..07487838b50 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -77,6 +77,27 @@ enum glsl_base_type glsl_get_sampler_result_type(const struct glsl_type *type); unsigned glsl_get_record_location_offset(const struct glsl_type *type, unsigned length); +static inline unsigned +glsl_get_bit_size(enum glsl_base_type type) +{ + switch (type) { + case GLSL_TYPE_INT: + case GLSL_TYPE_UINT: + case GLSL_TYPE_BOOL: + case GLSL_TYPE_FLOAT: /* TODO handle mediump */ + case GLSL_TYPE_SUBROUTINE: + return 32; + + case GLSL_TYPE_DOUBLE: + return 64; + + default: + unreachable("unknown base type"); + } + + return 0; +} + bool glsl_type_is_void(const struct glsl_type *type); bool glsl_type_is_error(const struct glsl_type *type); bool glsl_type_is_vector(const struct glsl_type *type); |