*/
#define DECL_SIMPLE_TYPE(NAME, GLTYPE, BASE_TYPE, ELEMENTS, COLS) \
- DECL_TYPE(NAME, GLTYPE, BASE_TYPE, ELEMENTS, COLS)
+ DECL_TYPE(NAME, { .gl_type = GLTYPE, .base_type = BASE_TYPE, .vector_elements = ELEMENTS, .matrix_columns = COLS, .name = #NAME })
#define DECL_SAMPLER_TYPE(NAME, GLTYPE, BASE_TYPE, DIM, SHADOW, ARRAY, SAMPLED_TYPE) \
- DECL_TYPE(NAME, GLTYPE, BASE_TYPE, DIM, SHADOW, ARRAY, SAMPLED_TYPE)
+ DECL_TYPE(NAME, { .gl_type = GLTYPE, .base_type = BASE_TYPE, .sampled_type = SAMPLED_TYPE, .sampler_dimensionality = DIM, .sampler_shadow = SHADOW, .sampler_array = ARRAY, .vector_elements = 1, .matrix_columns = 1, .name = #NAME })
DECL_SIMPLE_TYPE(error, GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0)
DECL_SIMPLE_TYPE(void, GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0)
*/
#include <stdio.h>
+#include <string.h>
#include "glsl_types.h"
#include "util/compiler.h"
#include "util/glheader.h"
*/
static uint32_t glsl_type_users = 0;
+glsl_type::glsl_type(const glsl_type_params ¶ms)
+{
+ gl_type = params.gl_type;
+ base_type = params.base_type;
+ sampled_type = params.sampled_type;
+ sampler_dimensionality = params.sampler_dimensionality;
+ sampler_shadow = params.sampler_shadow;
+ sampler_array = params.sampler_array;
+ vector_elements = params.vector_elements;
+ matrix_columns = params.matrix_columns;
+ length = params.length;
+ name = params.name;
+}
+
glsl_type::glsl_type(uint32_t gl_type,
glsl_base_type base_type, unsigned vector_elements,
unsigned matrix_columns, const char *name,
* @{
*/
#define DECL_TYPE(NAME, ...) \
- const glsl_type glsl_type::_##NAME##_type = glsl_type(__VA_ARGS__, #NAME); \
+ const glsl_type glsl_type::_##NAME##_type = glsl_type((glsl_type_params)__VA_ARGS__); \
const glsl_type *const glsl_type::NAME##_type = &glsl_type::_##NAME##_type;
#include "compiler/builtin_type_macros.h"
#undef DECL_TYPE
/* C++ struct types for glsl */
#ifdef __cplusplus
+/* TODO: Remove this once glsl_type is a plain struct. */
+struct glsl_type_params {
+ uint32_t gl_type;
+ glsl_base_type base_type:8;
+ glsl_base_type sampled_type:8;
+ unsigned sampler_dimensionality:4;
+ unsigned sampler_shadow:1;
+ unsigned sampler_array:1;
+ uint8_t vector_elements;
+ uint8_t matrix_columns;
+ unsigned length;
+ const char *name;
+};
+
struct glsl_type {
uint32_t gl_type;
glsl_base_type base_type:8;
*/
void *mem_ctx;
+ /** Constructor for builtins. */
+ explicit glsl_type(const glsl_type_params ¶ms);
+
/** Constructor for vector and matrix types */
glsl_type(uint32_t gl_type,
glsl_base_type base_type, unsigned vector_elements,