Fix softpipe vertex attribute setup.
Also, update vs constants when the projection matrix changes (fixes samples/prim.c)
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 );
#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
/* 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: */
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 */
/* 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 */
}
} 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.
*/
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;
}
}
break;\r
\r
case TGSI_FILE_OUTPUT:\r
+ /*\r
assert( usage_bitmask == 0x0 );\r
+ */\r
if( processor == TGSI_PROCESSOR_FRAGMENT ) {\r
/* depth result -> index 0\r
* color results -> index 1, 2, ...\r
}\r
}\r
else {\r
+ /* vertex output slots are tightly packed, find mapped pos */\r
/* mapped_index = VERT_RESULT_x */\r
- mapped_index = index;\r
+ mapped_index = 0;\r
+ for( i = 0; i < index; i++ ) {\r
+ if( usage_bitmask & (1 << i) ) {\r
+ mapped_index++;\r
+ }\r
+ }\r
}\r
break;\r
\r
const struct prog_instruction *inst,\r
struct tgsi_full_instruction *fullinst,\r
GLuint inputs_read,\r
+ GLuint outputs_written,\r
GLuint preamble_size,\r
GLuint processor )\r
{\r
processor,\r
fulldst->DstRegister.File,\r
inst->DstReg.Index,\r
- 0x0 );\r
+ outputs_written\r
+ );\r
fulldst->DstRegister.WriteMask = convert_writemask( inst->DstReg.WriteMask );\r
\r
for( i = 0; i < fullinst->Instruction.NumSrcRegs; i++ ) {\r
&program->Base.Instructions[i],\r
&fullinst,\r
inputs_read,\r
+ ~0, /*outputs_written*/\r
preamble_size,\r
TGSI_PROCESSOR_FRAGMENT ) ) {\r
assert( i == program->Base.NumInstructions - 1 );\r
struct tgsi_processor *processor;\r
struct tgsi_full_instruction fullinst;\r
GLuint inputs_read = ~0;\r
+ GLuint outputs_written;\r
+\r
+ outputs_written = program->Base.OutputsWritten;\r
\r
*(struct tgsi_version *) &tokens[0] = tgsi_build_version();\r
\r
&program->Base.Instructions[i],\r
&fullinst,\r
inputs_read,\r
+ outputs_written,\r
0,\r
TGSI_PROCESSOR_VERTEX ) ) {\r
assert( i == program->Base.NumInstructions - 1 );\r
/* 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 ||
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