[Mesa-dev] [PATCH 3/3] i965: Make sure GS output streams 1-3 aren't rasterized on Haswell+.

Kenneth Graunke kenneth at whitecape.org
Sat Apr 4 03:46:33 PDT 2015


Presumably no one has noticed this breakage because
ARB_transform_feedback3 isn't exposed on Haswell due to the ongoing
command streamer shenanigans, and ARB_gpu_shader5 isn't exposed on
Broadwell because we keep forgetting about it.

Fixes 3 Piglit tests:
- spec/arb_gpu_shader5/emitstreamvertex_nodraw
- spec/arb_gpu_shader5/xfb-streams
- spec/arb_transform_feedback3/ext_interleaved_two_bufs_gs_max

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: mesa-stable at lists.freedesktop.org
---
 src/mesa/drivers/dri/i965/gen7_sol_state.c | 21 +++++++++++++++++++++
 src/mesa/drivers/dri/i965/gen8_sol_state.c | 20 ++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 7e9b285..50aff14 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -223,6 +223,24 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,
    uint32_t dw1 = 0, dw2 = 0;
    int i;
 
+   /* On Haswell, enable the stream out function if the geometry shader uses
+    * multiple streams, even if transform feedback is inactive.  This is
+    * required to prevent streams 1-3 from being rasterized.
+    *
+    * From the Haswell PRM, "Command Reference: Instructions", Page 797
+    * (3DSTATE_STREAMOUT DWord 1 bits 28:27 "Render Stream Select"):
+    *
+    * "[DevHSW+] SO Function Enable must also be ENABLED in order for this
+    *  field to select a stream for rendering.  When SO Function Enable is
+    *  DISABLED and Render Disable is cleared (i.e., rendering is enabled),
+    *  StreamID is ignored downstream of the SO stage, allowing any stream
+    *  to be rendered."
+    *
+    * BRW_NEW_GEOMETRY_PROGRAM
+    */
+   if (brw->is_haswell && brw->geometry_program && brw->geometry_program->UsesStreams)
+      dw1 |= SO_FUNCTION_ENABLE;
+
    if (active) {
       int urb_entry_read_offset = 0;
       int urb_entry_read_length = (vue_map->num_slots + 1) / 2 -
@@ -282,6 +300,8 @@ upload_sol_state(struct brw_context *brw)
     * the nonpipelined SOL state (3DSTATE_SO_BUFFER, 3DSTATE_SO_DECL_LIST) or
     * MMIO register updates (current performed by the kernel at each batch
     * emit).
+    *
+    * BRW_NEW_GEOMETRY_PROGRAM
     */
    upload_3dstate_streamout(brw, active, &brw->vue_map_geom_out);
 }
@@ -290,6 +310,7 @@ const struct brw_tracked_state gen7_sol_state = {
    .dirty = {
       .mesa  = _NEW_LIGHT,
       .brw   = BRW_NEW_BATCH |
+               BRW_NEW_GEOMETRY_PROGRAM |
                BRW_NEW_VUE_MAP_GEOM_OUT |
                BRW_NEW_TRANSFORM_FEEDBACK,
    },
diff --git a/src/mesa/drivers/dri/i965/gen8_sol_state.c b/src/mesa/drivers/dri/i965/gen8_sol_state.c
index d98a226..4b2f377 100644
--- a/src/mesa/drivers/dri/i965/gen8_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_sol_state.c
@@ -109,6 +109,24 @@ gen8_upload_3dstate_streamout(struct brw_context *brw, bool active,
       &xfb_obj->shader_program->LinkedTransformFeedback;
    uint32_t dw1 = 0, dw2 = 0, dw3 = 0, dw4 = 0;
 
+   /* Enable the stream out function if the geometry shader uses multiple
+    * streams, even if transform feedback is inactive.  This is required
+    * to prevent streams 1-3 from being rasterized.
+    *
+    * From the Haswell PRM, "Command Reference: Instructions", Page 797
+    * (3DSTATE_STREAMOUT DWord 1 bits 28:27 "Render Stream Select"):
+    *
+    * "[DevHSW+] SO Function Enable must also be ENABLED in order for this
+    *  field to select a stream for rendering.  When SO Function Enable is
+    *  DISABLED and Render Disable is cleared (i.e., rendering is enabled),
+    *  StreamID is ignored downstream of the SO stage, allowing any stream
+    *  to be rendered."
+    *
+    * BRW_NEW_GEOMETRY_PROGRAM
+    */
+   if (brw->geometry_program && brw->geometry_program->UsesStreams)
+      dw1 |= SO_FUNCTION_ENABLE;
+
    if (active) {
       int urb_entry_read_offset = 0;
       int urb_entry_read_length = (vue_map->num_slots + 1) / 2 -
@@ -170,6 +188,7 @@ upload_sol_state(struct brw_context *brw)
       gen7_upload_3dstate_so_decl_list(brw, &brw->vue_map_geom_out);
    }
 
+   /* BRW_NEW_GEOMETRY_PROGRAM */
    gen8_upload_3dstate_streamout(brw, active, &brw->vue_map_geom_out);
 }
 
@@ -177,6 +196,7 @@ const struct brw_tracked_state gen8_sol_state = {
    .dirty = {
       .mesa  = _NEW_LIGHT,
       .brw   = BRW_NEW_BATCH |
+               BRW_NEW_GEOMETRY_PROGRAM |
                BRW_NEW_TRANSFORM_FEEDBACK |
                BRW_NEW_VUE_MAP_GEOM_OUT,
    },
-- 
2.3.4



More information about the mesa-dev mailing list