From 6d3a2c97f4a78e85545286e0e126cd3a27bd1cbd Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sun, 5 Sep 2010 18:49:54 +0200 Subject: glsl: make compiler options per-target This allows us to specify different options, especially useful for chips without unified shaders. Signed-off-by: Ian Romanick --- src/mesa/main/shaderapi.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/mesa/main/shaderapi.c') diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index cc350c93b9..2977a29ab7 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -94,18 +94,24 @@ _mesa_init_shader_state(GLcontext *ctx) /* Device drivers may override these to control what kind of instructions * are generated by the GLSL compiler. */ - ctx->Shader.EmitHighLevelInstructions = GL_TRUE; - ctx->Shader.EmitContReturn = GL_TRUE; - ctx->Shader.EmitCondCodes = GL_FALSE; - ctx->Shader.EmitComments = GL_FALSE; - ctx->Shader.EmitNoIfs = GL_FALSE; - ctx->Shader.Flags = get_shader_flags(); + struct gl_shader_compiler_options options; + GLuint i; + options.EmitHighLevelInstructions = GL_TRUE; + options.EmitContReturn = GL_TRUE; + options.EmitCondCodes = GL_FALSE; + options.EmitComments = GL_FALSE; + options.EmitNoIfs = GL_FALSE; /* Default pragma settings */ - ctx->Shader.DefaultPragmas.IgnoreOptimize = GL_FALSE; - ctx->Shader.DefaultPragmas.IgnoreDebug = GL_FALSE; - ctx->Shader.DefaultPragmas.Optimize = GL_TRUE; - ctx->Shader.DefaultPragmas.Debug = GL_FALSE; + options.DefaultPragmas.IgnoreOptimize = GL_FALSE; + options.DefaultPragmas.IgnoreDebug = GL_FALSE; + options.DefaultPragmas.Optimize = GL_TRUE; + options.DefaultPragmas.Debug = GL_FALSE; + + for(i = 0; i < MESA_SHADER_TYPES; ++i) + memcpy(&ctx->ShaderCompilerOptions[i], &options, sizeof(options)); + + ctx->Shader.Flags = get_shader_flags(); } @@ -789,13 +795,16 @@ static void compile_shader(GLcontext *ctx, GLuint shaderObj) { struct gl_shader *sh; + struct gl_shader_compiler_options *options; sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); if (!sh) return; + options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)]; + /* set default pragma state for shader */ - sh->Pragmas = ctx->Shader.DefaultPragmas; + sh->Pragmas = options->DefaultPragmas; /* this call will set the sh->CompileStatus field to indicate if * compilation was successful. -- cgit v1.2.3