diff options
author | Luca Barbieri <luca@luca-barbieri.com> | 2010-09-06 00:56:07 +0200 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-09-08 20:36:37 -0700 |
commit | ede4205b245ee58bacf866d298273ebbe31feacf (patch) | |
tree | 863681fadafd7e3e3d777cbd0bb07a5c0c58a703 /src/mesa/main | |
parent | 5ecd9c70cecc05eaa1fef05f9bd4e8cf50f2c03a (diff) |
mesa: add PIPE_SHADER_* like constants and conversions to/from enums (v2)
Changes in v2:
- No longer adds tessellation enums
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/mtypes.h | 9 | ||||
-rw-r--r-- | src/mesa/main/shaderobj.h | 31 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 40f12eb20d..7d5ce7040b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -41,6 +41,15 @@ #include "math/m_matrix.h" /* GLmatrix */ #include "main/simple_list.h" /* struct simple_node */ +/* Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as PIPE_SHADER_* + */ +#define MESA_SHADER_VERTEX 0 +#define MESA_SHADER_FRAGMENT 1 +#define MESA_SHADER_GEOMETRY 2 +#define MESA_SHADER_TYPES 3 + + /** * Internal token * Must be simply different than GL_VERTEX_PROGRAM diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h index 4800046375..cbe7ae7b06 100644 --- a/src/mesa/main/shaderobj.h +++ b/src/mesa/main/shaderobj.h @@ -96,6 +96,37 @@ _mesa_init_shader_state(GLcontext *ctx); extern void _mesa_free_shader_state(GLcontext *ctx); +static INLINE GLuint +_mesa_shader_type_to_index(GLenum v) +{ + switch(v) + { + case GL_VERTEX_SHADER: + return MESA_SHADER_VERTEX; + case GL_FRAGMENT_SHADER: + return MESA_SHADER_FRAGMENT; + case GL_GEOMETRY_SHADER: + return MESA_SHADER_GEOMETRY; + default: + ASSERT(0); + return ~0; + } +} + +static INLINE GLenum +_mesa_shader_index_to_type(GLuint i) +{ + GLenum enums[MESA_SHADER_TYPES] = { + GL_VERTEX_SHADER, + GL_FRAGMENT_SHADER, + GL_GEOMETRY_SHADER , + }; + if(i >= MESA_SHADER_TYPES) + return 0; + else + return enums[i]; +} + #ifdef __cplusplus } #endif |