Blender V5.0
attribute_convert.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_array_utils.hh"
10
11#include "BKE_attribute_math.hh"
12
13#include "GPU_vertex_buffer.hh"
14
15#include "attribute_convert.hh"
16
17namespace blender::draw {
18
20{
22 bke::attribute_math::convert_to_static_type(data_type, [&](auto dummy) {
23 using T = decltype(dummy);
24 using Converter = AttributeConverter<T>;
25 if constexpr (!std::is_void_v<typename Converter::VBOType>) {
27 vbo_name,
28 Converter::gpu_component_type,
29 Converter::gpu_component_len,
30 Converter::gpu_fetch_mode);
31 }
32 });
33 return format;
34}
35
37{
38 bke::attribute_math::convert_to_static_type(attribute.type(), [&](auto dummy) {
39 using T = decltype(dummy);
40 using Converter = AttributeConverter<T>;
41 using VBOType = typename Converter::VBOType;
42 if constexpr (!std::is_void_v<VBOType>) {
43 const Span<T> src = attribute.typed<T>();
44 MutableSpan<VBOType> data = vbo.data<VBOType>();
45 if constexpr (std::is_same_v<T, VBOType>) {
46 array_utils::copy(src, data);
47 }
48 else {
49 threading::parallel_for(src.index_range(), 8192, [&](const IndexRange range) {
50 for (const int i : range) {
51 data[i] = Converter::convert(src[i]);
52 }
53 });
54 }
55 }
56 });
57}
58
59} // namespace blender::draw
uint GPU_vertformat_attr_add_legacy(GPUVertFormat *, blender::StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
const CPPType & type() const
format
#define T
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
void vertbuf_data_extract_direct(const GSpan attribute, gpu::VertBuf &vbo)
GPUVertFormat init_format_for_attribute(const bke::AttrType data_type, const StringRef vbo_name)