From: Brian Date: Wed, 18 Apr 2007 22:43:40 +0000 (-0600) Subject: added _slang_gltype_from_specifier() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=addd03da2e254d16088171012c9ca0d157b0d4c2;p=mesa.git added _slang_gltype_from_specifier() --- diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index 664fd9bc576..6632da9f8f3 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -337,71 +337,3 @@ _slang_locate_variable(const slang_variable_scope * scope, return _slang_locate_variable(scope->outer_scope, a_name, 1); return NULL; } - -#if 0 -static GLenum -gl_type_from_specifier(const slang_type_specifier * type) -{ - switch (type->type) { - case SLANG_SPEC_BOOL: - return GL_BOOL_ARB; - case SLANG_SPEC_BVEC2: - return GL_BOOL_VEC2_ARB; - case SLANG_SPEC_BVEC3: - return GL_BOOL_VEC3_ARB; - case SLANG_SPEC_BVEC4: - return GL_BOOL_VEC4_ARB; - case SLANG_SPEC_INT: - return GL_INT; - case SLANG_SPEC_IVEC2: - return GL_INT_VEC2_ARB; - case SLANG_SPEC_IVEC3: - return GL_INT_VEC3_ARB; - case SLANG_SPEC_IVEC4: - return GL_INT_VEC4_ARB; - case SLANG_SPEC_FLOAT: - return GL_FLOAT; - case SLANG_SPEC_VEC2: - return GL_FLOAT_VEC2_ARB; - case SLANG_SPEC_VEC3: - return GL_FLOAT_VEC3_ARB; - case SLANG_SPEC_VEC4: - return GL_FLOAT_VEC4_ARB; - case SLANG_SPEC_MAT2: - return GL_FLOAT_MAT2_ARB; - case SLANG_SPEC_MAT3: - return GL_FLOAT_MAT3_ARB; - case SLANG_SPEC_MAT4: - return GL_FLOAT_MAT4_ARB; - case SLANG_SPEC_MAT23: - return GL_FLOAT_MAT2x3_ARB; - case SLANG_SPEC_MAT32: - return GL_FLOAT_MAT3x2_ARB; - case SLANG_SPEC_MAT24: - return GL_FLOAT_MAT2x4_ARB; - case SLANG_SPEC_MAT42: - return GL_FLOAT_MAT4x2_ARB; - case SLANG_SPEC_MAT34: - return GL_FLOAT_MAT3x4_ARB; - case SLANG_SPEC_MAT43: - return GL_FLOAT_MAT4x3_ARB; - case SLANG_SPEC_SAMPLER1D: - return GL_SAMPLER_1D_ARB; - case SLANG_SPEC_SAMPLER2D: - return GL_SAMPLER_2D_ARB; - case SLANG_SPEC_SAMPLER3D: - return GL_SAMPLER_3D_ARB; - case SLANG_SPEC_SAMPLERCUBE: - return GL_SAMPLER_CUBE_ARB; - case SLANG_SPEC_SAMPLER1DSHADOW: - return GL_SAMPLER_1D_SHADOW_ARB; - case SLANG_SPEC_SAMPLER2DSHADOW: - return GL_SAMPLER_2D_SHADOW_ARB; - case SLANG_SPEC_ARRAy: - return gl_type_from_specifier(type->_array); - default: - return GL_FLOAT; - } -} -#endif - diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c index 2af8eb736bb..957c302c5b3 100644 --- a/src/mesa/shader/slang/slang_typeinfo.c +++ b/src/mesa/shader/slang/slang_typeinfo.c @@ -944,3 +944,79 @@ _slang_type_dim(slang_type_specifier_type ty) return 0; } } + + +/** + * Return the GL_* type that corresponds to a SLANG_SPEC_* type. + */ +GLenum +_slang_gltype_from_specifier(const slang_type_specifier *type) +{ + switch (type->type) { + case SLANG_SPEC_BOOL: + return GL_BOOL; + case SLANG_SPEC_BVEC2: + return GL_BOOL_VEC2; + case SLANG_SPEC_BVEC3: + return GL_BOOL_VEC3; + case SLANG_SPEC_BVEC4: + return GL_BOOL_VEC4; + case SLANG_SPEC_INT: + return GL_INT; + case SLANG_SPEC_IVEC2: + return GL_INT_VEC2; + case SLANG_SPEC_IVEC3: + return GL_INT_VEC3; + case SLANG_SPEC_IVEC4: + return GL_INT_VEC4; + case SLANG_SPEC_FLOAT: + return GL_FLOAT; + case SLANG_SPEC_VEC2: + return GL_FLOAT_VEC2; + case SLANG_SPEC_VEC3: + return GL_FLOAT_VEC3; + case SLANG_SPEC_VEC4: + return GL_FLOAT_VEC4; + case SLANG_SPEC_MAT2: + return GL_FLOAT_MAT2; + case SLANG_SPEC_MAT3: + return GL_FLOAT_MAT3; + case SLANG_SPEC_MAT4: + return GL_FLOAT_MAT4; + case SLANG_SPEC_MAT23: + return GL_FLOAT_MAT2x3; + case SLANG_SPEC_MAT32: + return GL_FLOAT_MAT3x2; + case SLANG_SPEC_MAT24: + return GL_FLOAT_MAT2x4; + case SLANG_SPEC_MAT42: + return GL_FLOAT_MAT4x2; + case SLANG_SPEC_MAT34: + return GL_FLOAT_MAT3x4; + case SLANG_SPEC_MAT43: + return GL_FLOAT_MAT4x3; + case SLANG_SPEC_SAMPLER1D: + return GL_SAMPLER_1D; + case SLANG_SPEC_SAMPLER2D: + return GL_SAMPLER_2D; + case SLANG_SPEC_SAMPLER3D: + return GL_SAMPLER_3D; + case SLANG_SPEC_SAMPLERCUBE: + return GL_SAMPLER_CUBE; + case SLANG_SPEC_SAMPLER1DSHADOW: + return GL_SAMPLER_1D_SHADOW; + case SLANG_SPEC_SAMPLER2DSHADOW: + return GL_SAMPLER_2D_SHADOW; + case SLANG_SPEC_SAMPLER2DRECT: + return GL_SAMPLER_2D_RECT_ARB; + case SLANG_SPEC_SAMPLER2DRECTSHADOW: + return GL_SAMPLER_2D_RECT_SHADOW_ARB; + case SLANG_SPEC_ARRAY: + return _slang_gltype_from_specifier(type->_array); + case SLANG_SPEC_STRUCT: + /* fall-through */ + default: + return GL_NONE; + } +} + diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h index ffffd09a5c2..587331e8b1e 100644 --- a/src/mesa/shader/slang/slang_typeinfo.h +++ b/src/mesa/shader/slang/slang_typeinfo.h @@ -196,5 +196,7 @@ _slang_type_base(slang_type_specifier_type); extern GLuint _slang_type_dim(slang_type_specifier_type); +extern GLenum +_slang_gltype_from_specifier(const slang_type_specifier *type); #endif