r300-gallium: Properly interface with Draw for vert shaders.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Apr 2009 08:00:25 +0000 (01:00 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 5 Apr 2009 08:00:25 +0000 (01:00 -0700)
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_debug.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_tcl.c

index 9d2a07a7d97702d889ae055a7ac9613fa307da35..fec2bad546182a436583df405fb36bb0a702df53 100644 (file)
@@ -236,6 +236,9 @@ struct r300_vertex_shader {
     struct pipe_shader_state state;
     struct tgsi_shader_info info;
 
+    /* Fallback shader, because Draw has issues */
+    struct draw_vertex_shader* draw;
+
     /* Has this shader been translated yet? */
     boolean translated;
 
index 8d44756c3323504bc83a631d3633dca4ffebfa84..dd63136c9d62eb4f1b5ed6613e66950bcf3e53c8 100644 (file)
@@ -224,3 +224,15 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
         }
     }
 }
+
+void r300_vs_dump(struct r300_vertex_shader* vs)
+{
+    int i;
+
+    for (i = 0; i < vs->instruction_count; i++) {
+        debug_printf("inst0: 0x%x\n", vs->instructions[i].inst0);
+        debug_printf("inst1: 0x%x\n", vs->instructions[i].inst1);
+        debug_printf("inst2: 0x%x\n", vs->instructions[i].inst2);
+        debug_printf("inst3: 0x%x\n", vs->instructions[i].inst3);
+    }
+}
index de5d701ed9cd9a9c82a0d8b17d33ae39df2d9f9a..a1f873656dcab1c0411639c4cad62f86964261d7 100644 (file)
 
 #include "r300_reg.h"
 #include "r300_state_shader.h"
+#include "r300_state_tcl.h"
 
 void r500_fs_dump(struct r500_fragment_shader* fs);
 
+void r300_vs_dump(struct r300_vertex_shader* vs);
+
 #endif /* R300_DEBUG_H */
index 4dee4ab8ce1b4da1d0d9c7e1c8cb8acb18a146dd..5b3bb328ddfe5ec5b4217bc1d8cd5306f4b372d1 100644 (file)
@@ -403,6 +403,11 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
 
     rs->rs = *state;
 
+    /* If using HW TCL, tell Draw to not do its magic. */
+    if (r300_screen(pipe->screen)->caps->has_tcl) {
+        rs->rs.bypass_vs_clip_and_viewport = TRUE;
+    }
+
     return (void*)rs;
 }
 
@@ -604,6 +609,9 @@ static void* r300_create_vs_state(struct pipe_context* pipe,
 
         tgsi_scan_shader(shader->tokens, &vs->info);
 
+        /* Appease Draw. */
+        vs->draw = draw_create_vertex_shader(r300->draw, shader);
+
         return (void*)vs;
     } else {
         return draw_create_vertex_shader(r300->draw, shader);
@@ -624,6 +632,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
             r300_translate_vertex_shader(r300, vs);
         }
 
+        draw_bind_vertex_shader(r300->draw, vs->draw);
         r300->vs = vs;
         r300->dirty_state |= R300_NEW_VERTEX_SHADER;
     } else {
@@ -637,6 +646,9 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
     struct r300_context* r300 = r300_context(pipe);
 
     if (r300_screen(pipe->screen)->caps->has_tcl) {
+        struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
+
+        draw_delete_vertex_shader(r300->draw, vs->draw);
         FREE(shader);
     } else {
         draw_delete_vertex_shader(r300->draw,
index f01db2df3a25b834b26a0cb2d452a48c105e4194..d0dc4ef11147ec96fe405befe5eaea5a671edec1 100644 (file)
@@ -267,6 +267,7 @@ void r300_translate_vertex_shader(struct r300_context* r300,
 
     tgsi_dump(vs->state.tokens);
     /* XXX finish r300 vertex shader dumper */
+    r300_vs_dump(vs);
 
     tgsi_parse_free(&parser);
     FREE(assembler);