added _slang_gltype_from_specifier()
authorBrian <brian@yutani.localnet.net>
Wed, 18 Apr 2007 22:43:40 +0000 (16:43 -0600)
committerBrian <brian@yutani.localnet.net>
Wed, 18 Apr 2007 23:14:13 +0000 (17:14 -0600)
src/mesa/shader/slang/slang_compile_variable.c
src/mesa/shader/slang/slang_typeinfo.c
src/mesa/shader/slang/slang_typeinfo.h

index 664fd9bc57678284306080755494b2d7528828bb..6632da9f8f33d7e51f6bd111fe5377e51e0c13b4 100644 (file)
@@ -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
-
index 2af8eb736bb76928e03811db8c7df80fe7defc6b..957c302c5b32c0fb5cdc87860eaf00cecffaabb3 100644 (file)
@@ -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;
+   }
+}
+
index ffffd09a5c29c28113f4bb7441c8cd38aeb70e5b..587331e8b1e0dd55244e047006a32330c2ab85fc 100644 (file)
@@ -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