r300-gallium: Fix vertex shader OVM counting.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 25 Apr 2009 23:53:38 +0000 (16:53 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sat, 25 Apr 2009 23:54:47 +0000 (16:54 -0700)
Attribs must be packed: position, point size, colors, texcoords.

Thanks to osiris for pointing it out.

src/gallium/drivers/r300/r300_state_tcl.c
src/gallium/drivers/r300/r300_state_tcl.h

index bb96e2ad67f58b5f351cccfc1f013f8eb6be6931..d84912de48fdefab062cfb9abd5cc31bf979fd58 100644 (file)
@@ -34,14 +34,20 @@ static void r300_vs_declare(struct r300_vs_asm* assembler,
                     assembler->tab[decl->DeclarationRange.First] = 0;
                     break;
                 case TGSI_SEMANTIC_COLOR:
-                    assembler->tab[decl->DeclarationRange.First] = 2;
+                    assembler->tab[decl->DeclarationRange.First] =
+                        (assembler->point_size ? 1 : 0) +
+                        assembler->out_colors;
                     break;
+                case TGSI_SEMANTIC_FOG:
                 case TGSI_SEMANTIC_GENERIC:
                     /* XXX multiple? */
-                    assembler->tab[decl->DeclarationRange.First] = 6;
+                    assembler->tab[decl->DeclarationRange.First] =
+                        (assembler->point_size ? 1 : 0) +
+                        assembler->out_colors +
+                        assembler->out_texcoords;
                     break;
                 case TGSI_SEMANTIC_PSIZE:
-                    assembler->tab[decl->DeclarationRange.First] = 15;
+                    assembler->tab[decl->DeclarationRange.First] = 1;
                     break;
                 default:
                     debug_printf("r300: vs: Bad semantic declaration %d\n",
@@ -252,6 +258,28 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs,
     }
 }
 
+static void r300_vs_init(struct r300_vertex_shader* vs,
+                         struct r300_vs_asm* assembler)
+{
+    struct tgsi_shader_info* info = &vs->info;
+    int i;
+
+    for (i = 0; i < info->num_outputs; i++) {
+        switch (info->output_semantic_name[i]) {
+            case TGSI_SEMANTIC_PSIZE:
+                assembler->point_size = TRUE;
+                break;
+            case TGSI_SEMANTIC_COLOR:
+                assembler->out_colors++;
+                break;
+            case TGSI_SEMANTIC_FOG:
+            case TGSI_SEMANTIC_GENERIC:
+                assembler->out_texcoords++;
+                break;
+        }
+    }
+}
+
 void r300_translate_vertex_shader(struct r300_context* r300,
                                   struct r300_vertex_shader* vs)
 {
@@ -264,6 +292,10 @@ void r300_translate_vertex_shader(struct r300_context* r300,
     if (assembler == NULL) {
         return;
     }
+
+    /* Init assembler. */
+    r300_vs_init(vs, assembler);
+
     /* Setup starting offset for immediates. */
     assembler->imm_offset = consts->user_count;
 
index de944028baa6cdac6105041f7e25e972a6a2b21b..e2e1357d4360225ba190476195462078f652f605 100644 (file)
@@ -99,7 +99,13 @@ struct r300_vs_asm {
     unsigned imm_offset;
     /* Number of immediate constants. */
     unsigned imm_count;
-    /* Offsets into vertex output memory. */
+    /* Number of colors to write. */
+    unsigned out_colors;
+    /* Number of texcoords to write. */
+    unsigned out_texcoords;
+    /* Whether to emit point size. */
+    boolean point_size;
+    /* Tab of declared outputs to OVM outputs. */
     unsigned tab[16];
 };
 
@@ -115,7 +121,7 @@ static struct r300_vertex_shader r300_passthrough_vertex_shader = {
     .instructions[0].inst3 = 0x0,
     .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) |
         R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
-        R300_PVS_DST_OFFSET(2) | R300_PVS_DST_WE_XYZW,
+        R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW,
     .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
         R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW,
     .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO,
@@ -134,7 +140,7 @@ static struct r300_vertex_shader r300_texture_vertex_shader = {
     .instructions[0].inst3 = 0x0,
     .instructions[1].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) |
         R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) |
-        R300_PVS_DST_OFFSET(6) | R300_PVS_DST_WE_XYZW,
+        R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW,
     .instructions[1].inst1 = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) |
         R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW,
     .instructions[1].inst2 = R300_PVS_SRC_SWIZZLE_ZERO,