to reduce the amount of GLSL optimizations for drivers that can do better.
Reviewed-by: Eric Anholt <eric@anholt.net>
assign_subroutine_indexes(shader, state);
lower_subroutine(shader->ir, state);
+
/* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times
*/
- while (do_common_optimization(shader->ir, false, false, options,
- ctx->Const.NativeIntegers))
- ;
+ if (ctx->Const.GLSLOptimizeConservatively) {
+ /* Run it just once. */
+ do_common_optimization(shader->ir, false, false, options,
+ ctx->Const.NativeIntegers);
+ } else {
+ /* Repeat it until it stops making changes. */
+ while (do_common_optimization(shader->ir, false, false, options,
+ ctx->Const.NativeIntegers))
+ ;
+ }
validate_ir_tree(shader->ir);
lower_tess_level(prog->_LinkedShaders[i]);
}
- while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
- &ctx->Const.ShaderCompilerOptions[i],
- ctx->Const.NativeIntegers))
- ;
+ if (ctx->Const.GLSLOptimizeConservatively) {
+ /* Run it just once. */
+ do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
+ &ctx->Const.ShaderCompilerOptions[i],
+ ctx->Const.NativeIntegers);
+ } else {
+ /* Repeat it until it stops making changes. */
+ while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
+ &ctx->Const.ShaderCompilerOptions[i],
+ ctx->Const.NativeIntegers))
+ ;
+ }
lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i);
propagate_invariance(prog->_LinkedShaders[i]->ir);
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;
bool GLSLFragCoordIsSysVal;
bool GLSLFrontFacingIsSysVal;
+ /**
+ * Run the minimum amount of GLSL optimizations to be able to link
+ * shaders optimally (eliminate dead varyings and uniforms) and just do
+ * all the necessary lowering.
+ */
+ bool GLSLOptimizeConservatively;
+
/**
* Always use the GetTransformFeedbackVertexCount() driver hook, rather
* than passing the transform feedback object to the drawing function.