summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-09-28 15:05:51 -0700
committerJason Ekstrand <[email protected]>2017-10-12 22:39:29 -0700
commit9b3f917f9ed177e6de6fc7231dc9a0ab75301dac (patch)
treef2e80e5f14b503720520a4492cd3c60adca26e79
parentd6406271595f9a3cb765cf2be76ff5c2bf0cf8d7 (diff)
i965: Add a helper for populating constant buffers
Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_curbe.c12
-rw-r--r--src/mesa/drivers/dri/i965/brw_state.h7
-rw-r--r--src/mesa/drivers/dri/i965/gen6_constant_state.c26
3 files changed, 33 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c
index 07e3c42b152..9a9c6d08a0f 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -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) {
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index ab91d96df8a..97d03515599 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -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,
diff --git a/src/mesa/drivers/dri/i965/gen6_constant_state.c b/src/mesa/drivers/dri/i965/gen6_constant_state.c
index 9bb79cf849f..a902c6849af 100644
--- a/src/mesa/drivers/dri/i965/gen6_constant_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_constant_state.c
@@ -28,6 +28,20 @@
#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++) {