diff options
author | Eric Anholt <[email protected]> | 2013-06-19 16:00:23 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2013-06-21 10:04:29 -0700 |
commit | 10c14d16d28c5e868b042e575aaaa922604e5e7e (patch) | |
tree | 30b7b6e33265978ee547442d17b856e7634fb047 /src/mesa/main/shaderapi.c | |
parent | 88398a817c7402c8fa56823eaac4c755e5c2fdaf (diff) |
mesa: Move shader compiler API code to shaderapi.c
There was nothing ir_to_mesa-specific about this code, but it's not
exactly part of the compiler's core turning-source-into-IR job either.
v2: Split from the ir_to_mesa to glsl/ commit, avoid renaming the sh
variable.
Acked-by: Paul Berry <[email protected]> (v1)
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 88518caa53b..d214204a60a 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -48,10 +48,12 @@ #include "main/transformfeedback.h" #include "main/uniforms.h" #include "program/program.h" +#include "program/prog_print.h" #include "program/prog_parameter.h" #include "ralloc.h" #include <stdbool.h> #include "../glsl/glsl_parser_extras.h" +#include "../glsl/ir.h" #include "../glsl/ir_uniform.h" /** Define this to enable shader substitution (see below) */ @@ -743,10 +745,42 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) /* set default pragma state for shader */ sh->Pragmas = options->DefaultPragmas; - /* this call will set the sh->CompileStatus field to indicate if - * compilation was successful. - */ - _mesa_glsl_compile_shader(ctx, sh); + if (!sh->Source) { + /* If the user called glCompileShader without first calling + * glShaderSource, we should fail to compile, but not raise a GL_ERROR. + */ + sh->CompileStatus = GL_FALSE; + } else { + if (ctx->Shader.Flags & GLSL_DUMP) { + printf("GLSL source for %s shader %d:\n", + _mesa_glsl_shader_target_name(sh->Type), sh->Name); + printf("%s\n", sh->Source); + } + + /* this call will set the shader->CompileStatus field to indicate if + * compilation was successful. + */ + _mesa_glsl_compile_shader(ctx, sh); + + if (ctx->Shader.Flags & GLSL_LOG) { + _mesa_write_shader_to_file(sh); + } + + if (ctx->Shader.Flags & GLSL_DUMP) { + if (sh->CompileStatus) { + printf("GLSL IR for shader %d:\n", sh->Name); + _mesa_print_ir(sh->ir, NULL); + printf("\n\n"); + } else { + printf("GLSL shader %d failed to compile.\n", sh->Name); + } + if (sh->InfoLog && sh->InfoLog[0] != 0) { + printf("GLSL shader %d info log:\n", sh->Name); + printf("%s\n", sh->InfoLog); + } + } + + } if (sh->CompileStatus == GL_FALSE && (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) { |