52 if constexpr (std::is_same_v<AttributeType, VBOType>) {
57 return static_cast<VBOType
>(value);
142 bool build_on_device,
154 BLI_snprintf(attr_name,
sizeof(attr_name),
"a%s", attr_safe_name);
167 if (build_on_device) {
176 template<
typename AttributeType,
typename VBOType>
188 const AttributeType *attr_data =
static_cast<const AttributeType *
>(
195 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++, vbo_data++, mloop++) {
196 *vbo_data = Converter::convert_value(attr_data[mloop->
v]);
200 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++, vbo_data++) {
201 *vbo_data = Converter::convert_value(attr_data[ml_index]);
205 for (
int ml_index = 0; ml_index < mr->
loop_len; ml_index++, vbo_data++, mloop++) {
206 *vbo_data = Converter::convert_value(attr_data[mloop->
e]);
210 for (
int mp_index = 0; mp_index < mr->
poly_len; mp_index++) {
211 const MPoly &poly = mpoly[mp_index];
212 const VBOType value = Converter::convert_value(attr_data[mp_index]);
224 template<
typename AttributeType,
typename VBOType>
243 const AttributeType *attr_data =
nullptr;
260 *vbo_data = Converter::convert_value(*attr_data);
262 }
while ((l_iter = l_iter->
next) != l_first);
266 template<
typename AttributeType,
typename VBOType = AttributeType>
274 fill_vertbuf_with_attribute_bm<AttributeType>(mr, vbo_data, request);
277 fill_vertbuf_with_attribute<AttributeType>(mr, vbo_data, request);
297 extract_attr_generic<bool, float3>(mr, vbo, request);
300 extract_attr_generic<int8_t, float3>(mr, vbo, request);
303 extract_attr_generic<int32_t, float3>(mr, vbo, request);
306 extract_attr_generic<float, float3>(mr, vbo, request);
309 extract_attr_generic<float2>(mr, vbo, request);
312 extract_attr_generic<float3>(mr, vbo, request);
315 extract_attr_generic<MPropCol, gpuMeshCol>(mr, vbo, request);
318 extract_attr_generic<ColorGeometry4b, gpuMeshCol>(mr, vbo, request);
335 Mesh *coarse_mesh = subdiv_cache->
mesh;
348 extract_attr_generic<bool, float3>(mr, src_data, request);
351 extract_attr_generic<int8_t, float3>(mr, src_data, request);
354 extract_attr_generic<int32_t, float3>(mr, src_data, request);
357 extract_attr_generic<float, float3>(mr, src_data, request);
360 extract_attr_generic<float2>(mr, src_data, request);
363 extract_attr_generic<float3>(mr, src_data, request);
366 extract_attr_generic<MPropCol, gpuMeshCol>(mr, src_data, request);
369 extract_attr_generic<ColorGeometry4b, gpuMeshCol>(mr, src_data, request);
383 static_cast<int>(dimensions),
392 #define EXTRACT_INIT_WRAPPER(index) \
393 static void extract_attr_init##index( \
394 const MeshRenderData *mr, MeshBatchCache *cache, void *buf, void *tls_data) \
396 extract_attr_init(mr, cache, buf, tls_data, index); \
398 static void extract_attr_init_subdiv##index(const DRWSubdivCache *subdiv_cache, \
399 const MeshRenderData *mr, \
400 MeshBatchCache *cache, \
404 extract_attr_init_subdiv(subdiv_cache, mr, cache, buf, tls_data, index); \
440 #define CREATE_EXTRACTOR_ATTR(index) \
441 blender::draw::create_extractor_attr<index>(blender::draw::extract_attr_init##index, \
442 blender::draw::extract_attr_init_subdiv##index)
Generic geometry attributes built on CustomData.
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
int CustomData_get_n_offset(const struct CustomData *data, int type, int n)
#define BLI_assert_unreachable()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
void GPU_vertbuf_discard(GPUVertBuf *)
struct GPUVertBuf GPUVertBuf
GPUVertBuf * GPU_vertbuf_calloc(void)
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void GPU_vertbuf_init_with_format_ex(GPUVertBuf *, const GPUVertFormat *, GPUUsageType)
#define GPU_vertbuf_init_with_format(verts, format)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
void GPU_vertbuf_init_build_on_device(GPUVertBuf *verts, GPUVertFormat *format, uint v_len)
void GPU_vertbuf_tag_dirty(GPUVertBuf *verts)
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
Utilities for rendering attributes.
void draw_subdiv_interp_custom_data(const DRWSubdivCache *cache, GPUVertBuf *src_data, GPUVertBuf *dst_data, int dimensions, int dst_offset, bool compress_to_u16)
ccl_global float * buffer
MINLINE unsigned short unit_float_to_ushort_clamp(float val)
float BLI_color_from_srgb_table[256]
static GPUVertCompType get_comp_type_for_type(eCustomDataType type)
constexpr MeshExtract create_extractor_attr(ExtractInitFn fn, ExtractInitSubdivFn subdiv_fn)
static void fill_vertbuf_with_attribute(const MeshRenderData *mr, VBOType *vbo_data, const DRW_AttributeRequest &request)
static uint gpu_component_size_for_attribute_type(eCustomDataType type)
static void extract_attr_generic(const MeshRenderData *mr, GPUVertBuf *vbo, const DRW_AttributeRequest &request)
static void extract_attr_init_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, MeshBatchCache *cache, void *buffer, void *UNUSED(tls_data), int index)
static CustomData * get_custom_data_for_domain(const MeshRenderData *mr, eAttrDomain domain)
static void fill_vertbuf_with_attribute_bm(const MeshRenderData *mr, VBOType *&vbo_data, const DRW_AttributeRequest &request)
static void init_vbo_for_attribute(const MeshRenderData &mr, GPUVertBuf *vbo, const DRW_AttributeRequest &request, bool build_on_device, uint32_t len)
static GPUVertFetchMode get_fetch_mode_for_type(eCustomDataType type)
static void extract_attr_init(const MeshRenderData *mr, MeshBatchCache *cache, void *buf, void *UNUSED(tls_data), int index)
DRW_AttributeRequest requests[GPU_MAX_ATTR]
GPUVertBuf * attr[GPU_MAX_ATTR]
eMRExtractType extract_type
const char * default_color_name
const char * active_color_name
static gpuMeshCol convert_value(ColorGeometry4b value)
static gpuMeshCol convert_value(MPropCol value)
static VBOType convert_value(AttributeType value)