i965: support instanced GS on gen7
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 25 Jan 2014 21:02:08 +0000 (13:02 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 20 Feb 2014 18:33:09 +0000 (10:33 -0800)
v3:
 * Properly prevent dual object mode execution when
   the invocation count > 1

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_vec4_gs.c
src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
src/mesa/drivers/dri/i965/gen7_gs_state.c

index bdbbc3d733d0eb4d6e75133d00463b8c28708bdc..854583e4ba0d07bc3be3ccfc598032ea2431f179 100644 (file)
@@ -642,6 +642,8 @@ struct brw_gs_prog_data
 
    bool include_primitive_id;
 
+   int invocations;
+
    /**
     * True if the thread should be dispatched in DUAL_INSTANCE mode, false if
     * it should be dispatched in DUAL_OBJECT mode.
index 1b573448c062bec741d6b983d0d2171782f0faa1..01d3cb614146f2fac491c958f5f88331cfe57af1 100644 (file)
@@ -1518,6 +1518,7 @@ enum brw_message_target {
 # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_CUT         0
 # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_SID         1
 # define GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT                20
+# define GEN7_GS_INSTANCE_CONTROL_SHIFT                        15
 # define GEN7_GS_DISPATCH_MODE_SINGLE                  (0 << 11)
 # define GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE           (1 << 11)
 # define GEN7_GS_DISPATCH_MODE_DUAL_OBJECT             (2 << 11)
index 73a873354092deb7ce736a310fd2644c1c810916..85fb97999c7bdca7d826a1519f9bf7d49ef94a2b 100644 (file)
@@ -48,6 +48,8 @@ do_gs_prog(struct brw_context *brw,
    c.prog_data.include_primitive_id =
       (gp->program.Base.InputsRead & VARYING_BIT_PRIMITIVE_ID) != 0;
 
+   c.prog_data.invocations = gp->program.Invocations;
+
    /* Allocate the references to the uniforms that will end up in the
     * prog_data associated with the compiled program, and which will be freed
     * by the state cache.
index 1d00796be36ec3eb6b930091c635c89dd88d9c5a..0a2d8ff3af294e45e0ac1f5bf2e7e41184f9c79d 100644 (file)
@@ -595,9 +595,11 @@ brw_gs_emit(struct brw_context *brw,
    }
 
    /* Compile the geometry shader in DUAL_OBJECT dispatch mode, if we can do
-    * so without spilling.
+    * so without spilling. If the GS invocations count > 1, then we can't use
+    * dual object mode.
     */
-   if (likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
+   if (c->prog_data.invocations <= 1 &&
+       likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
       c->prog_data.dual_instanced_dispatch = false;
 
       vec4_gs_visitor v(brw, c, prog, shader, mem_ctx, true /* no_spills */);
index d2ba354e2c488caaa67aa6bd41838300264b2621..b179d1954b16a0c52a54bdca397563b1a782bc37 100644 (file)
@@ -153,6 +153,8 @@ upload_gs_state(struct brw_context *brw)
          ((brw->max_gs_threads - 1) << max_threads_shift) |
          (brw->gs.prog_data->control_data_header_size_hwords <<
           GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT) |
+         ((brw->gs.prog_data->invocations - 1) <<
+          GEN7_GS_INSTANCE_CONTROL_SHIFT) |
          (brw->gs.prog_data->dual_instanced_dispatch ?
           GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE :
           GEN7_GS_DISPATCH_MODE_DUAL_OBJECT) |