mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 19:20:08 +01:00
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 <kenneth@whitecape.org>
This commit is contained in:
parent
9fa41f0742
commit
8654931d11
3 changed files with 25 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue