diff options
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/builtin_types.h | 150 | ||||
-rw-r--r-- | src/glsl/glsl_types.h | 10 |
2 files changed, 99 insertions, 61 deletions
diff --git a/src/glsl/builtin_types.h b/src/glsl/builtin_types.h index 48202f5645..526421a017 100644 --- a/src/glsl/builtin_types.h +++ b/src/glsl/builtin_types.h @@ -26,10 +26,10 @@ #endif static const struct glsl_type _error_type = - glsl_type(GLSL_TYPE_ERROR, 0, 0, ""); + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_ERROR, 0, 0, ""); static const struct glsl_type void_type = - glsl_type(GLSL_TYPE_VOID, 0, 0, "void"); + glsl_type(GL_INVALID_ENUM, GLSL_TYPE_VOID, 0, 0, "void"); const glsl_type *const glsl_type::error_type = & _error_type; @@ -40,27 +40,33 @@ const glsl_type *const glsl_type::error_type = & _error_type; /*@{*/ static const struct glsl_type builtin_core_types[] = { - glsl_type( GLSL_TYPE_BOOL, 1, 1, "bool"), - glsl_type( GLSL_TYPE_BOOL, 2, 1, "bvec2"), - glsl_type( GLSL_TYPE_BOOL, 3, 1, "bvec3"), - glsl_type( GLSL_TYPE_BOOL, 4, 1, "bvec4"), - glsl_type( GLSL_TYPE_INT, 1, 1, "int"), - glsl_type( GLSL_TYPE_INT, 2, 1, "ivec2"), - glsl_type( GLSL_TYPE_INT, 3, 1, "ivec3"), - glsl_type( GLSL_TYPE_INT, 4, 1, "ivec4"), - glsl_type( GLSL_TYPE_FLOAT, 1, 1, "float"), - glsl_type( GLSL_TYPE_FLOAT, 2, 1, "vec2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 1, "vec3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 1, "vec4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 2, "mat2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 3, "mat3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 4, "mat4"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, "sampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, "sampler1DShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, "sampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, "sampler2DShadow"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, "sampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, "samplerCube"), + glsl_type(GL_BOOL, GLSL_TYPE_BOOL, 1, 1, "bool"), + glsl_type(GL_BOOL_VEC2, GLSL_TYPE_BOOL, 2, 1, "bvec2"), + glsl_type(GL_BOOL_VEC3, GLSL_TYPE_BOOL, 3, 1, "bvec3"), + glsl_type(GL_BOOL_VEC4, GLSL_TYPE_BOOL, 4, 1, "bvec4"), + glsl_type(GL_INT, GLSL_TYPE_INT, 1, 1, "int"), + glsl_type(GL_INT_VEC2, GLSL_TYPE_INT, 2, 1, "ivec2"), + glsl_type(GL_INT_VEC3, GLSL_TYPE_INT, 3, 1, "ivec3"), + glsl_type(GL_INT_VEC4, GLSL_TYPE_INT, 4, 1, "ivec4"), + glsl_type(GL_FLOAT, GLSL_TYPE_FLOAT, 1, 1, "float"), + glsl_type(GL_FLOAT_VEC2, GLSL_TYPE_FLOAT, 2, 1, "vec2"), + glsl_type(GL_FLOAT_VEC3, GLSL_TYPE_FLOAT, 3, 1, "vec3"), + glsl_type(GL_FLOAT_VEC4, GLSL_TYPE_FLOAT, 4, 1, "vec4"), + glsl_type(GL_FLOAT_MAT2, GLSL_TYPE_FLOAT, 2, 2, "mat2"), + glsl_type(GL_FLOAT_MAT3, GLSL_TYPE_FLOAT, 3, 3, "mat3"), + glsl_type(GL_FLOAT_MAT4, GLSL_TYPE_FLOAT, 4, 4, "mat4"), + glsl_type(GL_SAMPLER_1D, GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_FLOAT, + "sampler1D"), + glsl_type(GL_SAMPLER_1D_SHADOW, GLSL_SAMPLER_DIM_1D, 1, 0, GLSL_TYPE_FLOAT, + "sampler1DShadow"), + glsl_type(GL_SAMPLER_2D, GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_FLOAT, + "sampler2D"), + glsl_type(GL_SAMPLER_2D_SHADOW, GLSL_SAMPLER_DIM_2D, 1, 0, GLSL_TYPE_FLOAT, + "sampler2DShadow"), + glsl_type(GL_SAMPLER_3D, GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_FLOAT, + "sampler3D"), + glsl_type(GL_SAMPLER_CUBE, GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_FLOAT, + "samplerCube"), }; const glsl_type *const glsl_type::bool_type = & builtin_core_types[0]; @@ -181,12 +187,12 @@ static const struct glsl_type builtin_110_deprecated_structure_types[] = { /*@{*/ static const struct glsl_type builtin_120_types[] = { - glsl_type( GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), - glsl_type( GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), - glsl_type( GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), - glsl_type( GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), - glsl_type( GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), + glsl_type(GL_FLOAT_MAT2x3, GLSL_TYPE_FLOAT, 3, 2, "mat2x3"), + glsl_type(GL_FLOAT_MAT2x4, GLSL_TYPE_FLOAT, 4, 2, "mat2x4"), + glsl_type(GL_FLOAT_MAT3x2, GLSL_TYPE_FLOAT, 2, 3, "mat3x2"), + glsl_type(GL_FLOAT_MAT3x4, GLSL_TYPE_FLOAT, 4, 3, "mat3x4"), + glsl_type(GL_FLOAT_MAT4x2, GLSL_TYPE_FLOAT, 2, 4, "mat4x2"), + glsl_type(GL_FLOAT_MAT4x3, GLSL_TYPE_FLOAT, 3, 4, "mat4x3"), }; const glsl_type *const glsl_type::mat2x3_type = & builtin_120_types[0]; const glsl_type *const glsl_type::mat2x4_type = & builtin_120_types[1]; @@ -201,33 +207,50 @@ const glsl_type *const glsl_type::mat4x3_type = & builtin_120_types[5]; /*@{*/ static const struct glsl_type builtin_130_types[] = { - glsl_type( GLSL_TYPE_UINT, 1, 1, "uint"), - glsl_type( GLSL_TYPE_UINT, 2, 1, "uvec2"), - glsl_type( GLSL_TYPE_UINT, 3, 1, "uvec3"), - glsl_type( GLSL_TYPE_UINT, 4, 1, "uvec4"), + glsl_type(GL_UNSIGNED_INT, GLSL_TYPE_UINT, 1, 1, "uint"), + glsl_type(GL_UNSIGNED_INT_VEC2, GLSL_TYPE_UINT, 2, 1, "uvec2"), + glsl_type(GL_UNSIGNED_INT_VEC3, GLSL_TYPE_UINT, 3, 1, "uvec3"), + glsl_type(GL_UNSIGNED_INT_VEC4, GLSL_TYPE_UINT, 4, 1, "uvec4"), /* 1D and 2D texture arrays */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + glsl_type(GL_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type(GL_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_INT, "isampler1DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_UINT, "usampler1DArray"), + glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type(GL_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type(GL_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_INT, "isampler2DArray"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_UINT, "usampler2DArray"), + glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), /* cube shadow samplers */ - glsl_type(GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), + glsl_type(GL_SAMPLER_CUBE_SHADOW, + GLSL_SAMPLER_DIM_CUBE, 1, 0, GLSL_TYPE_FLOAT, "samplerCubeShadow"), /* signed and unsigned integer samplers */ - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), - glsl_type( GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), - glsl_type(GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), + glsl_type(GL_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_INT, "isampler1D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_1D, + GLSL_SAMPLER_DIM_1D, 0, 0, GLSL_TYPE_UINT, "usampler1D"), + glsl_type(GL_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_INT, "isampler2D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_2D, + GLSL_SAMPLER_DIM_2D, 0, 0, GLSL_TYPE_UINT, "usampler2D"), + glsl_type(GL_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_INT, "isampler3D"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_3D, + GLSL_SAMPLER_DIM_3D, 0, 0, GLSL_TYPE_UINT, "usampler3D"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_INT, "isamplerCube"), + glsl_type(GL_INT_SAMPLER_CUBE, + GLSL_SAMPLER_DIM_CUBE, 0, 0, GLSL_TYPE_UINT, "usamplerCube"), }; const glsl_type *const glsl_type::uint_type = & builtin_130_types[0]; @@ -239,8 +262,10 @@ const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3]; /*@{*/ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { - glsl_type(GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), - glsl_type(GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), + glsl_type(GL_SAMPLER_2D_RECT, + GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_FLOAT, "sampler2DRect"), + glsl_type(GL_SAMPLER_2D_RECT_SHADOW, + GLSL_SAMPLER_DIM_RECT, 1, 0, GLSL_TYPE_FLOAT, "sampler2DRectShadow"), }; /*@}*/ @@ -249,10 +274,14 @@ static const struct glsl_type builtin_ARB_texture_rectangle_types[] = { /*@{*/ static const struct glsl_type builtin_EXT_texture_array_types[] = { - glsl_type( GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), - glsl_type( GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), - glsl_type( GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), - glsl_type( GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), + glsl_type(GL_SAMPLER_1D_ARRAY, + GLSL_SAMPLER_DIM_1D, 0, 1, GLSL_TYPE_FLOAT, "sampler1DArray"), + glsl_type(GL_SAMPLER_1D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 0, 1, GLSL_TYPE_FLOAT, "sampler2DArray"), + glsl_type(GL_SAMPLER_2D_ARRAY, + GLSL_SAMPLER_DIM_1D, 1, 1, GLSL_TYPE_FLOAT, "sampler1DArrayShadow"), + glsl_type(GL_SAMPLER_2D_ARRAY_SHADOW, + GLSL_SAMPLER_DIM_2D, 1, 1, GLSL_TYPE_FLOAT, "sampler2DArrayShadow"), }; /*@}*/ @@ -261,8 +290,11 @@ static const struct glsl_type builtin_EXT_texture_array_types[] = { /*@{*/ static const struct glsl_type builtin_EXT_texture_buffer_object_types[] = { - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), - glsl_type( GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), + glsl_type(GL_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_FLOAT, "samplerBuffer"), + glsl_type(GL_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_INT, "isamplerBuffer"), + glsl_type(GL_UNSIGNED_INT_SAMPLER_BUFFER, + GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"), }; /*@}*/ diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 39e6ac970a..93cf60be8d 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -30,6 +30,7 @@ #include <cassert> extern "C" { +#include "GL/gl.h" #include <talloc.h> } @@ -55,6 +56,7 @@ enum glsl_sampler_dim { struct glsl_type { + GLenum gl_type; unsigned base_type:4; unsigned sampler_dimensionality:3; @@ -151,8 +153,10 @@ struct glsl_type { /*@}*/ - glsl_type(unsigned base_type, unsigned vector_elements, + glsl_type(GLenum gl_type, + unsigned base_type, unsigned vector_elements, unsigned matrix_columns, const char *name) : + gl_type(gl_type), base_type(base_type), sampler_dimensionality(0), sampler_shadow(0), sampler_array(0), sampler_type(0), @@ -166,8 +170,10 @@ struct glsl_type { memset(& fields, 0, sizeof(fields)); } - glsl_type(enum glsl_sampler_dim dim, bool shadow, bool array, + glsl_type(GLenum gl_type, + enum glsl_sampler_dim dim, bool shadow, bool array, unsigned type, const char *name) : + gl_type(gl_type), base_type(GLSL_TYPE_SAMPLER), sampler_dimensionality(dim), sampler_shadow(shadow), sampler_array(array), sampler_type(type), |