summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-23 19:03:42 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-08-23 19:03:42 -0600
commite967b246ecdc665d9f974d1e35380cb1cd11d61e (patch)
tree62fa8017c148482090984066532824b8b6b98426
parent30236573dadd83714220b72b0c04f1bbce69fbd6 (diff)
Vertex shader outputs are now tightly packed into the output slots.
Fix softpipe vertex attribute setup. Also, update vs constants when the projection matrix changes (fixes samples/prim.c)
-rw-r--r--src/mesa/pipe/draw/draw_prim.c57
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c33
-rw-r--r--src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c19
-rw-r--r--src/mesa/state_tracker/st_atom_vs.c8
4 files changed, 62 insertions, 55 deletions
diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c
index 2ba3cb3eb5..76c2a821b7 100644
--- a/src/mesa/pipe/draw/draw_prim.c
+++ b/src/mesa/pipe/draw/draw_prim.c
@@ -200,7 +200,7 @@ run_vertex_program(struct draw_context *draw,
machine.Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/
machine.Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/
#if 0
- if (1/*attr == 0*/) {
+ if (1) {
fprintf(file, "Input vertex %d: attr %d: %f %f %f %f\n",
j, attr, p[0], p[1], p[2], p[3]);
fflush( file );
@@ -212,12 +212,15 @@ run_vertex_program(struct draw_context *draw,
#if 0
printf("Consts:\n");
- for (i = 0; i < 4; i++) {
- printf(" %d: %f %f %f %f\n", i,
- machine.Consts[i][0],
- machine.Consts[i][1],
- machine.Consts[i][2],
- machine.Consts[i][3]);
+ {
+ int i;
+ for (i = 0; i < 4; i++) {
+ printf(" %d: %f %f %f %f\n", i,
+ machine.Consts[i][0],
+ machine.Consts[i][1],
+ machine.Consts[i][2],
+ machine.Consts[i][3]);
+ }
}
#endif
@@ -238,7 +241,7 @@ run_vertex_program(struct draw_context *draw,
/* store machine results */
assert(draw->vertex_shader.outputs_written & (1 << TGSI_ATTRIB_POS));
for (j = 0; j < count; j++) {
- unsigned attr, slot;
+ unsigned /**attr,**/ slot;
float x, y, z, w;
/* Handle attr[0] (position) specially: */
@@ -247,7 +250,7 @@ run_vertex_program(struct draw_context *draw,
z = vOut[j]->clip[2] = machine.Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine.Outputs[0].xyzw[3].f[j];
- vOut[j]->clipmask = compute_clipmask(x, y, z, w);
+ vOut[j]->clipmask = 0;/*compute_clipmask(x, y, z, w);*/
vOut[j]->edgeflag = 1;
/* divide by w */
@@ -273,33 +276,47 @@ run_vertex_program(struct draw_context *draw,
/* remaining attributes: */
/* pack into sequential post-transform attrib slots */
+#if 0
slot = 1;
for (attr = 1; attr < TGSI_ATTRIB_MAX; attr++) {
if (draw->vertex_shader.outputs_written & (1 << attr)) {
assert(slot < draw->vertex_info.num_attribs);
- vOut[j]->data[slot][0] = machine.Outputs[attr].xyzw[0].f[j];
- vOut[j]->data[slot][1] = machine.Outputs[attr].xyzw[1].f[j];
- vOut[j]->data[slot][2] = machine.Outputs[attr].xyzw[2].f[j];
- vOut[j]->data[slot][3] = machine.Outputs[attr].xyzw[3].f[j];
+ vOut[j]->data[slot][0] = machine.Outputs[/*attr*/slot].xyzw[0].f[j];
+ vOut[j]->data[slot][1] = machine.Outputs[/*attr*/slot].xyzw[1].f[j];
+ vOut[j]->data[slot][2] = machine.Outputs[/*attr*/slot].xyzw[2].f[j];
+ vOut[j]->data[slot][3] = machine.Outputs[/*attr*/slot].xyzw[3].f[j];
#if 0
- fprintf(file, "output attrib %d slot %d: %f %f %f %f\n",
+ fprintf(file, "output attrib %d slot %d: %f %f %f %f vert %p\n",
attr, slot,
vOut[j]->data[slot][0],
vOut[j]->data[slot][1],
vOut[j]->data[slot][2],
- vOut[j]->data[slot][3]);
+ vOut[j]->data[slot][3], vOut[j]);
#endif
slot++;
}
}
- }
+#else
+
+ for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
+ vOut[j]->data[slot][0] = machine.Outputs[slot].xyzw[0].f[j];
+ vOut[j]->data[slot][1] = machine.Outputs[slot].xyzw[1].f[j];
+ vOut[j]->data[slot][2] = machine.Outputs[slot].xyzw[2].f[j];
+ vOut[j]->data[slot][3] = machine.Outputs[slot].xyzw[3].f[j];
#if 0
- memcpy(
- quad->outputs.color,
- &machine.Outputs[1].xyzw[0].f[0],
- sizeof( quad->outputs.color ) );
+ fprintf(file, "output attrib slot %d: %f %f %f %f vert %p\n",
+ slot,
+ vOut[j]->data[slot][0],
+ vOut[j]->data[slot][1],
+ vOut[j]->data[slot][2],
+ vOut[j]->data[slot][3], vOut[j]);
#endif
+ }
+
+#endif
+
+ } /* loop over vertices */
}
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index 5c119ec8cd..a880e23abc 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -48,31 +48,6 @@ do { \
} while (0)
-static const unsigned frag_to_vf[PIPE_ATTRIB_MAX] =
-{
- TGSI_ATTRIB_POS,
- TGSI_ATTRIB_COLOR0,
- TGSI_ATTRIB_COLOR1,
- TGSI_ATTRIB_FOG,
- TGSI_ATTRIB_TEX0,
- TGSI_ATTRIB_TEX1,
- TGSI_ATTRIB_TEX2,
- TGSI_ATTRIB_TEX3,
- TGSI_ATTRIB_TEX4,
- TGSI_ATTRIB_TEX5,
- TGSI_ATTRIB_TEX6,
- TGSI_ATTRIB_TEX7,
- TGSI_ATTRIB_VAR0,
- TGSI_ATTRIB_VAR1,
- TGSI_ATTRIB_VAR2,
- TGSI_ATTRIB_VAR3,
- TGSI_ATTRIB_VAR4,
- TGSI_ATTRIB_VAR5,
- TGSI_ATTRIB_VAR6,
- TGSI_ATTRIB_VAR7,
-};
-
-
/**
* Determine which post-transform / pre-rasterization vertex attributes
* we need.
@@ -119,19 +94,17 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe )
*/
for (i = 1; i < TGSI_ATTRIB_TEX0; i++) {
if (inputsRead & (1 << i)) {
- assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0]));
if (softpipe->setup.flatshade
&& (i == TGSI_ATTRIB_COLOR0 || i == TGSI_ATTRIB_COLOR1))
- EMIT_ATTR(frag_to_vf[i], i, INTERP_CONSTANT);
+ EMIT_ATTR(i, i, INTERP_CONSTANT);
else
- EMIT_ATTR(frag_to_vf[i], i, INTERP_LINEAR);
+ EMIT_ATTR(i, i, INTERP_LINEAR);
}
}
for (i = TGSI_ATTRIB_TEX0; i < TGSI_ATTRIB_MAX; i++) {
if (inputsRead & (1 << i)) {
- assert(i < sizeof(frag_to_vf) / sizeof(frag_to_vf[0]));
- EMIT_ATTR(frag_to_vf[i], i, INTERP_PERSPECTIVE);
+ EMIT_ATTR(i, i, INTERP_PERSPECTIVE);
softpipe->need_w = TRUE;
}
}
diff --git a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
index 993d220c50..f33a702958 100644
--- a/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
+++ b/src/mesa/pipe/tgsi/mesa/mesa_to_tgsi.c
@@ -348,7 +348,9 @@ map_register_file_index(
break;
case TGSI_FILE_OUTPUT:
+ /*
assert( usage_bitmask == 0x0 );
+ */
if( processor == TGSI_PROCESSOR_FRAGMENT ) {
/* depth result -> index 0
* color results -> index 1, 2, ...
@@ -362,8 +364,14 @@ map_register_file_index(
}
}
else {
+ /* vertex output slots are tightly packed, find mapped pos */
/* mapped_index = VERT_RESULT_x */
- mapped_index = index;
+ mapped_index = 0;
+ for( i = 0; i < index; i++ ) {
+ if( usage_bitmask & (1 << i) ) {
+ mapped_index++;
+ }
+ }
}
break;
@@ -434,6 +442,7 @@ compile_instruction(
const struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
GLuint inputs_read,
+ GLuint outputs_written,
GLuint preamble_size,
GLuint processor )
{
@@ -453,7 +462,8 @@ compile_instruction(
processor,
fulldst->DstRegister.File,
inst->DstReg.Index,
- 0x0 );
+ outputs_written
+ );
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );
for( i = 0; i < fullinst->Instruction.NumSrcRegs; i++ ) {
@@ -921,6 +931,7 @@ tgsi_mesa_compile_fp_program(
&program->Base.Instructions[i],
&fullinst,
inputs_read,
+ ~0, /*outputs_written*/
preamble_size,
TGSI_PROCESSOR_FRAGMENT ) ) {
assert( i == program->Base.NumInstructions - 1 );
@@ -952,6 +963,9 @@ tgsi_mesa_compile_vp_program(
struct tgsi_processor *processor;
struct tgsi_full_instruction fullinst;
GLuint inputs_read = ~0;
+ GLuint outputs_written;
+
+ outputs_written = program->Base.OutputsWritten;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();
@@ -968,6 +982,7 @@ tgsi_mesa_compile_vp_program(
&program->Base.Instructions[i],
&fullinst,
inputs_read,
+ outputs_written,
0,
TGSI_PROCESSOR_VERTEX ) ) {
assert( i == program->Base.NumInstructions - 1 );
diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c
index 8a38020afd..f16fe2ae94 100644
--- a/src/mesa/state_tracker/st_atom_vs.c
+++ b/src/mesa/state_tracker/st_atom_vs.c
@@ -113,8 +113,10 @@ static void update_vs( struct st_context *st )
/* update pipe state */
memset( &vs, 0, sizeof(vs) );
- vs.outputs_written = vp->Base.Base.OutputsWritten;
- vs.inputs_read = vp->Base.Base.InputsRead;
+ vs.inputs_read
+ = tgsi_mesa_translate_vertex_input_mask(vp->Base.Base.InputsRead);
+ vs.outputs_written
+ = tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten);
vs.tokens = &vp->tokens[0];
if (memcmp(&vs, &st->state.vs, sizeof(vs)) != 0 ||
@@ -129,7 +131,7 @@ static void update_vs( struct st_context *st )
const struct st_tracked_state st_update_vs = {
.dirty = {
- .mesa = _NEW_PROGRAM | _NEW_MODELVIEW,
+ .mesa = _NEW_PROGRAM | _NEW_MODELVIEW | _NEW_PROJECTION, /*XXX MORE*/
.st = ST_NEW_VERTEX_PROGRAM,
},
.update = update_vs