compiler/types: Move builtin type initialization to C

While both clang and gcc can handle designated initializers in C++,
MSVC only does with the C++20 support enabled.  So move the initialization
of builtins to a C file.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25006>
This commit is contained in:
Caio Oliveira 2023-09-06 18:25:46 -07:00 committed by Marge Bot
parent 13d3efb2d1
commit bc9277d81c
4 changed files with 20 additions and 17 deletions

View file

@ -0,0 +1,13 @@
/*
* Copyright © 2009 Intel Corporation
* SPDX-License-Identifier: MIT
*/
#include "glsl_types.h"
#include "util/glheader.h"
#define DECL_TYPE(NAME, ...) \
const struct glsl_type glsl_type_builtin_##NAME = __VA_ARGS__;
#include "compiler/builtin_type_macros.h"
#undef DECL_TYPE

View file

@ -2904,17 +2904,10 @@ glsl_type::coordinate_components() const
return size;
}
/**
* Declarations of type flyweights (glsl_type::_foo_type) and
* convenience pointers (glsl_type::foo_type).
* @{
*/
#define DECL_TYPE(NAME, ...) \
const glsl_type glsl_type::_##NAME##_type = __VA_ARGS__; \
const glsl_type *const glsl_type::NAME##_type = &glsl_type::_##NAME##_type;
const glsl_type *const glsl_type::NAME##_type = &glsl_type_builtin_##NAME;
#include "compiler/builtin_type_macros.h"
#undef DECL_TYPE
/** @} */
union packed_type {
uint32_t u32;

View file

@ -1213,15 +1213,6 @@ private:
static bool record_key_compare(const void *a, const void *b);
static unsigned record_key_hash(const void *key);
/**
* \name Built-in type flyweights
*/
/*@{*/
#define DECL_TYPE(NAME, ...) static const glsl_type _##NAME##_type;
#include "compiler/builtin_type_macros.h"
#undef DECL_TYPE
/*@}*/
/**
* \name Friend functions.
*
@ -1240,6 +1231,11 @@ private:
#endif /* __cplusplus */
};
#define DECL_TYPE(NAME, ...) \
extern const struct glsl_type glsl_type_builtin_##NAME;
#include "compiler/builtin_type_macros.h"
#undef DECL_TYPE
struct glsl_struct_field {
const struct glsl_type *type;
const char *name;

View file

@ -25,6 +25,7 @@ inc_spirv = include_directories('spirv')
float64_glsl_file = files('glsl/float64.glsl')
files_libcompiler = files(
'builtin_type_defs.c',
'builtin_type_macros.h',
'glsl_types.cpp',
'glsl_types.h',