svga: Flush when switching between HW to SW TNL, after updating need_swtnl.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 17 Mar 2011 16:08:21 +0000 (16:08 +0000)
committerThomas Hellstrom <thellstrom@vmware.com>
Fri, 1 Jul 2011 11:30:36 +0000 (13:30 +0200)
Also, only flush when going from HW TNL to SW TNL, given it is impossible
for the buffers resulting from SWTNL to be ever referred by HW TNL path.

src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_draw.c

index eca529d262e37aa375de49189698d1f255b1940d..34b9e85c1a3d51b57164e2be921b7c427b489f6e 100644 (file)
@@ -372,9 +372,6 @@ struct svga_context
 
    /** List of buffers with queued transfers */
    struct list_head dirty_buffers;
-
-   /** Was the previous draw done with the SW path? */
-   boolean prev_draw_swtnl;
 };
 
 /* A flag for each state_tracker state object:
index 2093bcae101c8626cedf17a17456db763e3e4a99..a632fb12c94ec220bb68d05154d297add4b073e4 100644 (file)
@@ -141,18 +141,11 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    unsigned reduced_prim = u_reduced_prim( info->mode );
    unsigned count = info->count;
    enum pipe_error ret = 0;
+   boolean needed_swtnl;
 
    if (!u_trim_pipe_prim( info->mode, &count ))
       return;
 
-   if (svga->state.sw.need_swtnl != svga->prev_draw_swtnl) {
-      /* We're switching between SW and HW drawing.  Do a flush to avoid
-       * mixing HW and SW rendering with the same vertex buffer.
-       */
-      pipe->flush(pipe, NULL);
-      svga->prev_draw_swtnl = svga->state.sw.need_swtnl;
-   }
-
    /*
     * Mark currently bound target surfaces as dirty
     * doesn't really matter if it is done before drawing.
@@ -167,6 +160,8 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       svga->dirty |= SVGA_NEW_REDUCED_PRIMITIVE;
    }
    
+   needed_swtnl = svga->state.sw.need_swtnl;
+
    svga_update_state_retry( svga, SVGA_STATE_NEED_SWTNL );
 
 #ifdef DEBUG
@@ -176,6 +171,18 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
 #endif
 
    if (svga->state.sw.need_swtnl) {
+      if (!needed_swtnl) {
+         /*
+          * We're switching from HW to SW TNL.  SW TNL will require mapping all
+          * currently bound vertex buffers, some of which may already be
+          * referenced in the current command buffer as result of previous HW
+          * TNL. So flush now, to prevent the context to flush while a referred
+          * vertex buffer is mapped.
+          */
+
+         svga_context_flush(svga, NULL);
+      }
+
       ret = svga_swtnl_draw_vbo( svga, info );
    }
    else {