diff options
author | Eric Anholt <[email protected]> | 2011-08-22 11:32:11 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-08-30 12:09:40 -0700 |
commit | 8654931d117f178fa575d3fdc5bbff9f8bf9e816 (patch) | |
tree | 9ba5be6acac7a2d774f5a4947ef2532c7dec1ab7 /src/mesa/drivers/dri | |
parent | 9fa41f0742b7486e462e088a66bef8cebdf114f5 (diff) |
i965: Make the old VS backend record pull constant references in pull_params[].
We'll be using that to track things for the new VS backend, and this will
avoid cluttering brw_vs_surface_state.c for it.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_emit.c | 14 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 19 |
3 files changed, 25 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 21068d9cf73..69821d91914 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -312,6 +312,7 @@ struct brw_vs_prog_data { GLuint total_grf; GLbitfield64 outputs_written; GLuint nr_params; /**< number of float params/constants */ + GLuint nr_pull_params; /**< number of dwords referenced by pull_param[] */ GLuint total_scratch; GLuint inputs_read; diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index bfee811e13d..63d40611d25 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -147,6 +147,8 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c ) int constant = 0; int vert_result_reoder[VERT_RESULT_MAX]; int bfc = 0; + struct brw_vertex_program *vp = c->vp; + const struct gl_program_parameter_list *params = vp->program.Base.Parameters; /* Determine whether to use a real constant buffer or use a block * of GRF registers for constants. The later is faster but only @@ -249,6 +251,18 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c ) if (constant == max_constant) c->vp->use_const_buffer = GL_TRUE; + /* Set up the references to the pull parameters if present. This backend + * uses a 1:1 mapping from Mesa IR's index to location in the pull constant + * buffer, while the new VS backend allocates values to the pull buffer on + * demand. + */ + if (c->vp->use_const_buffer) { + for (i = 0; i < params->NumParameters * 4; i++) { + c->prog_data.pull_param[i] = ¶ms->ParameterValues[i / 4][i % 4].f; + } + c->prog_data.nr_pull_params = i; + } + for (i = 0; i < constant; i++) { c->regs[PROGRAM_STATE_VAR][i] = stride(brw_vec4_grf(reg + i / 2, (i % 2) * 4), diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index f9ee4d112a5..6748ff9aeb5 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -47,10 +47,10 @@ prepare_vs_constants(struct brw_context *brw) { struct gl_context *ctx = &brw->intel.ctx; struct intel_context *intel = &brw->intel; + /* BRW_NEW_VERTEX_PROGRAM */ struct brw_vertex_program *vp = (struct brw_vertex_program *) brw->vertex_program; const struct gl_program_parameter_list *params = vp->program.Base.Parameters; - const int size = params->NumParameters * 4 * sizeof(GLfloat); int i; if (vp->program.IsNVProgram) @@ -61,8 +61,8 @@ prepare_vs_constants(struct brw_context *brw) */ _mesa_load_state_parameters(&brw->intel.ctx, vp->program.Base.Parameters); - /* BRW_NEW_VERTEX_PROGRAM */ - if (!vp->use_const_buffer) { + /* CACHE_NEW_VS_PROG */ + if (!brw->vs.prog_data->nr_pull_params) { if (brw->vs.const_bo) { drm_intel_bo_unreference(brw->vs.const_bo); brw->vs.const_bo = NULL; @@ -74,13 +74,14 @@ prepare_vs_constants(struct brw_context *brw) /* _NEW_PROGRAM_CONSTANTS */ drm_intel_bo_unreference(brw->vs.const_bo); brw->vs.const_bo = drm_intel_bo_alloc(intel->bufmgr, "vp_const_buffer", - size, 64); + brw->vs.prog_data->nr_pull_params * 4, + 64); drm_intel_gem_bo_map_gtt(brw->vs.const_bo); - for (i = 0; i < params->NumParameters; i++) { - memcpy(brw->vs.const_bo->virtual + i * 4 * sizeof(float), - params->ParameterValues[i], - 4 * sizeof(float)); + for (i = 0; i < brw->vs.prog_data->nr_pull_params; i++) { + memcpy(brw->vs.const_bo->virtual + i * 4, + brw->vs.prog_data->pull_param[i], + 4); } if (0) { @@ -99,7 +100,7 @@ const struct brw_tracked_state brw_vs_constants = { .dirty = { .mesa = (_NEW_PROGRAM_CONSTANTS), .brw = (BRW_NEW_VERTEX_PROGRAM), - .cache = 0 + .cache = CACHE_NEW_VS_PROG, }, .prepare = prepare_vs_constants, }; |