i965: Add tessellation shader push constant support.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 1 Oct 2015 00:04:23 +0000 (17:04 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 11 Dec 2015 21:11:15 +0000 (13:11 -0800)
Based on a patch by Chris Forbes.

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_state.h
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/gen7_ds_state.c
src/mesa/drivers/dri/i965/gen7_hs_state.c
src/mesa/drivers/dri/i965/gen8_ds_state.c
src/mesa/drivers/dri/i965/gen8_hs_state.c

index fd3d3746579bad4e3ace6263836764c52dd9a4cc..1cc4c7b1282423cc506fe223dd2e90df7f4826a1 100644 (file)
@@ -1236,7 +1236,7 @@ struct brw_context
    } perfmon;
 
    int num_atoms[BRW_NUM_PIPELINES];
-   const struct brw_tracked_state render_atoms[74];
+   const struct brw_tracked_state render_atoms[76];
    const struct brw_tracked_state compute_atoms[10];
 
    /* If (INTEL_DEBUG & DEBUG_BATCH) */
index 986406bab199c260aaee6a85e71f81723c710cfd..d29b997b963c29110e8e20302b0b3568d3eef757 100644 (file)
@@ -143,6 +143,7 @@ extern const struct brw_tracked_state gen7_depthbuffer;
 extern const struct brw_tracked_state gen7_clip_state;
 extern const struct brw_tracked_state gen7_ds_state;
 extern const struct brw_tracked_state gen7_gs_state;
+extern const struct brw_tracked_state gen7_tcs_push_constants;
 extern const struct brw_tracked_state gen7_hs_state;
 extern const struct brw_tracked_state gen7_l3_state;
 extern const struct brw_tracked_state gen7_ps_state;
@@ -152,6 +153,7 @@ extern const struct brw_tracked_state gen7_sf_clip_viewport;
 extern const struct brw_tracked_state gen7_sf_state;
 extern const struct brw_tracked_state gen7_sol_state;
 extern const struct brw_tracked_state gen7_te_state;
+extern const struct brw_tracked_state gen7_tes_push_constants;
 extern const struct brw_tracked_state gen7_urb;
 extern const struct brw_tracked_state gen7_vs_state;
 extern const struct brw_tracked_state gen7_wm_state;
index a31e3f4eead436bed945f2c8e07d5e94f408e135..cf3cf97daea9484387f622cbbff4a87d80d71e87 100644 (file)
@@ -294,6 +294,8 @@ static const struct brw_tracked_state *gen8_render_atoms[] =
    &brw_wm_image_surfaces, /* Before wm push/pull constants and binding table */
 
    &gen6_vs_push_constants, /* Before vs_state */
+   &gen7_tcs_push_constants,
+   &gen7_tes_push_constants,
    &gen6_gs_push_constants, /* Before gs_state */
    &gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */
 
index 79993b6d9f0344d9e098d1c7aa584d5cd2f41014..4d3d94f68a68f2ba5802b9be33f73d3a5ac9ac06 100644 (file)
 #include "brw_defines.h"
 #include "intel_batchbuffer.h"
 
+static void
+gen7_upload_tes_push_constants(struct brw_context *brw)
+{
+   struct brw_stage_state *stage_state = &brw->tes.base;
+   /* BRW_NEW_TESS_EVAL_PROGRAM */
+   const struct brw_tess_eval_program *tep =
+      (struct brw_tess_eval_program *) brw->tess_eval_program;
+
+   if (tep) {
+      /* BRW_NEW_TES_PROG_DATA */
+      const struct brw_stage_prog_data *prog_data = &brw->tes.prog_data->base.base;
+      gen6_upload_push_constants(brw, &tep->program.Base, prog_data,
+                                      stage_state, AUB_TRACE_VS_CONSTANTS);
+   }
+
+   gen7_upload_constant_state(brw, stage_state, tep, _3DSTATE_CONSTANT_DS);
+}
+
+const struct brw_tracked_state gen7_tes_push_constants = {
+   .dirty = {
+      .mesa  = _NEW_PROGRAM_CONSTANTS,
+      .brw   = BRW_NEW_BATCH |
+               BRW_NEW_PUSH_CONSTANT_ALLOCATION |
+               BRW_NEW_TESS_EVAL_PROGRAM |
+               BRW_NEW_TES_PROG_DATA,
+   },
+   .emit = gen7_upload_tes_push_constants,
+};
+
 static void
 gen7_upload_ds_state(struct brw_context *brw)
 {
index ae55f340f52ab8eaaf5765efd4b2f3d5bcb57641..fcaa919785758cbebfe52079c7b48db7d4660295 100644 (file)
 #include "brw_defines.h"
 #include "intel_batchbuffer.h"
 
+static void
+gen7_upload_tcs_push_constants(struct brw_context *brw)
+{
+   struct brw_stage_state *stage_state = &brw->tcs.base;
+   /* BRW_NEW_TESS_CTRL_PROGRAM */
+   const struct brw_tess_ctrl_program *tcp =
+      (struct brw_tess_ctrl_program *) brw->tess_ctrl_program;
+
+   if (tcp) {
+      /* BRW_NEW_TCS_PROG_DATA */
+      const struct brw_stage_prog_data *prog_data = &brw->tcs.prog_data->base.base;
+      gen6_upload_push_constants(brw, &tcp->program.Base, prog_data,
+                                      stage_state, AUB_TRACE_VS_CONSTANTS);
+   }
+
+   gen7_upload_constant_state(brw, stage_state, tcp, _3DSTATE_CONSTANT_HS);
+}
+
+const struct brw_tracked_state gen7_tcs_push_constants = {
+   .dirty = {
+      .mesa  = _NEW_PROGRAM_CONSTANTS,
+      .brw   = BRW_NEW_BATCH |
+               BRW_NEW_PUSH_CONSTANT_ALLOCATION |
+               BRW_NEW_TESS_CTRL_PROGRAM |
+               BRW_NEW_TCS_PROG_DATA,
+   },
+   .emit = gen7_upload_tcs_push_constants,
+};
+
 static void
 gen7_upload_hs_state(struct brw_context *brw)
 {
index 3dcf3d394aa0c784463eb6f69541ebebea2b9731..4ce4ab30e11b3665533f22163999c43f3e67892f 100644 (file)
@@ -30,20 +30,6 @@ static void
 gen8_upload_ds_state(struct brw_context *brw)
 {
    /* Disable the DS Unit */
-   BEGIN_BATCH(11);
-   OUT_BATCH(_3DSTATE_CONSTANT_DS << 16 | (11 - 2));
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   ADVANCE_BATCH();
-
    int ds_pkt_len = brw->gen >= 9 ? 11 : 9;
    BEGIN_BATCH(ds_pkt_len);
    OUT_BATCH(_3DSTATE_DS << 16 | (ds_pkt_len - 2));
index c7e4c5004a9cf930e4480630739e48801866da34..62e714d522c58f71080b3cc34ed6158040e97d39 100644 (file)
@@ -30,20 +30,6 @@ static void
 gen8_upload_hs_state(struct brw_context *brw)
 {
    /* Disable the HS Unit */
-   BEGIN_BATCH(11);
-   OUT_BATCH(_3DSTATE_CONSTANT_HS << 16 | (11 - 2));
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   OUT_BATCH(0);
-   ADVANCE_BATCH();
-
    BEGIN_BATCH(9);
    OUT_BATCH(_3DSTATE_HS << 16 | (9 - 2));
    OUT_BATCH(0);