nv50/ir: saturate depth writes
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 20 Mar 2016 17:11:01 +0000 (13:11 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 28 Mar 2016 12:35:38 +0000 (08:35 -0400)
Apparently there's no post-FS clamping logic, so we have to do this by
hand. The depth will never be outside of the 0..1 range, even on
floating point zeta buffers, so this should be safe.

Fixes dEQP-GLES3.functional.fbo.depth.*clamp.* which tests writing
invalid values on various zeta buffer formats.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp

index 611d5f9c3edce28d50203989dc330c478e8bb77e..4f012cd3b91ed989ba9f7131bd86c4d9f4ed44b1 100644 (file)
@@ -3536,8 +3536,11 @@ Converter::exportOutputs()
          Symbol *sym = mkSymbol(FILE_SHADER_OUTPUT, 0, TYPE_F32,
                                 info->out[i].slot[c] * 4);
          Value *val = oData.load(sub.cur->values, i, c, NULL);
-         if (val)
+         if (val) {
+            if (info->out[i].sn == TGSI_SEMANTIC_POSITION)
+               mkOp1(OP_SAT, TYPE_F32, val, val);
             mkStore(OP_EXPORT, TYPE_F32, sym, NULL, val);
+         }
       }
    }
 }