[Mesa-dev] [PATCH] i965: Use software primitive restart when transform feedback active.

Paul Berry stereotype441 at gmail.com
Sat Apr 6 20:25:07 PDT 2013


When transform feedback is active, the driver manually counts the
number of primitives that run through the pipeline, so that if a batch
buffer flush happens, the next batch buffer can pick up transform
feedback where the last batch buffer left off.  Hardware-accelerated
primitive restart interferes with this process (because it makes the
primitive count depend not just on the number of vertices entering the
pipeline, but also on the contents of the index buffer).  So, when
transform feedback is active, we need to fall back to the software
implementation of primitive restart.

Fixes piglit test "spec/!OpenGL 3.1/primitive-restart-xfb flush".

NOTE: This is a candidate for stable release branches.
---
 src/mesa/drivers/dri/i965/brw_primitive_restart.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
index e6902b4..d0f0038 100644
--- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c
+++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
@@ -27,6 +27,7 @@
 
 #include "main/imports.h"
 #include "main/bufferobj.h"
+#include "main/transformfeedback.h"
 
 #include "brw_context.h"
 #include "brw_defines.h"
@@ -81,11 +82,18 @@ can_cut_index_handle_prims(struct gl_context *ctx,
    struct brw_context *brw = brw_context(ctx);
 
    if (brw->sol.counting_primitives_generated ||
-       brw->sol.counting_primitives_written) {
+       brw->sol.counting_primitives_written ||
+       _mesa_is_xfb_active_and_unpaused(ctx)) {
       /* Counting primitives generated in hardware is not currently
        * supported, so take the software path. We need to investigate
        * the *_PRIMITIVES_COUNT registers to allow this to be handled
        * entirely in hardware.
+       *
+       * Note that when transform feedback is active, we also count primitives
+       * (even if the client hasn't requested it), since that is the only way
+       * we can start at the proper place in the transform feedback buffer
+       * after a flush.  So we also have to fall back to software when
+       * transform feedback is active and unpaused.
        */
       return false;
    }
-- 
1.8.2



More information about the mesa-dev mailing list