From db629c0f4b0b1e09e1cf29e9eb5ca14c8cf9436c Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 12 Mar 2020 09:06:16 +0100 Subject: [PATCH] v3dv: fix viewport Z Vulkan has Z NDC range in [0, 1], we where using OpenGL's [-1, 1]. Fixes: dEQP-VK.draw.inverted_depth_ranges.nodepthclamp_deltasmall dEQP-VK.draw.inverted_depth_ranges.nodepthclamp_deltaone Part-of: --- src/broadcom/vulkan/v3dv_cmd_buffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 68d468d..511dceb 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -1899,8 +1899,9 @@ emit_viewport(struct v3dv_cmd_buffer *cmd_buffer) clip.viewport_z_scale_zc_to_zs = vpscale[2]; } cl_emit(&job->bcl, CLIPPER_Z_MIN_MAX_CLIPPING_PLANES, clip) { - float z1 = (vptranslate[2] - vpscale[2]); - float z2 = (vptranslate[2] + vpscale[2]); + /* Vulkan's Z NDC is [0..1], unlile OpenGL which is [-1, 1] */ + float z1 = vptranslate[2]; + float z2 = vptranslate[2] + vpscale[2]; clip.minimum_zw = MIN2(z1, z2); clip.maximum_zw = MAX2(z1, z2); } -- 2.7.4