i965: Reduce code duplication in handling of depth, stencil, and HiZ.
authorPaul Berry <stereotype441@gmail.com>
Tue, 26 Mar 2013 20:24:43 +0000 (13:24 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 2 Apr 2013 22:19:13 +0000 (15:19 -0700)
commit41e4bccc754bf3942255630ddd03601b95096c03
treeaa0ff537e332a02d95dcf9b314d0327027a8e925
parent2ad0ed63497f27b77be49cb04a6dc9df21fe75f2
i965: Reduce code duplication in handling of depth, stencil, and HiZ.

This patch consolidates duplicate code in the brw_depthbuffer and
gen7_depthbuffer state atoms.  Previously, these state atoms contained
5 chunks of code for emitting the _3DSTATE_DEPTH_BUFFER packet (3 for
Gen4-6 and 2 for Gen7).  Also a lot of logic for determining the
appropriate buffer setup was duplicated between the Gen4-6 and Gen7
functions.

This refactor splits the code into three separate functions:
brw_emit_depthbuffer(), which determines the appropriate buffer setup
in a mostly generation-independent way, brw_emit_depth_stencil_hiz(),
which emits the appropriate state packets for Gen4-6, and
gen7_emit_depth_stencil_hiz(), which emits the appropriate state
packets for Gen7.

Tested using Piglit on Gen5-7 (no regressions).

v2: Re-word some comments.  Fix an assertion that incorrectly
prohibited packed depth/stencil formats on Gen6 (these are allowed
provided that HiZ is disabled).

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_vtbl.c
src/mesa/drivers/dri/i965/gen7_misc_state.c
src/mesa/drivers/dri/intel/intel_context.h