Mesa (master): i965/gen7: Extract a function for setting up a shader stage' s constants.

Paul Berry stereotype441 at kemper.freedesktop.org
Wed Sep 11 19:06:20 UTC 2013


Module: Mesa
Branch: master
Commit: ec5c92429044db5aa797c377fe29984538f09785
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec5c92429044db5aa797c377fe29984538f09785

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Mon Sep  9 07:28:17 2013 -0700

i965/gen7: Extract a function for setting up a shader stage's constants.

This will allow us to reuse some code when setting up the geometry
shader stage.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_state.h     |    6 +++
 src/mesa/drivers/dri/i965/gen7_vs_state.c |   61 +++++++++++++++++------------
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 22e4a61..4c4a536 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -240,6 +240,12 @@ brw_vec4_upload_binding_table(struct brw_context *brw,
                               struct brw_stage_state *stage_state,
                               const struct brw_vec4_prog_data *prog_data);
 
+/* gen7_vs_state.c */
+void
+gen7_upload_constant_state(struct brw_context *brw,
+                           const struct brw_stage_state *stage_state,
+                           bool active, unsigned opcode);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c
index 6e72e8f..4fd1913 100644
--- a/src/mesa/drivers/dri/i965/gen7_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c
@@ -29,6 +29,40 @@
 #include "program/prog_statevars.h"
 #include "intel_batchbuffer.h"
 
+
+void
+gen7_upload_constant_state(struct brw_context *brw,
+                           const struct brw_stage_state *stage_state,
+                           bool active, unsigned opcode)
+{
+   if (!active || stage_state->push_const_size == 0) {
+      /* Disable the push constant buffers. */
+      BEGIN_BATCH(7);
+      OUT_BATCH(opcode << 16 | (7 - 2));
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      ADVANCE_BATCH();
+   } else {
+      BEGIN_BATCH(7);
+      OUT_BATCH(opcode << 16 | (7 - 2));
+      OUT_BATCH(stage_state->push_const_size);
+      OUT_BATCH(0);
+      /* Pointer to the constant buffer.  Covered by the set of state flags
+       * from gen6_prepare_wm_contants
+       */
+      OUT_BATCH(stage_state->push_const_offset | GEN7_MOCS_L3);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      ADVANCE_BATCH();
+   }
+}
+
+
 static void
 upload_vs_state(struct brw_context *brw)
 {
@@ -52,31 +86,8 @@ upload_vs_state(struct brw_context *brw)
    OUT_BATCH(stage_state->sampler_offset);
    ADVANCE_BATCH();
 
-   if (stage_state->push_const_size == 0) {
-      /* Disable the push constant buffers. */
-      BEGIN_BATCH(7);
-      OUT_BATCH(_3DSTATE_CONSTANT_VS << 16 | (7 - 2));
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      ADVANCE_BATCH();
-   } else {
-      BEGIN_BATCH(7);
-      OUT_BATCH(_3DSTATE_CONSTANT_VS << 16 | (7 - 2));
-      OUT_BATCH(stage_state->push_const_size);
-      OUT_BATCH(0);
-      /* Pointer to the VS constant buffer.  Covered by the set of
-       * state flags from gen6_prepare_wm_contants
-       */
-      OUT_BATCH(stage_state->push_const_offset | GEN7_MOCS_L3);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      OUT_BATCH(0);
-      ADVANCE_BATCH();
-   }
+   gen7_upload_constant_state(brw, stage_state, true /* active */,
+                              _3DSTATE_CONSTANT_VS);
 
    /* Use ALT floating point mode for ARB vertex programs, because they
     * require 0^0 == 1.




More information about the mesa-commit mailing list