diff options
author | Brian <[email protected]> | 2006-12-20 09:57:56 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2006-12-20 09:57:56 -0700 |
commit | 79a340bc15e13643b1016d011556ba622dd18a5f (patch) | |
tree | 4689ad270c871f5e8140f34d8c554d08903c7858 | |
parent | f2923613a40e07d06ce08d3355f3120d81b9e759 (diff) |
use cast wrappers for sanity checking
-rw-r--r-- | src/mesa/shader/slang/slang_link2.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mesa/shader/slang/slang_link2.c b/src/mesa/shader/slang/slang_link2.c index fa29e42706e..d3d53942654 100644 --- a/src/mesa/shader/slang/slang_link2.c +++ b/src/mesa/shader/slang/slang_link2.c @@ -269,6 +269,23 @@ slang_resolve_branches(struct gl_program *prog) } +/** cast wrapper */ +static struct gl_vertex_program * +vertex_program(struct gl_program *prog) +{ + assert(prog->Target == GL_VERTEX_PROGRAM_ARB); + return (struct gl_vertex_program *) prog; +} + + +/** cast wrapper */ +static struct gl_fragment_program * +fragment_program(struct gl_program *prog) +{ + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); + return (struct gl_fragment_program *) prog; +} + /** * Shader linker. Currently: @@ -305,9 +322,9 @@ _slang_link2(GLcontext *ctx, fragProg = NULL; for (i = 0; i < shProg->NumShaders; i++) { if (shProg->Shaders[i]->Type == GL_VERTEX_SHADER) - vertProg = (struct gl_vertex_program *) shProg->Shaders[i]->Programs[0]; + vertProg = vertex_program(shProg->Shaders[i]->Programs[0]); else if (shProg->Shaders[i]->Type == GL_FRAGMENT_SHADER) - fragProg = (struct gl_fragment_program *) shProg->Shaders[i]->Programs[0]; + fragProg = fragment_program(shProg->Shaders[i]->Programs[0]); else _mesa_problem(ctx, "unexpected shader target in slang_link2()"); } @@ -329,10 +346,10 @@ _slang_link2(GLcontext *ctx, * Make copies of the vertex/fragment programs now since we'll be * changing src/dst registers after merging the uniforms and varying vars. */ - shProg->VertexProgram = (struct gl_vertex_program *) - _mesa_clone_program(ctx, &vertProg->Base); - shProg->FragmentProgram = (struct gl_fragment_program *) - _mesa_clone_program(ctx, &fragProg->Base); + shProg->VertexProgram + = vertex_program(_mesa_clone_program(ctx, &vertProg->Base)); + shProg->FragmentProgram + = fragment_program(_mesa_clone_program(ctx, &fragProg->Base)); link_varying_vars(shProg, &shProg->VertexProgram->Base); link_varying_vars(shProg, &shProg->FragmentProgram->Base); |