[Mesa-dev] [PATCH] i965/fs: Fix saturate on MAD and LRP with the NIR backend.

Kenneth Graunke kenneth at whitecape.org
Tue Feb 3 01:18:49 PST 2015


Fixes misrendering in "Witcher 2" with INTEL_USE_NIR=1, and probably
many other programs.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

This depends on Jason's 3 patch series that removes emit_percomp.
It's available in the 'nir-madfix' branch of my tree.

This was caught by tests/spec/arb_fragment_program/lrp_sat.shader_test
with my in-progress Mesa IR -> NIR converter code, so I don't think we
need to write more Piglit tests.  We just don't have a GLSL based one.

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index fbb1622..153a1be 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1070,12 +1070,14 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
       break;
 
    case nir_op_ffma:
-      emit(MAD(result, op[2], op[1], op[0]));
+      inst = emit(MAD(result, op[2], op[1], op[0]));
+      inst->saturate = instr->dest.saturate;
       break;
 
    case nir_op_flrp:
       /* TODO emulate for gen < 6 */
-      emit(LRP(result, op[2], op[1], op[0]));
+      inst = emit(LRP(result, op[2], op[1], op[0]));
+      inst->saturate = instr->dest.saturate;
       break;
 
    case nir_op_bcsel:
-- 
2.2.2



More information about the mesa-dev mailing list