25 if (!mr.
mesh->
runtime->subsurf_optimal_display_edges.is_empty()) {
46 return uint2(corner, corner_next);
58 const uint loose_start = mr.corners_num;
59 if (visible.size() == mr.loose_edges.size()) {
60 array_utils::fill_index_range(data.cast<uint>(), loose_start);
63 visible.foreach_index_optimized<int>(GrainSize(4096), [&](const int i, const int pos) {
64 data[pos] = loose_start + uint2(i * 2 + 0, i * 2 + 1);
76 visible = IndexMask::from_predicate(
77 visible,
GrainSize(4096), memory, [&](
const int i) {
return !hide_edge[loose_edges[i]]; });
81 visible = IndexMask::from_predicate(visible,
GrainSize(4096), memory, [&](
const int64_t i) {
97 no_loose_wire = visible_loose_edges.
is_empty();
115 visible_non_loose_edges.
size() + visible_loose_edges.
size(),
131 threading::memory_bandwidth_bound_task(
132 used.as_span().size_in_bytes() + data.size_in_bytes() + corner_edges.
size_in_bytes(),
134 threading::parallel_for(faces.index_range(), 2048, [&](const IndexRange range) {
135 for (const int face_index : range) {
136 const IndexRange face = faces[face_index];
137 for (const int corner : face) {
138 const int edge = corner_edges[corner];
141 data[edge] = edge_from_corners(face, corner);
150 threading::memory_bandwidth_bound_task(
151 map.as_span().size_in_bytes() + data.size_in_bytes() + corner_edges.size_in_bytes(),
153 index_mask::build_reverse_map(visible_non_loose_edges, map.as_mutable_span());
154 threading::parallel_for(faces.index_range(), 2048, [&](const IndexRange range) {
155 for (const int face_index : range) {
156 const IndexRange face = faces[face_index];
157 for (const int corner : face) {
158 const int edge = corner_edges[corner];
159 const int vbo_index = map[edge];
160 if (vbo_index != -1) {
162 data[vbo_index] = edge_from_corners(face, corner);
175 lines_loose, lines, visible_non_loose_edges.size() * 2, visible_loose_edges.size() * 2);
188 const IndexMask visible_loose_edges = IndexMask::from_predicate(
195 no_loose_wire = visible_loose_edges.
is_empty();
208 const IndexMask visible_non_loose_edges = IndexMask::from_predicate(
209 non_loose_edges,
GrainSize(2048), memory, [&](
const int i) {
217 visible_non_loose_edges.
size() + visible_loose_edges.
size(),
233 lines_loose, lines, visible_non_loose_edges.
size() * 2, visible_loose_edges.
size() * 2);
252 const int edge_loose_offset,
264 if (
format.attr_len == 0) {
278 if (orig_index_edge ==
nullptr) {
282 const bool value = hide_edge[loose_edges[i]];
283 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
295 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
302 const bool value = (orig_index_edge[loose_edges[i]] ==
ORIGINDEX_NONE) ?
304 hide_edge[loose_edges[i]];
305 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
320 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
327 subdiv_cache, ibo, flags,
uint(edge_loose_offset), loose_edges_num);
339 no_loose_wire = loose_ibo_size == 0;
350 if (non_loose_ibo_size > 0) {
void GPU_indexbuf_build_in_place_ex(GPUIndexBufBuilder *builder, uint index_min, uint index_max, bool uses_restart_indices, blender::gpu::IndexBuf *elem)
blender::MutableSpan< uint32_t > GPU_indexbuf_get_data(GPUIndexBufBuilder *)
void GPU_indexbuf_create_subrange_in_place(blender::gpu::IndexBuf *elem, blender::gpu::IndexBuf *elem_src, uint start, uint length)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_init_build_on_device(blender::gpu::IndexBuf *elem, uint index_len)
#define GPU_vertbuf_init_with_format(verts, format)
blender::gpu::VertBuf * GPU_vertbuf_calloc()
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_discard(blender::gpu::VertBuf *)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test_bool(ele, hflag)
ATTR_WARN_UNUSED_RESULT BMesh * bm
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr MutableSpan< NewT > cast() const
constexpr void fill(const T &value) const
constexpr int64_t size_in_bytes() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
static IndexMask from_bools_inverse(const IndexMask &universe, Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_bits(BitSpan bits, IndexMaskMemory &memory)
IndexMask complement(const IndexMask &universe, IndexMaskMemory &memory) const
void foreach_index(Fn &&fn) const
bool DRW_ibo_requested(blender::gpu::IndexBuf *ibo)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
int face_corner_next(const IndexRange face, const int corner)
static void extract_lines_mesh(const MeshRenderData &mr, gpu::IndexBuf *lines, gpu::IndexBuf *lines_loose, bool &no_loose_wire)
static void fill_loose_lines_ibo(const MeshRenderData &mr, const IndexMask &visible, MutableSpan< uint2 > data)
int subdiv_loose_edges_num(const MeshRenderData &mr, const DRWSubdivCache &cache)
static uint2 edge_from_corners(const IndexRange face, const int corner)
static IndexMask calc_mesh_edge_visibility(const MeshRenderData &mr, const IndexMask &mask, IndexMaskMemory &memory)
static void extract_lines_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache, const MeshRenderData &mr, const int edge_loose_offset, gpu::IndexBuf *ibo)
BLI_INLINE BMEdge * bm_original_edge_get(const MeshRenderData &mr, int idx)
int subdiv_edges_per_coarse_edge(const DRWSubdivCache &cache)
static void extract_lines_bm(const MeshRenderData &mr, gpu::IndexBuf *lines, gpu::IndexBuf *lines_loose, bool &no_loose_wire)
static IndexMask calc_visible_loose_edge_indices(const MeshRenderData &mr, IndexMaskMemory &memory)
void extract_lines(const MeshRenderData &mr, gpu::IndexBuf *lines, gpu::IndexBuf *lines_loose, bool &no_loose_wire)
void draw_subdiv_build_lines_buffer(const DRWSubdivCache &cache, gpu::IndexBuf *lines_indices)
void draw_subdiv_build_lines_loose_buffer(const DRWSubdivCache &cache, gpu::IndexBuf *lines_indices, gpu::VertBuf *lines_flags, uint edge_loose_offset, uint num_loose_edges)
void extract_lines_subdiv(const DRWSubdivCache &subdiv_cache, const MeshRenderData &mr, gpu::IndexBuf *lines, gpu::IndexBuf *lines_loose, bool &no_loose_wire)
void memory_bandwidth_bound_task(const int64_t approximate_bytes_touched, const Function &function)
VecBase< uint32_t, 2 > uint2
MeshRuntimeHandle * runtime
VArraySpan< bool > hide_edge
eMRExtractType extract_type
const int * orig_index_edge
OffsetIndices< int > faces