[Mesa-dev] [PATCH] i965 Gen6+: De-compact clip plane constants for old VS backend.

Paul Berry stereotype441 at gmail.com
Mon Oct 10 15:13:13 PDT 2011


In commit 018ea68d8780ab5baeef0b8122b8410e5e55ae6d, when I
de-compacted clip planes on Gen6+, I updated both the old and new VS
back-ends to reflect the change in how clip planes are stored, but I
failed to change the code in gen6_vs_state.c that uploads clip plane
constants when using the old VS back-end.

As a result, if the set of enabled clip planes wasn't contiguous
starting with 0, then clipping would not occur properly.  This patch
corrects gen6_vs_state.c to upload clip plane constants in the new
de-compacted form.

This only affects the old VS back-end (which is used for
fixed-function and ARB vertex programs, not for GLSL vertex shaders).

Fixes Piglit test fixed-clip-enables.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41603
---
 src/mesa/drivers/dri/i965/gen6_vs_state.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
index 14a96fc..1c57a3b 100644
--- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
@@ -76,15 +76,14 @@ gen6_prepare_vs_push_constants(struct brw_context *brw)
          /* This should be loaded like any other param, but it's ad-hoc
           * until we redo the VS backend.
           */
-         if (!uses_clip_distance) {
+         if (ctx->Transform.ClipPlanesEnabled != 0 && !uses_clip_distance) {
             gl_clip_plane *clip_planes = brw_select_clip_planes(ctx);
-            for (i = 0; i < MAX_CLIP_PLANES; i++) {
-               if (ctx->Transform.ClipPlanesEnabled & (1 << i)) {
-                  memcpy(param, clip_planes[i], 4 * sizeof(float));
-                  param += 4;
-                  params_uploaded++;
-               }
-            }
+            int num_userclip_plane_consts
+               = _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
+            int num_floats = 4 * num_userclip_plane_consts;
+            memcpy(param, clip_planes, num_floats * sizeof(float));
+            param += num_floats;
+            params_uploaded += num_userclip_plane_consts;
          }
 
          /* Align to a reg for convenience for brw_vs_emit.c */
-- 
1.7.6.4



More information about the mesa-dev mailing list