draw: don't emit vertex to streams with no outputs
authorDave Airlie <airlied@redhat.com>
Thu, 23 Jan 2020 07:17:21 +0000 (17:17 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Feb 2020 00:54:42 +0000 (00:54 +0000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3530>

src/gallium/auxiliary/draw/draw_llvm.c

index 0960124bafec27ce1b1727ee30fd4c02aa574b1a..0701082850f2b6821721bd202a9c56cb2fb61f8a 100644 (file)
@@ -1557,12 +1557,17 @@ draw_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
       indices[i] = LLVMBuildAdd(builder, indices[i], currently_emitted, "");
    }
 
+   LLVMValueRef stream_idx = LLVMBuildExtractElement(builder, stream_id, lp_build_const_int32(gallivm, 0), "");
+   LLVMValueRef cnd = LLVMBuildICmp(builder, LLVMIntULT, stream_idx, lp_build_const_int32(gallivm, variant->shader->base.num_vertex_streams), "");
+   struct lp_build_if_state if_ctx;
+   lp_build_if(&if_ctx, gallivm, cnd);
    io = lp_build_pointer_get(builder, io, LLVMBuildExtractElement(builder, stream_id, lp_build_const_int32(gallivm, 0), ""));
 
    convert_to_aos(gallivm, io, indices,
                   outputs, clipmask,
                   gs_info->num_outputs, gs_type,
                   FALSE);
+   lp_build_endif(&if_ctx);
 }
 
 static void