From d7b79f3531de5cdee2bb61b54f3549252e7ae97a Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Fri, 3 Dec 2021 10:29:16 +0100 Subject: [PATCH] v3d,v3dv: don't disable EZ for passthrough Z writes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The early-Z test uses Z values produced from FEP, so when we write Z from a shader we need to disable EZ. However, there are some instances where want to write the FEP-Z from the shader, in which case we would not need to disable EZ. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/vulkan/v3dvx_cmd_buffer.c | 3 ++- src/broadcom/vulkan/v3dvx_pipeline.c | 1 + src/gallium/drivers/v3d/v3dx_draw.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/broadcom/vulkan/v3dvx_cmd_buffer.c b/src/broadcom/vulkan/v3dvx_cmd_buffer.c index 4c2b1d4bade..02c24c338be 100644 --- a/src/broadcom/vulkan/v3dvx_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dvx_cmd_buffer.c @@ -1429,7 +1429,8 @@ job_update_ez_state(struct v3dv_job *job, /* If the FS writes Z, then it may update against the chosen EZ direction */ struct v3dv_shader_variant *fs_variant = pipeline->shared_data->variants[BROADCOM_SHADER_FRAGMENT]; - if (fs_variant->prog_data.fs->writes_z) { + if (fs_variant->prog_data.fs->writes_z && + !fs_variant->prog_data.fs->writes_z_from_fep) { job->ez_state = V3D_EZ_DISABLED; return; } diff --git a/src/broadcom/vulkan/v3dvx_pipeline.c b/src/broadcom/vulkan/v3dvx_pipeline.c index 7c6fae22ad1..c17638754d2 100644 --- a/src/broadcom/vulkan/v3dvx_pipeline.c +++ b/src/broadcom/vulkan/v3dvx_pipeline.c @@ -388,6 +388,7 @@ pack_shader_state_record(struct v3dv_pipeline *pipeline) * shader needs to write the Z value (even just discards). */ shader.fragment_shader_does_z_writes = prog_data_fs->writes_z; + /* Set if the EZ test must be disabled (due to shader side * effects and the early_z flag not being present in the * shader). diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index ae8537d8347..25ef97f888e 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -605,6 +605,7 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d, */ shader.fragment_shader_does_z_writes = v3d->prog.fs->prog_data.fs->writes_z; + /* Set if the EZ test must be disabled (due to shader side * effects and the early_z flag not being present in the * shader). @@ -879,7 +880,8 @@ v3d_update_job_ez(struct v3d_context *v3d, struct v3d_job *job) * the chosen EZ direction (though we could use * ARB_conservative_depth's hints to avoid this) */ - if (v3d->prog.fs->prog_data.fs->writes_z) { + if (v3d->prog.fs->prog_data.fs->writes_z && + !v3d->prog.fs->prog_data.fs->writes_z_from_fep) { job->ez_state = V3D_EZ_DISABLED; }