i965/blorp: Use prog data counters to guide sf/sbe setup
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Sun, 15 May 2016 08:34:37 +0000 (11:34 +0300)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Thu, 23 Jun 2016 18:39:09 +0000 (21:39 +0300)
just as core upload logic does.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_blorp.c
src/mesa/drivers/dri/i965/brw_blorp.h
src/mesa/drivers/dri/i965/gen6_blorp.c
src/mesa/drivers/dri/i965/gen7_blorp.c
src/mesa/drivers/dri/i965/gen8_blorp.c

index 9590968eef263535c1452cc182ba5f7d87d0820e..ce37838d8cb47152f3c2c321e8da3208d7ecd7e6 100644 (file)
@@ -142,7 +142,6 @@ brw_blorp_params_init(struct brw_blorp_params *params)
    memset(params, 0, sizeof(*params));
    params->hiz_op = GEN6_HIZ_OP_NONE;
    params->fast_clear_op = 0;
-   params->num_varyings = 0;
    params->num_draw_buffers = 1;
    params->num_layers = 1;
 }
@@ -232,6 +231,8 @@ brw_blorp_compile_nir_shader(struct brw_context *brw, struct nir_shader *nir,
    prog_data->first_curbe_grf_2 = wm_prog_data.dispatch_grf_start_reg_2;
    prog_data->ksp_offset_2 = wm_prog_data.prog_offset_2;
    prog_data->persample_msaa_dispatch = wm_prog_data.persample_dispatch;
+   prog_data->flat_inputs = wm_prog_data.flat_inputs;
+   prog_data->num_varying_inputs = wm_prog_data.num_varying_inputs;
 
    prog_data->nr_params = wm_prog_data.base.nr_params;
    for (unsigned i = 0; i < ARRAY_SIZE(param); i++)
index 7ec587520d8cf96850b3cd753ec5c85939cd87ef..b895e393b37400613174f0611efaa19f23e77884 100644 (file)
@@ -223,6 +223,13 @@ struct brw_blorp_prog_data
     */
    bool persample_msaa_dispatch;
 
+   /**
+    * Mask of which FS inputs are marked flat by the shader source.  This is
+    * needed for setting up 3DSTATE_SF/SBE.
+    */
+   uint32_t flat_inputs;
+   unsigned num_varying_inputs;
+
    /* The compiler will re-arrange push constants and store the upload order
     * here. Given an index 'i' in the final upload buffer, param[i] gives the
     * index in the uniform store. In other words, the value to be uploaded can
@@ -249,7 +256,6 @@ struct brw_blorp_params
    };
    bool color_write_disable[4];
    struct brw_blorp_wm_push_constants wm_push_consts;
-   unsigned num_varyings;
    unsigned num_draw_buffers;
    unsigned num_layers;
    uint32_t wm_prog_kernel;
index 5f84ab09e10d9ddbbab3d09c2b67bde0ff093bf6..317a5f2dd21b1aa6844af82c071b512f6f908f34 100644 (file)
@@ -597,16 +597,22 @@ static void
 gen6_blorp_emit_sf_config(struct brw_context *brw,
                           const struct brw_blorp_params *params)
 {
+   const unsigned num_varyings =
+      params->wm_prog_data ? params->wm_prog_data->num_varying_inputs : 0;
+
    BEGIN_BATCH(20);
    OUT_BATCH(_3DSTATE_SF << 16 | (20 - 2));
-   OUT_BATCH(params->num_varyings << GEN6_SF_NUM_OUTPUTS_SHIFT |
+   OUT_BATCH(num_varyings << GEN6_SF_NUM_OUTPUTS_SHIFT |
              1 << GEN6_SF_URB_ENTRY_READ_LENGTH_SHIFT |
              BRW_SF_URB_ENTRY_READ_OFFSET <<
                 GEN6_SF_URB_ENTRY_READ_OFFSET_SHIFT);
    OUT_BATCH(0); /* dw2 */
    OUT_BATCH(params->dst.num_samples > 1 ? GEN6_SF_MSRAST_ON_PATTERN : 0);
-   for (int i = 0; i < 16; ++i)
+   for (int i = 0; i < 13; ++i)
       OUT_BATCH(0);
+   OUT_BATCH(params->wm_prog_data ? params->wm_prog_data->flat_inputs : 0);
+   OUT_BATCH(0);
+   OUT_BATCH(0);
    ADVANCE_BATCH();
 }
 
index 235f0b504e17a7eaf9e5d724436c32ded8877329..92617dbcae39b568596f6b09b000ac7f45a16f55 100644 (file)
@@ -443,15 +443,21 @@ gen7_blorp_emit_sf_config(struct brw_context *brw,
 
    /* 3DSTATE_SBE */
    {
+      const unsigned num_varyings =
+         params->wm_prog_data ? params->wm_prog_data->num_varying_inputs : 0;
+
       BEGIN_BATCH(14);
       OUT_BATCH(_3DSTATE_SBE << 16 | (14 - 2));
       OUT_BATCH(GEN7_SBE_SWIZZLE_ENABLE |
-                params->num_varyings << GEN7_SBE_NUM_OUTPUTS_SHIFT |
+                num_varyings << GEN7_SBE_NUM_OUTPUTS_SHIFT |
                 1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT |
                 BRW_SF_URB_ENTRY_READ_OFFSET <<
                    GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT);
-      for (int i = 0; i < 12; ++i)
+      for (int i = 0; i < 9; ++i)
          OUT_BATCH(0);
+      OUT_BATCH(params->wm_prog_data ? params->wm_prog_data->flat_inputs : 0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
       ADVANCE_BATCH();
    }
 }
index fcf5a5390737c0e4b301c2e97eef574d239d06a0..8d696cf75ca17a419e56d5ff0255126e31131975 100644 (file)
@@ -294,22 +294,31 @@ static void
 gen8_blorp_emit_sbe_state(struct brw_context *brw,
                           const struct brw_blorp_params *params)
 {
+   const unsigned num_varyings = params->wm_prog_data->num_varying_inputs;
+
    /* 3DSTATE_SBE */
    {
       const unsigned sbe_cmd_length = brw->gen == 8 ? 4 : 6;
       BEGIN_BATCH(sbe_cmd_length);
       OUT_BATCH(_3DSTATE_SBE << 16 | (sbe_cmd_length - 2));
       OUT_BATCH(GEN7_SBE_SWIZZLE_ENABLE |
-                params->num_varyings << GEN7_SBE_NUM_OUTPUTS_SHIFT |
+                num_varyings << GEN7_SBE_NUM_OUTPUTS_SHIFT |
                 1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT |
                 BRW_SF_URB_ENTRY_READ_OFFSET <<
                    GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT |
                 GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH |
                 GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET);
       OUT_BATCH(0);
-      OUT_BATCH(0);
+      OUT_BATCH(params->wm_prog_data->flat_inputs);
       if (sbe_cmd_length >= 6) {
-         OUT_BATCH(GEN9_SBE_ACTIVE_COMPONENT_XYZW << (0 << 1));
+         /* Fragment coordinates are always enabled. */
+         uint32_t dw4 = (GEN9_SBE_ACTIVE_COMPONENT_XYZW << (0 << 1));
+
+         for (unsigned i = 0; i < num_varyings; ++i) {
+            dw4 |= (GEN9_SBE_ACTIVE_COMPONENT_XYZW << ((i + 1) << 1));
+         }
+
+         OUT_BATCH(dw4);
          OUT_BATCH(0);
       }
       ADVANCE_BATCH();