etnaviv: disable earlyZ when shader writes fragment depth
authorJonathan Marek <jonathan@marek.ca>
Tue, 17 Sep 2019 11:49:46 +0000 (07:49 -0400)
committerJonathan Marek <jonathan@marek.ca>
Sat, 28 Sep 2019 04:34:43 +0000 (00:34 -0400)
Fixes the following piglit test: fragdepth_gles2

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_emit.c
src/gallium/drivers/etnaviv/etnaviv_internal.h
src/gallium/drivers/etnaviv/etnaviv_shader.c

index a9ed1f615e9568b1de311d3def2624901eb6f057..338ea9ebca02f01fbe64f62393298df215cfba97 100644 (file)
@@ -451,9 +451,10 @@ etna_emit_state(struct etna_context *ctx)
                               : ctx->shader_state.PS_TEMP_REGISTER_CONTROL);
       /*01010*/ EMIT_STATE(PS_CONTROL, ctx->shader_state.PS_CONTROL);
    }
-   if (unlikely(dirty & (ETNA_DIRTY_ZSA | ETNA_DIRTY_FRAMEBUFFER))) {
-      uint32_t val = etna_zsa_state(ctx->zsa)->PE_DEPTH_CONFIG;
-      /*01400*/ EMIT_STATE(PE_DEPTH_CONFIG, val | ctx->framebuffer.PE_DEPTH_CONFIG);
+   if (unlikely(dirty & (ETNA_DIRTY_ZSA | ETNA_DIRTY_FRAMEBUFFER | ETNA_DIRTY_SHADER))) {
+      /*01400*/ EMIT_STATE(PE_DEPTH_CONFIG, (etna_zsa_state(ctx->zsa)->PE_DEPTH_CONFIG |
+                                             ctx->framebuffer.PE_DEPTH_CONFIG) &
+                                            ctx->shader_state.PE_DEPTH_CONFIG);
    }
    if (unlikely(dirty & (ETNA_DIRTY_VIEWPORT))) {
       /*01404*/ EMIT_STATE(PE_DEPTH_NEAR, ctx->viewport.PE_DEPTH_NEAR);
index 82315e03b586ac6cd8b6978c1a9271cef3b8ba1e..e5a5b590efa0db2899d99a15d962eeb640b9f4cb 100644 (file)
@@ -257,6 +257,7 @@ struct compiled_shader_state {
    uint32_t PS_TEMP_REGISTER_CONTROL_MSAA; /* Adds a temporary if needed to make space for extra input */
    uint32_t PS_CONTROL;
    uint32_t PS_START_PC;
+   uint32_t PE_DEPTH_CONFIG;
    uint32_t GL_VARYING_TOTAL_COMPONENTS;
    uint32_t GL_VARYING_NUM_COMPONENTS;
    uint32_t GL_VARYING_COMPONENT_USE[2];
index a5310ddde291135eb08ebfd4d90d4b951947f345..98d4c2874a7fada2bf4faeecd2f8355edb70ea7d 100644 (file)
@@ -199,6 +199,9 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
       VIVS_GL_HALTI5_SH_SPECIALS_PS_PCOORD_IN((link.pcoord_varying_comp_ofs != -1) ?
                                               link.pcoord_varying_comp_ofs : 0x7f);
 
+   /* mask out early Z bit when frag depth is written */
+   cs->PE_DEPTH_CONFIG = ~COND(fs->ps_depth_out_reg >= 0, VIVS_PE_DEPTH_CONFIG_EARLY_Z);
+
    /* reference instruction memory */
    cs->vs_inst_mem_size = vs->code_size;
    cs->VS_INST_MEM = vs->code;