i965: Add a helper for populating constant buffers
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 28 Sep 2017 22:05:51 +0000 (15:05 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 13 Oct 2017 05:39:29 +0000 (22:39 -0700)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/gen6_constant_state.c

index 07e3c42b152ab4462431fa755a2f38e12ce12fb9..9a9c6d08a0f5774010aa75fac4f73a5a1bd0356c 100644 (file)
@@ -227,9 +227,9 @@ brw_upload_constant_buffer(struct brw_context *brw)
       GLuint offset = brw->curbe.wm_start * 16;
 
       /* BRW_NEW_FS_PROG_DATA | _NEW_PROGRAM_CONSTANTS: copy uniform values */
-      for (i = 0; i < brw->wm.base.prog_data->nr_params; i++) {
-        buf[offset + i] = *brw->wm.base.prog_data->param[i];
-      }
+      brw_populate_constant_data(brw, fp, brw->wm.base.prog_data, &buf[offset],
+                                 brw->wm.base.prog_data->param,
+                                 brw->wm.base.prog_data->nr_params);
    }
 
    /* clipper constants */
@@ -268,9 +268,9 @@ brw_upload_constant_buffer(struct brw_context *brw)
       GLuint offset = brw->curbe.vs_start * 16;
 
       /* BRW_NEW_VS_PROG_DATA | _NEW_PROGRAM_CONSTANTS: copy uniform values */
-      for (i = 0; i < brw->vs.base.prog_data->nr_params; i++) {
-         buf[offset + i] = *brw->vs.base.prog_data->param[i];
-      }
+      brw_populate_constant_data(brw, vp, brw->vs.base.prog_data, &buf[offset],
+                                 brw->vs.base.prog_data->param,
+                                 brw->vs.base.prog_data->nr_params);
    }
 
    if (0) {
index ab91d96df8aada313a97c9c943a5b3bd6475713e..97d03515599ab5f65db3b8a3ec3ae6ecfb492862 100644 (file)
@@ -235,6 +235,13 @@ void brw_emit_sampler_state(struct brw_context *brw,
 
 /* gen6_constant_state.c */
 void
+brw_populate_constant_data(struct brw_context *brw,
+                           const struct gl_program *prog,
+                           const struct brw_stage_prog_data *prog_data,
+                           void *dst,
+                           const union gl_constant_value **param,
+                           unsigned nr_params);
+void
 brw_upload_pull_constants(struct brw_context *brw,
                           GLbitfield64 brw_new_constbuf,
                           const struct gl_program *prog,
index 9bb79cf849fcc373b17c28ebb82f554cc3377757..a902c6849afc33d02cbaf979d449adee5fb1407f 100644 (file)
 #include "intel_buffer_objects.h"
 #include "program/prog_parameter.h"
 
+void
+brw_populate_constant_data(struct brw_context *brw,
+                           const struct gl_program *prog,
+                           const struct brw_stage_prog_data *prog_data,
+                           void *void_dst,
+                           const union gl_constant_value **param,
+                           unsigned nr_params)
+{
+   gl_constant_value *dst = void_dst;
+   for (unsigned i = 0; i < nr_params; i++)
+      dst[i] = *param[i];
+}
+
+
 /**
  * Creates a streamed BO containing the push constants for the VS or GS on
  * gen6+.
@@ -82,9 +96,9 @@ gen6_upload_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 < prog_data->nr_params; i++) {
-         param[i] = *prog_data->param[i];
-      }
+      brw_populate_constant_data(brw, prog, prog_data, param,
+                                 prog_data->param,
+                                 prog_data->nr_params);
 
       if (0) {
          fprintf(stderr, "%s constants:\n",
@@ -169,9 +183,9 @@ brw_upload_pull_constants(struct brw_context *brw,
 
    STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
 
-   for (i = 0; i < prog_data->nr_pull_params; i++) {
-      constants[i] = *prog_data->pull_param[i];
-   }
+   brw_populate_constant_data(brw, prog, prog_data, constants,
+                              prog_data->pull_param,
+                              prog_data->nr_pull_params);
 
    if (0) {
       for (i = 0; i < ALIGN(prog_data->nr_pull_params, 4) / 4; i++) {