[Mesa-dev] [PATCH 2/7] i965: Fix transform feedback of gl_ClipVertex.

Paul Berry stereotype441 at gmail.com
Thu Dec 29 09:16:23 PST 2011


Previously, on i965 Gen6 and above, we weren't allocating space for
gl_ClipVertex in the VUE, since the VS was automatically converting it
to clip distances.  This prevented transform feedback from being able
to capture gl_ClipVertex.

This patch goes aheads and allocates space for gl_ClipVertex in the
VUE on Gen6 and above.  The old behavior is retained on Gen5 and
below, since (a) transform feedback is not yet supported on those
platforms, and (b) those platforms don't currently support
gl_ClipVertex anyhow.

Note: this constitutes a slight waste of VUE space for shaders that
use gl_ClipVertex and don't use transform feedback to capture it.
However, that seems preferable to making the VUE map (and all of the
state that depends on it) dependent on transform feedback settings.

Fixes Piglit test "EXT_transform_feedback/builtin-varyings
gl_ClipVertex".
---
 src/mesa/drivers/dri/i965/brw_vs.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 6eec973..2f17900 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -139,14 +139,17 @@ brw_compute_vue_map(struct brw_vue_map *vue_map,
     * assign them contiguously.  Don't reassign outputs that already have a
     * slot.
     *
-    * Also, don't assign a slot for VERT_RESULT_CLIP_VERTEX, since it is
-    * unsupported in pre-GEN6, and in GEN6+ the vertex shader converts it into
-    * clip distances.
+    * Also, prior to Gen6, don't assign a slot for VERT_RESULT_CLIP_VERTEX,
+    * since it is unsupported.  In Gen6 and above, VERT_RESULT_CLIP_VERTEX may
+    * be needed for transform feedback; since we don't want to have to
+    * recompute the VUE map (and everything that depends on it) when transform
+    * feedback is enabled or disabled, just go ahead and assign a slot for it.
     */
    for (int i = 0; i < VERT_RESULT_MAX; ++i) {
+      if (intel->gen < 6 && i == VERT_RESULT_CLIP_VERTEX)
+         continue;
       if ((outputs_written & BITFIELD64_BIT(i)) &&
-          vue_map->vert_result_to_slot[i] == -1 &&
-          i != VERT_RESULT_CLIP_VERTEX) {
+          vue_map->vert_result_to_slot[i] == -1) {
          assign_vue_slot(vue_map, i);
       }
    }
-- 
1.7.6.4



More information about the mesa-dev mailing list