Blender V5.3
extract_mesh_vbo_fdots_edituv_data.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "extract_mesh.hh"
10
11#include "draw_cache_impl.hh"
12
13namespace blender::draw {
14
16{
17 static const GPUVertFormat format = []() {
18 GPUVertFormat format{};
19 GPU_vertformat_attr_add(&format, "data", gpu::VertAttrType::UINT_8_8_8_8);
20 GPU_vertformat_alias_add(&format, "flag");
21 return format;
22 }();
23 gpu::VertBufPtr vbo = gpu::VertBufPtr(GPU_vertbuf_create_with_format(format));
25 MutableSpan vbo_data = vbo->data<EditLoopData>();
26 const BMesh &bm = *mr.bm;
27 const BMUVOffsets offsets = BM_uv_map_offsets_get(&bm);
29 threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
30 for (const int face_index : range) {
31 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
32 vbo_data[face_index] = {};
33 mesh_render_data_face_flag(mr, &face, offsets, vbo_data[face_index]);
34 }
35 });
36 }
37 else {
38 if (mr.orig_index_face) {
39 const Span<int> orig_index_face(mr.orig_index_face, mr.faces_num);
40 threading::parallel_for(IndexRange(mr.faces_num), 4096, [&](const IndexRange range) {
41 for (const int face : range) {
42 vbo_data[face] = {};
43 if (orig_index_face[face] == ORIGINDEX_NONE) {
44 continue;
45 }
46 const BMFace *orig_face = bm_original_face_get(mr, face);
47 mesh_render_data_face_flag(mr, orig_face, offsets, vbo_data[face]);
48 }
49 });
50 }
51 else {
52 vbo_data.fill({});
53 }
54 }
55 return vbo;
56}
57
58} // namespace blender::draw
constexpr IndexRange()=default
constexpr T * data() const
Definition BLI_span.hh:545
Extraction of Mesh data into VBO to feed to GPU.
gpu::VertBufPtr extract_face_dots_edituv_data(const MeshRenderData &mr)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition BLI_task.hh:69
void GPU_vertformat_alias_add(GPUVertFormat *, StringRef alias)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
BMUVOffsets BM_uv_map_offsets_get(const BMesh *bm)