From 3182209673fcf157efa7872036e67fae2a5e84ba Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 10 Sep 2020 10:36:27 +0200 Subject: [PATCH] v3d/compiler: fix V3D double-rounding of .8 fixed-point XY coordinates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-V3D 4.3 hardware has a quirk where it expects XY coordinates in .8 fixed-point format, but then it will internally round it to .6 fixed-point, introducing a double rounding. The double rounding can cause very slight differences in triangle raterization coverage that can actually be noticed by some CTS tests. The correct fix for this as recommended by Broadcom is to convert to .8 fixed-point with ffloor(). Fixes: dEQP-VK.renderpass.suballocation.subpass_dependencies.late_fragment_tests.* Reviewed-by: Alejandro PiƱeiro Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/broadcom/compiler/v3d_nir_lower_io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/broadcom/compiler/v3d_nir_lower_io.c b/src/broadcom/compiler/v3d_nir_lower_io.c index 4761b58722e..188194e3936 100644 --- a/src/broadcom/compiler/v3d_nir_lower_io.c +++ b/src/broadcom/compiler/v3d_nir_lower_io.c @@ -524,7 +524,18 @@ v3d_nir_emit_ff_vpm_outputs(struct v3d_compile *c, nir_builder *b, scale = nir_load_viewport_y_scale(b); pos = nir_fmul(b, pos, scale); pos = nir_fmul(b, pos, rcp_wc); - pos = nir_f2i32(b, nir_fround_even(b, pos)); + /* Pre-V3D 4.3 hardware has a quirk where it expects XY + * coordinates in .8 fixed-point format, but then it + * will internally round it to .6 fixed-point, + * introducing a double rounding. The double rounding + * can cause very slight differences in triangle + * raterization coverage that can actually be noticed by + * some CTS tests. + * + * The correct fix for this as recommended by Broadcom + * is to convert to .8 fixed-point with ffloor(). + */ + pos = nir_f2i32(b, nir_ffloor(b, pos)); v3d_nir_store_output(b, state->vp_vpm_offset + i, offset_reg, pos); }