summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-08-22 00:21:55 +0200
committerLuca Barbieri <[email protected]>2010-08-22 15:42:16 +0200
commita0c45eabf961905ea7bd48b2750fce41c8ba542b (patch)
treeddec8e9da584d332ec75d554bbe42c4e08dee6f8
parent8a878c266a8bf50b49d3ef8c5984790581e33133 (diff)
nvfx: use relocations array for vp constants
-rw-r--r--src/gallium/drivers/nvfx/nvfx_fragprog.c18
-rw-r--r--src/gallium/drivers/nvfx/nvfx_shader.h2
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state.h2
-rw-r--r--src/gallium/drivers/nvfx/nvfx_vertprog.c47
4 files changed, 34 insertions, 35 deletions
diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
index db33ecd78cf..025989ac5bb 100644
--- a/src/gallium/drivers/nvfx/nvfx_fragprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
@@ -270,7 +270,7 @@ nv40_fp_if(struct nvfx_fpc *fpc, struct nvfx_src src)
static void
nv40_fp_cal(struct nvfx_fpc *fpc, unsigned target)
{
- struct nvfx_label_relocation reloc;
+ struct nvfx_relocation reloc;
uint32_t *hw;
fpc->inst_offset = fpc->fp->insn_len;
grow_insns(fpc, 4);
@@ -284,7 +284,7 @@ nv40_fp_cal(struct nvfx_fpc *fpc, unsigned target)
hw[3] = 0;
reloc.target = target;
reloc.location = fpc->inst_offset + 2;
- util_dynarray_append(&fpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);
}
static void
@@ -306,7 +306,7 @@ nv40_fp_ret(struct nvfx_fpc *fpc)
static void
nv40_fp_rep(struct nvfx_fpc *fpc, unsigned count, unsigned target)
{
- struct nvfx_label_relocation reloc;
+ struct nvfx_relocation reloc;
uint32_t *hw;
fpc->inst_offset = fpc->fp->insn_len;
grow_insns(fpc, 4);
@@ -325,7 +325,7 @@ nv40_fp_rep(struct nvfx_fpc *fpc, unsigned count, unsigned target)
hw[3] = 0; /* | end_offset */
reloc.target = target;
reloc.location = fpc->inst_offset + 3;
- util_dynarray_append(&fpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);
//util_dynarray_append(&fpc->loop_stack, unsigned, target);
}
@@ -333,7 +333,7 @@ nv40_fp_rep(struct nvfx_fpc *fpc, unsigned count, unsigned target)
static void
nv40_fp_bra(struct nvfx_fpc *fpc, unsigned target)
{
- struct nvfx_label_relocation reloc;
+ struct nvfx_relocation reloc;
uint32_t *hw;
fpc->inst_offset = fpc->fp->insn_len;
grow_insns(fpc, 4);
@@ -349,10 +349,10 @@ nv40_fp_bra(struct nvfx_fpc *fpc, unsigned target)
hw[3] = 0; /* | endif_offset */
reloc.target = target;
reloc.location = fpc->inst_offset + 2;
- util_dynarray_append(&fpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);
reloc.target = target;
reloc.location = fpc->inst_offset + 3;
- util_dynarray_append(&fpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&fpc->label_relocs, struct nvfx_relocation, reloc);
}
static void
@@ -1041,9 +1041,9 @@ nvfx_fragprog_translate(struct nvfx_context *nvfx,
}
util_dynarray_append(&insns, unsigned, fp->insn_len);
- for(unsigned i = 0; i < fpc->label_relocs.size; i += sizeof(struct nvfx_label_relocation))
+ for(unsigned i = 0; i < fpc->label_relocs.size; i += sizeof(struct nvfx_relocation))
{
- struct nvfx_label_relocation* label_reloc = (struct nvfx_label_relocation*)((char*)fpc->label_relocs.data + i);
+ struct nvfx_relocation* label_reloc = (struct nvfx_relocation*)((char*)fpc->label_relocs.data + i);
fp->insn[label_reloc->location] |= ((unsigned*)insns.data)[label_reloc->target];
}
util_dynarray_fini(&insns);
diff --git a/src/gallium/drivers/nvfx/nvfx_shader.h b/src/gallium/drivers/nvfx/nvfx_shader.h
index 52e684aec3b..c711484ee2b 100644
--- a/src/gallium/drivers/nvfx/nvfx_shader.h
+++ b/src/gallium/drivers/nvfx/nvfx_shader.h
@@ -509,7 +509,7 @@ nvfx_src_abs(struct nvfx_src src)
return src;
}
-struct nvfx_label_relocation {
+struct nvfx_relocation {
unsigned location;
unsigned target;
};
diff --git a/src/gallium/drivers/nvfx/nvfx_state.h b/src/gallium/drivers/nvfx/nvfx_state.h
index 6d589af5f35..1247abcfa21 100644
--- a/src/gallium/drivers/nvfx/nvfx_state.h
+++ b/src/gallium/drivers/nvfx/nvfx_state.h
@@ -9,7 +9,6 @@
struct nvfx_vertex_program_exec {
uint32_t data[4];
- int const_index;
};
struct nvfx_vertex_program_data {
@@ -46,6 +45,7 @@ struct nvfx_vertex_program {
uint32_t clip_ctrl;
struct util_dynarray branch_relocs;
+ struct util_dynarray const_relocs;
};
struct nvfx_fragment_program_data {
diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
index 38f37168a18..996680e32cc 100644
--- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
@@ -113,6 +113,7 @@ emit_src(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, uint32_t *hw, int pos,
{
struct nvfx_vertex_program *vp = vpc->vp;
uint32_t sr = 0;
+ struct nvfx_relocation reloc;
switch (src.reg.type) {
case NVFXSR_TEMP:
@@ -128,9 +129,9 @@ emit_src(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, uint32_t *hw, int pos,
case NVFXSR_CONST:
sr |= (NVFX_VP(SRC_REG_TYPE_CONST) <<
NVFX_VP(SRC_REG_TYPE_SHIFT));
- assert(vpc->vpi->const_index == -1 ||
- vpc->vpi->const_index == src.reg.index);
- vpc->vpi->const_index = src.reg.index;
+ reloc.location = vp->nr_insns - 1;
+ reloc.target = src.reg.index;
+ util_dynarray_append(&vp->const_relocs, struct nvfx_relocation, reloc);
break;
case NVFXSR_NONE:
sr |= (NVFX_VP(SRC_REG_TYPE_INPUT) <<
@@ -308,7 +309,6 @@ nvfx_vp_emit(struct nvfx_vpc *vpc, struct nvfx_insn insn)
vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
vpc->vpi = &vp->insns[vp->nr_insns - 1];
memset(vpc->vpi, 0, sizeof(*vpc->vpi));
- vpc->vpi->const_index = -1;
hw = vpc->vpi->data;
@@ -440,7 +440,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
struct nvfx_reg dst;
struct nvfx_src none = nvfx_src(nvfx_reg(NVFXSR_NONE, 0));
struct nvfx_insn insn;
- struct nvfx_label_relocation reloc;
+ struct nvfx_relocation reloc;
struct nvfx_loop_entry loop;
int mask;
int ai = -1, ci = -1, ii = -1;
@@ -662,7 +662,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
reloc.location = vpc->vp->nr_insns;
reloc.target = finst->Label.Label + 1;
- util_dynarray_append(&vpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&vpc->label_relocs, struct nvfx_relocation, reloc);
insn = arith(SCA, BRA, none.reg, 0, none, none, none);
insn.cc_test = NVFX_COND_EQ;
@@ -675,7 +675,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
case TGSI_OPCODE_CAL:
reloc.location = vpc->vp->nr_insns;
reloc.target = finst->Label.Label;
- util_dynarray_append(&vpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&vpc->label_relocs, struct nvfx_relocation, reloc);
if(finst->Instruction.Opcode == TGSI_OPCODE_CAL)
insn = arith(SCA, CAL, none.reg, 0, none, none, none);
@@ -707,7 +707,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
reloc.location = vpc->vp->nr_insns;
reloc.target = loop.cont_target;
- util_dynarray_append(&vpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&vpc->label_relocs, struct nvfx_relocation, reloc);
nvfx_vp_emit(vpc, arith(SCA, BRA, none.reg, 0, none, none, none));
break;
@@ -717,7 +717,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
reloc.location = vpc->vp->nr_insns;
reloc.target = loop.cont_target;
- util_dynarray_append(&vpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&vpc->label_relocs, struct nvfx_relocation, reloc);
nvfx_vp_emit(vpc, arith(SCA, BRA, none.reg, 0, none, none, none));
break;
@@ -727,7 +727,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
reloc.location = vpc->vp->nr_insns;
reloc.target = loop.brk_target;
- util_dynarray_append(&vpc->label_relocs, struct nvfx_label_relocation, reloc);
+ util_dynarray_append(&vpc->label_relocs, struct nvfx_relocation, reloc);
nvfx_vp_emit(vpc, arith(SCA, BRA, none.reg, 0, none, none, none));
break;
@@ -979,17 +979,17 @@ nvfx_vertprog_translate(struct nvfx_context *nvfx,
util_dynarray_append(&insns, unsigned, vp->nr_insns);
- for(unsigned i = 0; i < vpc->label_relocs.size; i += sizeof(struct nvfx_label_relocation))
+ for(unsigned i = 0; i < vpc->label_relocs.size; i += sizeof(struct nvfx_relocation))
{
- struct nvfx_label_relocation* label_reloc = (struct nvfx_label_relocation*)((char*)vpc->label_relocs.data + i);
- struct nvfx_label_relocation hw_reloc;
+ struct nvfx_relocation* label_reloc = (struct nvfx_relocation*)((char*)vpc->label_relocs.data + i);
+ struct nvfx_relocation hw_reloc;
hw_reloc.location = label_reloc->location;
hw_reloc.target = ((unsigned*)insns.data)[label_reloc->target];
//debug_printf("hw %u -> tgsi %u = hw %u\n", hw_reloc.location, label_reloc->target, hw_reloc.target);
- util_dynarray_append(&vp->branch_relocs, struct nvfx_label_relocation, hw_reloc);
+ util_dynarray_append(&vp->branch_relocs, struct nvfx_relocation, hw_reloc);
}
util_dynarray_fini(&insns);
util_dynarray_trim(&vp->branch_relocs);
@@ -1155,9 +1155,9 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)
*/
if (vp->exec_start != vp->exec->start) {
//printf("vp_relocs %u -> %u\n", vp->exec_start, vp->exec->start);
- for(unsigned i = 0; i < vp->branch_relocs.size; i += sizeof(struct nvfx_label_relocation))
+ for(unsigned i = 0; i < vp->branch_relocs.size; i += sizeof(struct nvfx_relocation))
{
- struct nvfx_label_relocation* reloc = (struct nvfx_label_relocation*)((char*)vp->branch_relocs.data + i);
+ struct nvfx_relocation* reloc = (struct nvfx_relocation*)((char*)vp->branch_relocs.data + i);
uint32_t* hw = vp->insns[reloc->location].data;
unsigned target = vp->exec->start + reloc->target;
@@ -1182,16 +1182,15 @@ nvfx_vertprog_validate(struct nvfx_context *nvfx)
}
if (vp->nr_consts && vp->data_start != vp->data->start) {
- for (i = 0; i < vp->nr_insns; i++) {
- struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
+ for(unsigned i = 0; i < vp->const_relocs.size; i += sizeof(struct nvfx_relocation))
+ {
+ struct nvfx_relocation* reloc = (struct nvfx_relocation*)((char*)vp->const_relocs.data + i);
+ struct nvfx_vertex_program_exec *vpi = &vp->insns[reloc->location];
- if (vpi->const_index >= 0) {
- vpi->data[1] &= ~NVFX_VP(INST_CONST_SRC_MASK);
- vpi->data[1] |=
- (vpi->const_index + vp->data->start) <<
+ vpi->data[1] &= ~NVFX_VP(INST_CONST_SRC_MASK);
+ vpi->data[1] |=
+ (reloc->target + vp->data->start) <<
NVFX_VP(INST_CONST_SRC_SHIFT);
-
- }
}
vp->data_start = vp->data->start;