Blender V5.3
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{
21 GPUVertFormat format{};
22 bke::attribute_math::to_static_type(data_type, [&]<typename T>() {
24 if constexpr (!std::is_void_v<typename Converter::VBOType>) {
26 vbo_name,
27 Converter::gpu_component_type,
28 Converter::gpu_component_len,
29 Converter::gpu_fetch_mode);
30 }
31 });
32 return format;
33}
34
36{
37 bke::attribute_math::to_static_type(attribute.type(), [&]<typename T>() {
38 using Converter = AttributeConverter<T>;
39 using VBOType = typename Converter::VBOType;
40 if constexpr (!std::is_void_v<VBOType>) {
41 const Span<T> src = attribute.typed<T>();
42 MutableSpan<VBOType> data = vbo.data<VBOType>();
43 if constexpr (std::is_same_v<T, VBOType>) {
44 array_utils::copy(src, data);
45 }
46 else {
47 threading::parallel_for(src.index_range(), 8192, [&](const IndexRange range) {
48 for (const int i : range) {
49 data[i] = Converter::convert(src[i]);
50 }
51 });
52 }
53 }
54 });
55}
56
57} // namespace blender::draw
#define attribute(slot)
#define T
void to_static_type(const CPPType &cpp_type, Fn &&fn)
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)
uint GPU_vertformat_attr_add_legacy(GPUVertFormat *, StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)