[Mesa-dev] [PATCH 1/9] svga: Flush when switching between HW to SW TNL, after updating need_swtnl.

Thomas Hellstrom thellstrom at vmware.com
Thu Jun 30 00:29:29 PDT 2011


From: José Fonseca <jfonseca at vmware.com>

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   |    3 ---
 src/gallium/drivers/svga/svga_pipe_draw.c |   23 +++++++++++++++--------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index eca529d..34b9e85 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -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:
diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c
index 2093bca..a632fb1 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -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 {
-- 
1.6.2.5



More information about the mesa-dev mailing list