diff options
Diffstat (limited to 'src/mesa/drivers/glslcompiler')
-rw-r--r-- | src/mesa/drivers/glslcompiler/glslcompiler.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index d58f32b2930..7259bf4c560 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -49,16 +49,14 @@ #include "main/context.h" #include "main/extensions.h" #include "main/framebuffer.h" -#include "main/shaders.h" -#include "shader/shader_api.h" -#include "shader/prog_print.h" +#include "main/shaderapi.h" +#include "main/shaderobj.h" +#include "program/prog_print.h" #include "drivers/common/driverfuncs.h" #include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" #include "swrast/swrast.h" -#include "swrast/s_context.h" -#include "swrast/s_triangle.h" #include "swrast_setup/swrast_setup.h" #include "vbo/vbo.h" @@ -72,6 +70,7 @@ struct options { gl_prog_print_mode Mode; const char *VertFile; const char *FragFile; + const char *GeoFile; const char *OutputFile; GLboolean Params; struct gl_sl_pragmas Pragmas; @@ -126,6 +125,7 @@ CreateContext(void) _mesa_destroy_visual(vis); if (buf) _mesa_destroy_framebuffer(buf); + free(cc); return GL_FALSE; } @@ -143,6 +143,7 @@ CreateContext(void) !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(vis); + _mesa_destroy_framebuffer(buf); _mesa_free_context_data(ctx); free(cc); return GL_FALSE; @@ -251,7 +252,8 @@ CompileShader(const char *filename, GLenum type) GLuint shader; assert(type == GL_FRAGMENT_SHADER || - type == GL_VERTEX_SHADER); + type == GL_VERTEX_SHADER || + type == GL_GEOMETRY_SHADER_ARB); shader = _mesa_CreateShader(type); ReadShader(shader, filename); @@ -267,6 +269,7 @@ Usage(void) printf("Usage:\n"); printf(" --vs FILE vertex shader input filename\n"); printf(" --fs FILE fragment shader input filename\n"); + printf(" --gs FILE geometry shader input filename\n"); printf(" --arb emit ARB-style instructions\n"); printf(" --nv emit NV-style instructions\n"); printf(" --link run linker\n"); @@ -290,6 +293,7 @@ ParseOptions(int argc, char *argv[]) Options.Mode = PROG_PRINT_DEBUG; Options.VertFile = NULL; Options.FragFile = NULL; + Options.GeoFile = NULL; Options.OutputFile = NULL; Options.Params = GL_FALSE; Options.Pragmas.IgnoreOptimize = GL_FALSE; @@ -311,6 +315,10 @@ ParseOptions(int argc, char *argv[]) Options.FragFile = argv[i + 1]; i++; } + else if (strcmp(argv[i], "--gs") == 0) { + Options.GeoFile = argv[i + 1]; + i++; + } else if (strcmp(argv[i], "--arb") == 0) { Options.Mode = PROG_PRINT_ARB; } @@ -369,7 +377,7 @@ ParseOptions(int argc, char *argv[]) int main(int argc, char *argv[]) { - GLuint v_shader = 0, f_shader = 0; + GLuint v_shader = 0, f_shader = 0, g_shader = 0; ParseOptions(argc, argv); @@ -386,10 +394,19 @@ main(int argc, char *argv[]) f_shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); } - if (v_shader || f_shader) { + if (Options.GeoFile) { + g_shader = CompileShader(Options.GeoFile, GL_GEOMETRY_SHADER_ARB); + } + + + if (v_shader || f_shader || g_shader) { if (Options.OutputFile) { + FILE *f; fclose(stdout); - /*stdout =*/ freopen(Options.OutputFile, "w", stdout); + /*stdout =*/ f = freopen(Options.OutputFile, "w", stdout); + if (!f) { + fprintf(stderr, "freopen error\n"); + } } if (stdout && v_shader) { PrintShaderInstructions(v_shader, stdout); @@ -397,6 +414,9 @@ main(int argc, char *argv[]) if (stdout && f_shader) { PrintShaderInstructions(f_shader, stdout); } + if (stdout && g_shader) { + PrintShaderInstructions(g_shader, stdout); + } if (Options.OutputFile) { fclose(stdout); } |