mesa: add gl_constants::GLSLOptimizeConservatively

to reduce the amount of GLSL optimizations for drivers that can do better.

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Marek Olšák
2016-12-31 13:42:09 +01:00
parent e51baeb6c1
commit 0a5018c1a4
4 changed files with 37 additions and 10 deletions

View File

@@ -1949,12 +1949,20 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
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);

View File

@@ -5048,10 +5048,18 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
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);