diff options
author | Marek Olšák <[email protected]> | 2016-05-30 17:43:26 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-06-06 22:50:55 +0200 |
commit | 589d6b58c3355f3ff8e5bef4b3f5e94b479cc96b (patch) | |
tree | 9e0a5878b71f82f51f459829bc46855a9f2eeae9 /src | |
parent | 991cbfcb1459f3adce13d70c383f9c4c6fd4ee96 (diff) |
st/mesa: change SQRT lowering to fix the game Risen
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94627
(against nouveau)
Acked-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 91a0a26de82..06eb6f159b0 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1901,13 +1901,15 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) if (have_sqrt) { emit_scalar(ir, TGSI_OPCODE_SQRT, result_dst, op[0]); } else { - /* sqrt(x) = x * rsq(x). */ - emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, op[0]); - emit_asm(ir, TGSI_OPCODE_MUL, result_dst, result_src, op[0]); - /* For incoming channels <= 0, set the result to 0. */ - op[0].negate = ~op[0].negate; - emit_asm(ir, TGSI_OPCODE_CMP, result_dst, - op[0], result_src, st_src_reg_for_float(0.0)); + /* This is the only instruction sequence that makes the game "Risen" + * render correctly. ABS is not required for the game, but since GLSL + * declares negative values as "undefined", allowing us to do whatever + * we want, I choose to use ABS to match DX9 and pre-GLSL RSQ + * behavior. + */ + emit_scalar(ir, TGSI_OPCODE_ABS, result_dst, op[0]); + emit_scalar(ir, TGSI_OPCODE_RSQ, result_dst, result_src); + emit_scalar(ir, TGSI_OPCODE_RCP, result_dst, result_src); } break; case ir_unop_rsq: |