broadcom/compiler: don't enable early fragment tests if shader writes Z

We had an optimization to auto-enable early fragment tests when a shader
didn't have side effects, but of course, we cannot do that this if the
shader writes Z, as in that case the fragment tests need to use the
value written from the shader.

Also, if the shader enables early fragment tests, then any shader Z
writes should be ignored.

Fixes:
dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.*

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12736>
This commit is contained in:
Iago Toral Quiroga 2021-09-06 10:55:02 +02:00
parent 38d79d00a1
commit 3ef2ca9cbf
3 changed files with 11 additions and 14 deletions

View file

@ -3,8 +3,3 @@ dEQP-VK.geometry.input.basic_primitive.line_strip_adjacency,Fail
# CTS bug; fix submitted
dEQP-VK.spirv_assembly.instruction.graphics.variable_pointers.graphics.writes_single_buffer_geom,Fail
# Triagged
dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_greater,Fail
dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_less,Fail
dEQP-VK.spirv_assembly.instruction.graphics.early_fragment.depth_not_equal,Fail

View file

@ -1670,6 +1670,15 @@ vir_emit_tlb_color_write(struct v3d_compile *c, unsigned rt)
static void
emit_frag_end(struct v3d_compile *c)
{
/* If the shader has no non-TLB side effects and doesn't write Z
* we can promote it to enabling early_fragment_tests even
* if the user didn't.
*/
if (c->output_position_index == -1 &&
!(c->s->info.num_images || c->s->info.num_ssbos)) {
c->s->info.fs.early_fragment_tests = true;
}
if (c->output_sample_mask_index != -1) {
vir_SETMSF_dest(c, vir_nop_reg(),
vir_AND(c,
@ -1694,7 +1703,8 @@ emit_frag_end(struct v3d_compile *c)
}
struct qreg tlbu_reg = vir_magic_reg(V3D_QPU_WADDR_TLBU);
if (c->output_position_index != -1) {
if (c->output_position_index != -1 &&
!c->s->info.fs.early_fragment_tests) {
struct qinst *inst = vir_MOV_dest(c, tlbu_reg,
c->outputs[c->output_position_index]);
uint8_t tlb_specifier = TLB_TYPE_DEPTH;

View file

@ -984,14 +984,6 @@ v3d_nir_lower_fs_early(struct v3d_compile *c)
/* The lowering pass can introduce new sysval reads */
nir_shader_gather_info(c->s, nir_shader_get_entrypoint(c->s));
}
/* If the shader has no non-TLB side effects, we can promote it to
* enabling early_fragment_tests even if the user didn't.
*/
if (!(c->s->info.num_images ||
c->s->info.num_ssbos)) {
c->s->info.fs.early_fragment_tests = true;
}
}
static void