49 const uint loose_start = mr.corners_num;
50 if (visible.size() == mr.loose_edges.size()) {
51 array_utils::fill_index_range(data.cast<uint>(), loose_start);
54 visible.foreach_index_optimized<int>(
55 [&](const int i, const int pos) {
56 data[pos] = loose_start + uint2(i * 2 + 0, i * 2 + 1);
73 visible, memory, [&](
const int i) {
return !hide_edge[loose_edges[i]]; });
93 no_loose_wire = visible_loose_edges.
is_empty();
95 if (lines_loose && !lines) {
110 visible_non_loose_edges.
size() + visible_loose_edges.
size(),
129 threading::parallel_for(faces.index_range(), 2048, [&](const IndexRange range) {
130 for (const int face_index : range) {
131 const IndexRange face = faces[face_index];
132 for (const int corner : face) {
133 const int edge = corner_edges[corner];
136 data[edge] = edge_from_corners(face, corner);
146 map.as_span().size_in_bytes() +
data.size_in_bytes() + corner_edges.size_in_bytes(),
148 index_mask::build_reverse_map(visible_non_loose_edges, map.as_mutable_span());
149 threading::parallel_for(faces.index_range(), 2048, [&](const IndexRange range) {
150 for (const int face_index : range) {
151 const IndexRange face = faces[face_index];
152 for (const int corner : face) {
153 const int edge = corner_edges[corner];
154 const int vbo_index = map[edge];
155 if (vbo_index != -1) {
157 data[vbo_index] = edge_from_corners(face, corner);
170 lines->get(), visible_non_loose_edges.size() * 2, visible_loose_edges.size() * 2));
185 loose_edges.
index_range(), memory, [&](
const int i) {
186 const BMEdge &edge = *BM_edge_at_index(&const_cast<BMesh &>(bm), loose_edges[i]);
187 return !BM_elem_flag_test_bool(&edge, BM_ELEM_HIDDEN);
191 no_loose_wire = visible_loose_edges.
is_empty();
193 if (lines_loose && !lines) {
204 non_loose_edges, memory, [&](
const int i) {
212 visible_non_loose_edges.
size() + visible_loose_edges.
size(),
219 [&](
const int i,
const int pos) {
230 lines->get(), visible_non_loose_edges.
size() * 2, visible_loose_edges.
size() * 2));
249 const int edge_loose_offset,
262 gpu::VertAttrType::UINT_32);
274 if (orig_index_edge ==
nullptr) {
278 const bool value = hide_edge[loose_edges[i]];
279 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
291 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
298 const bool value = (orig_index_edge[loose_edges[i]] ==
ORIGINDEX_NONE) ?
300 hide_edge[loose_edges[i]];
301 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
316 flags_data.
slice(i * edges_per_edge, edges_per_edge).
fill(value);
323 subdiv_cache, ibo, flags,
uint(edge_loose_offset), loose_edges_num);
335 no_loose_wire = loose_ibo_size == 0;
337 if (lines_loose && !lines) {
346 if (non_loose_ibo_size > 0) {
#define GPU_vertbuf_init_with_format(verts, format)
#define BM_elem_index_get(ele)
#define BM_elem_flag_test_bool(ele, hflag)
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
IndexRange index_range() const
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
static IndexMask from_bits(BitSpan bits, LinearAllocator<> &memory)
static IndexMask from_bools_inverse(Span< bool > bools, LinearAllocator<> &memory)
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr void fill(const T &value) const
constexpr int64_t size_in_bytes() const
constexpr bool is_empty() const
constexpr bool is_empty() const
void to_indices(MutableSpan< T > r_indices) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexMask complement(const IndexMask &universe, LinearAllocator<> &memory) const
IndexMask indices_non_negative(const IndexMask &universe, Span< int > values, LinearAllocator<> &memory)
static void fill_loose_lines_ibo(const MeshRenderData &mr, const IndexMask &visible, MutableSpan< uint2 > data)
static void extract_lines_bm(const MeshRenderData &mr, gpu::IndexBufPtr *lines, gpu::IndexBufPtr *lines_loose, bool &no_loose_wire)
int subdiv_loose_edges_num(const MeshRenderData &mr, const DRWSubdivCache &cache)
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 IndexMask calc_visible_loose_edge_indices(const MeshRenderData &mr, IndexMaskMemory &memory)
void draw_subdiv_build_lines_buffer(const DRWSubdivCache &cache, gpu::IndexBuf *lines_indices)
void extract_lines(const MeshRenderData &mr, gpu::IndexBufPtr *lines, gpu::IndexBufPtr *lines_loose, bool &no_loose_wire)
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)
static void extract_lines_mesh(const MeshRenderData &mr, gpu::IndexBufPtr *lines, gpu::IndexBufPtr *lines_loose, bool &no_loose_wire)
void extract_lines_subdiv(const DRWSubdivCache &subdiv_cache, const MeshRenderData &mr, gpu::IndexBufPtr *lines, gpu::IndexBufPtr *lines_loose, bool &no_loose_wire)
constexpr ParallelGrainSize grain_size(int grain_size)
std::unique_ptr< IndexBuf, IndexBufDeleter > IndexBufPtr
void memory_bandwidth_bound_task(const int64_t approximate_bytes_touched, const Function &function)
VecBase< uint32_t, 2 > uint2
gpu::IndexBuf * GPU_indexbuf_build_on_device(uint index_len)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
BLI_INLINE BMEdge * BM_edge_at_index(BMesh *bm, const int index)
GPUVertFormat GPU_vertformat_from_attribute(StringRef name, gpu::VertAttrType type)
BMesh const char void * data
gpu::VertBuf * GPU_vertbuf_calloc()
MutableSpan< uint32_t > GPU_indexbuf_get_data(GPUIndexBufBuilder *)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
gpu::IndexBuf * GPU_indexbuf_build_ex(GPUIndexBufBuilder *builder, uint index_min, uint index_max, bool uses_restart_indices)
gpu::IndexBuf * GPU_indexbuf_create_subrange(gpu::IndexBuf *elem_src, uint start, uint length)
void GPU_vertbuf_discard(gpu::VertBuf *)
PipelineCompute lines(lines_main)
PipelineCompute lines_loose(lines_loose_main)
bke::MeshRuntime * runtime
BitVector subsurf_optimal_display_edges
VArraySpan< bool > hide_edge
MeshExtractType extract_type
const int * orig_index_edge
OffsetIndices< int > faces