summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-09-18 19:37:36 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-09-18 19:38:35 -0600
commitbb611c5f1f6aec7ac51d4fa3301422b47f6de795 (patch)
treea50b77cdfd0b62b4872465bd1a346ba0fbab1a38 /src/mesa/pipe/draw
parent63be96bdc7e9f388a5c49295bd7e150462fd003a (diff)
Checkpoint: rework shader input/output register mapping.
This is a step toward removing TGSI_ATTRIB_ tokens. Basically, when translating Mesa programs to TGSI programs, pass in input and output register re-maps, plus interpolation info. There's some known breakage (cubemap.c) so more to be done...
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c39
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c14
2 files changed, 32 insertions, 21 deletions
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
index 0dbbdf17f2..ce402d681f 100644
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ b/src/mesa/pipe/draw/draw_vertex_fetch.c
@@ -67,6 +67,10 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4])
}
}
+
+/**
+ * Fetch vertex attributes for 'count' vertices.
+ */
void draw_vertex_fetch( struct draw_context *draw,
struct tgsi_exec_machine *machine,
const unsigned *elts,
@@ -74,27 +78,26 @@ void draw_vertex_fetch( struct draw_context *draw,
{
unsigned j;
-
- /* load machine inputs */
+ /* loop over vertices */
for (j = 0; j < count; j++) {
- unsigned attr;
- for (attr = 0; attr < 16; attr++) {
- if (draw->vertex_shader.inputs_read & (1 << attr)) {
- unsigned buf = draw->vertex_element[attr].vertex_buffer_index;
- const void *src
- = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf]
- + draw->vertex_buffer[buf].buffer_offset
- + draw->vertex_element[attr].src_offset
- + elts[j] * draw->vertex_buffer[buf].pitch);
- float p[4];
+ uint attr;
+ /* loop over vertex attributes (vertex shader inputs) */
+ for (attr = 0; attr < draw->vertex_shader.num_inputs; attr++) {
+
+ unsigned buf = draw->vertex_element[attr].vertex_buffer_index;
+ const void *src
+ = (const void *) ((const ubyte *) draw->mapped_vbuffer[buf]
+ + draw->vertex_buffer[buf].buffer_offset
+ + draw->vertex_element[attr].src_offset
+ + elts[j] * draw->vertex_buffer[buf].pitch);
+ float p[4];
- fetch_attrib4(src, draw->vertex_element[attr].src_format, p);
+ fetch_attrib4(src, draw->vertex_element[attr].src_format, p);
- machine->Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/
- machine->Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/
- machine->Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/
- machine->Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/
- }
+ machine->Inputs[attr].xyzw[0].f[j] = p[0]; /*X*/
+ machine->Inputs[attr].xyzw[1].f[j] = p[1]; /*Y*/
+ machine->Inputs[attr].xyzw[2].f[j] = p[2]; /*Z*/
+ machine->Inputs[attr].xyzw[3].f[j] = p[3]; /*W*/
}
}
}
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 8effc74cbe..cb6c605b8d 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -114,7 +114,6 @@ run_vertex_program(struct draw_context *draw,
draw_vertex_fetch( draw, &machine, elts, count );
-
/* run shader */
if( draw->vertex_shader.executable != NULL ) {
#if defined(USE_X86_ASM) || defined(SLANG_X86)
@@ -159,14 +158,23 @@ run_vertex_program(struct draw_context *draw,
vOut[j]->data[0][2] = z * scale[2] + trans[2];
vOut[j]->data[0][3] = w;
- /* remaining attributes are packed into sequential post-transform
+ /* Remaining attributes are packed into sequential post-transform
* vertex attrib slots.
+ * Skip 0 since we just did it above.
+ * Subtract two because of the VERTEX_HEADER, CLIP_POS attribs.
*/
- for (slot = 1; slot < draw->vertex_info.num_attribs; slot++) {
+ for (slot = 1; slot < draw->vertex_info.num_attribs - 2; 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];
+ /*
+ printf("output %d: %f %f %f %f\n", slot,
+ vOut[j]->data[slot][0],
+ vOut[j]->data[slot][1],
+ vOut[j]->data[slot][2],
+ vOut[j]->data[slot][3]);
+ */
}
} /* loop over vertices */
}