nv50/ir: fix ConstantFolding with saturation
For mul(a, +-1) codegen can generate OP_MOV with a saturation flag set which is ignored at emission. The same can happen with add(a, 0), and others. Adding an assert for detecting more of such issues. Fixes wrongly rendered water in Hitman Absolution running under wine. Also a few shaders in Mad Max and Alien Isolation produce such MOVs. CC: <mesa-stable@lists.freedesktop.org> Signed-off-by: Karol Herbst <karolherbst@gmail.com> Reviewed-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de> [imirkin: generalize the fix for other cases] Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:

committed by
Ilia Mirkin

parent
cc43c4a9e5
commit
24a799ad35
@@ -2006,6 +2006,7 @@ CodeEmitterNVC0::getSRegEncoding(const ValueRef& ref)
|
||||
void
|
||||
CodeEmitterNVC0::emitMOV(const Instruction *i)
|
||||
{
|
||||
assert(!i->saturate);
|
||||
if (i->def(0).getFile() == FILE_PREDICATE) {
|
||||
if (i->src(0).getFile() == FILE_GPR) {
|
||||
code[0] = 0xfc01c003;
|
||||
|
@@ -1509,6 +1509,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// This can get left behind some of the optimizations which simplify
|
||||
// saturatable values.
|
||||
if (newi->op == OP_MOV && newi->saturate) {
|
||||
newi->saturate = 0;
|
||||
newi->op = OP_SAT;
|
||||
}
|
||||
|
||||
if (newi->op != op)
|
||||
foldCount++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user