nak: Saturate depth writes

Otherwise, they get may clipped away.  This seems wrong in light of
unrestricted depth but it fixes a bunch of CTS tests for now so let's go
with it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand
2023-09-14 20:56:33 -05:00
committed by Marge Bot
parent 6abbef04b0
commit 2c91587ac5
+13 -1
View File
@@ -1654,7 +1654,19 @@ impl<'a> ShaderFromNir<'a> {
srcs.push(Src::new_zero());
}
if info.writes_depth {
srcs.push(self.fs_out_regs[depth_idx].into());
// Saturate depth writes.
//
// TODO: This seems wrong in light of unrestricted depth but
// it's needed to pass CTS tests for now.
let depth = self.fs_out_regs[depth_idx];
let sat_depth = b.alloc_ssa(RegFile::GPR, 1);
b.push_op(OpFAdd {
dst: sat_depth.into(),
srcs: [depth.into(), Src::new_zero()],
saturate: true,
rnd_mode: FRndMode::NearestEven,
});
srcs.push(sat_depth.into());
}
}