diff options
author | Brian Paul <brianp@vmware.com> | 2009-03-19 10:26:50 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2009-03-19 10:29:13 -0600 |
commit | bbd208b60c4d39cccb931b4d23efc9d42648afd3 (patch) | |
tree | 0bef67c80ac9040637b188e6b2c98c78820e4c96 /src/mesa | |
parent | 65fc2ca82a38bc00ae4223124932af6771765041 (diff) | |
download | external_mesa3d-bbd208b60c4d39cccb931b4d23efc9d42648afd3.zip external_mesa3d-bbd208b60c4d39cccb931b4d23efc9d42648afd3.tar.gz external_mesa3d-bbd208b60c4d39cccb931b4d23efc9d42648afd3.tar.bz2 |
glslcompiler: added new options to override debug/optimization pragmas
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/glslcompiler/glslcompiler.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index 54a4c1a..e4527ab 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -73,6 +73,7 @@ struct options { const char *FragFile; const char *OutputFile; GLboolean Params; + struct gl_sl_pragmas Pragmas; }; static struct options Options; @@ -148,6 +149,9 @@ CreateContext(void) TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; _swsetup_Wakeup( ctx ); + /* Override the context's default pragma settings */ + ctx->Shader.DefaultPragmas = Options.Pragmas; + _mesa_make_current(ctx, buf, buf); return GL_TRUE; @@ -256,10 +260,13 @@ Usage(void) printf("Usage:\n"); printf(" --vs FILE vertex shader input filename\n"); printf(" --fs FILE fragment shader input filename\n"); - printf(" --arb emit ARB-style instructions (the default)\n"); + printf(" --arb emit ARB-style instructions\n"); printf(" --nv emit NV-style instructions\n"); - printf(" --debug emit debug-style instructions\n"); - printf(" --number, -n emit line numbers\n"); + printf(" --debug force #pragma debug(on)\n"); + printf(" --nodebug force #pragma debug(off)\n"); + printf(" --opt force #pragma optimize(on)\n"); + printf(" --noopt force #pragma optimize(off)\n"); + printf(" --number, -n emit line numbers (if --arb or --nv)\n"); printf(" --output, -o FILE output filename\n"); printf(" --params also emit program parameter info\n"); printf(" --help display this information\n"); @@ -272,11 +279,15 @@ ParseOptions(int argc, char *argv[]) int i; Options.LineNumbers = GL_FALSE; - Options.Mode = PROG_PRINT_ARB; + Options.Mode = PROG_PRINT_DEBUG; Options.VertFile = NULL; Options.FragFile = NULL; Options.OutputFile = NULL; Options.Params = GL_FALSE; + Options.Pragmas.IgnoreOptimize = GL_FALSE; + Options.Pragmas.IgnoreDebug = GL_FALSE; + Options.Pragmas.Debug = GL_FALSE; + Options.Pragmas.Optimize = GL_TRUE; if (argc == 1) { Usage(); @@ -299,7 +310,20 @@ ParseOptions(int argc, char *argv[]) Options.Mode = PROG_PRINT_NV; } else if (strcmp(argv[i], "--debug") == 0) { - Options.Mode = PROG_PRINT_DEBUG; + Options.Pragmas.IgnoreDebug = GL_TRUE; + Options.Pragmas.Debug = GL_TRUE; + } + else if (strcmp(argv[i], "--nodebug") == 0) { + Options.Pragmas.IgnoreDebug = GL_TRUE; + Options.Pragmas.Debug = GL_FALSE; + } + else if (strcmp(argv[i], "--opt") == 0) { + Options.Pragmas.IgnoreOptimize = GL_TRUE; + Options.Pragmas.Optimize = GL_TRUE; + } + else if (strcmp(argv[i], "--noopt") == 0) { + Options.Pragmas.IgnoreOptimize = GL_TRUE; + Options.Pragmas.Optimize = GL_FALSE; } else if (strcmp(argv[i], "--number") == 0 || strcmp(argv[i], "-n") == 0) { @@ -323,6 +347,11 @@ ParseOptions(int argc, char *argv[]) exit(1); } } + + if (Options.Mode == PROG_PRINT_DEBUG) { + /* always print line numbers when emitting debug-style output */ + Options.LineNumbers = GL_TRUE; + } } @@ -331,13 +360,13 @@ main(int argc, char *argv[]) { GLuint shader = 0; + ParseOptions(argc, argv); + if (!CreateContext()) { fprintf(stderr, "%s: Failed to create compiler context\n", Prog); exit(1); } - ParseOptions(argc, argv); - if (Options.VertFile) { shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); } |