OSDN Git Service

r300-gallium: Prevent assert when fogcoords are present.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 22:02:45 +0000 (15:02 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 20 May 2009 23:05:11 +0000 (16:05 -0700)
Seems like this file is the source of all bad logic. (Pun intended.)

src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_state_shader.c

index caa5f3b..7ae339c 100644 (file)
@@ -64,6 +64,7 @@ static void r300_vs_tab_routes(struct r300_context* r300,
                     break;
                 case TGSI_SEMANTIC_FOG:
                     fog = TRUE;
+                    /* Fall through */
                 case TGSI_SEMANTIC_GENERIC:
                     texs++;
                     break;
@@ -103,6 +104,9 @@ static void r300_vs_tab_routes(struct r300_context* r300,
         }
     }
 
+    /* XXX magic */
+    assert(texs <= 8);
+
     /* Do the actual vertex_info setup.
      *
      * vertex_info has four uints of hardware-specific data in it.
@@ -140,17 +144,21 @@ static void r300_vs_tab_routes(struct r300_context* r300,
         vinfo->hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
     }
 
-    for (i = 0; i < texs; i++) {
+    /* Init i right here, increment it if fog is enabled.
+     * This gets around a double-increment problem. */
+    i = 0;
+
+    if (fog) {
+        i++;
         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
+            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
         vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
         vinfo->hwfmt[3] |= (4 << (3 * i));
     }
 
-    if (fog) {
-        i++;
+    for (i; i < texs; i++) {
         draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
-            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
+            draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
         vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
         vinfo->hwfmt[3] |= (4 << (3 * i));
     }
index f27d723..d087771 100644 (file)
@@ -31,6 +31,7 @@ static void r300_fs_declare(struct r300_fs_asm* assembler,
                 case TGSI_SEMANTIC_COLOR:
                     assembler->color_count++;
                     break;
+                case TGSI_SEMANTIC_FOG:
                 case TGSI_SEMANTIC_GENERIC:
                     assembler->tex_count++;
                     break;