i965: Implement "Static Vertex Count" geometry shader optimization.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 25 Sep 2015 01:21:59 +0000 (18:21 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 26 Sep 2015 19:01:58 +0000 (12:01 -0700)
commitf0a618ee7c26a3dd54292fbc2bfd914b0d680ed9
tree4ab41436c615886e74efccd2b10c329b29c2bb14
parentbcef2abad7cf255b6ac112b9ebf0ff75e491c968
i965: Implement "Static Vertex Count" geometry shader optimization.

Broadwell's 3DSTATE_GS contains new "Static Output" and "Static Vertex
Count" fields, which control a new optimization.  Normally, geometry
shaders can output arbitrary numbers of vertices, which means that
resource allocation has to be done on the fly.  However, if the number
of vertices is statically known, the hardware can pre-allocate resources
up front, which is more efficient.

Thanks to the new NIR GS intrinsics, this is easy.  We just call the
function introduced in the previous commit to get the vertex count.
If it obtains a count, we stop emitting the extra 32-bit "Vertex Count"
field in the VUE, and instead fill out the 3DSTATE_GS fields.

Improves performance of Gl32GSCloth by 5.16347% +/- 0.12611% (n=91)
on my Lenovo X250 laptop (Broadwell GT2) at 1024x768.

shader-db statistics for geometry shaders only:

total instructions in shared programs: 3227 -> 3207 (-0.62%)
instructions in affected programs:     242 -> 222 (-8.26%)
helped:                                10

v2: Don't break non-NIR paths (just skip this optimization).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
src/mesa/drivers/dri/i965/gen8_gs_state.c