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 <stereotype441@gmail.com> (v1) Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -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)) {
|
||||
|
@@ -3108,23 +3108,10 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
|
||||
new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
|
||||
|
||||
const char *source = shader->Source;
|
||||
/* Check if the user called glCompileShader without first calling
|
||||
* glShaderSource. This should fail to compile, but not raise a GL_ERROR.
|
||||
*/
|
||||
if (source == NULL) {
|
||||
shader->CompileStatus = GL_FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
state->error = glcpp_preprocess(state, &source, &state->info_log,
|
||||
&ctx->Extensions, ctx);
|
||||
|
||||
if (ctx->Shader.Flags & GLSL_DUMP) {
|
||||
printf("GLSL source for %s shader %d:\n",
|
||||
_mesa_glsl_shader_target_name(state->target), shader->Name);
|
||||
printf("%s\n", shader->Source);
|
||||
}
|
||||
|
||||
if (!state->error) {
|
||||
_mesa_glsl_lexer_ctor(state, source);
|
||||
_mesa_glsl_parse(state);
|
||||
@@ -3160,24 +3147,6 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
|
||||
sizeof(shader->builtins_to_link[0]) * state->num_builtins_to_link);
|
||||
shader->num_builtins_to_link = state->num_builtins_to_link;
|
||||
|
||||
if (ctx->Shader.Flags & GLSL_LOG) {
|
||||
_mesa_write_shader_to_file(shader);
|
||||
}
|
||||
|
||||
if (ctx->Shader.Flags & GLSL_DUMP) {
|
||||
if (shader->CompileStatus) {
|
||||
printf("GLSL IR for shader %d:\n", shader->Name);
|
||||
_mesa_print_ir(shader->ir, NULL);
|
||||
printf("\n\n");
|
||||
} else {
|
||||
printf("GLSL shader %d failed to compile.\n", shader->Name);
|
||||
}
|
||||
if (shader->InfoLog && shader->InfoLog[0] != 0) {
|
||||
printf("GLSL shader %d info log:\n", shader->Name);
|
||||
printf("%s\n", shader->InfoLog);
|
||||
}
|
||||
}
|
||||
|
||||
if (shader->UniformBlocks)
|
||||
ralloc_free(shader->UniformBlocks);
|
||||
shader->NumUniformBlocks = state->num_uniform_blocks;
|
||||
|
Reference in New Issue
Block a user