i965: Fix alpha-to-coverage and alpha test enabled checks
authorAnuj Phogat <anuj.phogat@gmail.com>
Thu, 20 Oct 2016 18:40:40 +0000 (11:40 -0700)
committerAnuj Phogat <anuj.phogat@gmail.com>
Tue, 8 Nov 2016 00:13:02 +0000 (16:13 -0800)
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/gen6_wm_state.c
src/mesa/drivers/dri/i965/gen7_wm_state.c
src/mesa/drivers/dri/i965/gen8_depth_state.c

index f433ed6..f434af9 100644 (file)
@@ -528,7 +528,8 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
 
    /* _NEW_MULTISAMPLE, _NEW_COLOR, _NEW_BUFFERS */
    key->replicate_alpha = ctx->DrawBuffer->_NumColorDrawBuffers > 1 &&
-      (ctx->Multisample.SampleAlphaToCoverage || ctx->Color.AlphaEnabled);
+      (_mesa_is_alpha_test_enabled(ctx) ||
+       _mesa_is_alpha_to_coverage_enabled(ctx));
 
    /* _NEW_BUFFERS _NEW_MULTISAMPLE */
    /* Ignore sample qualifier while computing this flag. */
@@ -547,7 +548,6 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
       key->input_slots_valid = brw->vue_map_geom_out.slots_valid;
    }
 
-
    /* _NEW_COLOR | _NEW_BUFFERS */
    /* Pre-gen6, the hardware alpha test always used each render
     * target's alpha to do alpha test, as opposed to render target 0's alpha
index a618ea9..a67e626 100644 (file)
@@ -251,9 +251,10 @@ upload_wm_state(struct brw_context *brw)
                                       (ctx->Color.BlendEnabled & 1) &&
                                       ctx->Color.Blend[0]._UsesDualSrc;
 
-   /* _NEW_COLOR, _NEW_MULTISAMPLE */
-   const bool kill_enable = prog_data->uses_kill || ctx->Color.AlphaEnabled ||
-                            ctx->Multisample.SampleAlphaToCoverage ||
+   /* _NEW_COLOR, _NEW_MULTISAMPLE _NEW_BUFFERS */
+   const bool kill_enable = prog_data->uses_kill ||
+                            _mesa_is_alpha_test_enabled(ctx) ||
+                            _mesa_is_alpha_to_coverage_enabled(ctx) ||
                             prog_data->uses_omask;
 
    /* Rendering against the gl-context is always taken into account. */
index 110c02c..be026e0 100644 (file)
@@ -69,11 +69,12 @@ upload_wm_state(struct brw_context *brw)
    dw1 |= prog_data->barycentric_interp_modes <<
       GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT;
 
-   /* _NEW_COLOR, _NEW_MULTISAMPLE */
+   /* _NEW_COLOR, _NEW_MULTISAMPLE _NEW_BUFFERS */
    /* Enable if the pixel shader kernel generates and outputs oMask.
     */
-   if (prog_data->uses_kill || ctx->Color.AlphaEnabled ||
-       ctx->Multisample.SampleAlphaToCoverage ||
+   if (prog_data->uses_kill ||
+       _mesa_is_alpha_test_enabled(ctx) ||
+       _mesa_is_alpha_to_coverage_enabled(ctx) ||
        prog_data->uses_omask) {
       dw1 |= GEN7_WM_KILL_ENABLE;
    }
index 73b2186..0543bf1 100644 (file)
@@ -293,10 +293,12 @@ pma_fix_enable(const struct brw_context *brw)
    const bool ps_computes_depth =
       wm_prog_data->computed_depth_mode != BRW_PSCDEPTH_OFF;
 
-   /* BRW_NEW_FS_PROG_DATA:        3DSTATE_PS_EXTRA::PixelShaderKillsPixels
-    * BRW_NEW_FS_PROG_DATA:        3DSTATE_PS_EXTRA::oMask Present to RenderTarget
+   /* BRW_NEW_FS_PROG_DATA:     3DSTATE_PS_EXTRA::PixelShaderKillsPixels
+    * BRW_NEW_FS_PROG_DATA:     3DSTATE_PS_EXTRA::oMask Present to RenderTarget
     * _NEW_MULTISAMPLE:         3DSTATE_PS_BLEND::AlphaToCoverageEnable
     * _NEW_COLOR:               3DSTATE_PS_BLEND::AlphaTestEnable
+    * _NEW_BUFFERS:             3DSTATE_PS_BLEND::AlphaTestEnable
+    *                           3DSTATE_PS_BLEND::AlphaToCoverageEnable
     *
     * 3DSTATE_WM_CHROMAKEY::ChromaKeyKillEnable is always false.
     * 3DSTATE_WM::ForceKillPix != ForceOff is always true.
@@ -304,8 +306,8 @@ pma_fix_enable(const struct brw_context *brw)
    const bool kill_pixel =
       wm_prog_data->uses_kill ||
       wm_prog_data->uses_omask ||
-      (_mesa_is_multisample_enabled(ctx) && ctx->Multisample.SampleAlphaToCoverage) ||
-      ctx->Color.AlphaEnabled;
+      _mesa_is_alpha_test_enabled(ctx) ||
+      _mesa_is_alpha_to_coverage_enabled(ctx);
 
    /* The big formula in CACHE_MODE_1::NP PMA FIX ENABLE. */
    return !wm_force_thread_dispatch &&