i965: very crude and hacky way of handling immediates

This commit is contained in:
Zack Rusin 2007-12-20 12:54:23 -05:00
parent a85535b7cb
commit 4fa7afabc9
3 changed files with 33 additions and 9 deletions

View file

@ -327,6 +327,9 @@ struct brw_vs_prog_data {
unsigned max_const;
float imm_buf[PIPE_MAX_CONSTANT][4];
unsigned num_imm;
/* Used for calculating urb partitions:
*/
unsigned urb_entry_size;

View file

@ -252,13 +252,23 @@ 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;
/* map the vertex constant buffer and copy to curbe: */
ws->buffer_map(ws, cbuffer->buffer, 0);
ws->buffer_get_subdata(ws, cbuffer->buffer,
0,
cbuffer->size,
&buf[offset]);
ws->buffer_unmap(ws, cbuffer->buffer);
if (cbuffer->size) {
/* map the vertex constant buffer and copy to curbe: */
ws->buffer_map(ws, cbuffer->buffer, 0);
ws->buffer_get_subdata(ws, cbuffer->buffer,
0,
cbuffer->size,
&buf[offset]);
ws->buffer_unmap(ws, cbuffer->buffer);
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) {

View file

@ -627,9 +627,12 @@ static struct brw_reg get_reg( struct brw_vs_compile *c,
case TGSI_FILE_TEMPORARY:
case TGSI_FILE_INPUT:
case TGSI_FILE_OUTPUT:
case TGSI_FILE_CONSTANT:
assert(c->regs[file][index].nr != 0);
return c->regs[file][index];
case TGSI_FILE_CONSTANT:
case TGSI_FILE_IMMEDIATE:
assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0);
return c->regs[TGSI_FILE_CONSTANT][index];
case TGSI_FILE_ADDRESS:
assert(index == 0);
return c->regs[file][index];
@ -1298,6 +1301,14 @@ void brw_vs_emit(struct brw_vs_compile *c)
}
break;
case TGSI_TOKEN_TYPE_IMMEDIATE: {
int i;
struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
/*assert(imm->Immediate.Size == 4);*/
c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;
c->prog_data.imm_buf[c->prog_data.num_imm][3] = imm->u.ImmediateFloat32[3].Float;
c->prog_data.num_imm++;
}
break;
case TGSI_TOKEN_TYPE_INSTRUCTION: {
@ -1306,7 +1317,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.max_const = 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);
brw_set_access_mode(p, BRW_ALIGN_1);