[Mesa-dev] [PATCH 15/22] i965/vs: generalize gen6_vs_push_constants in preparation for GS.

Paul Berry stereotype441 at gmail.com
Mon Aug 26 15:12:46 PDT 2013


---
 src/mesa/drivers/dri/i965/brw_context.h   |  7 +++++
 src/mesa/drivers/dri/i965/gen6_vs_state.c | 45 ++++++++++++++++++++-----------
 2 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 622b5c8..28943e2 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1628,6 +1628,13 @@ brw_setup_vec4_key_clip_info(struct brw_context *brw,
                              struct brw_vec4_prog_key *key,
                              bool program_uses_clip_distance);
 
+void
+gen6_upload_vec4_push_constants(struct brw_context *brw,
+                                const struct gl_program *prog,
+                                const struct brw_vec4_prog_data *prog_data,
+                                struct brw_vec4_context_base *vec4_ctx,
+                                enum state_struct_type type);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
index 9f99db8..f59b353 100644
--- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
@@ -33,32 +33,30 @@
 #include "program/prog_statevars.h"
 #include "intel_batchbuffer.h"
 
-static void
-gen6_upload_vs_push_constants(struct brw_context *brw)
+void
+gen6_upload_vec4_push_constants(struct brw_context *brw,
+                                const struct gl_program *prog,
+                                const struct brw_vec4_prog_data *prog_data,
+                                struct brw_vec4_context_base *vec4_ctx,
+                                enum state_struct_type type)
 {
    struct gl_context *ctx = &brw->ctx;
-   struct brw_vec4_context_base *vec4_ctx = &brw->vs.base;
-
-   /* _BRW_NEW_VERTEX_PROGRAM */
-   const struct brw_vertex_program *vp =
-      brw_vertex_program_const(brw->vertex_program);
 
    /* Updates the ParamaterValues[i] pointers for all parameters of the
     * basic type of PROGRAM_STATE_VAR.
     */
    /* XXX: Should this happen somewhere before to get our state flag set? */
-   _mesa_load_state_parameters(ctx, vp->program.Base.Parameters);
+   _mesa_load_state_parameters(ctx, prog->Parameters);
 
-   /* CACHE_NEW_VS_PROG */
-   if (brw->vs.prog_data->base.nr_params == 0) {
+   if (prog_data->nr_params == 0) {
       vec4_ctx->push_const_size = 0;
    } else {
       int params_uploaded;
       float *param;
       int i;
 
-      param = brw_state_batch(brw, AUB_TRACE_VS_CONSTANTS,
-			      brw->vs.prog_data->base.nr_params * sizeof(float),
+      param = brw_state_batch(brw, type,
+			      prog_data->nr_params * sizeof(float),
 			      32, &vec4_ctx->push_const_offset);
 
       /* _NEW_PROGRAM_CONSTANTS
@@ -67,13 +65,13 @@ gen6_upload_vs_push_constants(struct brw_context *brw)
        * side effect of dereferencing uniforms, so _NEW_PROGRAM_CONSTANTS
        * wouldn't be set for them.
       */
-      for (i = 0; i < brw->vs.prog_data->base.nr_params; i++) {
-         param[i] = *brw->vs.prog_data->base.param[i];
+      for (i = 0; i < prog_data->nr_params; i++) {
+         param[i] = *prog_data->param[i];
       }
-      params_uploaded = brw->vs.prog_data->base.nr_params / 4;
+      params_uploaded = prog_data->nr_params / 4;
 
       if (0) {
-	 printf("VS constant buffer:\n");
+	 printf("Constant buffer:\n");
 	 for (i = 0; i < params_uploaded; i++) {
 	    float *buf = param + i * 4;
 	    printf("%d: %f %f %f %f\n",
@@ -87,6 +85,21 @@ gen6_upload_vs_push_constants(struct brw_context *brw)
    }
 }
 
+static void
+gen6_upload_vs_push_constants(struct brw_context *brw)
+{
+   struct brw_vec4_context_base *vec4_ctx = &brw->vs.base;
+
+   /* _BRW_NEW_VERTEX_PROGRAM */
+   const struct brw_vertex_program *vp =
+      brw_vertex_program_const(brw->vertex_program);
+   /* CACHE_NEW_VS_PROG */
+   const struct brw_vec4_prog_data *prog_data = &brw->vs.prog_data->base;
+
+   gen6_upload_vec4_push_constants(brw, &vp->program.Base, prog_data,
+                                   vec4_ctx, AUB_TRACE_VS_CONSTANTS);
+}
+
 const struct brw_tracked_state gen6_vs_push_constants = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS,
-- 
1.8.4



More information about the mesa-dev mailing list