From ce7963f338ab95b06619074bc6aaf99c96ff5f11 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 5 Apr 2009 01:00:25 -0700 Subject: [PATCH] r300-gallium: Properly interface with Draw for vert shaders. --- src/gallium/drivers/r300/r300_context.h | 3 +++ src/gallium/drivers/r300/r300_debug.c | 12 ++++++++++++ src/gallium/drivers/r300/r300_debug.h | 3 +++ src/gallium/drivers/r300/r300_state.c | 12 ++++++++++++ src/gallium/drivers/r300/r300_state_tcl.c | 1 + 5 files changed, 31 insertions(+) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 9d2a07a7d97..fec2bad5461 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -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; diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 8d44756c332..dd63136c9d6 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -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); + } +} diff --git a/src/gallium/drivers/r300/r300_debug.h b/src/gallium/drivers/r300/r300_debug.h index de5d701ed9c..a1f873656dc 100644 --- a/src/gallium/drivers/r300/r300_debug.h +++ b/src/gallium/drivers/r300/r300_debug.h @@ -25,7 +25,10 @@ #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 */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 4dee4ab8ce1..5b3bb328ddf 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -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, diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index f01db2df3a2..d0dc4ef1114 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -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); -- 2.30.2