aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2010-06-28 17:31:21 -0400
committerZack Rusin <[email protected]>2010-06-28 22:53:21 -0400
commitda7bd6a90e1fee5c16327338fd251c0f6be34e36 (patch)
tree5f7e3d8f6d30799033afd78beec3e643ef4c7d6c /src/mesa/main/shaderapi.c
parent0b50fcbd556ead8d35c2b543f13de433996a5822 (diff)
mesa: initial support for ARB_geometry_shader4
laying down the foundation for everything and implementing most of the stuff. linking, gl_VerticesIn and multidimensional inputs are left.
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 0bd44154f26..01b72446a2c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -379,6 +379,7 @@ create_shader(GLcontext *ctx, GLenum type)
switch (type) {
case GL_FRAGMENT_SHADER:
case GL_VERTEX_SHADER:
+ case GL_GEOMETRY_SHADER_ARB:
sh = ctx->Driver.NewShader(ctx, name, type);
break;
default:
@@ -1503,6 +1504,77 @@ _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat,
#endif /* FEATURE_ES2 */
+#if FEATURE_ARB_geometry_shader4
+
+static struct gl_geometry_program *
+_mesa_geometry_from_shader(GLuint program)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg = NULL;
+ struct gl_shader *sh = NULL;
+ GLuint i;
+
+ shProg = _mesa_lookup_shader_program(ctx, program);
+
+ if (!ctx->Extensions.ARB_geometry_shader4) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramParameteriARB");
+ return NULL;
+ }
+
+ if (!shProg) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB");
+ return NULL;
+ }
+ for (i = 0; i < shProg->NumShaders; ++i) {
+ if (shProg->Shaders[i]->Type == GL_GEOMETRY_SHADER_ARB) {
+ sh = shProg->Shaders[i];
+ }
+ }
+ if (!sh || !sh->Program) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB");
+ return NULL;
+ }
+ return (struct gl_geometry_program *) sh->Program;
+}
+
+static void
+_mesa_program_parameteri(GLcontext *ctx, GLuint program,
+ GLenum pname, GLint value)
+{
+ struct gl_geometry_program *gprog;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_GEOMETRY_VERTICES_OUT_ARB:
+ gprog = _mesa_geometry_from_shader(program);
+ if (gprog)
+ gprog->VerticesOut = value;
+ break;
+ case GL_GEOMETRY_INPUT_TYPE_ARB:
+ gprog = _mesa_geometry_from_shader(program);
+ if (gprog)
+ gprog->InputType = value;
+ break;
+ case GL_GEOMETRY_OUTPUT_TYPE_ARB:
+ gprog = _mesa_geometry_from_shader(program);
+ if (gprog)
+ gprog->OutputType = value;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB");
+ break;
+ }
+}
+
+void GLAPIENTRY
+_mesa_ProgramParameteriARB(GLuint program, GLenum pname,
+ GLint value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_program_parameteri(ctx, program, pname, value);
+}
+
+#endif
/**
* Plug in shader-related functions into API dispatch table.
@@ -1548,5 +1620,9 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec)
SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB);
SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
#endif
+
+#if FEATURE_ARB_geometry_shader4
+ SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB);
+#endif
}