diff options
author | Kenneth Graunke <[email protected]> | 2014-11-30 01:14:17 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-12-04 15:04:35 -0800 |
commit | 8daf3c53c7df806f7302446acb8a58d391f69779 (patch) | |
tree | 753ff5de419c6ab93481f467686b4d433ec294de /src/mesa/drivers/dri/i965/gen7_wm_state.c | |
parent | 4265148ac62366033cfa6ae37e6a8f8c3e1fa864 (diff) |
i965: Move PSCDEPTH calculations from draw time to compile time.
The "Pixel Shader Computed Depth Mode" value is entirely based on the
shader program, so we can easily do it at compile time. This avoids the
if+switch on every 3DSTATE_WM (Gen7)/3DSTATE_PS_EXTRA (Gen8+) upload,
and shares a bit more code.
This also simplifies the PMA stall code, making it match the formula
more closely, and drops a BRW_NEW_FRAGMENT_PROGRAM dependency. (Note
that the previous comment was wrong - the code and the documentation
have != PSCDEPTH_OFF, not ==.)
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/gen7_wm_state.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_wm_state.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c index 575eaf56de9..5a5c726e2bc 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c @@ -41,7 +41,7 @@ upload_wm_state(struct brw_context *brw) brw_fragment_program_const(brw->fragment_program); /* BRW_NEW_FS_PROG_DATA */ const struct brw_wm_prog_data *prog_data = brw->wm.prog_data; - bool writes_depth = false; + bool writes_depth = prog_data->computed_depth_mode != BRW_PSCDEPTH_OFF; uint32_t dw1, dw2; /* _NEW_BUFFERS */ @@ -62,24 +62,8 @@ upload_wm_state(struct brw_context *brw) if (fp->program.Base.InputsRead & VARYING_BIT_POS) dw1 |= GEN7_WM_USES_SOURCE_DEPTH | GEN7_WM_USES_SOURCE_W; - if (fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { - writes_depth = fp->program.FragDepthLayout != FRAG_DEPTH_LAYOUT_UNCHANGED; - - switch (fp->program.FragDepthLayout) { - case FRAG_DEPTH_LAYOUT_NONE: - case FRAG_DEPTH_LAYOUT_ANY: - dw1 |= GEN7_WM_PSCDEPTH_ON; - break; - case FRAG_DEPTH_LAYOUT_GREATER: - dw1 |= GEN7_WM_PSCDEPTH_ON_GE; - break; - case FRAG_DEPTH_LAYOUT_LESS: - dw1 |= GEN7_WM_PSCDEPTH_ON_LE; - break; - case FRAG_DEPTH_LAYOUT_UNCHANGED: - break; - } - } + + dw1 |= prog_data->computed_depth_mode << GEN7_WM_COMPUTED_DEPTH_MODE_SHIFT; dw1 |= prog_data->barycentric_interp_modes << GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT; |