summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPekka Paalanen <[email protected]>2009-01-26 21:15:48 +0200
committerPekka Paalanen <[email protected]>2009-01-26 21:34:39 +0200
commitf25421a59b002a8b679df86c0a072cf853e94f10 (patch)
tree2d5e1748035c764c59b5ce3c2893a144bd802063 /src
parent94ff37f0dc78a7f305f309ea8d5e111508c5b9f2 (diff)
nv20: rewrite vertex layout
NV20 seems to be very different to NV10. In vertex array, pos is first, not last. There are maximum 16 attributes and only few are currently known. This makes trivial/tri work on NV20. Signed-off-by: Pekka Paalanen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/nv20/nv20_state_emit.c85
1 files changed, 59 insertions, 26 deletions
diff --git a/src/gallium/drivers/nv20/nv20_state_emit.c b/src/gallium/drivers/nv20/nv20_state_emit.c
index 5265bf3a314..cbdc674b09d 100644
--- a/src/gallium/drivers/nv20/nv20_state_emit.c
+++ b/src/gallium/drivers/nv20/nv20_state_emit.c
@@ -159,8 +159,8 @@ static void nv20_state_emit_framebuffer(struct nv20_context* nv20)
BEGIN_RING(kelvin, NV20TCL_RT_HORIZ, 3);
OUT_RING ((w << 16) | 0);
- OUT_RING ((h << 16) | 0);
- OUT_RING (rt_format);
+ OUT_RING ((h << 16) | 0); /*NV20TCL_RT_VERT */
+ OUT_RING (rt_format); /* NV20TCL_RT_FORMAT */
BEGIN_RING(kelvin, NV20TCL_VIEWPORT_CLIP_HORIZ(0), 2);
OUT_RING (((w - 1) << 16) | 0);
OUT_RING (((h - 1) << 16) | 0);
@@ -170,24 +170,29 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
{
struct nv20_fragment_program *fp = nv20->fragprog.current;
struct draw_context *dc = nv20->draw;
- uint32_t src;
+ int src;
int i;
struct vertex_info *vinfo = &nv20->vertex_info;
const enum interp_mode colorInterp = INTERP_LINEAR;
boolean colors[2] = { FALSE };
- boolean generics[4] = { FALSE };
+ boolean generics[12] = { FALSE };
boolean fog = FALSE;
memset(vinfo, 0, sizeof(*vinfo));
/*
- * NV10 hardware vertex attribute order:
- * fog, weight, normal, tex1, tex0, 2nd color, color, position
+ * Assumed NV20 hardware vertex attribute order:
+ * 0 position, 1 ?, 2 ?, 3 col0,
+ * 4 col1?, 5 ?, 6 ?, 7 ?,
+ * 8 ?, 9 tex0, 10 tex1, 11 tex2,
+ * 12 tex3, 13 ?, 14 ?, 15 ?
+ * unaccounted: wgh, nor, fog
+ * There are total 16 attrs.
* vinfo->hwfmt[0] has a used-bit corresponding to each of these.
* relation to TGSI_SEMANTIC_*:
* - POSITION: position (always used)
- * - COLOR: 2nd color, color
- * - GENERIC: weight, normal, tex1, tex0
+ * - COLOR: col1, col0
+ * - GENERIC: tex3, tex2, tex1, tex0, normal, weight
* - FOG: fog
*/
@@ -202,7 +207,7 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
colors[isi] = TRUE;
break;
case TGSI_SEMANTIC_GENERIC:
- assert(isi < 4);
+ assert(isi < 12);
generics[isi] = TRUE;
break;
case TGSI_SEMANTIC_FOG:
@@ -213,37 +218,65 @@ static void nv20_vertex_layout(struct nv20_context *nv20)
}
}
- if (fog) {
- int src = draw_find_vs_output(dc, TGSI_SEMANTIC_FOG, 0);
- draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << 7);
+ /* always do position */ {
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_POSITION, 0);
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src);
+ vinfo->hwfmt[0] |= (1 << 0);
}
- for (i = 3; i >= 0; i--) {
- int src;
+ /* two unnamed generics */
+ for (i = 4; i < 6; i++) {
if (!generics[i])
continue;
src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- vinfo->hwfmt[0] |= (1 << (i + 3));
+ vinfo->hwfmt[0] |= (1 << (i - 3));
}
- if (colors[1]) {
- int src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 1);
+ if (colors[0]) {
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
- vinfo->hwfmt[0] |= (1 << 2);
+ vinfo->hwfmt[0] |= (1 << 3);
}
- if (colors[0]) {
- int src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 0);
+ if (colors[1]) {
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_COLOR, 1);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
- vinfo->hwfmt[0] |= (1 << 1);
+ vinfo->hwfmt[0] |= (1 << 4);
}
- /* always do position */
- src = draw_find_vs_output(dc, TGSI_SEMANTIC_POSITION, 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR, src);
- vinfo->hwfmt[0] |= (1 << 0);
+ /* four unnamed generics */
+ for (i = 6; i < 10; i++) {
+ if (!generics[i])
+ continue;
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
+ vinfo->hwfmt[0] |= (1 << (i - 1));
+ }
+
+ /* tex0, tex1, tex2, tex3 */
+ for (i = 0; i < 4; i++) {
+ if (!generics[i])
+ continue;
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
+ vinfo->hwfmt[0] |= (1 << (i + 9));
+ }
+
+ /* two unnamed generics */
+ for (i = 10; i < 12; i++) {
+ if (!generics[i])
+ continue;
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_GENERIC, i);
+ draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
+ vinfo->hwfmt[0] |= (1 << (i + 3));
+ }
+
+ if (fog) {
+ src = draw_find_vs_output(dc, TGSI_SEMANTIC_FOG, 0);
+ draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
+ vinfo->hwfmt[0] |= (1 << 15);
+ }
draw_compute_vertex_size(vinfo);
}