From 492644dbef40393f8cc6686ec26216cfd7e9abc3 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Fri, 1 Sep 2023 00:36:29 -0700 Subject: [PATCH] compiler/types: Move static asserts about glsl_type to a central place Take it out of the way to reduce noise when reworking (and eventually removing) the constructor code. Reviewed-by: Emma Anholt Part-of: --- src/compiler/glsl_types.cpp | 24 ++++++++++++------------ src/compiler/glsl_types.h | 2 -- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 787848d..fe39e23 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -78,18 +78,6 @@ glsl_type::glsl_type(void *mem_ctx, uint32_t gl_type, length(0), explicit_stride(explicit_stride), explicit_alignment(explicit_alignment) { - /* Values of these types must fit in the two bits of - * glsl_type::sampled_type. - */ - STATIC_ASSERT((unsigned(GLSL_TYPE_UINT) & 3) == unsigned(GLSL_TYPE_UINT)); - STATIC_ASSERT((unsigned(GLSL_TYPE_INT) & 3) == unsigned(GLSL_TYPE_INT)); - STATIC_ASSERT((unsigned(GLSL_TYPE_FLOAT) & 3) == unsigned(GLSL_TYPE_FLOAT)); - - ASSERT_BITFIELD_SIZE(glsl_type, base_type, GLSL_TYPE_ERROR); - ASSERT_BITFIELD_SIZE(glsl_type, sampled_type, GLSL_TYPE_ERROR); - ASSERT_BITFIELD_SIZE(glsl_type, sampler_dimensionality, - GLSL_SAMPLER_DIM_SUBPASS_MS); - assert(mem_ctx != NULL); assert(name != NULL); @@ -462,6 +450,18 @@ const glsl_type *glsl_type::get_uint16_type() const void glsl_type_singleton_init_or_ref() { + /* Values of these types must fit in the two bits of + * glsl_type::sampled_type. + */ + STATIC_ASSERT((unsigned(GLSL_TYPE_UINT) & 3) == unsigned(GLSL_TYPE_UINT)); + STATIC_ASSERT((unsigned(GLSL_TYPE_INT) & 3) == unsigned(GLSL_TYPE_INT)); + STATIC_ASSERT((unsigned(GLSL_TYPE_FLOAT) & 3) == unsigned(GLSL_TYPE_FLOAT)); + + ASSERT_BITFIELD_SIZE(glsl_type, base_type, GLSL_TYPE_ERROR); + ASSERT_BITFIELD_SIZE(glsl_type, sampled_type, GLSL_TYPE_ERROR); + ASSERT_BITFIELD_SIZE(glsl_type, sampler_dimensionality, + GLSL_SAMPLER_DIM_SUBPASS_MS); + simple_mtx_lock(&glsl_type_cache_mutex); if (glsl_type_cache.users == 0) glsl_type_cache.mem_ctx = ralloc_context(NULL); diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index c38c508..cf40766 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -323,13 +323,11 @@ struct glsl_type { */ unsigned packed:1; -private: glsl_type() { // Dummy constructor, just for the sake of ASSERT_BITFIELD_SIZE. } -public: /** * \name Vector and matrix element counts * -- 2.7.4