r300-gallium: vs: Use a tab to properly set up OVM.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Apr 2009 08:32:55 +0000 (01:32 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Apr 2009 08:32:55 +0000 (01:32 -0700)
src/gallium/drivers/r300/r300_state_tcl.c
src/gallium/drivers/r300/r300_state_tcl.h

index d0dc4ef11147ec96fe405befe5eaea5a671edec1..a00abfd02fddb7bc00506b3f517f0c0f081a1060 100644 (file)
@@ -27,12 +27,18 @@ static void r300_vs_declare(struct r300_vs_asm* assembler,
 {
     switch (decl->Declaration.File) {
         case TGSI_FILE_INPUT:
+            break;
+        case TGSI_FILE_OUTPUT:
             switch (decl->Semantic.SemanticName) {
+                case TGSI_SEMANTIC_POSITION:
+                    assembler->tab[decl->DeclarationRange.First] = 0;
+                    break;
                 case TGSI_SEMANTIC_COLOR:
-                    assembler->color_count++;
+                    assembler->tab[decl->DeclarationRange.First] = 2;
                     break;
                 case TGSI_SEMANTIC_GENERIC:
-                    assembler->tex_count++;
+                    /* XXX multiple? */
+                    assembler->tab[decl->DeclarationRange.First] = 6;
                     break;
                 default:
                     debug_printf("r300: vs: Bad semantic declaration %d\n",
@@ -40,7 +46,6 @@ static void r300_vs_declare(struct r300_vs_asm* assembler,
                     break;
             }
             break;
-        case TGSI_FILE_OUTPUT:
         case TGSI_FILE_CONSTANT:
             break;
         case TGSI_FILE_TEMPORARY:
@@ -50,8 +55,6 @@ static void r300_vs_declare(struct r300_vs_asm* assembler,
             debug_printf("r300: vs: Bad file %d\n", decl->Declaration.File);
             break;
     }
-
-    assembler->temp_offset = assembler->color_count + assembler->tex_count;
 }
 
 static INLINE unsigned r300_vs_src_type(struct r300_vs_asm* assembler,
@@ -88,46 +91,15 @@ static INLINE unsigned r300_vs_dst_type(struct r300_vs_asm* assembler,
     return 0;
 }
 
-static INLINE unsigned r300_vs_src(struct r300_vs_asm* assembler,
-                                   struct tgsi_src_register* src)
-{
-    switch (src->File) {
-        case TGSI_FILE_NULL:
-            return 0;
-        case TGSI_FILE_INPUT:
-            /* XXX may be wrong */
-            return src->Index;
-            break;
-        case TGSI_FILE_TEMPORARY:
-            return src->Index + assembler->temp_offset;
-            break;
-        case TGSI_FILE_IMMEDIATE:
-            return (src->Index + assembler->imm_offset) | (1 << 8);
-            break;
-        case TGSI_FILE_CONSTANT:
-            /* XXX magic */
-            return src->Index | (1 << 8);
-            break;
-        default:
-            debug_printf("r300: vs: Unimplemented src %d\n", src->File);
-            break;
-    }
-    return 0;
-}
-
 static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler,
                                    struct tgsi_dst_register* dst)
 {
     switch (dst->File) {
-        case TGSI_FILE_NULL:
-            /* This happens during KIL instructions. */
-            return 0;
+        case TGSI_FILE_TEMPORARY:
+            return dst->Index;
             break;
         case TGSI_FILE_OUTPUT:
-            return 0;
-            break;
-        case TGSI_FILE_TEMPORARY:
-            return dst->Index + assembler->temp_offset;
+            return assembler->tab[dst->Index];
             break;
         default:
             debug_printf("r300: vs: Unimplemented dst %d\n", dst->File);
@@ -161,7 +133,7 @@ static void r300_vs_emit_inst(struct r300_vertex_shader* vs,
     int i = vs->instruction_count;
     vs->instructions[i].inst0 = R300_PVS_DST_OPCODE(R300_VE_ADD) |
         R300_PVS_DST_REG_TYPE(r300_vs_dst_type(assembler, &dst->DstRegister)) |
-        R300_PVS_DST_OFFSET(dst->DstRegister.Index);
+        R300_PVS_DST_OFFSET(r300_vs_dst(assembler, &dst->DstRegister));
     switch (count) {
         case 3:
             vs->instructions[i].inst3 =
@@ -265,6 +237,9 @@ void r300_translate_vertex_shader(struct r300_context* r300,
             "%d from user and %d from immediates\n", consts->count,
             consts->user_count, assembler->imm_count);
 
+    debug_printf("r300: vs: tab: %d %d %d %d\n", assembler->tab[0],
+            assembler->tab[1], assembler->tab[2], assembler->tab[3]);
+
     tgsi_dump(vs->state.tokens);
     /* XXX finish r300 vertex shader dumper */
     r300_vs_dump(vs);
index ae8ff6c3147584da4a8308ecd8711a6b0414dd87..75fe44aec50e13093fc81ef59eedf1a4d7b76342 100644 (file)
@@ -87,10 +87,6 @@ struct r300_vs_asm {
     unsigned color_count;
     /* Number of texcoords. */
     unsigned tex_count;
-    /* Offset for temporary registers. Inputs and temporaries have no
-     * distinguishing markings, so inputs start at 0 and the first usable
-     * temporary register is after all inputs. */
-    unsigned temp_offset;
     /* Number of requested temporary registers. */
     unsigned temp_count;
     /* Offset for immediate constants. Neither R300 nor R500 can do four
@@ -99,6 +95,8 @@ struct r300_vs_asm {
     unsigned imm_offset;
     /* Number of immediate constants. */
     unsigned imm_count;
+    /* Offsets into vertex output memory. */
+    unsigned tab[16];
 };
 
 static struct r300_vertex_shader r300_passthrough_vertex_shader = {