summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-11-23 10:28:43 -0700
committerBrian Paul <brianp@vmware.com>2010-11-23 15:52:43 -0700
commitc628fd743ee3c3305e9beac7f0e6efacf6982115 (patch)
tree873ae98daf0b76c1778e0c10da0226ca91bff089 /src/mesa/main
parent512f840702d58b48607a9dca06dd939256c7afed (diff)
mesa: replace #defines with new gl_shader_type enum
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/context.c2
-rw-r--r--src/mesa/main/mtypes.h22
-rw-r--r--src/mesa/main/shaderobj.c9
-rw-r--r--src/mesa/main/shaderobj.h4
4 files changed, 22 insertions, 15 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4ed179a834..e2c91c3e40 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1829,7 +1829,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->Shader.Flags & GLSL_LOG) {
struct gl_shader_program *shProg[MESA_SHADER_TYPES];
- unsigned i;
+ gl_shader_type i;
shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 87b96489db..80c20e09d9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -41,14 +41,6 @@
#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
-
/**
* Color channel data type.
@@ -130,6 +122,20 @@ struct st_context;
/**
+ * Shader stages. Note that these will become 5 with tessellation.
+ * These MUST have the same values as gallium's PIPE_SHADER_*
+ */
+typedef enum
+{
+ MESA_SHADER_VERTEX = 0,
+ MESA_SHADER_FRAGMENT = 1,
+ MESA_SHADER_GEOMETRY = 2,
+ MESA_SHADER_TYPES = 3
+} gl_shader_type;
+
+
+
+/**
* Indexes for vertex program attributes.
* GL_NV_vertex_program aliases generic attributes over the conventional
* attributes. In GL_ARB_vertex_program shader the aliasing is optional.
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index b6594cbe6f..216bbce003 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -291,6 +291,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
GLuint i;
+ gl_shader_type sh;
assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
@@ -326,10 +327,10 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
shProg->TransformFeedback.NumVarying = 0;
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
- if (shProg->_LinkedShaders[i] != NULL) {
- ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[i]);
- shProg->_LinkedShaders[i] = NULL;
+ for (sh = 0; sh < MESA_SHADER_TYPES; sh++) {
+ if (shProg->_LinkedShaders[sh] != NULL) {
+ ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]);
+ shProg->_LinkedShaders[sh] = NULL;
}
}
}
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 346a5b7517..de7c998cf0 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -98,7 +98,7 @@ extern void
_mesa_free_shader_state(struct gl_context *ctx);
-static INLINE GLuint
+static INLINE gl_shader_type
_mesa_shader_type_to_index(GLenum v)
{
switch (v) {
@@ -110,7 +110,7 @@ _mesa_shader_type_to_index(GLenum v)
return MESA_SHADER_GEOMETRY;
default:
ASSERT(0 && "bad value in _mesa_shader_type_to_index()");
- return ~0;
+ return MESA_SHADER_TYPES;
}
}