diff options
author | Brian Paul <[email protected]> | 2010-07-02 15:34:58 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-07-02 15:36:14 -0600 |
commit | ae8164a67b05cdc6d9b520b9704330537f3a6024 (patch) | |
tree | b523da694edbb1ab6f6ed43a685e56089e18909f /src | |
parent | d981bde38472d8d3bb74dab67eccd7c82915a566 (diff) |
mesa: add geometry shader fields to gl_shader_program
These 3 fields are per shader-program. Copy them into the geometry
program at link time for convenient access later.
Also, add some missing glGetProgramiv() queries.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/mtypes.h | 8 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 75 | ||||
-rw-r--r-- | src/mesa/main/shaderobj.c | 5 | ||||
-rw-r--r-- | src/mesa/slang/slang_link.c | 7 |
4 files changed, 42 insertions, 53 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f2d2133fe7f..0aeb130cb85 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2109,6 +2109,14 @@ struct gl_shader_program GLchar **VaryingNames; /**< Array [NumVarying] of char * */ } TransformFeedback; + /** Geometry shader state - copied into gl_geometry_program at link time */ + struct { + GLint VerticesOut; + GLenum InputType; /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB, + GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */ + GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ + } Geom; + /* post-link info: */ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 11eb41b49c0..9b251c9b457 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -661,6 +661,17 @@ get_programiv(GLcontext *ctx, GLuint program, GLenum pname, GLint *params) *params = shProg->TransformFeedback.BufferMode; break; #endif +#if FEATURE_ARB_geometry_shader4 + case GL_GEOMETRY_VERTICES_OUT_ARB: + *params = shProg->Geom.VerticesOut; + break; + case GL_GEOMETRY_INPUT_TYPE_ARB: + *params = shProg->Geom.InputType; + break; + case GL_GEOMETRY_OUTPUT_TYPE_ARB: + *params = shProg->Geom.OutputType; + break; +#endif default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)"); return; @@ -1505,55 +1516,22 @@ _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, #endif /* FEATURE_ES2 */ + #if FEATURE_ARB_geometry_shader4 -/** - * Look up a geometry program given a shader ID. - * An error will be recorded if the ID is invalid, etc. - */ -static struct gl_geometry_program * -_mesa_geometry_from_shader(GLuint program) +void GLAPIENTRY +_mesa_ProgramParameteriARB(GLuint program, GLenum pname, + GLint value) { + struct gl_shader_program *shProg; 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); - gprog = _mesa_geometry_from_shader(program); - if (!gprog) { - /* error will have been recorded */ + shProg = _mesa_lookup_shader_program_err(ctx, program, + "glProgramParameteri"); + if (!shProg) return; - } switch (pname) { case GL_GEOMETRY_VERTICES_OUT_ARB: @@ -1564,7 +1542,7 @@ _mesa_program_parameteri(GLcontext *ctx, GLuint program, value); return; } - gprog->VerticesOut = value; + shProg->Geom.VerticesOut = value; break; case GL_GEOMETRY_INPUT_TYPE_ARB: switch (value) { @@ -1573,7 +1551,7 @@ _mesa_program_parameteri(GLcontext *ctx, GLuint program, case GL_LINES_ADJACENCY_ARB: case GL_TRIANGLES: case GL_TRIANGLES_ADJACENCY_ARB: - gprog->InputType = value; + shProg->Geom.InputType = value; break; default: _mesa_error(ctx, GL_INVALID_VALUE, @@ -1587,7 +1565,7 @@ _mesa_program_parameteri(GLcontext *ctx, GLuint program, case GL_POINTS: case GL_LINE_STRIP: case GL_TRIANGLE_STRIP: - gprog->OutputType = value; + shProg->Geom.OutputType = value; break; default: _mesa_error(ctx, GL_INVALID_VALUE, @@ -1603,16 +1581,9 @@ _mesa_program_parameteri(GLcontext *ctx, GLuint program, } } -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. */ diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c index 00bc510ee81..14bbb2e4bc3 100644 --- a/src/mesa/main/shaderobj.c +++ b/src/mesa/main/shaderobj.c @@ -241,6 +241,11 @@ _mesa_new_shader_program(GLcontext *ctx, GLuint name) shProg->Name = name; shProg->RefCount = 1; shProg->Attributes = _mesa_new_parameter_list(); +#if FEATURE_ARB_geometry_shader4 + shProg->Geom.VerticesOut = 0; + shProg->Geom.InputType = GL_TRIANGLES; + shProg->Geom.OutputType = GL_TRIANGLE_STRIP; +#endif } return shProg; } diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c index d4656ed493c..8aa007bd1ec 100644 --- a/src/mesa/slang/slang_link.c +++ b/src/mesa/slang/slang_link.c @@ -1096,7 +1096,7 @@ _slang_link(GLcontext *ctx, "Geometry shader without a vertex shader is illegal!\n"); return; } - if (shProg->GeometryProgram->VerticesOut == 0) { + if (shProg->Geom.VerticesOut == 0) { link_error(shProg, "GEOMETRY_VERTICES_OUT is zero\n"); return; @@ -1166,6 +1166,11 @@ _slang_link(GLcontext *ctx, /* Compute initial program's TexturesUsed info */ _mesa_update_shader_textures_used(&shProg->GeometryProgram->Base); + /* Copy some per-shader-program fields to per-shader object */ + shProg->GeometryProgram->VerticesOut = shProg->Geom.VerticesOut; + shProg->GeometryProgram->InputType = shProg->Geom.InputType; + shProg->GeometryProgram->OutputType = shProg->Geom.OutputType; + /* notify driver that a new fragment program has been compiled/linked */ geomNotify = ctx->Driver.ProgramStringNotify(ctx, MESA_GEOMETRY_PROGRAM, &shProg->GeometryProgram->Base); |