r300-gallium: Always do VTE, never software viewport.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 18 May 2009 16:40:13 +0000 (09:40 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 18 May 2009 16:51:09 +0000 (09:51 -0700)
This makes glxgears draw properly with SW TCL.

src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c

index a1cdea30deeb032e8854d4da82fae8904dae1860..21c0fe2b803b97d2edf811995e604ee00a15119b 100644 (file)
@@ -145,8 +145,15 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     r300->context.is_texture_referenced = r300_is_texture_referenced;
     r300->context.is_buffer_referenced = r300_is_buffer_referenced;
 
+    /* Create a Draw. This is used for vert collation and SW TCL. */
     r300->draw = draw_create();
+    /* Enable our renderer. */
     draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));
+    /* Tell Draw that we can always do non-UCP clipping. */
+    draw_set_driver_clipping(r300->draw, TRUE);
+    /* Force Draw to never do viewport transform, since (again) we can do
+     * transform in hardware, always. */
+    draw_set_viewport_state(r300->draw, &r300_viewport_identity);
 
     r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
     r300->rs_block = CALLOC_STRUCT(r300_rs_block);
index 96f1f11246cc9af04ad64df07c14aa40d62ef70d..58f1fa0e2e4d09b75f68b36fae476565e3a41713 100644 (file)
@@ -63,6 +63,11 @@ struct r300_rs_state {
     /* Draw-specific rasterizer state */
     struct pipe_rasterizer_state rs;
 
+    /* Whether or not to enable the VTE. This is referenced at the very
+     * last moment during emission of VTE state, to decide whether or not
+     * the VTE should be used for transformation. */
+    boolean enable_vte;
+
     uint32_t vap_control_status;    /* R300_VAP_CNTL_STATUS: 0x2140 */
     uint32_t point_size;            /* R300_GA_POINT_SIZE: 0x421c */
     uint32_t point_minmax;          /* R300_GA_POINT_MINMAX: 0x4230 */
@@ -255,6 +260,11 @@ struct r300_vertex_shader {
     } instructions[128]; /*< XXX magic number */
 };
 
+static struct pipe_viewport_state r300_viewport_identity = {
+    .scale = {1.0, 1.0, 1.0, 1.0},
+    .translate = {0.0, 0.0, 0.0, 0.0},
+};
+
 struct r300_context {
     /* Parent class */
     struct pipe_context context;
index b7d1cf8a92fcbea814048ed5cee53aefa6635a4b..0cb0507fc85c1886c06b3e971831cd651b154312 100644 (file)
@@ -429,7 +429,11 @@ void r300_emit_viewport_state(struct r300_context* r300,
     OUT_CS_32F(viewport->zscale);
     OUT_CS_32F(viewport->zoffset);
 
-    OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
+    if (r300->rs_state->enable_vte) {
+        OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control);
+    } else {
+        OUT_CS_REG(R300_VAP_VTE_CNTL, 0);
+    }
     END_CS;
 }
 
index e818a776994fd7b71dbbe4a261d42e182a90000d..d7825e0e5f52aacee7948e326b226b0027ef6f34 100644 (file)
@@ -343,6 +343,8 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
     /* Copy rasterizer state for Draw. */
     rs->rs = *state;
 
+    rs->enable_vte = !state->bypass_vs_clip_and_viewport;
+
     /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL.
      * Else, enable HW TCL and force Draw's TCL off. */
     if (state->bypass_vs_clip_and_viewport ||
@@ -557,11 +559,11 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
+    //draw_flush(r300->draw);
 
-    if (r300_screen(r300->context.screen)->caps->has_tcl) {
+    if (TRUE || r300_screen(r300->context.screen)->caps->has_tcl) {
         /* Do the transform in HW. */
-        r300->viewport_state->vte_control = R300_VTX_XY_FMT | R300_VTX_Z_FMT;
+        r300->viewport_state->vte_control = R300_VTX_W0_FMT;
 
         if (state->scale[0] != 1.0f) {
             assert(state->scale[0] != 0.0f);