42 SNPRINTF(attr_name,
"a%s", attr_safe_name);
54 if (build_on_device) {
69 using VBOType =
typename Converter::VBOType;
72 if constexpr (std::is_same_v<T, VBOType>) {
77 for (const int i : range) {
78 data[i] = Converter::convert(attribute[indices[i]]);
90 using VBOType =
typename Converter::VBOType;
93 threading::parallel_for(faces.index_range(), 2048, [&](
const IndexRange range) {
94 for (const int i : range) {
95 data.slice(faces[i]).fill(Converter::convert(attribute[i]));
104 using VBOType =
typename Converter::VBOType;
105 VBOType *data = vbo.
data<VBOType>().
data();
111 for ([[maybe_unused]]
const int i :
IndexRange(face->len)) {
113 *data = Converter::convert(*src);
124 using VBOType =
typename Converter::VBOType;
125 VBOType *data = vbo.
data<VBOType>().
data();
131 for ([[maybe_unused]]
const int i :
IndexRange(face->len)) {
133 *data = Converter::convert(src);
144 using VBOType =
typename Converter::VBOType;
145 VBOType *data = vbo.
data<VBOType>().
data();
150 const T &src = *
static_cast<const T *
>(
POINTER_OFFSET(face->head.data, cd_offset));
151 std::fill_n(data, face->len, Converter::convert(src));
160 using VBOType =
typename Converter::VBOType;
161 VBOType *data = vbo.
data<VBOType>().
data();
167 for ([[maybe_unused]]
const int i :
IndexRange(face->len)) {
169 *data = Converter::convert(src);
179 case bke::AttrDomain::Point:
181 case bke::AttrDomain::Corner:
183 case bke::AttrDomain::Face:
185 case bke::AttrDomain::Edge:
201 bke::attribute_math::convert_to_static_type(request.
cd_type, [&](
auto dummy) {
202 using T = decltype(dummy);
203 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
204 switch (request.domain) {
205 case bke::AttrDomain::Point:
206 extract_data_bmesh_vert<T>(*mr.bm, cd_offset, vbo);
208 case bke::AttrDomain::Edge:
209 extract_data_bmesh_edge<T>(*mr.bm, cd_offset, vbo);
211 case bke::AttrDomain::Face:
212 extract_data_bmesh_face<T>(*mr.bm, cd_offset, vbo);
214 case bke::AttrDomain::Corner:
215 extract_data_bmesh_loop<T>(*mr.bm, cd_offset, vbo);
218 BLI_assert_unreachable();
225 const StringRef name = request.attribute_name;
227 const GVArraySpan attribute = *attributes.lookup_or_default(name, request.domain, data_type);
229 bke::attribute_math::convert_to_static_type(request.cd_type, [&](
auto dummy) {
230 using T = decltype(dummy);
231 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
232 switch (request.domain) {
233 case bke::AttrDomain::Point:
234 extract_data_mesh_mapped_corner(attribute.typed<T>(), mr.corner_verts, vbo);
236 case bke::AttrDomain::Edge:
237 extract_data_mesh_mapped_corner(attribute.typed<T>(), mr.corner_edges, vbo);
239 case bke::AttrDomain::Face:
240 extract_data_mesh_face(mr.faces, attribute.typed<T>(), vbo);
242 case bke::AttrDomain::Corner:
243 vertbuf_data_extract_direct(attribute.typed<T>(), vbo);
246 BLI_assert_unreachable();
274 const Mesh *coarse_mesh = subdiv_cache.
mesh;
289 bke::attribute_math::convert_to_static_type(request.
cd_type, [&](
auto dummy) {
290 using T = decltype(dummy);
291 using Converter = AttributeConverter<T>;
292 if constexpr (!std::is_void_v<typename Converter::VBOType>) {
293 draw_subdiv_interp_custom_data(subdiv_cache,
296 Converter::gpu_component_type,
297 Converter::gpu_component_len,
310 if (
format.attr_len == 0) {
321 attr_name, bke::AttrDomain::Corner, {1.0f, 0.0f, 1.0f, 1.0f});
322 attribute.varray.materialize(vbo_data);
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
#define SNPRINTF(dst, format,...)
#define POINTER_OFFSET(v, ofs)
void GPU_vertbuf_init_build_on_device(blender::gpu::VertBuf &verts, const GPUVertFormat &format, uint v_len)
void GPU_vertbuf_tag_dirty(blender::gpu::VertBuf *verts)
#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_init_with_format_ex(blender::gpu::VertBuf &verts, const GPUVertFormat &format, GPUUsageType)
void GPU_vertbuf_discard(blender::gpu::VertBuf *)
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
constexpr IndexRange index_range() const
Utilities for rendering attributes.
bool DRW_vbo_requested(blender::gpu::VertBuf *vbo)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
GPUVertFormat init_format_for_attribute(const eCustomDataType data_type, const StringRefNull vbo_name)
static void extract_data_bmesh_edge(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void init_vbo_for_attribute(const MeshRenderData &mr, gpu::VertBuf &vbo, const DRW_AttributeRequest &request, bool build_on_device, uint32_t len)
void extract_attributes_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, const Span< DRW_AttributeRequest > requests, const Span< gpu::VertBuf * > vbos)
static void extract_data_bmesh_vert(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static const CustomData * get_custom_data_for_domain(const BMesh &bm, bke::AttrDomain domain)
static void extract_data_bmesh_loop(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void extract_data_mesh_face(const OffsetIndices< int > faces, const Span< T > attribute, gpu::VertBuf &vbo)
static void extract_data_bmesh_face(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void extract_attribute(const MeshRenderData &mr, const DRW_AttributeRequest &request, gpu::VertBuf &vbo)
void extract_attr_viewer(const MeshRenderData &mr, gpu::VertBuf &vbo)
void extract_attributes(const MeshRenderData &mr, const Span< DRW_AttributeRequest > requests, const Span< gpu::VertBuf * > vbos)
static void extract_data_mesh_mapped_corner(const Span< T > attribute, const Span< int > indices, gpu::VertBuf &vbo)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
blender::bke::AttrDomain domain
const char * default_color_name
const char * active_color_name
eMRExtractType extract_type