i965/vs: generalize gen6_vs_push_constants in preparation for GS.
authorPaul Berry <stereotype441@gmail.com>
Wed, 27 Mar 2013 20:15:45 +0000 (13:15 -0700)
committerPaul Berry <stereotype441@gmail.com>
Sun, 1 Sep 2013 00:12:43 +0000 (17:12 -0700)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_vs_state.c

index f4a8647a0c13441fcf8bdd3ad64839e5eb9e84e5..7aafe6e45792ee552d19558fe02b6d4e306dfb58 100644 (file)
@@ -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_stage_state *stage_state,
+                                enum state_struct_type type);
+
 #ifdef __cplusplus
 }
 #endif
index 98c7aec1ec65a7a3ec36a66a293fc5704385f704..569ec8cdc891ef9084c6b34c6eb283ae805af53c 100644 (file)
 #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_stage_state *stage_state,
+                                enum state_struct_type type)
 {
    struct gl_context *ctx = &brw->ctx;
-   struct brw_stage_state *stage_state = &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) {
       stage_state->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, &stage_state->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_stage_state *stage_state = &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,
+                                   stage_state, AUB_TRACE_VS_CONSTANTS);
+}
+
 const struct brw_tracked_state gen6_vs_push_constants = {
    .dirty = {
       .mesa  = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS,