[Mesa-dev] [PATCH] draw/llvm: skip clipping and viewport transform if there's no position output

sroland at vmware.com sroland at vmware.com
Fri Mar 1 05:54:13 PST 2013


From: Roland Scheidegger <sroland at vmware.com>

With glsl 1.40 writing position is not required (useful for transform
feedback, though in fact it's still possible to rasterize such geometry
even if the results aren't too well defined).
Prevents crashes in that case. Fixes piglit glsl-1.40-tf-no-position.
Not quite sure this is 100% correct as it also skips clipdistance
clipping which could still work (but not sure if the result would
really be needed?)
---
 src/gallium/auxiliary/draw/draw_llvm.c |   57 +++++++++++++++++---------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 8e46687..763158b 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1349,36 +1349,41 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
                   sampler,
                   variant->key.clamp_vertex_color);
 
-      /* store original positions in clip before further manipulation */
-      store_clip(gallivm, vs_type, io, outputs, 0, cv);
-      store_clip(gallivm, vs_type, io, outputs, 1, pos);
-
-      /* do cliptest */
-      if (enable_cliptest) {
-         LLVMValueRef temp = LLVMBuildLoad(builder, clipmask_bool_ptr, "");
-         /* allocate clipmask, assign it integer type */
-         clipmask = generate_clipmask(llvm,
-                                      gallivm,
-                                      vs_type,
-                                      outputs,
-                                      variant->key.clip_xy,
-                                      variant->key.clip_z, 
-                                      variant->key.clip_user,
-                                      variant->key.clip_halfz,
-                                      variant->key.ucp_enable,
-                                      context_ptr, &have_clipdist);
-         temp = LLVMBuildOr(builder, clipmask, temp, "");
-         /* store temporary clipping boolean value */
-         LLVMBuildStore(builder, temp, clipmask_bool_ptr);
+      if (pos != -1) {
+         /* store original positions in clip before further manipulation */
+         store_clip(gallivm, vs_type, io, outputs, 0, cv);
+         store_clip(gallivm, vs_type, io, outputs, 1, pos);
+
+         /* do cliptest */
+         if (enable_cliptest) {
+            LLVMValueRef temp = LLVMBuildLoad(builder, clipmask_bool_ptr, "");
+            /* allocate clipmask, assign it integer type */
+            clipmask = generate_clipmask(llvm,
+                                         gallivm,
+                                         vs_type,
+                                         outputs,
+                                         variant->key.clip_xy,
+                                         variant->key.clip_z,
+                                         variant->key.clip_user,
+                                         variant->key.clip_halfz,
+                                         variant->key.ucp_enable,
+                                         context_ptr, &have_clipdist);
+            temp = LLVMBuildOr(builder, clipmask, temp, "");
+            /* store temporary clipping boolean value */
+            LLVMBuildStore(builder, temp, clipmask_bool_ptr);
+         }
+         else {
+            clipmask = lp_build_const_int_vec(gallivm, lp_int_type(vs_type), 0);
+         }
+
+         /* do viewport mapping */
+         if (!bypass_viewport) {
+            generate_viewport(variant, builder, vs_type, outputs, context_ptr);
+         }
       }
       else {
          clipmask = lp_build_const_int_vec(gallivm, lp_int_type(vs_type), 0);
       }
-      
-      /* do viewport mapping */
-      if (!bypass_viewport) {
-         generate_viewport(variant, builder, vs_type, outputs, context_ptr);
-      }
 
       /* store clipmask in vertex header, 
        * original positions in clip 
-- 
1.7.9.5



More information about the mesa-dev mailing list