40 SNPRINTF(attr_name,
"a%s", attr_safe_name);
52 if (build_on_device) {
67 using VBOType =
typename Converter::VBOType;
70 if constexpr (std::is_same_v<T, VBOType>) {
75 for (const int i : range) {
76 data[i] = Converter::convert(attribute[indices[i]]);
88 using VBOType =
typename Converter::VBOType;
92 for (const int i : range) {
93 data.slice(faces[i]).fill(Converter::convert(attribute[i]));
102 using VBOType =
typename Converter::VBOType;
111 *
data = Converter::convert(*src);
122 using VBOType =
typename Converter::VBOType;
131 *
data = Converter::convert(src);
142 using VBOType =
typename Converter::VBOType;
149 std::fill_n(
data, face->
len, Converter::convert(src));
158 using VBOType =
typename Converter::VBOType;
167 *
data = Converter::convert(src);
179 using T = decltype(dummy);
180 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
181 switch (attr.domain) {
182 case bke::AttrDomain::Point:
183 extract_data_bmesh_vert<T>(*mr.bm, attr.offset, vbo);
185 case bke::AttrDomain::Edge:
186 extract_data_bmesh_edge<T>(*mr.bm, attr.offset, vbo);
188 case bke::AttrDomain::Face:
189 extract_data_bmesh_face<T>(*mr.bm, attr.offset, vbo);
191 case bke::AttrDomain::Corner:
192 extract_data_bmesh_loop<T>(*mr.bm, attr.offset, vbo);
195 BLI_assert_unreachable();
206 using T = decltype(dummy);
207 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
208 switch (attr.domain) {
209 case bke::AttrDomain::Point:
210 extract_data_mesh_mapped_corner(GVArraySpan(*attr).typed<T>(), mr.corner_verts, vbo);
212 case bke::AttrDomain::Edge:
213 extract_data_mesh_mapped_corner(GVArraySpan(*attr).typed<T>(), mr.corner_edges, vbo);
215 case bke::AttrDomain::Face:
216 extract_data_mesh_face(mr.faces, GVArraySpan(*attr).typed<T>(), vbo);
218 case bke::AttrDomain::Corner:
219 vertbuf_data_extract_direct(GVArraySpan(*attr).typed<T>(), vbo);
222 BLI_assert_unreachable();
267 const Mesh *coarse_mesh = subdiv_cache.
mesh;
298 using T =
decltype(dummy);
300 if constexpr (!std::is_void_v<typename Converter::VBOType>) {
304 Converter::gpu_component_type,
305 Converter::gpu_component_len,
316 "attribute_value", gpu::VertAttrType::SFLOAT_32_32_32_32);
326 attribute.
varray.materialize(vbo_data);
#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)
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
#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)
#define BM_FACE_FIRST_LOOP(p)
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const blender::StringRef name)
#define BM_ITER_MESH(ele, iter, bm, itype)
BMesh const char void * data
const CPPType & type() const
constexpr T * data() const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
GAttributeReader lookup(const StringRef attribute_id) const
Utilities for rendering attributes.
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
AttrType cpp_type_to_attribute_type(const CPPType &type)
static void extract_data_bmesh_edge(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
gpu::VertBufPtr extract_attribute_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, StringRef name)
static gpu::VertBufPtr init_coarse_data(const bke::AttrType type, const int coarse_corners_num)
static void extract_data_bmesh_vert(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void init_vbo_for_attribute(const MeshRenderData &mr, gpu::VertBuf &vbo, const StringRef name, const bke::AttrType type, bool build_on_device, uint32_t len)
void draw_subdiv_interp_custom_data(const DRWSubdivCache &cache, gpu::VertBuf &src_data, gpu::VertBuf &dst_data, GPUVertCompType comp_type, int dimensions, int dst_offset)
gpu::VertBufPtr extract_attribute(const MeshRenderData &mr, StringRef name)
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)
GPUVertFormat init_format_for_attribute(const bke::AttrType data_type, const StringRef vbo_name)
static void extract_attribute_data(const MeshRenderData &mr, const BMDataLayerLookup &attr, gpu::VertBuf &vbo)
static void extract_data_mesh_mapped_corner(const Span< T > attribute, const Span< int > indices, gpu::VertBuf &vbo)
gpu::VertBufPtr extract_attr_viewer(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))
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
blender::bke::AttrType type
const char * default_color_name
MeshExtractType extract_type
const char * active_color_name