--- src/mesa/drivers/dri/i965/brw_context.h | 20 +++++++++-- src/mesa/drivers/dri/i965/gen6_vs_state.c | 56 +++++++++++++++++++------------ src/mesa/drivers/dri/i965/gen7_vs_state.c | 6 ++-- 3 files changed, 56 insertions(+), 26 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 301552f..b4e1e45 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -835,6 +835,16 @@ struct brw_query_object { /** + * Info that is common to the configuration of VS and GS push constants. + */ +struct brw_push_const_info +{ + uint32_t offset; /* Offset in the batchbuffer */ + int size; /* in 256-bit register increments */ +}; + + +/** * brw_context is derived from gl_context. */ struct brw_context @@ -1146,8 +1156,7 @@ struct brw_context uint32_t prog_offset; uint32_t state_offset; - uint32_t push_const_offset; /* Offset in the batchbuffer */ - int push_const_size; /* in 256-bit register increments */ + struct brw_push_const_info push_const; /** @{ register allocator */ @@ -1631,6 +1640,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_push_const_info *const_info, + 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 d511fe9..cb6ed71 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -33,31 +33,31 @@ #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_push_const_info *const_info, + enum state_struct_type type) { struct gl_context *ctx = &brw->ctx; - /* _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) { - brw->vs.push_const_size = 0; + if (prog_data->nr_params == 0) { + const_info->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), - 32, &brw->vs.push_const_offset); + param = brw_state_batch(brw, type, + prog_data->nr_params * sizeof(float), + 32, &const_info->offset); /* _NEW_PROGRAM_CONSTANTS * @@ -65,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", @@ -79,12 +79,26 @@ gen6_upload_vs_push_constants(struct brw_context *brw) } } - brw->vs.push_const_size = (params_uploaded + 1) / 2; + const_info->size = (params_uploaded + 1) / 2; /* We can only push 32 registers of constants at a time. */ - assert(brw->vs.push_const_size <= 32); + assert(const_info->size <= 32); } } +static void +gen6_upload_vs_push_constants(struct brw_context *brw) +{ + /* _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; + struct brw_push_const_info *const_info = &brw->vs.push_const; + + gen6_upload_vec4_push_constants(brw, &vp->program.Base, prog_data, + const_info, AUB_TRACE_VS_CONSTANTS); +} + const struct brw_tracked_state gen6_vs_push_constants = { .dirty = { .mesa = _NEW_TRANSFORM | _NEW_PROGRAM_CONSTANTS, @@ -114,7 +128,7 @@ upload_vs_state(struct brw_context *brw) */ intel_emit_post_sync_nonzero_flush(brw); - if (brw->vs.push_const_size == 0) { + if (brw->vs.push_const.size == 0) { /* Disable the push constant buffers. */ BEGIN_BATCH(5); OUT_BATCH(_3DSTATE_CONSTANT_VS << 16 | (5 - 2)); @@ -131,8 +145,8 @@ upload_vs_state(struct brw_context *brw) /* Pointer to the VS constant buffer. Covered by the set of * state flags from gen6_upload_vs_constants */ - OUT_BATCH(brw->vs.push_const_offset + - brw->vs.push_const_size - 1); + OUT_BATCH(brw->vs.push_const.offset + + brw->vs.push_const.size - 1); OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(0); diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 07f0931..9dd7078 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -51,7 +51,7 @@ upload_vs_state(struct brw_context *brw) OUT_BATCH(brw->vs.sampler_offset); ADVANCE_BATCH(); - if (brw->vs.push_const_size == 0) { + if (brw->vs.push_const.size == 0) { /* Disable the push constant buffers. */ BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_CONSTANT_VS << 16 | (7 - 2)); @@ -67,12 +67,12 @@ upload_vs_state(struct brw_context *brw) BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_CONSTANT_VS << 16 | (7 - 2)); - OUT_BATCH(brw->vs.push_const_size); + OUT_BATCH(brw->vs.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(brw->vs.push_const_offset | mocs); + OUT_BATCH(brw->vs.push_const.offset | mocs); OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(0); -- 1.8.3.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev