diff options
author | Younes Manton <[email protected]> | 2010-04-30 20:42:30 -0400 |
---|---|---|
committer | Younes Manton <[email protected]> | 2010-04-30 20:42:30 -0400 |
commit | a8ea1dacc63ac567498049e5756c247b9fec6cd9 (patch) | |
tree | 4031e2e2b6166bd926b43fa4bbb3aab773a30ee5 /src/mesa/drivers/glslcompiler/glslcompiler.c | |
parent | 404fb63b4649f58fce443615e49337d42b8ddece (diff) | |
parent | 35d960cc744c374ccaad48c3d80559b59c74e28a (diff) |
Merge branch 'master' of ssh://git.freedesktop.org/git/mesa/mesa into pipe-video
Conflicts:
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/util/u_format.csv
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/drivers/identity/id_objects.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/nv40/Makefile
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/drivers/softpipe/sp_video_context.h
src/gallium/include/pipe/p_format.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_video_context.h
src/gallium/include/pipe/p_video_state.h
src/gallium/include/state_tracker/dri1_api.h
src/gallium/include/state_tracker/drm_api.h
src/gallium/state_trackers/dri/common/dri_context.c
src/gallium/state_trackers/xorg/xvmc/attributes.c
src/gallium/state_trackers/xorg/xvmc/block.c
src/gallium/state_trackers/xorg/xvmc/context.c
src/gallium/state_trackers/xorg/xvmc/subpicture.c
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/tests/.gitignore
src/gallium/state_trackers/xorg/xvmc/tests/Makefile
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/g3dvl/vl_winsys.h
src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
src/gallium/winsys/sw/Makefile
Diffstat (limited to 'src/mesa/drivers/glslcompiler/glslcompiler.c')
-rw-r--r-- | src/mesa/drivers/glslcompiler/glslcompiler.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index 66035a4a43c..d58f32b2930 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -68,6 +68,7 @@ static const char *Prog = "glslcompiler"; struct options { GLboolean LineNumbers; + GLboolean Link; gl_prog_print_mode Mode; const char *VertFile; const char *FragFile; @@ -207,23 +208,29 @@ ReadShader(GLuint shader, const char *filename) } -#if 0 static void -CheckLink(GLuint prog) +CheckLink(GLuint v_shader, GLuint f_shader) { + GLuint prog; GLint stat; + + prog = _mesa_CreateProgram(); + + _mesa_AttachShader(prog, v_shader); + _mesa_AttachShader(prog, f_shader); + + _mesa_LinkProgramARB(prog); _mesa_GetProgramiv(prog, GL_LINK_STATUS, &stat); if (!stat) { GLchar log[1000]; GLsizei len; _mesa_GetProgramInfoLog(prog, 1000, &len, log); - fprintf(stderr, "%s: Linker error:\n%s\n", Prog, log); + fprintf(stderr, "Linker error:\n%s\n", log); } else { - fprintf(stderr, "%s: Link success!\n", Prog); + fprintf(stderr, "Link success!\n"); } } -#endif static void @@ -262,6 +269,7 @@ Usage(void) printf(" --fs FILE fragment shader input filename\n"); printf(" --arb emit ARB-style instructions\n"); printf(" --nv emit NV-style instructions\n"); + printf(" --link run linker\n"); printf(" --debug force #pragma debug(on)\n"); printf(" --nodebug force #pragma debug(off)\n"); printf(" --opt force #pragma optimize(on)\n"); @@ -309,6 +317,9 @@ ParseOptions(int argc, char *argv[]) else if (strcmp(argv[i], "--nv") == 0) { Options.Mode = PROG_PRINT_NV; } + else if (strcmp(argv[i], "--link") == 0) { + Options.Link = GL_TRUE; + } else if (strcmp(argv[i], "--debug") == 0) { Options.Pragmas.IgnoreDebug = GL_TRUE; Options.Pragmas.Debug = GL_TRUE; @@ -358,7 +369,7 @@ ParseOptions(int argc, char *argv[]) int main(int argc, char *argv[]) { - GLuint shader = 0; + GLuint v_shader = 0, f_shader = 0; ParseOptions(argc, argv); @@ -368,24 +379,38 @@ main(int argc, char *argv[]) } if (Options.VertFile) { - shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); + v_shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); } - else if (Options.FragFile) { - shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); + + if (Options.FragFile) { + f_shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); } - if (shader) { + if (v_shader || f_shader) { if (Options.OutputFile) { fclose(stdout); /*stdout =*/ freopen(Options.OutputFile, "w", stdout); } - if (stdout) { - PrintShaderInstructions(shader, stdout); + if (stdout && v_shader) { + PrintShaderInstructions(v_shader, stdout); + } + if (stdout && f_shader) { + PrintShaderInstructions(f_shader, stdout); } if (Options.OutputFile) { fclose(stdout); } } + if (Options.Link) { + if (!v_shader || !f_shader) { + fprintf(stderr, + "--link option requires both a vertex and fragment shader.\n"); + exit(1); + } + + CheckLink(v_shader, f_shader); + } + return 0; } |