mesa: add PIPE_SHADER_* like constants and conversions to/from enums (v2)

Changes in v2:
- No longer adds tessellation enums
This commit is contained in:
Luca Barbieri
2010-09-06 00:56:07 +02:00
committed by Ian Romanick
parent 5ecd9c70ce
commit ede4205b24
3 changed files with 72 additions and 0 deletions
+9
View File
@@ -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
+31
View File
@@ -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
+32
View File
@@ -167,5 +167,37 @@ _mesa_find_free_register(const GLboolean used[],
extern void
_mesa_postprocess_program(GLcontext *ctx, struct gl_program *prog);
/* keep these in the same order as TGSI_PROCESSOR_* */
static INLINE GLuint
_mesa_program_target_to_index(GLenum v)
{
switch(v)
{
case GL_VERTEX_PROGRAM_ARB:
return MESA_SHADER_VERTEX;
case GL_FRAGMENT_PROGRAM_ARB:
return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_PROGRAM_NV:
return MESA_SHADER_GEOMETRY;
default:
ASSERT(0);
return ~0;
}
}
static INLINE GLenum
_mesa_program_index_to_target(GLuint i)
{
GLenum enums[MESA_SHADER_TYPES] = {
GL_VERTEX_PROGRAM_ARB,
GL_FRAGMENT_PROGRAM_ARB,
GL_GEOMETRY_PROGRAM_NV,
};
if(i >= MESA_SHADER_TYPES)
return 0;
else
return enums[i];
}
#endif /* PROGRAM_H */