diff options
Diffstat (limited to 'source/blender')
41 files changed, 586 insertions, 645 deletions
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index e6c8558bb37..9cb3743dd02 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -39,8 +39,8 @@ set(INC set(SRC intern/draw_cache.c intern/draw_cache_extract_mesh.cc - intern/draw_cache_extract_mesh_render_data.c - intern/mesh_extractors/extract_mesh.c + intern/draw_cache_extract_mesh_render_data.cc + intern/mesh_extractors/extract_mesh.cc intern/mesh_extractors/extract_mesh_ibo_edituv.cc intern/mesh_extractors/extract_mesh_ibo_fdots.cc intern/mesh_extractors/extract_mesh_ibo_lines.cc @@ -75,7 +75,7 @@ set(SRC intern/draw_cache_impl_displist.c intern/draw_cache_impl_gpencil.c intern/draw_cache_impl_lattice.c - intern/draw_cache_impl_mesh.c + intern/draw_cache_impl_mesh.cc intern/draw_cache_impl_metaball.c intern/draw_cache_impl_particles.c intern/draw_cache_impl_pointcloud.c @@ -201,7 +201,7 @@ set(SRC intern/DRW_render.h intern/draw_attributes.h intern/draw_cache.h - intern/draw_cache_extract.h + intern/draw_cache_extract.hh intern/draw_cache_impl.h intern/draw_cache_inline.h intern/draw_color_management.h @@ -221,7 +221,7 @@ set(SRC intern/draw_texture_pool.h intern/draw_view.h intern/draw_view_data.h - intern/mesh_extractors/extract_mesh.h + intern/mesh_extractors/extract_mesh.hh intern/smaa_textures.h engines/basic/basic_engine.h engines/basic/basic_private.h diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index f84a6c86fac..8fb4210901f 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -84,9 +84,9 @@ DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs, bool drw_custom_data_match_attribute(const CustomData *custom_data, const char *name, int *r_layer_index, - int *r_type) + eCustomDataType *r_type) { - const int possible_attribute_types[7] = { + const eCustomDataType possible_attribute_types[7] = { CD_PROP_BOOL, CD_PROP_INT8, CD_PROP_INT32, @@ -97,7 +97,7 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data, }; for (int i = 0; i < ARRAY_SIZE(possible_attribute_types); i++) { - const int attr_type = possible_attribute_types[i]; + const eCustomDataType attr_type = possible_attribute_types[i]; int layer_index = CustomData_get_named_layer(custom_data, attr_type, name); if (layer_index == -1) { continue; diff --git a/source/blender/draw/intern/draw_attributes.h b/source/blender/draw/intern/draw_attributes.h index c375670cd70..4f82f3b94e9 100644 --- a/source/blender/draw/intern/draw_attributes.h +++ b/source/blender/draw/intern/draw_attributes.h @@ -53,7 +53,7 @@ DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs, bool drw_custom_data_match_attribute(const CustomData *custom_data, const char *name, int *r_layer_index, - int *r_type); + eCustomDataType *r_type); #ifdef __cplusplus } diff --git a/source/blender/draw/intern/draw_cache_extract.h b/source/blender/draw/intern/draw_cache_extract.hh index ce3ad9923da..b16a35347c0 100644 --- a/source/blender/draw/intern/draw_cache_extract.h +++ b/source/blender/draw/intern/draw_cache_extract.hh @@ -7,11 +7,13 @@ #pragma once -struct DRWSubdivCache; -struct MeshRenderData; -struct TaskGraph; +#include <algorithm> + +#include "BLI_utildefines.h" #include "DNA_customdata_types.h" +#include "DNA_mesh_types.h" +#include "DNA_view3d_enums.h" #include "BKE_attribute.h" #include "BKE_object.h" @@ -22,8 +24,12 @@ struct TaskGraph; #include "draw_attributes.h" +struct DRWSubdivCache; +struct MeshRenderData; +struct TaskGraph; + /* Vertex Group Selection and display options */ -typedef struct DRW_MeshWeightState { +struct DRW_MeshWeightState { int defgroup_active; int defgroup_len; @@ -37,7 +43,7 @@ typedef struct DRW_MeshWeightState { /* Set of all locked and unlocked deform bones for Lock Relative mode. */ bool *defgroup_locked; /* [defgroup_len] */ bool *defgroup_unlocked; /* [defgroup_len] */ -} DRW_MeshWeightState; +}; /* DRW_MeshWeightState.flags */ enum { @@ -46,7 +52,7 @@ enum { DRW_MESH_WEIGHT_STATE_LOCK_RELATIVE = (1 << 2), }; -typedef struct DRW_MeshCDMask { +struct DRW_MeshCDMask { uint32_t uv : 8; uint32_t tan : 8; uint32_t vcol : 8; @@ -56,20 +62,20 @@ typedef struct DRW_MeshCDMask { /** Edit uv layer is from the base edit mesh as * modifiers could remove it. (see T68857) */ uint32_t edit_uv : 1; -} DRW_MeshCDMask; +}; /* Keep `DRW_MeshCDMask` struct within an `uint32_t`. * bit-wise and atomic operations are used to compare and update the struct. * See `mesh_cd_layers_type_*` functions. */ BLI_STATIC_ASSERT(sizeof(DRW_MeshCDMask) <= sizeof(uint32_t), "DRW_MeshCDMask exceeds 32 bits") -typedef enum eMRIterType { +enum eMRIterType { MR_ITER_LOOPTRI = 1 << 0, MR_ITER_POLY = 1 << 1, MR_ITER_LEDGE = 1 << 2, MR_ITER_LVERT = 1 << 3, -} eMRIterType; +}; ENUM_OPERATORS(eMRIterType, MR_ITER_LVERT) -typedef enum eMRDataType { +enum eMRDataType { MR_DATA_NONE = 0, MR_DATA_POLY_NOR = 1 << 1, MR_DATA_LOOP_NOR = 1 << 2, @@ -78,25 +84,37 @@ typedef enum eMRDataType { /** Force loop normals calculation. */ MR_DATA_TAN_LOOP_NOR = 1 << 5, MR_DATA_POLYS_SORTED = 1 << 6, -} eMRDataType; +}; ENUM_OPERATORS(eMRDataType, MR_DATA_POLYS_SORTED) -#ifdef __cplusplus -extern "C" { -#endif - BLI_INLINE int mesh_render_mat_len_get(const Object *object, const Mesh *me) { if (me->edit_mesh != NULL) { const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object); if (editmesh_eval_final != NULL) { - return MAX2(1, editmesh_eval_final->totcol); + return std::max<int>(1, editmesh_eval_final->totcol); } } - return MAX2(1, me->totcol); + return std::max<int>(1, me->totcol); } -typedef struct MeshBufferList { +struct MeshBufferList { + + // enum class BufferItem { + // PosNor, + // LNor, + // EdgeFac, + // Weights, + // UV, + // Tan, + // VCol, + // SculptData, + // Orco, + // EditData, + // EditUVData, + // EditUVStretchArea, + + // } /* Every VBO below contains at least enough * data for every loops in the mesh (except fdots and skin roots). * For some VBOs, it extends to (in this exact order) : @@ -148,9 +166,9 @@ typedef struct MeshBufferList { GPUIndexBuf *edituv_points; GPUIndexBuf *edituv_fdots; } ibo; -} MeshBufferList; +}; -typedef struct MeshBatchList { +struct MeshBatchList { /* Surfaces / Render */ GPUBatch *surface; GPUBatch *surface_weights; @@ -184,7 +202,7 @@ typedef struct MeshBatchList { GPUBatch *wire_loops; /* Loops around faces. no edges between selected faces */ GPUBatch *wire_loops_uvs; /* Same as wire_loops but only has uvs. */ GPUBatch *sculpt_overlays; -} MeshBatchList; +}; #define MBC_BATCH_LEN (sizeof(MeshBatchList) / sizeof(void *)) #define MBC_VBO_LEN (sizeof(((MeshBufferList){0}).vbo) / sizeof(void *)) @@ -192,7 +210,7 @@ typedef struct MeshBatchList { #define MBC_BATCH_INDEX(batch) (offsetof(MeshBatchList, batch) / sizeof(void *)) -typedef enum DRWBatchFlag { +enum DRWBatchFlag { MBC_SURFACE = (1u << MBC_BATCH_INDEX(surface)), MBC_SURFACE_WEIGHTS = (1u << MBC_BATCH_INDEX(surface_weights)), MBC_EDIT_TRIANGLES = (1u << MBC_BATCH_INDEX(edit_triangles)), @@ -221,23 +239,25 @@ typedef enum DRWBatchFlag { MBC_WIRE_LOOPS = (1u << MBC_BATCH_INDEX(wire_loops)), MBC_WIRE_LOOPS_UVS = (1u << MBC_BATCH_INDEX(wire_loops_uvs)), MBC_SCULPT_OVERLAYS = (1u << MBC_BATCH_INDEX(sculpt_overlays)), -} DRWBatchFlag; + MBC_SURFACE_PER_MAT = (1u << MBC_BATCH_LEN), +}; +ENUM_OPERATORS(DRWBatchFlag, MBC_SURFACE_PER_MAT); BLI_STATIC_ASSERT(MBC_BATCH_LEN < 32, "Number of batches exceeded the limit of bit fields"); -typedef struct MeshExtractLooseGeom { +struct MeshExtractLooseGeom { int edge_len; int vert_len; int *verts; int *edges; -} MeshExtractLooseGeom; +}; /** * Data that are kept around between extractions to reduce rebuilding time. * * - Loose geometry. */ -typedef struct MeshBufferCache { +struct MeshBufferCache { MeshBufferList buff; MeshExtractLooseGeom loose_geom; @@ -247,7 +267,7 @@ typedef struct MeshBufferCache { int *mat_tri_len; int visible_tri_len; } poly_sorted; -} MeshBufferCache; +}; #define FOREACH_MESH_BUFFER_CACHE(batch_cache, mbc) \ for (MeshBufferCache *mbc = &batch_cache->final; \ @@ -256,7 +276,7 @@ typedef struct MeshBufferCache { &batch_cache->cage : \ ((mbc == &batch_cache->cage) ? &batch_cache->uv_cage : NULL)) -typedef struct MeshBatchCache { +struct MeshBatchCache { MeshBufferCache final, cage, uv_cage; MeshBatchList batch; @@ -302,12 +322,14 @@ typedef struct MeshBatchCache { eV3DShadingColorType color_type; bool pbvh_is_drawing; -} MeshBatchCache; +}; #define MBC_EDITUV \ (MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | \ MBC_EDITUV_EDGES | MBC_EDITUV_VERTS | MBC_EDITUV_FACEDOTS | MBC_WIRE_LOOPS_UVS) +namespace blender::draw { + void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, MeshBatchCache *cache, MeshBufferCache *mbc, @@ -328,6 +350,4 @@ void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, struct DRWSubdivCache *subdiv_cache, struct MeshRenderData *mr); -#ifdef __cplusplus -} -#endif +} // namespace blender::draw diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index 3d44d3d1b3f..00005fd7b4c 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -24,11 +24,11 @@ #include "GPU_capabilities.h" -#include "draw_cache_extract.h" +#include "draw_cache_extract.hh" #include "draw_cache_inline.h" #include "draw_subdivision.h" -#include "mesh_extractors/extract_mesh.h" +#include "mesh_extractors/extract_mesh.hh" // #define DEBUG_TIME @@ -551,21 +551,21 @@ static struct TaskNode *mesh_extract_render_data_node_create(struct TaskGraph *t /** \name Extract Loop * \{ */ -static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, - MeshBatchCache *cache, - MeshBufferCache *mbc, - Object *object, - Mesh *me, - - const bool is_editmode, - const bool is_paint_mode, - const bool is_mode_active, - const float obmat[4][4], - const bool do_final, - const bool do_uvedit, - const Scene *scene, - const ToolSettings *ts, - const bool use_hide) +void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, + MeshBatchCache *cache, + MeshBufferCache *mbc, + Object *object, + Mesh *me, + + const bool is_editmode, + const bool is_paint_mode, + const bool is_mode_active, + const float obmat[4][4], + const bool do_final, + const bool do_uvedit, + const Scene *scene, + const ToolSettings *ts, + const bool use_hide) { /* For each mesh where batches needs to be updated a sub-graph will be added to the task_graph. * This sub-graph starts with an extract_render_data_node. This fills/converts the required @@ -772,10 +772,10 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, /** \name Subdivision Extract Loop * \{ */ -static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, - MeshBufferCache *mbc, - DRWSubdivCache *subdiv_cache, - MeshRenderData *mr) +void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, + MeshBufferCache *mbc, + DRWSubdivCache *subdiv_cache, + MeshRenderData *mr) { /* Create an array containing all the extractors that needs to be executed. */ ExtractorRunDatas extractors; @@ -908,46 +908,3 @@ static void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, /** \} */ } // namespace blender::draw - -extern "C" { -void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, - MeshBatchCache *cache, - MeshBufferCache *mbc, - Object *object, - Mesh *me, - - const bool is_editmode, - const bool is_paint_mode, - const bool is_mode_active, - const float obmat[4][4], - const bool do_final, - const bool do_uvedit, - const Scene *scene, - const ToolSettings *ts, - const bool use_hide) -{ - blender::draw::mesh_buffer_cache_create_requested(task_graph, - cache, - mbc, - object, - me, - is_editmode, - is_paint_mode, - is_mode_active, - obmat, - do_final, - do_uvedit, - scene, - ts, - use_hide); -} - -void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache *cache, - MeshBufferCache *mbc, - DRWSubdivCache *subdiv_cache, - MeshRenderData *mr) -{ - blender::draw::mesh_buffer_cache_create_requested_subdiv(cache, mbc, subdiv_cache, mr); -} - -} // extern "C" diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc index 0a93f346b37..82be73f6de8 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc @@ -9,7 +9,7 @@ #include "MEM_guardedalloc.h" -#include "BLI_alloca.h" +#include "BLI_array.hh" #include "BLI_bitmap.h" #include "BLI_math.h" #include "BLI_task.h" @@ -22,7 +22,7 @@ #include "ED_mesh.h" -#include "mesh_extractors/extract_mesh.h" +#include "mesh_extractors/extract_mesh.hh" /* ---------------------------------------------------------------------- */ /** \name Update Loose Geometry @@ -78,7 +78,8 @@ static void mesh_render_data_loose_geom_mesh(const MeshRenderData *mr, MeshBuffe { BLI_bitmap *lvert_map = BLI_BITMAP_NEW(mr->vert_len, __func__); - cache->loose_geom.edges = MEM_mallocN(mr->edge_len * sizeof(*cache->loose_geom.edges), __func__); + cache->loose_geom.edges = static_cast<int *>( + MEM_mallocN(mr->edge_len * sizeof(*cache->loose_geom.edges), __func__)); const MEdge *med = mr->medge; for (int med_index = 0; med_index < mr->edge_len; med_index++, med++) { if (med->flag & ME_LOOSEEDGE) { @@ -89,19 +90,20 @@ static void mesh_render_data_loose_geom_mesh(const MeshRenderData *mr, MeshBuffe BLI_BITMAP_ENABLE(lvert_map, med->v2); } if (cache->loose_geom.edge_len < mr->edge_len) { - cache->loose_geom.edges = MEM_reallocN( - cache->loose_geom.edges, cache->loose_geom.edge_len * sizeof(*cache->loose_geom.edges)); + cache->loose_geom.edges = static_cast<int *>(MEM_reallocN( + cache->loose_geom.edges, cache->loose_geom.edge_len * sizeof(*cache->loose_geom.edges))); } - cache->loose_geom.verts = MEM_mallocN(mr->vert_len * sizeof(*cache->loose_geom.verts), __func__); + cache->loose_geom.verts = static_cast<int *>( + MEM_mallocN(mr->vert_len * sizeof(*cache->loose_geom.verts), __func__)); for (int v = 0; v < mr->vert_len; v++) { if (!BLI_BITMAP_TEST(lvert_map, v)) { cache->loose_geom.verts[cache->loose_geom.vert_len++] = v; } } if (cache->loose_geom.vert_len < mr->vert_len) { - cache->loose_geom.verts = MEM_reallocN( - cache->loose_geom.verts, cache->loose_geom.vert_len * sizeof(*cache->loose_geom.verts)); + cache->loose_geom.verts = static_cast<int *>(MEM_reallocN( + cache->loose_geom.verts, cache->loose_geom.vert_len * sizeof(*cache->loose_geom.verts))); } MEM_freeN(lvert_map); @@ -112,15 +114,16 @@ static void mesh_render_data_lverts_bm(const MeshRenderData *mr, MeshBufferCache int elem_id; BMIter iter; BMVert *eve; - cache->loose_geom.verts = MEM_mallocN(mr->vert_len * sizeof(*cache->loose_geom.verts), __func__); + cache->loose_geom.verts = static_cast<int *>( + MEM_mallocN(mr->vert_len * sizeof(*cache->loose_geom.verts), __func__)); BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, elem_id) { if (eve->e == NULL) { cache->loose_geom.verts[cache->loose_geom.vert_len++] = elem_id; } } if (cache->loose_geom.vert_len < mr->vert_len) { - cache->loose_geom.verts = MEM_reallocN( - cache->loose_geom.verts, cache->loose_geom.vert_len * sizeof(*cache->loose_geom.verts)); + cache->loose_geom.verts = static_cast<int *>(MEM_reallocN( + cache->loose_geom.verts, cache->loose_geom.vert_len * sizeof(*cache->loose_geom.verts))); } } @@ -129,15 +132,16 @@ static void mesh_render_data_ledges_bm(const MeshRenderData *mr, MeshBufferCache int elem_id; BMIter iter; BMEdge *ede; - cache->loose_geom.edges = MEM_mallocN(mr->edge_len * sizeof(*cache->loose_geom.edges), __func__); + cache->loose_geom.edges = static_cast<int *>( + MEM_mallocN(mr->edge_len * sizeof(*cache->loose_geom.edges), __func__)); BM_ITER_MESH_INDEX (ede, &iter, bm, BM_EDGES_OF_MESH, elem_id) { if (ede->l == NULL) { cache->loose_geom.edges[cache->loose_geom.edge_len++] = elem_id; } } if (cache->loose_geom.edge_len < mr->edge_len) { - cache->loose_geom.edges = MEM_reallocN( - cache->loose_geom.edges, cache->loose_geom.edge_len * sizeof(*cache->loose_geom.edges)); + cache->loose_geom.edges = static_cast<int *>(MEM_reallocN( + cache->loose_geom.edges, cache->loose_geom.edge_len * sizeof(*cache->loose_geom.edges))); } } @@ -192,12 +196,13 @@ static void mesh_render_data_polys_sorted_ensure(MeshRenderData *mr, MeshBufferC static void mesh_render_data_polys_sorted_build(MeshRenderData *mr, MeshBufferCache *cache) { - int *tri_first_index = MEM_mallocN(sizeof(*tri_first_index) * mr->poly_len, __func__); + int *tri_first_index = static_cast<int *>( + MEM_mallocN(sizeof(*tri_first_index) * mr->poly_len, __func__)); int *mat_tri_len = mesh_render_data_mat_tri_len_build(mr); /* Apply offset. */ int visible_tri_len = 0; - int *mat_tri_offs = BLI_array_alloca(mat_tri_offs, mr->mat_len); + blender::Array<int, 32> mat_tri_offs(mr->mat_len); { for (int i = 0; i < mr->mat_len; i++) { mat_tri_offs[i] = visible_tri_len; @@ -245,8 +250,8 @@ static void mesh_render_data_mat_tri_len_bm_range_fn(void *__restrict userdata, const int iter, const TaskParallelTLS *__restrict tls) { - MeshRenderData *mr = userdata; - int *mat_tri_len = tls->userdata_chunk; + MeshRenderData *mr = static_cast<MeshRenderData *>(userdata); + int *mat_tri_len = static_cast<int *>(tls->userdata_chunk); BMesh *bm = mr->bm; BMFace *efa = BM_face_at_index(bm, iter); @@ -260,8 +265,8 @@ static void mesh_render_data_mat_tri_len_mesh_range_fn(void *__restrict userdata const int iter, const TaskParallelTLS *__restrict tls) { - MeshRenderData *mr = userdata; - int *mat_tri_len = tls->userdata_chunk; + MeshRenderData *mr = static_cast<MeshRenderData *>(userdata); + int *mat_tri_len = static_cast<int *>(tls->userdata_chunk); const MPoly *mp = &mr->mpoly[iter]; if (!(mr->use_hide && (mp->flag & ME_HIDE))) { @@ -274,9 +279,9 @@ static void mesh_render_data_mat_tri_len_reduce_fn(const void *__restrict userda void *__restrict chunk_join, void *__restrict chunk) { - const MeshRenderData *mr = userdata; - int *dst_mat_len = chunk_join; - int *src_mat_len = chunk; + const MeshRenderData *mr = static_cast<const MeshRenderData *>(userdata); + int *dst_mat_len = static_cast<int *>(chunk_join); + int *src_mat_len = static_cast<int *>(chunk); for (int i = 0; i < mr->mat_len; i++) { dst_mat_len[i] += src_mat_len[i]; } @@ -288,7 +293,7 @@ static int *mesh_render_data_mat_tri_len_build_threaded(MeshRenderData *mr, { /* Extending the #MatOffsetUserData with an int per material slot. */ size_t mat_tri_len_size = sizeof(int) * mr->mat_len; - int *mat_tri_len = MEM_callocN(mat_tri_len_size, __func__); + int *mat_tri_len = static_cast<int *>(MEM_callocN(mat_tri_len_size, __func__)); TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); @@ -330,7 +335,8 @@ void mesh_render_data_update_looptris(MeshRenderData *mr, /* NOTE(campbell): It's possible to skip allocating tessellation, * the tessellation can be calculated as part of the iterator, see: P2188. * The overall advantage is small (around 1%), so keep this as-is. */ - mr->mlooptri = MEM_mallocN(sizeof(*mr->mlooptri) * mr->tri_len, "MR_DATATYPE_LOOPTRI"); + mr->mlooptri = static_cast<MLoopTri *>( + MEM_mallocN(sizeof(*mr->mlooptri) * mr->tri_len, "MR_DATATYPE_LOOPTRI")); if (mr->poly_normals != NULL) { BKE_mesh_recalc_looptri_with_normals(me->mloop, me->mpoly, @@ -368,8 +374,10 @@ void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_ mr->poly_normals = BKE_mesh_poly_normals_ensure(mr->me); } if (((data_flag & MR_DATA_LOOP_NOR) && is_auto_smooth) || (data_flag & MR_DATA_TAN_LOOP_NOR)) { - mr->loop_normals = MEM_mallocN(sizeof(*mr->loop_normals) * mr->loop_len, __func__); - short(*clnors)[2] = CustomData_get_layer(&mr->me->ldata, CD_CUSTOMLOOPNORMAL); + mr->loop_normals = static_cast<float(*)[3]>( + MEM_mallocN(sizeof(*mr->loop_normals) * mr->loop_len, __func__)); + short(*clnors)[2] = static_cast<short(*)[2]>( + CustomData_get_layer(&mr->me->ldata, CD_CUSTOMLOOPNORMAL)); BKE_mesh_normals_loop_split(mr->me->mvert, mr->vert_normals, mr->vert_len, @@ -405,7 +413,8 @@ void mesh_render_data_update_normals(MeshRenderData *mr, const eMRDataType data_ poly_normals = mr->bm_poly_normals; } - mr->loop_normals = MEM_mallocN(sizeof(*mr->loop_normals) * mr->loop_len, __func__); + mr->loop_normals = static_cast<float(*)[3]>( + MEM_mallocN(sizeof(*mr->loop_normals) * mr->loop_len, __func__)); const int clnors_offset = CustomData_get_offset(&mr->bm->ldata, CD_CUSTOMLOOPNORMAL); BM_loops_calc_normal_vcos(mr->bm, vert_coords, @@ -432,7 +441,7 @@ MeshRenderData *mesh_render_data_create(Object *object, const bool do_uvedit, const ToolSettings *ts) { - MeshRenderData *mr = MEM_callocN(sizeof(*mr), __func__); + MeshRenderData *mr = static_cast<MeshRenderData *>(MEM_callocN(sizeof(*mr), __func__)); mr->toolsettings = ts; mr->mat_len = mesh_render_mat_len_get(object, me); @@ -491,9 +500,12 @@ MeshRenderData *mesh_render_data_create(Object *object, #endif if (use_mapped) { - mr->v_origindex = CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX); - mr->e_origindex = CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX); - mr->p_origindex = CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX); + mr->v_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); + mr->e_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); + mr->p_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); use_mapped = (mr->v_origindex || mr->e_origindex || mr->p_origindex); } @@ -513,9 +525,12 @@ MeshRenderData *mesh_render_data_create(Object *object, bool use_mapped = is_paint_mode && mr->me && !mr->me->runtime.is_original; if (use_mapped) { - mr->v_origindex = CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX); - mr->e_origindex = CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX); - mr->p_origindex = CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX); + mr->v_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); + mr->e_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); + mr->p_origindex = static_cast<const int *>( + CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); use_mapped = (mr->v_origindex || mr->e_origindex || mr->p_origindex); } @@ -531,14 +546,14 @@ MeshRenderData *mesh_render_data_create(Object *object, mr->poly_len = mr->me->totpoly; mr->tri_len = poly_to_tri_count(mr->poly_len, mr->loop_len); - mr->mvert = CustomData_get_layer(&mr->me->vdata, CD_MVERT); - mr->medge = CustomData_get_layer(&mr->me->edata, CD_MEDGE); - mr->mloop = CustomData_get_layer(&mr->me->ldata, CD_MLOOP); - mr->mpoly = CustomData_get_layer(&mr->me->pdata, CD_MPOLY); + mr->mvert = static_cast<MVert *>(CustomData_get_layer(&mr->me->vdata, CD_MVERT)); + mr->medge = static_cast<MEdge *>(CustomData_get_layer(&mr->me->edata, CD_MEDGE)); + mr->mloop = static_cast<MLoop *>(CustomData_get_layer(&mr->me->ldata, CD_MLOOP)); + mr->mpoly = static_cast<MPoly *>(CustomData_get_layer(&mr->me->pdata, CD_MPOLY)); - mr->v_origindex = CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX); - mr->e_origindex = CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX); - mr->p_origindex = CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX); + mr->v_origindex = static_cast<const int *>(CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); + mr->e_origindex = static_cast<const int *>(CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); + mr->p_origindex = static_cast<const int *>(CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); } else { /* #BMesh */ diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 68f210105b0..22b843650ca 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -512,7 +512,7 @@ static bool curves_ensure_attributes(const Curves &curves, ListBase gpu_attrs = GPU_material_attributes(gpu_material); LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) { const char *name = gpu_attr->name; - int type = gpu_attr->type; + eCustomDataType type = static_cast<eCustomDataType>(gpu_attr->type); int layer = -1; eAttrDomain domain; diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.cc index a7fd484c72f..1f83e0e3fce 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -7,15 +7,19 @@ * \brief Mesh API for render engines */ +#include <optional> + #include "MEM_guardedalloc.h" -#include "BLI_alloca.h" #include "BLI_bitmap.h" #include "BLI_buffer.h" #include "BLI_edgehash.h" +#include "BLI_index_range.hh" #include "BLI_listbase.h" +#include "BLI_map.hh" #include "BLI_math_bits.h" #include "BLI_math_vector.h" +#include "BLI_span.hh" #include "BLI_string.h" #include "BLI_task.h" #include "BLI_utildefines.h" @@ -52,13 +56,17 @@ #include "ED_mesh.h" #include "ED_uvedit.h" -#include "draw_cache_extract.h" +#include "draw_cache_extract.hh" #include "draw_cache_inline.h" #include "draw_subdivision.h" #include "draw_cache_impl.h" /* own include */ -#include "mesh_extractors/extract_mesh.h" +#include "mesh_extractors/extract_mesh.hh" + +using blender::IndexRange; +using blender::Map; +using blender::Span; /* ---------------------------------------------------------------------- */ /** \name Dependencies between buffer and batch @@ -69,21 +77,7 @@ #define BUFFER_INDEX(buff_name) ((offsetof(MeshBufferList, buff_name) - offsetof(MeshBufferList, vbo)) / sizeof(void *)) #define BUFFER_LEN (sizeof(MeshBufferList) / sizeof(void *)) -#define _BATCH_FLAG1(b) (1u << MBC_BATCH_INDEX(b)) -#define _BATCH_FLAG2(b1, b2) _BATCH_FLAG1(b1) | _BATCH_FLAG1(b2) -#define _BATCH_FLAG3(b1, b2, b3) _BATCH_FLAG2(b1, b2) | _BATCH_FLAG1(b3) -#define _BATCH_FLAG4(b1, b2, b3, b4) _BATCH_FLAG3(b1, b2, b3) | _BATCH_FLAG1(b4) -#define _BATCH_FLAG5(b1, b2, b3, b4, b5) _BATCH_FLAG4(b1, b2, b3, b4) | _BATCH_FLAG1(b5) -#define _BATCH_FLAG6(b1, b2, b3, b4, b5, b6) _BATCH_FLAG5(b1, b2, b3, b4, b5) | _BATCH_FLAG1(b6) -#define _BATCH_FLAG7(b1, b2, b3, b4, b5, b6, b7) _BATCH_FLAG6(b1, b2, b3, b4, b5, b6) | _BATCH_FLAG1(b7) -#define _BATCH_FLAG8(b1, b2, b3, b4, b5, b6, b7, b8) _BATCH_FLAG7(b1, b2, b3, b4, b5, b6, b7) | _BATCH_FLAG1(b8) -#define _BATCH_FLAG9(b1, b2, b3, b4, b5, b6, b7, b8, b9) _BATCH_FLAG8(b1, b2, b3, b4, b5, b6, b7, b8) | _BATCH_FLAG1(b9) -#define _BATCH_FLAG10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) _BATCH_FLAG9(b1, b2, b3, b4, b5, b6, b7, b8, b9) | _BATCH_FLAG1(b10) -#define _BATCH_FLAG18(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18) _BATCH_FLAG10(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10) | _BATCH_FLAG8(b11, b12, b13, b14, b15, b16, b17, b18) - -#define BATCH_FLAG(...) VA_NARGS_CALL_OVERLOAD(_BATCH_FLAG, __VA_ARGS__) - -#define _BATCH_MAP1(a) g_buffer_deps[BUFFER_INDEX(a)] +#define _BATCH_MAP1(a) batches_that_use_buffer(BUFFER_INDEX(a)) #define _BATCH_MAP2(a, b) _BATCH_MAP1(a) | _BATCH_MAP1(b) #define _BATCH_MAP3(a, b, c) _BATCH_MAP2(a, b) | _BATCH_MAP1(c) #define _BATCH_MAP4(a, b, c, d) _BATCH_MAP3(a, b, c) | _BATCH_MAP1(d) @@ -96,132 +90,110 @@ #define BATCH_MAP(...) VA_NARGS_CALL_OVERLOAD(_BATCH_MAP, __VA_ARGS__) -#ifndef NDEBUG -# define MDEPS_ASSERT_INDEX(buffer_index, batch_flag) \ - g_buffer_deps_d[buffer_index] |= batch_flag; \ - BLI_assert(g_buffer_deps[buffer_index] & batch_flag) - -# define _MDEPS_ASSERT2(b, n1) MDEPS_ASSERT_INDEX(BUFFER_INDEX(n1), b) -# define _MDEPS_ASSERT3(b, n1, n2) _MDEPS_ASSERT2(b, n1); _MDEPS_ASSERT2(b, n2) -# define _MDEPS_ASSERT4(b, n1, n2, n3) _MDEPS_ASSERT3(b, n1, n2); _MDEPS_ASSERT2(b, n3) -# define _MDEPS_ASSERT5(b, n1, n2, n3, n4) _MDEPS_ASSERT4(b, n1, n2, n3); _MDEPS_ASSERT2(b, n4) -# define _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5) _MDEPS_ASSERT5(b, n1, n2, n3, n4); _MDEPS_ASSERT2(b, n5) -# define _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6) _MDEPS_ASSERT6(b, n1, n2, n3, n4, n5); _MDEPS_ASSERT2(b, n6) -# define _MDEPS_ASSERT8(b, n1, n2, n3, n4, n5, n6, n7) _MDEPS_ASSERT7(b, n1, n2, n3, n4, n5, n6); _MDEPS_ASSERT2(b, n7) -# define _MDEPS_ASSERT21(b, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20) _MDEPS_ASSERT8(b, n1, n2, n3, n4, n5, n6, n7); _MDEPS_ASSERT8(b, n8, n9, n10, n11, n12, n13, n14); _MDEPS_ASSERT7(b, n15, n16, n17, n18, n19, n20) -# define _MDEPS_ASSERT22(b, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21) _MDEPS_ASSERT21(b, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20); _MDEPS_ASSERT2(b, n21); - -# define MDEPS_ASSERT_FLAG(...) VA_NARGS_CALL_OVERLOAD(_MDEPS_ASSERT, __VA_ARGS__) -# define MDEPS_ASSERT(batch_name, ...) MDEPS_ASSERT_FLAG(BATCH_FLAG(batch_name), __VA_ARGS__) -# define MDEPS_ASSERT_MAP_INDEX(buff_index) BLI_assert(g_buffer_deps_d[buff_index] == g_buffer_deps[buff_index]) -# define MDEPS_ASSERT_MAP(buff_name) MDEPS_ASSERT_MAP_INDEX(BUFFER_INDEX(buff_name)) -#else -# define MDEPS_ASSERT_INDEX(buffer_index, batch_flag) -# define MDEPS_ASSERT_FLAG(...) -# define MDEPS_ASSERT(batch_name, ...) -# define MDEPS_ASSERT_MAP_INDEX(buff_index) -# define MDEPS_ASSERT_MAP(buff_name) -#endif - /* clang-format on */ #define TRIS_PER_MAT_INDEX BUFFER_LEN -#define SURFACE_PER_MAT_FLAG (1u << MBC_BATCH_LEN) - -static const DRWBatchFlag g_buffer_deps[] = { - [BUFFER_INDEX(vbo.pos_nor)] = BATCH_FLAG(surface, - surface_weights, - edit_triangles, - edit_vertices, - edit_edges, - edit_vnor, - edit_lnor, - edit_mesh_analysis, - edit_selection_verts, - edit_selection_edges, - edit_selection_faces, - all_verts, - all_edges, - loose_edges, - edge_detection, - wire_edges, - wire_loops, - sculpt_overlays) | - SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.lnor)] = BATCH_FLAG(surface, edit_lnor, wire_loops) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.edge_fac)] = BATCH_FLAG(wire_edges), - [BUFFER_INDEX(vbo.weights)] = BATCH_FLAG(surface_weights), - [BUFFER_INDEX(vbo.uv)] = BATCH_FLAG(surface, - edituv_faces_stretch_area, - edituv_faces_stretch_angle, - edituv_faces, - edituv_edges, - edituv_verts, - wire_loops_uvs) | - SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.tan)] = SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.vcol)] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.sculpt_data)] = BATCH_FLAG(sculpt_overlays), - [BUFFER_INDEX(vbo.orco)] = SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.edit_data)] = BATCH_FLAG(edit_triangles, edit_edges, edit_vertices), - [BUFFER_INDEX(vbo.edituv_data)] = BATCH_FLAG(edituv_faces, - edituv_faces_stretch_area, - edituv_faces_stretch_angle, - edituv_edges, - edituv_verts), - [BUFFER_INDEX(vbo.edituv_stretch_area)] = BATCH_FLAG(edituv_faces_stretch_area), - [BUFFER_INDEX(vbo.edituv_stretch_angle)] = BATCH_FLAG(edituv_faces_stretch_angle), - [BUFFER_INDEX(vbo.mesh_analysis)] = BATCH_FLAG(edit_mesh_analysis), - [BUFFER_INDEX(vbo.fdots_pos)] = BATCH_FLAG(edit_fdots, edit_selection_fdots), - [BUFFER_INDEX(vbo.fdots_nor)] = BATCH_FLAG(edit_fdots), - [BUFFER_INDEX(vbo.fdots_uv)] = BATCH_FLAG(edituv_fdots), - [BUFFER_INDEX(vbo.fdots_edituv_data)] = BATCH_FLAG(edituv_fdots), - [BUFFER_INDEX(vbo.skin_roots)] = BATCH_FLAG(edit_skin_roots), - [BUFFER_INDEX(vbo.vert_idx)] = BATCH_FLAG(edit_selection_verts), - [BUFFER_INDEX(vbo.edge_idx)] = BATCH_FLAG(edit_selection_edges), - [BUFFER_INDEX(vbo.poly_idx)] = BATCH_FLAG(edit_selection_faces), - [BUFFER_INDEX(vbo.fdot_idx)] = BATCH_FLAG(edit_selection_fdots), - [BUFFER_INDEX(vbo.attr) + 0] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 1] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 2] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 3] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 4] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 5] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 6] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 7] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 8] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 9] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 10] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 11] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 12] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 13] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - [BUFFER_INDEX(vbo.attr) + 14] = BATCH_FLAG(surface) | SURFACE_PER_MAT_FLAG, - - [BUFFER_INDEX(ibo.tris)] = BATCH_FLAG(surface, - surface_weights, - edit_triangles, - edit_lnor, - edit_mesh_analysis, - edit_selection_faces, - sculpt_overlays), - [BUFFER_INDEX(ibo.lines)] = BATCH_FLAG( - edit_edges, edit_selection_edges, all_edges, wire_edges), - [BUFFER_INDEX(ibo.lines_loose)] = BATCH_FLAG(loose_edges), - [BUFFER_INDEX(ibo.points)] = BATCH_FLAG(edit_vnor, edit_vertices, edit_selection_verts), - [BUFFER_INDEX(ibo.fdots)] = BATCH_FLAG(edit_fdots, edit_selection_fdots), - [BUFFER_INDEX(ibo.lines_paint_mask)] = BATCH_FLAG(wire_loops), - [BUFFER_INDEX(ibo.lines_adjacency)] = BATCH_FLAG(edge_detection), - [BUFFER_INDEX(ibo.edituv_tris)] = BATCH_FLAG( - edituv_faces, edituv_faces_stretch_area, edituv_faces_stretch_angle), - [BUFFER_INDEX(ibo.edituv_lines)] = BATCH_FLAG(edituv_edges, wire_loops_uvs), - [BUFFER_INDEX(ibo.edituv_points)] = BATCH_FLAG(edituv_verts), - [BUFFER_INDEX(ibo.edituv_fdots)] = BATCH_FLAG(edituv_fdots), - [TRIS_PER_MAT_INDEX] = SURFACE_PER_MAT_FLAG, -}; - -#ifndef NDEBUG -static DRWBatchFlag g_buffer_deps_d[ARRAY_SIZE(g_buffer_deps)] = {0}; -#endif + +static constexpr DRWBatchFlag batches_that_use_buffer(const int buffer_index) +{ + switch (buffer_index) { + case BUFFER_INDEX(vbo.pos_nor): + return MBC_SURFACE | MBC_SURFACE_WEIGHTS | MBC_EDIT_TRIANGLES | MBC_EDIT_VERTICES | + MBC_EDIT_EDGES | MBC_EDIT_VNOR | MBC_EDIT_LNOR | MBC_EDIT_MESH_ANALYSIS | + MBC_EDIT_SELECTION_VERTS | MBC_EDIT_SELECTION_EDGES | MBC_EDIT_SELECTION_FACES | + MBC_ALL_VERTS | MBC_ALL_EDGES | MBC_LOOSE_EDGES | MBC_EDGE_DETECTION | + MBC_WIRE_EDGES | MBC_WIRE_LOOPS | MBC_SCULPT_OVERLAYS | MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.lnor): + return MBC_SURFACE | MBC_EDIT_LNOR | MBC_WIRE_LOOPS | MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.edge_fac): + return MBC_WIRE_EDGES; + case BUFFER_INDEX(vbo.weights): + return MBC_SURFACE_WEIGHTS; + case BUFFER_INDEX(vbo.uv): + return MBC_SURFACE | MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | + MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS | MBC_WIRE_LOOPS_UVS | + MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.tan): + return MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.vcol): + return MBC_SURFACE | MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.sculpt_data): + return MBC_SCULPT_OVERLAYS; + case BUFFER_INDEX(vbo.orco): + return MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(vbo.edit_data): + return MBC_EDIT_TRIANGLES | MBC_EDIT_EDGES | MBC_EDIT_VERTICES; + case BUFFER_INDEX(vbo.edituv_data): + return MBC_EDITUV_FACES | MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | + MBC_EDITUV_EDGES | MBC_EDITUV_VERTS; + case BUFFER_INDEX(vbo.edituv_stretch_area): + return MBC_EDITUV_FACES_STRETCH_AREA; + case BUFFER_INDEX(vbo.edituv_stretch_angle): + return MBC_EDITUV_FACES_STRETCH_ANGLE; + case BUFFER_INDEX(vbo.mesh_analysis): + return MBC_EDIT_MESH_ANALYSIS; + case BUFFER_INDEX(vbo.fdots_pos): + return MBC_EDIT_FACEDOTS | MBC_EDIT_SELECTION_FACEDOTS; + case BUFFER_INDEX(vbo.fdots_nor): + return MBC_EDIT_FACEDOTS; + case BUFFER_INDEX(vbo.fdots_uv): + return MBC_EDITUV_FACEDOTS; + case BUFFER_INDEX(vbo.fdots_edituv_data): + return MBC_EDITUV_FACEDOTS; + case BUFFER_INDEX(vbo.skin_roots): + return MBC_SKIN_ROOTS; + case BUFFER_INDEX(vbo.vert_idx): + return MBC_EDIT_SELECTION_VERTS; + case BUFFER_INDEX(vbo.edge_idx): + return MBC_EDIT_SELECTION_EDGES; + case BUFFER_INDEX(vbo.poly_idx): + return MBC_EDIT_SELECTION_FACES; + case BUFFER_INDEX(vbo.fdot_idx): + return MBC_EDIT_SELECTION_FACEDOTS; + case BUFFER_INDEX(vbo.attr[0]): + case BUFFER_INDEX(vbo.attr[1]): + case BUFFER_INDEX(vbo.attr[2]): + case BUFFER_INDEX(vbo.attr[3]): + case BUFFER_INDEX(vbo.attr[4]): + case BUFFER_INDEX(vbo.attr[5]): + case BUFFER_INDEX(vbo.attr[6]): + case BUFFER_INDEX(vbo.attr[7]): + case BUFFER_INDEX(vbo.attr[8]): + case BUFFER_INDEX(vbo.attr[9]): + case BUFFER_INDEX(vbo.attr[10]): + case BUFFER_INDEX(vbo.attr[11]): + case BUFFER_INDEX(vbo.attr[12]): + case BUFFER_INDEX(vbo.attr[13]): + case BUFFER_INDEX(vbo.attr[14]): + return MBC_SURFACE | MBC_SURFACE_PER_MAT; + case BUFFER_INDEX(ibo.tris): + return MBC_SURFACE | MBC_SURFACE_WEIGHTS | MBC_EDIT_TRIANGLES | MBC_EDIT_LNOR | + MBC_EDIT_MESH_ANALYSIS | MBC_EDIT_SELECTION_FACES | MBC_SCULPT_OVERLAYS; + case BUFFER_INDEX(ibo.lines): + return MBC_EDIT_EDGES | MBC_EDIT_SELECTION_EDGES | MBC_ALL_EDGES | MBC_WIRE_EDGES; + case BUFFER_INDEX(ibo.lines_loose): + return MBC_LOOSE_EDGES; + case BUFFER_INDEX(ibo.points): + return MBC_EDIT_VNOR | MBC_EDIT_VERTICES | MBC_EDIT_SELECTION_VERTS; + case BUFFER_INDEX(ibo.fdots): + return MBC_EDIT_FACEDOTS | MBC_EDIT_SELECTION_FACEDOTS; + case BUFFER_INDEX(ibo.lines_paint_mask): + return MBC_WIRE_LOOPS; + case BUFFER_INDEX(ibo.lines_adjacency): + return MBC_EDGE_DETECTION; + case BUFFER_INDEX(ibo.edituv_tris): + return MBC_EDITUV_FACES | MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE; + case BUFFER_INDEX(ibo.edituv_lines): + return MBC_EDITUV_EDGES | MBC_WIRE_LOOPS_UVS; + case BUFFER_INDEX(ibo.edituv_points): + return MBC_EDITUV_VERTS; + case BUFFER_INDEX(ibo.edituv_fdots): + return MBC_EDITUV_FACEDOTS; + case TRIS_PER_MAT_INDEX: + return MBC_SURFACE_PER_MAT; + } + return (DRWBatchFlag)0; +} static void mesh_batch_cache_discard_surface_batches(MeshBatchCache *cache); static void mesh_batch_cache_clear(Mesh *me); @@ -229,14 +201,14 @@ static void mesh_batch_cache_clear(Mesh *me); static void mesh_batch_cache_discard_batch(MeshBatchCache *cache, const DRWBatchFlag batch_map) { for (int i = 0; i < MBC_BATCH_LEN; i++) { - DRWBatchFlag batch_requested = (1u << i); + DRWBatchFlag batch_requested = (DRWBatchFlag)(1u << i); if (batch_map & batch_requested) { GPU_BATCH_DISCARD_SAFE(((GPUBatch **)&cache->batch)[i]); cache->batch_ready &= ~batch_requested; } } - if (batch_map & SURFACE_PER_MAT_FLAG) { + if (batch_map & MBC_SURFACE_PER_MAT) { mesh_batch_cache_discard_surface_batches(cache); } } @@ -374,7 +346,7 @@ static void mesh_cd_calc_active_mloopcol_layer(const Object *object, DRW_MeshCDMask *cd_used) { const Mesh *me_final = editmesh_final_or_this(object, me); - Mesh me_query = {0}; + Mesh me_query = blender::dna::shallow_zero_initialize(); const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final); const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final); @@ -451,7 +423,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, /* Create a mesh with final customdata domains * we can query with attribute API. */ - Mesh me_query = {0}; + Mesh me_query = blender::dna::shallow_zero_initialize(); BKE_id_attribute_copy_domains_temp( ID_ME, cd_vdata, cd_edata, cd_ldata, cd_pdata, NULL, &me_query.id); @@ -466,10 +438,9 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, ListBase gpu_attrs = GPU_material_attributes(gpumat); LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) { const char *name = gpu_attr->name; - int type = gpu_attr->type; + eCustomDataType type = static_cast<eCustomDataType>(gpu_attr->type); int layer = -1; - /* ATTR_DOMAIN_NUM is standard for "invalid value". */ - eAttrDomain domain = ATTR_DOMAIN_NUM; + std::optional<eAttrDomain> domain; if (type == CD_AUTO_FROM_NAME) { /* We need to deduce what exact layer is used. @@ -535,7 +506,6 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, } else { layer = -1; - domain = ATTR_DOMAIN_NUM; } } @@ -602,8 +572,8 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, break; } - if (layer != -1 && domain != ATTR_DOMAIN_NUM) { - drw_attributes_add_request(attributes, type, layer, domain); + if (layer != -1 && domain.has_value()) { + drw_attributes_add_request(attributes, type, layer, *domain); } break; } @@ -613,11 +583,13 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object, case CD_PROP_INT32: case CD_PROP_FLOAT: case CD_PROP_FLOAT2: { - if (layer != -1 && domain != ATTR_DOMAIN_NUM) { - drw_attributes_add_request(attributes, type, layer, domain); + if (layer != -1 && domain.has_value()) { + drw_attributes_add_request(attributes, type, layer, *domain); } break; } + default: + break; } } } @@ -654,13 +626,14 @@ static void drw_mesh_weight_state_copy(struct DRW_MeshWeightState *wstate_dst, memcpy(wstate_dst, wstate_src, sizeof(*wstate_dst)); if (wstate_src->defgroup_sel) { - wstate_dst->defgroup_sel = MEM_dupallocN(wstate_src->defgroup_sel); + wstate_dst->defgroup_sel = static_cast<bool *>(MEM_dupallocN(wstate_src->defgroup_sel)); } if (wstate_src->defgroup_locked) { - wstate_dst->defgroup_locked = MEM_dupallocN(wstate_src->defgroup_locked); + wstate_dst->defgroup_locked = static_cast<bool *>(MEM_dupallocN(wstate_src->defgroup_locked)); } if (wstate_src->defgroup_unlocked) { - wstate_dst->defgroup_unlocked = MEM_dupallocN(wstate_src->defgroup_unlocked); + wstate_dst->defgroup_unlocked = static_cast<bool *>( + MEM_dupallocN(wstate_src->defgroup_unlocked)); } } @@ -764,7 +737,7 @@ BLI_INLINE void mesh_batch_cache_add_request(MeshBatchCache *cache, DRWBatchFlag static bool mesh_batch_cache_valid(Object *object, Mesh *me) { - MeshBatchCache *cache = me->runtime.batch_cache; + MeshBatchCache *cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); if (cache == NULL) { return false; @@ -798,10 +771,11 @@ static bool mesh_batch_cache_valid(Object *object, Mesh *me) static void mesh_batch_cache_init(Object *object, Mesh *me) { - MeshBatchCache *cache = me->runtime.batch_cache; + MeshBatchCache *cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); if (!cache) { - cache = me->runtime.batch_cache = MEM_callocN(sizeof(*cache), __func__); + me->runtime.batch_cache = MEM_cnew<MeshBatchCache>(__func__); + cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); } else { memset(cache, 0, sizeof(*cache)); @@ -821,12 +795,14 @@ static void mesh_batch_cache_init(Object *object, Mesh *me) } cache->mat_len = mesh_render_mat_len_get(object, me); - cache->surface_per_mat = MEM_callocN(sizeof(*cache->surface_per_mat) * cache->mat_len, __func__); - cache->tris_per_mat = MEM_callocN(sizeof(*cache->tris_per_mat) * cache->mat_len, __func__); + cache->surface_per_mat = static_cast<GPUBatch **>( + MEM_callocN(sizeof(*cache->surface_per_mat) * cache->mat_len, __func__)); + cache->tris_per_mat = static_cast<GPUIndexBuf **>( + MEM_callocN(sizeof(*cache->tris_per_mat) * cache->mat_len, __func__)); cache->is_dirty = false; - cache->batch_ready = 0; - cache->batch_requested = 0; + cache->batch_ready = (DRWBatchFlag)0; + cache->batch_requested = (DRWBatchFlag)0; drw_mesh_weight_state_clear(&cache->weight_state); } @@ -841,7 +817,7 @@ void DRW_mesh_batch_cache_validate(Object *object, Mesh *me) static MeshBatchCache *mesh_batch_cache_get(Mesh *me) { - return me->runtime.batch_cache; + return static_cast<MeshBatchCache *>(me->runtime.batch_cache); } static void mesh_batch_cache_check_vertex_group(MeshBatchCache *cache, @@ -950,7 +926,7 @@ static void mesh_batch_cache_discard_uvedit_select(MeshBatchCache *cache) void DRW_mesh_batch_cache_dirty_tag(Mesh *me, eMeshBatchDirtyMode mode) { - MeshBatchCache *cache = me->runtime.batch_cache; + MeshBatchCache *cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); if (cache == NULL) { return; } @@ -1038,7 +1014,7 @@ static void mesh_batch_cache_free_subdiv_cache(MeshBatchCache *cache) static void mesh_batch_cache_clear(Mesh *me) { - MeshBatchCache *cache = me->runtime.batch_cache; + MeshBatchCache *cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); if (!cache) { return; } @@ -1061,7 +1037,7 @@ static void mesh_batch_cache_clear(Mesh *me) MEM_SAFE_FREE(cache->surface_per_mat); cache->mat_len = 0; - cache->batch_ready = 0; + cache->batch_ready = (DRWBatchFlag)0; drw_mesh_weight_state_clear(&cache->weight_state); mesh_batch_cache_free_subdiv_cache(cache); @@ -1110,7 +1086,7 @@ static void sculpt_request_active_vcol(MeshBatchCache *cache, Object *object, Me const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final); const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final); - Mesh me_query = {0}; + Mesh me_query = blender::dna::shallow_zero_initialize(); BKE_id_attribute_copy_domains_temp(ID_ME, cd_vdata, NULL, cd_ldata, NULL, NULL, &me_query.id); CustomDataLayer *active = BKE_id_attributes_active_color_get(&me_query.id); @@ -1471,7 +1447,7 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_edges(Object *object, Mesh *me) void DRW_mesh_batch_cache_free_old(Mesh *me, int ctime) { - MeshBatchCache *cache = me->runtime.batch_cache; + MeshBatchCache *cache = static_cast<MeshBatchCache *>(me->runtime.batch_cache); if (cache == NULL) { return; @@ -1513,7 +1489,7 @@ static void drw_mesh_batch_cache_check_available(struct TaskGraph *task_graph, M * happening in release builds). */ BLI_task_graph_work_and_wait(task_graph); for (int i = 0; i < MBC_BATCH_LEN; i++) { - BLI_assert(!DRW_batch_requested(((GPUBatch **)&cache->batch)[i], 0)); + BLI_assert(!DRW_batch_requested(((GPUBatch **)&cache->batch)[i], (GPUPrimType)0)); } for (int i = 0; i < MBC_VBO_LEN; i++) { BLI_assert(!DRW_vbo_requested(((GPUVertBuf **)&cache->final.buff.vbo)[i])); @@ -1559,6 +1535,25 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, return; } +#ifdef DEBUG + /* Map the index of a buffer to a flag containing all batches that use it. */ + Map<int, DRWBatchFlag> batches_that_use_buffer_local; + + auto assert_deps_valid = [&](DRWBatchFlag batch_flag, Span<int> used_buffer_indices) { + for (const int buffer_index : used_buffer_indices) { + batches_that_use_buffer_local.add_or_modify( + buffer_index, + [&](DRWBatchFlag *value) { *value = batch_flag; }, + [&](DRWBatchFlag *value) { *value |= batch_flag; }); + BLI_assert(batches_that_use_buffer(buffer_index) & batch_flag); + } + }; +#else + auto assert_deps_valid = [&](DRWBatchFlag UNUSED(batch_flag), + Span<int> UNUSED(used_buffer_indices)) {}; + +#endif + /* Sanity check. */ if ((me->edit_mesh != NULL) && (ob->mode & OB_MODE_EDIT)) { BLI_assert(BKE_object_get_editmesh_eval_final(ob) != NULL); @@ -1572,7 +1567,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, const bool is_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob); DRWBatchFlag batch_requested = cache->batch_requested; - cache->batch_requested = 0; + cache->batch_requested = (DRWBatchFlag)0; if (batch_requested & MBC_SURFACE_WEIGHTS) { /* Check vertex weights. */ @@ -1692,7 +1687,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, * per redraw when smooth shading is enabled. */ const bool do_update_sculpt_normals = ob->sculpt && ob->sculpt->pbvh; if (do_update_sculpt_normals) { - Mesh *mesh = ob->data; + Mesh *mesh = static_cast<Mesh *>(ob->data); BKE_pbvh_update_normals(ob->sculpt->pbvh, mesh->runtime.subdiv_ccg); } @@ -1712,27 +1707,15 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, MeshBufferList *mbuflist = &cache->final.buff; /* Initialize batches and request VBO's & IBO's. */ - MDEPS_ASSERT(surface, - ibo.tris, - vbo.lnor, - vbo.pos_nor, - vbo.uv, - vbo.vcol, - vbo.attr[0], - vbo.attr[1], - vbo.attr[2], - vbo.attr[3], - vbo.attr[4], - vbo.attr[5], - vbo.attr[6], - vbo.attr[7], - vbo.attr[8], - vbo.attr[9], - vbo.attr[10], - vbo.attr[11], - vbo.attr[12], - vbo.attr[13], - vbo.attr[14]); + assert_deps_valid( + MBC_SURFACE, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.lnor), BUFFER_INDEX(vbo.pos_nor), + BUFFER_INDEX(vbo.uv), BUFFER_INDEX(vbo.vcol), BUFFER_INDEX(vbo.attr[0]), + BUFFER_INDEX(vbo.attr[1]), BUFFER_INDEX(vbo.attr[2]), BUFFER_INDEX(vbo.attr[3]), + BUFFER_INDEX(vbo.attr[4]), BUFFER_INDEX(vbo.attr[5]), BUFFER_INDEX(vbo.attr[6]), + BUFFER_INDEX(vbo.attr[7]), BUFFER_INDEX(vbo.attr[8]), BUFFER_INDEX(vbo.attr[9]), + BUFFER_INDEX(vbo.attr[10]), BUFFER_INDEX(vbo.attr[11]), BUFFER_INDEX(vbo.attr[12]), + BUFFER_INDEX(vbo.attr[13]), BUFFER_INDEX(vbo.attr[14])}); if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.surface, &mbuflist->ibo.tris); /* Order matters. First ones override latest VBO's attributes. */ @@ -1746,52 +1729,61 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, } drw_add_attributes_vbo(cache->batch.surface, mbuflist, &cache->attr_used); } - MDEPS_ASSERT(all_verts, vbo.pos_nor); + assert_deps_valid(MBC_ALL_VERTS, {BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) { DRW_vbo_request(cache->batch.all_verts, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(sculpt_overlays, ibo.tris, vbo.pos_nor, vbo.sculpt_data); + assert_deps_valid( + MBC_SCULPT_OVERLAYS, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.sculpt_data)}); if (DRW_batch_requested(cache->batch.sculpt_overlays, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.sculpt_overlays, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.sculpt_overlays, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.sculpt_overlays, &mbuflist->vbo.sculpt_data); } - MDEPS_ASSERT(all_edges, ibo.lines, vbo.pos_nor); + assert_deps_valid(MBC_ALL_EDGES, {BUFFER_INDEX(ibo.lines), BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.all_edges, &mbuflist->ibo.lines); DRW_vbo_request(cache->batch.all_edges, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(loose_edges, ibo.lines_loose, vbo.pos_nor); + assert_deps_valid(MBC_LOOSE_EDGES, {BUFFER_INDEX(ibo.lines_loose), BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.loose_edges, GPU_PRIM_LINES)) { DRW_ibo_request(NULL, &mbuflist->ibo.lines); DRW_ibo_request(cache->batch.loose_edges, &mbuflist->ibo.lines_loose); DRW_vbo_request(cache->batch.loose_edges, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(edge_detection, ibo.lines_adjacency, vbo.pos_nor); + assert_deps_valid(MBC_EDGE_DETECTION, + {BUFFER_INDEX(ibo.lines_adjacency), BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.edge_detection, GPU_PRIM_LINES_ADJ)) { DRW_ibo_request(cache->batch.edge_detection, &mbuflist->ibo.lines_adjacency); DRW_vbo_request(cache->batch.edge_detection, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(surface_weights, ibo.tris, vbo.pos_nor, vbo.weights); + assert_deps_valid( + MBC_SURFACE_WEIGHTS, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.weights)}); if (DRW_batch_requested(cache->batch.surface_weights, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.surface_weights, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.surface_weights, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.surface_weights, &mbuflist->vbo.weights); } - MDEPS_ASSERT(wire_loops, ibo.lines_paint_mask, vbo.lnor, vbo.pos_nor); + assert_deps_valid( + MBC_WIRE_LOOPS, + {BUFFER_INDEX(ibo.lines_paint_mask), BUFFER_INDEX(vbo.lnor), BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.wire_loops, &mbuflist->ibo.lines_paint_mask); /* Order matters. First ones override latest VBO's attributes. */ DRW_vbo_request(cache->batch.wire_loops, &mbuflist->vbo.lnor); DRW_vbo_request(cache->batch.wire_loops, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(wire_edges, ibo.lines, vbo.pos_nor, vbo.edge_fac); + assert_deps_valid( + MBC_WIRE_EDGES, + {BUFFER_INDEX(ibo.lines), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.edge_fac)}); if (DRW_batch_requested(cache->batch.wire_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.wire_edges, &mbuflist->ibo.lines); DRW_vbo_request(cache->batch.wire_edges, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.wire_edges, &mbuflist->vbo.edge_fac); } - MDEPS_ASSERT(wire_loops_uvs, ibo.edituv_lines, vbo.uv); + assert_deps_valid(MBC_WIRE_LOOPS_UVS, {BUFFER_INDEX(ibo.edituv_lines), BUFFER_INDEX(vbo.uv)}); if (DRW_batch_requested(cache->batch.wire_loops_uvs, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.wire_loops_uvs, &mbuflist->ibo.edituv_lines); /* For paint overlay. Active layer should have been queried. */ @@ -1799,7 +1791,9 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, DRW_vbo_request(cache->batch.wire_loops_uvs, &mbuflist->vbo.uv); } } - MDEPS_ASSERT(edit_mesh_analysis, ibo.tris, vbo.pos_nor, vbo.mesh_analysis); + assert_deps_valid( + MBC_EDIT_MESH_ANALYSIS, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.mesh_analysis)}); if (DRW_batch_requested(cache->batch.edit_mesh_analysis, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edit_mesh_analysis, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.edit_mesh_analysis, &mbuflist->vbo.pos_nor); @@ -1807,29 +1801,16 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, } /* Per Material */ - MDEPS_ASSERT_FLAG(SURFACE_PER_MAT_FLAG, - vbo.lnor, - vbo.pos_nor, - vbo.uv, - vbo.tan, - vbo.vcol, - vbo.orco, - vbo.attr[0], - vbo.attr[1], - vbo.attr[2], - vbo.attr[3], - vbo.attr[4], - vbo.attr[5], - vbo.attr[6], - vbo.attr[7], - vbo.attr[8], - vbo.attr[9], - vbo.attr[10], - vbo.attr[11], - vbo.attr[12], - vbo.attr[13], - vbo.attr[14]); - MDEPS_ASSERT_INDEX(TRIS_PER_MAT_INDEX, SURFACE_PER_MAT_FLAG); + assert_deps_valid( + MBC_SURFACE_PER_MAT, + {BUFFER_INDEX(vbo.lnor), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.uv), + BUFFER_INDEX(vbo.tan), BUFFER_INDEX(vbo.vcol), BUFFER_INDEX(vbo.orco), + BUFFER_INDEX(vbo.attr[0]), BUFFER_INDEX(vbo.attr[1]), BUFFER_INDEX(vbo.attr[2]), + BUFFER_INDEX(vbo.attr[3]), BUFFER_INDEX(vbo.attr[4]), BUFFER_INDEX(vbo.attr[5]), + BUFFER_INDEX(vbo.attr[6]), BUFFER_INDEX(vbo.attr[7]), BUFFER_INDEX(vbo.attr[8]), + BUFFER_INDEX(vbo.attr[9]), BUFFER_INDEX(vbo.attr[10]), BUFFER_INDEX(vbo.attr[11]), + BUFFER_INDEX(vbo.attr[12]), BUFFER_INDEX(vbo.attr[13]), BUFFER_INDEX(vbo.attr[14])}); + assert_deps_valid(MBC_SURFACE_PER_MAT, {TRIS_PER_MAT_INDEX}); for (int i = 0; i < cache->mat_len; i++) { if (DRW_batch_requested(cache->surface_per_mat[i], GPU_PRIM_TRIS)) { DRW_ibo_request(cache->surface_per_mat[i], &cache->tris_per_mat[i]); @@ -1855,66 +1836,83 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, mbuflist = (do_cage) ? &cache->cage.buff : &cache->final.buff; /* Edit Mesh */ - MDEPS_ASSERT(edit_triangles, ibo.tris, vbo.pos_nor, vbo.edit_data); + assert_deps_valid( + MBC_EDIT_TRIANGLES, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.edit_data)}); if (DRW_batch_requested(cache->batch.edit_triangles, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edit_triangles, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.edit_triangles, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_triangles, &mbuflist->vbo.edit_data); } - MDEPS_ASSERT(edit_vertices, ibo.points, vbo.pos_nor, vbo.edit_data); + assert_deps_valid( + MBC_EDIT_VERTICES, + {BUFFER_INDEX(ibo.points), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.edit_data)}); if (DRW_batch_requested(cache->batch.edit_vertices, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_vertices, &mbuflist->ibo.points); DRW_vbo_request(cache->batch.edit_vertices, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_vertices, &mbuflist->vbo.edit_data); } - MDEPS_ASSERT(edit_edges, ibo.lines, vbo.pos_nor, vbo.edit_data); + assert_deps_valid( + MBC_EDIT_EDGES, + {BUFFER_INDEX(ibo.lines), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.edit_data)}); if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.edit_edges, &mbuflist->ibo.lines); DRW_vbo_request(cache->batch.edit_edges, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_edges, &mbuflist->vbo.edit_data); } - MDEPS_ASSERT(edit_vnor, ibo.points, vbo.pos_nor); + assert_deps_valid(MBC_EDIT_VNOR, {BUFFER_INDEX(ibo.points), BUFFER_INDEX(vbo.pos_nor)}); if (DRW_batch_requested(cache->batch.edit_vnor, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_vnor, &mbuflist->ibo.points); DRW_vbo_request(cache->batch.edit_vnor, &mbuflist->vbo.pos_nor); } - MDEPS_ASSERT(edit_lnor, ibo.tris, vbo.pos_nor, vbo.lnor); + assert_deps_valid(MBC_EDIT_LNOR, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.lnor)}); if (DRW_batch_requested(cache->batch.edit_lnor, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_lnor, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.edit_lnor, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_lnor, &mbuflist->vbo.lnor); } - MDEPS_ASSERT(edit_fdots, ibo.fdots, vbo.fdots_pos, vbo.fdots_nor); + assert_deps_valid( + MBC_EDIT_FACEDOTS, + {BUFFER_INDEX(ibo.fdots), BUFFER_INDEX(vbo.fdots_pos), BUFFER_INDEX(vbo.fdots_nor)}); if (DRW_batch_requested(cache->batch.edit_fdots, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_fdots, &mbuflist->ibo.fdots); DRW_vbo_request(cache->batch.edit_fdots, &mbuflist->vbo.fdots_pos); DRW_vbo_request(cache->batch.edit_fdots, &mbuflist->vbo.fdots_nor); } - MDEPS_ASSERT(edit_skin_roots, vbo.skin_roots); + assert_deps_valid(MBC_SKIN_ROOTS, {BUFFER_INDEX(vbo.skin_roots)}); if (DRW_batch_requested(cache->batch.edit_skin_roots, GPU_PRIM_POINTS)) { DRW_vbo_request(cache->batch.edit_skin_roots, &mbuflist->vbo.skin_roots); } /* Selection */ - MDEPS_ASSERT(edit_selection_verts, ibo.points, vbo.pos_nor, vbo.vert_idx); + assert_deps_valid( + MBC_EDIT_SELECTION_VERTS, + {BUFFER_INDEX(ibo.points), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.vert_idx)}); if (DRW_batch_requested(cache->batch.edit_selection_verts, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_selection_verts, &mbuflist->ibo.points); DRW_vbo_request(cache->batch.edit_selection_verts, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_selection_verts, &mbuflist->vbo.vert_idx); } - MDEPS_ASSERT(edit_selection_edges, ibo.lines, vbo.pos_nor, vbo.edge_idx); + assert_deps_valid( + MBC_EDIT_SELECTION_EDGES, + {BUFFER_INDEX(ibo.lines), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.edge_idx)}); if (DRW_batch_requested(cache->batch.edit_selection_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.edit_selection_edges, &mbuflist->ibo.lines); DRW_vbo_request(cache->batch.edit_selection_edges, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_selection_edges, &mbuflist->vbo.edge_idx); } - MDEPS_ASSERT(edit_selection_faces, ibo.tris, vbo.pos_nor, vbo.poly_idx); + assert_deps_valid( + MBC_EDIT_SELECTION_FACES, + {BUFFER_INDEX(ibo.tris), BUFFER_INDEX(vbo.pos_nor), BUFFER_INDEX(vbo.poly_idx)}); if (DRW_batch_requested(cache->batch.edit_selection_faces, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edit_selection_faces, &mbuflist->ibo.tris); DRW_vbo_request(cache->batch.edit_selection_faces, &mbuflist->vbo.pos_nor); DRW_vbo_request(cache->batch.edit_selection_faces, &mbuflist->vbo.poly_idx); } - MDEPS_ASSERT(edit_selection_fdots, ibo.fdots, vbo.fdots_pos, vbo.fdot_idx); + assert_deps_valid( + MBC_EDIT_SELECTION_FACEDOTS, + {BUFFER_INDEX(ibo.fdots), BUFFER_INDEX(vbo.fdots_pos), BUFFER_INDEX(vbo.fdot_idx)}); if (DRW_batch_requested(cache->batch.edit_selection_fdots, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edit_selection_fdots, &mbuflist->ibo.fdots); DRW_vbo_request(cache->batch.edit_selection_fdots, &mbuflist->vbo.fdots_pos); @@ -1929,126 +1927,141 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, mbuflist = (do_uvcage) ? &cache->uv_cage.buff : &cache->final.buff; /* Edit UV */ - MDEPS_ASSERT(edituv_faces, ibo.edituv_tris, vbo.uv, vbo.edituv_data); + assert_deps_valid( + MBC_EDITUV_FACES, + {BUFFER_INDEX(ibo.edituv_tris), BUFFER_INDEX(vbo.uv), BUFFER_INDEX(vbo.edituv_data)}); if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edituv_faces, &mbuflist->ibo.edituv_tris); DRW_vbo_request(cache->batch.edituv_faces, &mbuflist->vbo.uv); DRW_vbo_request(cache->batch.edituv_faces, &mbuflist->vbo.edituv_data); } - MDEPS_ASSERT(edituv_faces_stretch_area, - ibo.edituv_tris, - vbo.uv, - vbo.edituv_data, - vbo.edituv_stretch_area); + assert_deps_valid(MBC_EDITUV_FACES_STRETCH_AREA, + {BUFFER_INDEX(ibo.edituv_tris), + BUFFER_INDEX(vbo.uv), + BUFFER_INDEX(vbo.edituv_data), + BUFFER_INDEX(vbo.edituv_stretch_area)}); if (DRW_batch_requested(cache->batch.edituv_faces_stretch_area, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edituv_faces_stretch_area, &mbuflist->ibo.edituv_tris); DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbuflist->vbo.uv); DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbuflist->vbo.edituv_data); DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbuflist->vbo.edituv_stretch_area); } - MDEPS_ASSERT(edituv_faces_stretch_angle, - ibo.edituv_tris, - vbo.uv, - vbo.edituv_data, - vbo.edituv_stretch_angle); + assert_deps_valid(MBC_EDITUV_FACES_STRETCH_ANGLE, + {BUFFER_INDEX(ibo.edituv_tris), + BUFFER_INDEX(vbo.uv), + BUFFER_INDEX(vbo.edituv_data), + BUFFER_INDEX(vbo.edituv_stretch_angle)}); if (DRW_batch_requested(cache->batch.edituv_faces_stretch_angle, GPU_PRIM_TRIS)) { DRW_ibo_request(cache->batch.edituv_faces_stretch_angle, &mbuflist->ibo.edituv_tris); DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbuflist->vbo.uv); DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbuflist->vbo.edituv_data); DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbuflist->vbo.edituv_stretch_angle); } - MDEPS_ASSERT(edituv_edges, ibo.edituv_lines, vbo.uv, vbo.edituv_data); + assert_deps_valid( + MBC_EDITUV_EDGES, + {BUFFER_INDEX(ibo.edituv_lines), BUFFER_INDEX(vbo.uv), BUFFER_INDEX(vbo.edituv_data)}); if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.edituv_edges, &mbuflist->ibo.edituv_lines); DRW_vbo_request(cache->batch.edituv_edges, &mbuflist->vbo.uv); DRW_vbo_request(cache->batch.edituv_edges, &mbuflist->vbo.edituv_data); } - MDEPS_ASSERT(edituv_verts, ibo.edituv_points, vbo.uv, vbo.edituv_data); + assert_deps_valid( + MBC_EDITUV_VERTS, + {BUFFER_INDEX(ibo.edituv_points), BUFFER_INDEX(vbo.uv), BUFFER_INDEX(vbo.edituv_data)}); if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edituv_verts, &mbuflist->ibo.edituv_points); DRW_vbo_request(cache->batch.edituv_verts, &mbuflist->vbo.uv); DRW_vbo_request(cache->batch.edituv_verts, &mbuflist->vbo.edituv_data); } - MDEPS_ASSERT(edituv_fdots, ibo.edituv_fdots, vbo.fdots_uv, vbo.fdots_edituv_data); + assert_deps_valid(MBC_EDITUV_FACEDOTS, + {BUFFER_INDEX(ibo.edituv_fdots), + BUFFER_INDEX(vbo.fdots_uv), + BUFFER_INDEX(vbo.fdots_edituv_data)}); if (DRW_batch_requested(cache->batch.edituv_fdots, GPU_PRIM_POINTS)) { DRW_ibo_request(cache->batch.edituv_fdots, &mbuflist->ibo.edituv_fdots); DRW_vbo_request(cache->batch.edituv_fdots, &mbuflist->vbo.fdots_uv); DRW_vbo_request(cache->batch.edituv_fdots, &mbuflist->vbo.fdots_edituv_data); } - MDEPS_ASSERT_MAP(vbo.lnor); - MDEPS_ASSERT_MAP(vbo.pos_nor); - MDEPS_ASSERT_MAP(vbo.uv); - MDEPS_ASSERT_MAP(vbo.vcol); - MDEPS_ASSERT_MAP(vbo.sculpt_data); - MDEPS_ASSERT_MAP(vbo.weights); - MDEPS_ASSERT_MAP(vbo.edge_fac); - MDEPS_ASSERT_MAP(vbo.mesh_analysis); - MDEPS_ASSERT_MAP(vbo.tan); - MDEPS_ASSERT_MAP(vbo.orco); - MDEPS_ASSERT_MAP(vbo.edit_data); - MDEPS_ASSERT_MAP(vbo.fdots_pos); - MDEPS_ASSERT_MAP(vbo.fdots_nor); - MDEPS_ASSERT_MAP(vbo.skin_roots); - MDEPS_ASSERT_MAP(vbo.vert_idx); - MDEPS_ASSERT_MAP(vbo.edge_idx); - MDEPS_ASSERT_MAP(vbo.poly_idx); - MDEPS_ASSERT_MAP(vbo.fdot_idx); - MDEPS_ASSERT_MAP(vbo.edituv_data); - MDEPS_ASSERT_MAP(vbo.edituv_stretch_area); - MDEPS_ASSERT_MAP(vbo.edituv_stretch_angle); - MDEPS_ASSERT_MAP(vbo.fdots_uv); - MDEPS_ASSERT_MAP(vbo.fdots_edituv_data); - for (int i = 0; i < GPU_MAX_ATTR; i++) { - MDEPS_ASSERT_MAP(vbo.attr[i]); - } - - MDEPS_ASSERT_MAP(ibo.tris); - MDEPS_ASSERT_MAP(ibo.lines); - MDEPS_ASSERT_MAP(ibo.lines_loose); - MDEPS_ASSERT_MAP(ibo.lines_adjacency); - MDEPS_ASSERT_MAP(ibo.lines_paint_mask); - MDEPS_ASSERT_MAP(ibo.points); - MDEPS_ASSERT_MAP(ibo.fdots); - MDEPS_ASSERT_MAP(ibo.edituv_tris); - MDEPS_ASSERT_MAP(ibo.edituv_lines); - MDEPS_ASSERT_MAP(ibo.edituv_points); - MDEPS_ASSERT_MAP(ibo.edituv_fdots); - - MDEPS_ASSERT_MAP_INDEX(TRIS_PER_MAT_INDEX); +#ifdef DEBUG + auto assert_final_deps_valid = [&](const int buffer_index) { + BLI_assert(batches_that_use_buffer(buffer_index) == + batches_that_use_buffer_local.lookup(buffer_index)); + }; + assert_final_deps_valid(BUFFER_INDEX(vbo.lnor)); + assert_final_deps_valid(BUFFER_INDEX(vbo.pos_nor)); + assert_final_deps_valid(BUFFER_INDEX(vbo.uv)); + assert_final_deps_valid(BUFFER_INDEX(vbo.vcol)); + assert_final_deps_valid(BUFFER_INDEX(vbo.sculpt_data)); + assert_final_deps_valid(BUFFER_INDEX(vbo.weights)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edge_fac)); + assert_final_deps_valid(BUFFER_INDEX(vbo.mesh_analysis)); + assert_final_deps_valid(BUFFER_INDEX(vbo.tan)); + assert_final_deps_valid(BUFFER_INDEX(vbo.orco)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edit_data)); + assert_final_deps_valid(BUFFER_INDEX(vbo.fdots_pos)); + assert_final_deps_valid(BUFFER_INDEX(vbo.fdots_nor)); + assert_final_deps_valid(BUFFER_INDEX(vbo.skin_roots)); + assert_final_deps_valid(BUFFER_INDEX(vbo.vert_idx)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edge_idx)); + assert_final_deps_valid(BUFFER_INDEX(vbo.poly_idx)); + assert_final_deps_valid(BUFFER_INDEX(vbo.fdot_idx)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edituv_data)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edituv_stretch_area)); + assert_final_deps_valid(BUFFER_INDEX(vbo.edituv_stretch_angle)); + assert_final_deps_valid(BUFFER_INDEX(vbo.fdots_uv)); + assert_final_deps_valid(BUFFER_INDEX(vbo.fdots_edituv_data)); + for (const int i : IndexRange(GPU_MAX_ATTR)) { + assert_final_deps_valid(BUFFER_INDEX(vbo.attr[i])); + } + + assert_final_deps_valid(BUFFER_INDEX(ibo.tris)); + assert_final_deps_valid(BUFFER_INDEX(ibo.lines)); + assert_final_deps_valid(BUFFER_INDEX(ibo.lines_loose)); + assert_final_deps_valid(BUFFER_INDEX(ibo.lines_adjacency)); + assert_final_deps_valid(BUFFER_INDEX(ibo.lines_paint_mask)); + assert_final_deps_valid(BUFFER_INDEX(ibo.points)); + assert_final_deps_valid(BUFFER_INDEX(ibo.fdots)); + assert_final_deps_valid(BUFFER_INDEX(ibo.edituv_tris)); + assert_final_deps_valid(BUFFER_INDEX(ibo.edituv_lines)); + assert_final_deps_valid(BUFFER_INDEX(ibo.edituv_points)); + assert_final_deps_valid(BUFFER_INDEX(ibo.edituv_fdots)); + + assert_final_deps_valid(TRIS_PER_MAT_INDEX); +#endif if (do_uvcage) { - mesh_buffer_cache_create_requested(task_graph, - cache, - &cache->uv_cage, - ob, - me, - is_editmode, - is_paint_mode, - is_mode_active, - ob->obmat, - false, - true, - scene, - ts, - true); + blender::draw::mesh_buffer_cache_create_requested(task_graph, + cache, + &cache->uv_cage, + ob, + me, + is_editmode, + is_paint_mode, + is_mode_active, + ob->obmat, + false, + true, + scene, + ts, + true); } if (do_cage) { - mesh_buffer_cache_create_requested(task_graph, - cache, - &cache->cage, - ob, - me, - is_editmode, - is_paint_mode, - is_mode_active, - ob->obmat, - false, - false, - scene, - ts, - true); + blender::draw::mesh_buffer_cache_create_requested(task_graph, + cache, + &cache->cage, + ob, + me, + is_editmode, + is_paint_mode, + is_mode_active, + ob->obmat, + false, + false, + scene, + ts, + true); } if (do_subdivision) { @@ -2072,20 +2085,20 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, mesh_batch_cache_free_subdiv_cache(cache); } - mesh_buffer_cache_create_requested(task_graph, - cache, - &cache->final, - ob, - me, - is_editmode, - is_paint_mode, - is_mode_active, - ob->obmat, - true, - false, - scene, - ts, - use_hide); + blender::draw::mesh_buffer_cache_create_requested(task_graph, + cache, + &cache->final, + ob, + me, + is_editmode, + is_paint_mode, + is_mode_active, + ob->obmat, + true, + false, + scene, + ts, + use_hide); /* Ensure that all requested batches have finished. * Ideally we want to remove this sync, but there are cases where this doesn't work. diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index b5cdbd3617e..e7726ff55ca 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -39,10 +39,10 @@ #include "opensubdiv_evaluator_capi.h" #include "opensubdiv_topology_refiner_capi.h" -#include "draw_cache_extract.h" +#include "draw_cache_extract.hh" #include "draw_cache_impl.h" #include "draw_cache_inline.h" -#include "mesh_extractors/extract_mesh.h" +#include "mesh_extractors/extract_mesh.hh" extern "C" char datatoc_common_subdiv_custom_data_interp_comp_glsl[]; extern "C" char datatoc_common_subdiv_ibo_lines_comp_glsl[]; @@ -2099,7 +2099,7 @@ static bool draw_subdiv_create_requested_buffers(const Scene *scene, draw_subdiv_cache_update_extra_coarse_face_data(draw_cache, mesh_eval, mr); - mesh_buffer_cache_create_requested_subdiv(batch_cache, mbc, draw_cache, mr); + blender::draw::mesh_buffer_cache_create_requested_subdiv(batch_cache, mbc, draw_cache, mr); mesh_render_data_free(mr); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh.c b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc index 9dc82fa3d32..7e02fbbf7d0 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh.c +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh.cc @@ -13,7 +13,7 @@ #include "ED_uvedit.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_cache_impl.h" @@ -29,7 +29,7 @@ void *mesh_extract_buffer_get(const MeshExtract *extractor, MeshBufferList *mbuf eMRIterType mesh_extract_iter_type(const MeshExtract *ext) { - eMRIterType type = 0; + eMRIterType type = (eMRIterType)0; SET_FLAG_FROM_TEST(type, (ext->iter_looptri_bm || ext->iter_looptri_mesh), MR_ITER_LOOPTRI); SET_FLAG_FROM_TEST(type, (ext->iter_poly_bm || ext->iter_poly_mesh), MR_ITER_POLY); SET_FLAG_FROM_TEST(type, (ext->iter_ledge_bm || ext->iter_ledge_mesh), MR_ITER_LEDGE); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh.h b/source/blender/draw/intern/mesh_extractors/extract_mesh.hh index b88cd9e77d2..bc97a62e4b1 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh.h +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh.hh @@ -17,11 +17,7 @@ #include "BKE_customdata.h" #include "BKE_editmesh.h" -#include "draw_cache_extract.h" - -#ifdef __cplusplus -extern "C" { -#endif +#include "draw_cache_extract.hh" struct DRWSubdivCache; @@ -31,13 +27,13 @@ struct DRWSubdivCache; /** \name Mesh Render Data * \{ */ -typedef enum eMRExtractType { +enum eMRExtractType { MR_EXTRACT_BMESH, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH, -} eMRExtractType; +}; -typedef struct MeshRenderData { +struct MeshRenderData { eMRExtractType extract_type; int poly_len, edge_len, vert_len, loop_len; @@ -95,7 +91,7 @@ typedef struct MeshRenderData { int *mat_tri_len; int visible_tri_len; } poly_sorted; -} MeshRenderData; +}; BLI_INLINE BMFace *bm_original_face_get(const MeshRenderData *mr, int idx) { @@ -159,71 +155,71 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData *mr, const BMFace *e /* TODO(jbakker): move parameters inside a struct. */ -typedef void(ExtractTriBMeshFn)(const MeshRenderData *mr, BMLoop **elt, int elt_index, void *data); -typedef void(ExtractTriMeshFn)(const MeshRenderData *mr, - const MLoopTri *mlt, - int elt_index, - void *data); -typedef void(ExtractPolyBMeshFn)(const MeshRenderData *mr, - const BMFace *f, - int f_index, - void *data); -typedef void(ExtractPolyMeshFn)(const MeshRenderData *mr, - const MPoly *mp, - int mp_index, +using ExtractTriBMeshFn = void(const MeshRenderData *mr, BMLoop **elt, int elt_index, void *data); +using ExtractTriMeshFn = void(const MeshRenderData *mr, + const MLoopTri *mlt, + int elt_index, + void *data); +using ExtractPolyBMeshFn = void(const MeshRenderData *mr, + const BMFace *f, + int f_index, void *data); -typedef void(ExtractLEdgeBMeshFn)(const MeshRenderData *mr, - const BMEdge *eed, - int ledge_index, - void *data); -typedef void(ExtractLEdgeMeshFn)(const MeshRenderData *mr, - const MEdge *med, +using ExtractPolyMeshFn = void(const MeshRenderData *mr, + const MPoly *mp, + int mp_index, + void *data); +using ExtractLEdgeBMeshFn = void(const MeshRenderData *mr, + const BMEdge *eed, int ledge_index, void *data); -typedef void(ExtractLVertBMeshFn)(const MeshRenderData *mr, - const BMVert *eve, - int lvert_index, - void *data); -typedef void(ExtractLVertMeshFn)(const MeshRenderData *mr, - const MVert *mv, +using ExtractLEdgeMeshFn = void(const MeshRenderData *mr, + const MEdge *med, + int ledge_index, + void *data); +using ExtractLVertBMeshFn = void(const MeshRenderData *mr, + const BMVert *eve, int lvert_index, void *data); -typedef void(ExtractLooseGeomSubdivFn)(const struct DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - void *buffer, - void *data); -typedef void(ExtractInitFn)(const MeshRenderData *mr, - struct MeshBatchCache *cache, - void *buffer, - void *r_data); -typedef void(ExtractFinishFn)(const MeshRenderData *mr, - struct MeshBatchCache *cache, - void *buffer, - void *data); -typedef void(ExtractTaskReduceFn)(void *userdata, void *task_userdata); - -typedef void(ExtractInitSubdivFn)(const struct DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - struct MeshBatchCache *cache, - void *buf, - void *data); -typedef void(ExtractIterSubdivBMeshFn)(const struct DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - void *data, - uint subdiv_quad_index, - const BMFace *coarse_quad); -typedef void(ExtractIterSubdivMeshFn)(const struct DRWSubdivCache *subdiv_cache, +using ExtractLVertMeshFn = void(const MeshRenderData *mr, + const MVert *mv, + int lvert_index, + void *data); +using ExtractLooseGeomSubdivFn = void(const struct DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *buffer, + void *data); +using ExtractInitFn = void(const MeshRenderData *mr, + struct MeshBatchCache *cache, + void *buffer, + void *r_data); +using ExtractFinishFn = void(const MeshRenderData *mr, + struct MeshBatchCache *cache, + void *buffer, + void *data); +using ExtractTaskReduceFn = void(void *userdata, void *task_userdata); + +using ExtractInitSubdivFn = void(const struct DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + struct MeshBatchCache *cache, + void *buf, + void *data); +using ExtractIterSubdivBMeshFn = void(const struct DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, void *data, uint subdiv_quad_index, - const MPoly *coarse_quad); -typedef void(ExtractFinishSubdivFn)(const struct DRWSubdivCache *subdiv_cache, - const MeshRenderData *mr, - struct MeshBatchCache *cache, - void *buf, - void *data); - -typedef struct MeshExtract { + const BMFace *coarse_quad); +using ExtractIterSubdivMeshFn = void(const struct DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + void *data, + uint subdiv_quad_index, + const MPoly *coarse_quad); +using ExtractFinishSubdivFn = void(const struct DRWSubdivCache *subdiv_cache, + const MeshRenderData *mr, + struct MeshBatchCache *cache, + void *buf, + void *data); + +struct MeshExtract { /** Executed on main thread and return user data for iteration functions. */ ExtractInitFn *init; /** Executed on one (or more if use_threading) worker thread(s). */ @@ -254,7 +250,7 @@ typedef struct MeshExtract { * buffer. */ size_t mesh_buffer_offset; -} MeshExtract; +}; /** \} */ @@ -291,14 +287,14 @@ void mesh_render_data_update_looptris(MeshRenderData *mr, /* draw_cache_extract_mesh_extractors.c */ -typedef struct EditLoopData { +struct EditLoopData { uchar v_flag; uchar e_flag; /* This is used for both vertex and edge creases. The edge crease value is stored in the bottom 4 * bits, while the vertex crease is stored in the upper 4 bits. */ uchar crease; uchar bweight; -} EditLoopData; +}; void *mesh_extract_buffer_get(const MeshExtract *extractor, MeshBufferList *mbuflist); eMRIterType mesh_extract_iter_type(const MeshExtract *ext); @@ -359,7 +355,3 @@ extern const MeshExtract extract_edge_idx; extern const MeshExtract extract_vert_idx; extern const MeshExtract extract_fdot_idx; extern const MeshExtract extract_attr[GPU_MAX_ATTR]; - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc index 2c4e7bfa802..9824602b129 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc @@ -7,7 +7,7 @@ #include "BLI_bitmap.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -584,9 +584,7 @@ constexpr MeshExtract create_extractor_edituv_fdots() } // namespace blender::draw -extern "C" { const MeshExtract extract_edituv_tris = blender::draw::create_extractor_edituv_tris(); const MeshExtract extract_edituv_lines = blender::draw::create_extractor_edituv_lines(); const MeshExtract extract_edituv_points = blender::draw::create_extractor_edituv_points(); const MeshExtract extract_edituv_fdots = blender::draw::create_extractor_edituv_fdots(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc index 4bf732caf0a..4eebea1b79f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc @@ -7,7 +7,7 @@ #include "BLI_bitmap.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { /* ---------------------------------------------------------------------- */ @@ -95,6 +95,4 @@ constexpr MeshExtract create_extractor_fdots() } // namespace blender::draw -extern "C" { const MeshExtract extract_fdots = blender::draw::create_extractor_fdots(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc index 3cecaf81b8a..7d584824045 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc @@ -7,7 +7,7 @@ #include "MEM_guardedalloc.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -320,9 +320,7 @@ constexpr MeshExtract create_extractor_lines_loose_only() } // namespace blender::draw -extern "C" { const MeshExtract extract_lines = blender::draw::create_extractor_lines(); const MeshExtract extract_lines_with_lines_loose = blender::draw::create_extractor_lines_with_lines_loose(); const MeshExtract extract_lines_loose_only = blender::draw::create_extractor_lines_loose_only(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc index de464fb286f..9ba9453dada 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc @@ -11,7 +11,7 @@ #include "MEM_guardedalloc.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -253,6 +253,4 @@ constexpr MeshExtract create_extractor_lines_adjacency() } // namespace blender::draw -extern "C" { const MeshExtract extract_lines_adjacency = blender::draw::create_extractor_lines_adjacency(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc index 286c7ea9c43..713a533492f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc @@ -12,7 +12,7 @@ #include "MEM_guardedalloc.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { /* ---------------------------------------------------------------------- */ @@ -181,6 +181,4 @@ constexpr MeshExtract create_extractor_lines_paint_mask() } // namespace blender::draw -extern "C" { const MeshExtract extract_lines_paint_mask = blender::draw::create_extractor_lines_paint_mask(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc index 503ce0e79e9..e746b37fd30 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc @@ -10,7 +10,7 @@ #include "MEM_guardedalloc.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -322,6 +322,4 @@ constexpr MeshExtract create_extractor_points() } // namespace blender::draw -extern "C" { const MeshExtract extract_points = blender::draw::create_extractor_points(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc index 6ca5692f387..4c8d1d0002a 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc @@ -7,7 +7,7 @@ #include "MEM_guardedalloc.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -243,7 +243,5 @@ constexpr MeshExtract create_extractor_tris_single_mat() } // namespace blender::draw -extern "C" { const MeshExtract extract_tris = blender::draw::create_extractor_tris(); const MeshExtract extract_tris_single_mat = blender::draw::create_extractor_tris_single_mat(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index fa41facb751..5f07f8dfb72 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -16,7 +16,7 @@ #include "draw_attributes.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -447,7 +447,6 @@ constexpr MeshExtract create_extractor_attr(ExtractInitFn fn, ExtractInitSubdivF } // namespace blender::draw -extern "C" { #define CREATE_EXTRACTOR_ATTR(index) \ blender::draw::create_extractor_attr<index>(blender::draw::extract_attr_init##index, \ blender::draw::extract_attr_init_subdiv##index) @@ -469,4 +468,3 @@ const MeshExtract extract_attr[GPU_MAX_ATTR] = { CREATE_EXTRACTOR_ATTR(13), CREATE_EXTRACTOR_ATTR(14), }; -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc index f3b41efe1c3..a11f740239a 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc @@ -10,7 +10,7 @@ #include "GPU_capabilities.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -303,6 +303,4 @@ constexpr MeshExtract create_extractor_edge_fac() } // namespace blender::draw -extern "C" { const MeshExtract extract_edge_fac = blender::draw::create_extractor_edge_fac(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc index 1e158a7e6d7..3bb706e82cd 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_cache_impl.h" @@ -367,6 +367,4 @@ constexpr MeshExtract create_extractor_edit_data() } // namespace blender::draw -extern "C" { const MeshExtract extract_edit_data = blender::draw::create_extractor_edit_data(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc index f79fe345f5a..6d54fce2a0d 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_cache_impl.h" @@ -199,6 +199,4 @@ constexpr MeshExtract create_extractor_edituv_data() } // namespace blender::draw -extern "C" { const MeshExtract extract_edituv_data = blender::draw::create_extractor_edituv_data(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc index fb4b95885fc..5d6dd14b57a 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc @@ -9,7 +9,7 @@ #include "BKE_mesh.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -292,7 +292,5 @@ constexpr MeshExtract create_extractor_edituv_edituv_stretch_angle() } // namespace blender::draw -extern "C" { const MeshExtract extract_edituv_stretch_angle = blender::draw::create_extractor_edituv_edituv_stretch_angle(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc index ab397cc1717..70dcc24f946 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc @@ -9,7 +9,7 @@ #include "BKE_mesh.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -180,7 +180,5 @@ constexpr MeshExtract create_extractor_edituv_stretch_area() } // namespace blender::draw -extern "C" { const MeshExtract extract_edituv_stretch_area = blender::draw::create_extractor_edituv_stretch_area(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc index 1c4f6112877..64bec0adad4 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_cache_impl.h" @@ -81,6 +81,4 @@ constexpr MeshExtract create_extractor_fdots_edituv_data() } // namespace blender::draw -extern "C" { const MeshExtract extract_fdots_edituv_data = blender::draw::create_extractor_fdots_edituv_data(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc index 909c9ac2300..8d189db9f12 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_nor.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -180,7 +180,5 @@ constexpr MeshExtract create_extractor_fdots_nor_hq() } // namespace blender::draw -extern "C" { const MeshExtract extract_fdots_nor = blender::draw::create_extractor_fdots_nor(); const MeshExtract extract_fdots_nor_hq = blender::draw::create_extractor_fdots_nor_hq(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc index 1671a1cd1e7..822b5928c49 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_pos.cc @@ -7,7 +7,7 @@ #include "BLI_bitmap.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -139,6 +139,4 @@ constexpr MeshExtract create_extractor_fdots_pos() } // namespace blender::draw -extern "C" { const MeshExtract extract_fdots_pos = blender::draw::create_extractor_fdots_pos(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc index e7a3cb03903..de21c63e5fd 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc @@ -7,7 +7,7 @@ #include "BLI_bitmap.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -109,6 +109,4 @@ constexpr MeshExtract create_extractor_fdots_uv() } // namespace blender::draw -extern "C" { const MeshExtract extract_fdots_uv = blender::draw::create_extractor_fdots_uv(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc index 8bc8b32fdf3..42a9a58bbe4 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_lnor.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -234,7 +234,5 @@ constexpr MeshExtract create_extractor_lnor_hq() } // namespace blender::draw -extern "C" { const MeshExtract extract_lnor = blender::draw::create_extractor_lnor(); const MeshExtract extract_lnor_hq = blender::draw::create_extractor_lnor_hq(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc index 968c1f693fb..b57e2f6b807 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_mesh_analysis.cc @@ -14,7 +14,7 @@ #include "BKE_editmesh_bvh.h" #include "BKE_editmesh_cache.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -633,6 +633,4 @@ constexpr MeshExtract create_extractor_mesh_analysis() } // namespace blender::draw -extern "C" { const MeshExtract extract_mesh_analysis = blender::draw::create_extractor_mesh_analysis(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc index 94674a54f12..68d838e9e62 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_orco.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -94,6 +94,4 @@ constexpr MeshExtract create_extractor_orco() } // namespace blender::draw -extern "C" { const MeshExtract extract_orco = blender::draw::create_extractor_orco(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc index 5c0116f08d7..313744bdd27 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_pos_nor.cc @@ -7,7 +7,7 @@ #include "MEM_guardedalloc.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -552,7 +552,5 @@ constexpr MeshExtract create_extractor_pos_nor_hq() } // namespace blender::draw -extern "C" { const MeshExtract extract_pos_nor = blender::draw::create_extractor_pos_nor(); const MeshExtract extract_pos_nor_hq = blender::draw::create_extractor_pos_nor_hq(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc index 5658ed85c8b..0d959e324f8 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_sculpt_data.cc @@ -12,7 +12,7 @@ #include "BKE_paint.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -215,6 +215,4 @@ constexpr MeshExtract create_extractor_sculpt_data() } // namespace blender::draw -extern "C" { const MeshExtract extract_sculpt_data = blender::draw::create_extractor_sculpt_data(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc index f4c54b2f881..6230e1974be 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_select_idx.cc @@ -6,7 +6,7 @@ */ #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -411,9 +411,7 @@ constexpr MeshExtract create_extractor_fdot_idx() } // namespace blender::draw -extern "C" { const MeshExtract extract_poly_idx = blender::draw::create_extractor_poly_idx(); const MeshExtract extract_edge_idx = blender::draw::create_extractor_edge_idx(); const MeshExtract extract_vert_idx = blender::draw::create_extractor_vert_idx(); const MeshExtract extract_fdot_idx = blender::draw::create_extractor_fdot_idx(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc index bb6331dd377..a275f247cad 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_skin_roots.cc @@ -5,7 +5,7 @@ * \ingroup draw */ -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -72,6 +72,4 @@ constexpr MeshExtract create_extractor_skin_roots() } // namespace blender::draw -extern "C" { const MeshExtract extract_skin_roots = blender::draw::create_extractor_skin_roots(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index 91cd675d32f..83453d6ef38 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -14,7 +14,7 @@ #include "BKE_mesh.h" #include "BKE_mesh_tangent.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" #include "draw_subdivision.h" @@ -367,7 +367,5 @@ constexpr MeshExtract create_extractor_tan_hq() } // namespace blender::draw -extern "C" { const MeshExtract extract_tan = blender::draw::create_extractor_tan(); const MeshExtract extract_tan_hq = blender::draw::create_extractor_tan_hq(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc index 2808a0a3a71..ddb8ed9b25b 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc @@ -8,7 +8,7 @@ #include "BLI_string.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -168,6 +168,4 @@ constexpr MeshExtract create_extractor_uv() } // namespace blender::draw -extern "C" { const MeshExtract extract_uv = blender::draw::create_extractor_uv(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc index 91ac3f22617..0e192e34dff 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc @@ -12,7 +12,7 @@ #include "BLI_vector.hh" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" struct VColRef { const CustomDataLayer *layer; @@ -380,6 +380,4 @@ constexpr MeshExtract create_extractor_vcol() } // namespace blender::draw -extern "C" { const MeshExtract extract_vcol = blender::draw::create_extractor_vcol(); -} diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc index 89aa16ca0c7..c64cca4dff5 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_weights.cc @@ -10,7 +10,7 @@ #include "BKE_deform.h" #include "draw_subdivision.h" -#include "extract_mesh.h" +#include "extract_mesh.hh" namespace blender::draw { @@ -208,6 +208,4 @@ constexpr MeshExtract create_extractor_weights() } // namespace blender::draw -extern "C" { const MeshExtract extract_weights = blender::draw::create_extractor_weights(); -} diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c index cac6f7cb38b..3c6a03c56d3 100644 --- a/source/blender/gpu/intern/gpu_node_graph.c +++ b/source/blender/gpu/intern/gpu_node_graph.c @@ -347,7 +347,7 @@ static char attr_prefix_get(eCustomDataType type) static void attr_input_name(GPUMaterialAttribute *attr) { - /* NOTE: Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */ + /* NOTE: Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.cc */ if (attr->type == CD_ORCO) { /* OPTI: orco is computed from local positions, but only if no modifier is present. */ STRNCPY(attr->input_name, "orco"); diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 4a57f60be26..a66badb4a68 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -83,7 +83,7 @@ typedef struct Mesh_Runtime { /** * Data used to efficiently draw the mesh in the viewport, especially useful when - * the same mesh is used in many objects or instances. See `draw_cache_impl_mesh.c`. + * the same mesh is used in many objects or instances. See `draw_cache_impl_mesh.cc`. */ void *batch_cache; |