X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fff_fragment_shader.cpp;h=48b84e8fd7324211b178428d418b75521c2f2030;hb=4807a83da0e0f5e3272e85504ee3b2213ef1910a;hp=83881e9ccf1307398f905b4ec36c73f14c3f5561;hpb=fd2b3da5c8cdbc5b00436185a3c03dfb7b7bd853;p=mesa.git diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 83881e9ccf1..48b84e8fd73 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -103,7 +103,6 @@ struct state_key { GLuint nr_enabled_units:8; GLuint enabled_units:8; GLuint separate_specular:1; - GLuint fog_enabled:1; GLuint fog_mode:2; /**< FOG_x */ GLuint inputs_available:12; GLuint num_draw_buffers:4; @@ -127,10 +126,10 @@ struct state_key { } unit[MAX_TEXTURE_UNITS]; }; -#define FOG_LINEAR 0 -#define FOG_EXP 1 -#define FOG_EXP2 2 -#define FOG_UNKNOWN 3 +#define FOG_NONE 0 +#define FOG_LINEAR 1 +#define FOG_EXP 2 +#define FOG_EXP2 3 static GLuint translate_fog_mode( GLenum mode ) { @@ -138,7 +137,7 @@ static GLuint translate_fog_mode( GLenum mode ) case GL_LINEAR: return FOG_LINEAR; case GL_EXP: return FOG_EXP; case GL_EXP2: return FOG_EXP2; - default: return FOG_UNKNOWN; + default: return FOG_NONE; } } @@ -302,7 +301,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) /* _NEW_PROGRAM */ const GLboolean vertexShader = (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] && - ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus && + ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->data->LinkStatus && ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]); const GLboolean vertexProgram = ctx->VertexProgram._Enabled; GLbitfield fp_inputs = 0x0; @@ -369,9 +368,9 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx ) if (vertexShader) vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program; else - vprog = &ctx->VertexProgram.Current->Base; + vprog = ctx->VertexProgram.Current; - vp_outputs = vprog->OutputsWritten; + vp_outputs = vprog->info.outputs_written; /* These get generated in the setup routine regardless of the * vertex program: @@ -463,7 +462,6 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) /* _NEW_FOG */ if (ctx->Fog.Enabled) { - key->fog_enabled = 1; key->fog_mode = translate_fog_mode(ctx->Fog.Mode); inputs_referenced |= VARYING_BIT_FOGC; /* maybe */ } @@ -992,7 +990,7 @@ static void load_texture( texenv_fragment_program *p, GLuint unit ) if (p->state->unit[unit].shadow) { texcoord = texcoord->clone(p->mem_ctx, NULL); - tex->shadow_comparitor = new(p->mem_ctx) ir_swizzle(texcoord, + tex->shadow_comparator = new(p->mem_ctx) ir_swizzle(texcoord, coords, 0, 0, 0, 1); coords++; @@ -1182,7 +1180,7 @@ emit_instructions(texenv_fragment_program *p) cf = new(p->mem_ctx) ir_dereference_variable(spec_result); } - if (key->fog_enabled) { + if (key->fog_mode) { cf = emit_fog_instructions(p, cf); } @@ -1204,6 +1202,9 @@ create_new_program(struct gl_context *ctx, struct state_key *key) p.mem_ctx = ralloc_context(NULL); p.shader = _mesa_new_shader(0, MESA_SHADER_FRAGMENT); +#ifdef DEBUG + p.shader->SourceChecksum = 0xf18ed; /* fixed */ +#endif p.shader->ir = new(p.shader) exec_list; state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT, p.shader); @@ -1253,14 +1254,17 @@ create_new_program(struct gl_context *ctx, struct state_key *key) const struct gl_shader_compiler_options *options = &ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; - while (do_common_optimization(p.shader->ir, false, false, options, - ctx->Const.NativeIntegers)) - ; + /* Conservative approach: Don't optimize here, the linker does it too. */ + if (!ctx->Const.GLSLOptimizeConservatively) { + while (do_common_optimization(p.shader->ir, false, false, options, + ctx->Const.NativeIntegers)) + ; + } + reparent_ir(p.shader->ir, p.shader->ir); p.shader->CompileStatus = true; p.shader->Version = state->language_version; - p.shader->uses_builtin_functions = state->uses_builtin_functions; p.shader_program->Shaders = (gl_shader **)malloc(sizeof(*p.shader_program->Shaders)); p.shader_program->Shaders[0] = p.shader; @@ -1268,9 +1272,9 @@ create_new_program(struct gl_context *ctx, struct state_key *key) _mesa_glsl_link_shader(ctx, p.shader_program); - if (!p.shader_program->LinkStatus) + if (!p.shader_program->data->LinkStatus) _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n", - p.shader_program->InfoLog); + p.shader_program->data->InfoLog); ralloc_free(p.mem_ctx); return p.shader_program;