summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbdiel Janulgue <[email protected]>2014-06-16 12:16:57 -0700
committerAbdiel Janulgue <[email protected]>2014-08-31 21:04:08 +0300
commitcfa8c1cb39846c3211e0d88612122b2f5ec45f23 (patch)
treeb7233001d351c508a99c3042f416a98e625757c4
parent8935c129372c02c56005463bb8b7182e0aeefd65 (diff)
ir_to_mesa, glsl_to_tgsi: lower ir_unop_saturate
Needed when vertex programs doesn't allow saturate Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Abdiel Janulgue <[email protected]>
-rw-r--r--src/mesa/program/ir_to_mesa.cpp5
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp6
2 files changed, 9 insertions, 2 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index e5844c3c437..ff3d0d6717e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2990,9 +2990,12 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
/* Lowering */
do_mat_op_to_vec(ir);
+ GLenum target = _mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage);
lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
| LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
- | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
+ | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)
+ | ((target == GL_VERTEX_PROGRAM_ARB) ? SAT_TO_CLAMP
+ : 0)));
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 84bdc4f0617..575da1eaf8f 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5429,6 +5429,9 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS))
lower_offset_arrays(ir);
do_mat_op_to_vec(ir);
+ /* Emit saturates in the vertex shader only if SM 3.0 is supported. */
+ bool vs_sm3 = (_mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage) ==
+ GL_VERTEX_PROGRAM_ARB) && st_context(ctx)->has_shader_model3;
lower_instructions(ir,
MOD_TO_FRACT |
DIV_TO_MUL_RCP |
@@ -5438,7 +5441,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
CARRY_TO_ARITH |
BORROW_TO_ARITH |
(options->EmitNoPow ? POW_TO_EXP2 : 0) |
- (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0));
+ (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) |
+ (vs_sm3 ? SAT_TO_CLAMP : 0));
lower_ubo_reference(prog->_LinkedShaders[i], ir);
do_vec_index_to_cond_assign(ir);