From f9e0e2b3efbc45a290f0a84a1beb63cd8c4f8428 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 24 Dec 2007 07:57:34 -0500 Subject: [PATCH] i965: a little better way of handling immediates --- src/mesa/pipe/i965simple/brw_context.h | 1 + src/mesa/pipe/i965simple/brw_curbe.c | 9 ++++++--- src/mesa/pipe/i965simple/brw_vs_emit.c | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h index 139f13ad4ee..c610a435e0a 100644 --- a/src/mesa/pipe/i965simple/brw_context.h +++ b/src/mesa/pipe/i965simple/brw_context.h @@ -329,6 +329,7 @@ struct brw_vs_prog_data { float imm_buf[PIPE_MAX_CONSTANT][4]; unsigned num_imm; + unsigned num_consts; /* Used for calculating urb partitions: */ diff --git a/src/mesa/pipe/i965simple/brw_curbe.c b/src/mesa/pipe/i965simple/brw_curbe.c index 603116c8634..4d79a7abe22 100644 --- a/src/mesa/pipe/i965simple/brw_curbe.c +++ b/src/mesa/pipe/i965simple/brw_curbe.c @@ -252,9 +252,14 @@ static void upload_constant_buffer(struct brw_context *brw) /*unsigned nr = vp->max_const;*/ const struct pipe_constant_buffer *cbuffer = brw->attribs.Constants[0]; struct pipe_winsys *ws = brw->pipe.winsys; - if (cbuffer->size) { + /* FIXME: buffer size is num_consts + num_immediates */ + if (brw->vs.prog_data->num_consts) { /* map the vertex constant buffer and copy to curbe: */ ws->buffer_map(ws, cbuffer->buffer, 0); + /* FIXME: this is wrong. the cbuffer->size currently + * represents size of consts + immediates. so if we'll + * have both we'll copy over the end of the buffer + * with the subsequent memcpy */ ws->buffer_get_subdata(ws, cbuffer->buffer, 0, cbuffer->size, @@ -263,12 +268,10 @@ static void upload_constant_buffer(struct brw_context *brw) offset += cbuffer->size; } /*immediates*/ -#if 0 if (brw->vs.prog_data->num_imm) { memcpy(&buf[offset], brw->vs.prog_data->imm_buf, brw->vs.prog_data->num_imm * 4 * sizeof(float)); } -#endif } if (1) { diff --git a/src/mesa/pipe/i965simple/brw_vs_emit.c b/src/mesa/pipe/i965simple/brw_vs_emit.c index f3507f60f7a..0cc0a437b0b 100644 --- a/src/mesa/pipe/i965simple/brw_vs_emit.c +++ b/src/mesa/pipe/i965simple/brw_vs_emit.c @@ -630,6 +630,8 @@ static struct brw_reg get_reg( struct brw_vs_compile *c, assert(c->regs[file][index].nr != 0); return c->regs[file][index]; case TGSI_FILE_CONSTANT: + assert(c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_consts].nr != 0); + return c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_consts]; case TGSI_FILE_IMMEDIATE: assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0); return c->regs[TGSI_FILE_CONSTANT][index]; @@ -1317,6 +1319,7 @@ void brw_vs_emit(struct brw_vs_compile *c) /* first instruction (declerations finished). * now that we know what vars are being used allocate * registers for them.*/ + c->prog_data.num_consts = prog_info.num_consts; c->prog_data.max_const = prog_info.num_consts + c->prog_data.num_imm; brw_vs_alloc_regs(c, &prog_info); -- 2.30.2