From 0fafa4ea425cbf2e416f45cbed6ebf256a7634c6 Mon Sep 17 00:00:00 2001 From: Abdie Janulgue Date: Mon, 8 Sep 2014 15:59:35 +0300 Subject: [PATCH] ir_to_mesa: Don't optimize clamp into saturate when target is GL_VERTEX_PROGRAM_ARB Add the the same restriction as in the previous try_emit_sat when trying to optimize clamp. Fixes an infinite loop in swrast where the lowering pass unpacks saturate into clamp but the opt_algebraic pass tries to do the opposite. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83463 Signed-off-by: Abdiel Janulgue --- src/glsl/opt_algebraic.cpp | 3 ++- src/mesa/main/mtypes.h | 1 + src/mesa/program/ir_to_mesa.cpp | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp index 447618f..0a82835 100644 --- a/src/glsl/opt_algebraic.cpp +++ b/src/glsl/opt_algebraic.cpp @@ -658,7 +658,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) case ir_binop_min: case ir_binop_max: - if (ir->type->base_type != GLSL_TYPE_FLOAT) + if (ir->type->base_type != GLSL_TYPE_FLOAT || + options->EmitNoSat) break; /* Replace min(max) operations and its commutative combinations with diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 4fb30ff..3e951e2 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2899,6 +2899,7 @@ struct gl_shader_compiler_options GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ GLboolean EmitNoPow; /**< Emit POW opcodes? */ + GLboolean EmitNoSat; GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */ /** diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 49e4a7a..91587ec 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2940,7 +2940,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) bool progress; exec_list *ir = prog->_LinkedShaders[i]->ir; - const struct gl_shader_compiler_options *options = + struct gl_shader_compiler_options *options = &ctx->Const.ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage]; do { @@ -2954,6 +2954,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) | ((options->EmitNoPow) ? POW_TO_EXP2 : 0) | ((target == GL_VERTEX_PROGRAM_ARB) ? SAT_TO_CLAMP : 0))); + options->EmitNoSat = (target == GL_VERTEX_PROGRAM_ARB); progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; -- 1.9.1