Blender V4.3
draw_cache_impl_mesh.cc File Reference

Mesh API for render engines. More...

#include <optional>
#include "MEM_guardedalloc.h"
#include "BLI_bitmap.h"
#include "BLI_buffer.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_string_ref.hh"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_attribute.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_editmesh.hh"
#include "BKE_editmesh_cache.hh"
#include "BKE_editmesh_tangent.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_tangent.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_object_deform.h"
#include "BKE_paint.hh"
#include "BKE_pbvh_api.hh"
#include "BKE_subdiv_modifier.hh"
#include "atomic_ops.h"
#include "bmesh.hh"
#include "GPU_batch.hh"
#include "GPU_material.hh"
#include "DRW_render.hh"
#include "ED_mesh.hh"
#include "ED_uvedit.hh"
#include "draw_cache_extract.hh"
#include "draw_cache_inline.hh"
#include "draw_subdivision.hh"
#include "draw_cache_impl.hh"
#include "draw_manager_c.hh"
#include "mesh_extractors/extract_mesh.hh"

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::draw
 

Functions

Vertex Group Selection
static void blender::draw::drw_mesh_weight_state_clear (DRW_MeshWeightState *wstate)
 
static void blender::draw::drw_mesh_weight_state_copy (DRW_MeshWeightState *wstate_dst, const DRW_MeshWeightState *wstate_src)
 
static bool blender::draw::drw_mesh_flags_equal (const bool *array1, const bool *array2, int size)
 
static bool blender::draw::drw_mesh_weight_state_compare (const DRW_MeshWeightState *a, const DRW_MeshWeightState *b)
 
static void blender::draw::drw_mesh_weight_state_extract (Object &ob, Mesh &mesh, const ToolSettings &ts, bool paint_mode, DRW_MeshWeightState *wstate)
 
Mesh gpu::Batch Cache
BLI_INLINE void blender::draw::mesh_batch_cache_add_request (MeshBatchCache &cache, DRWBatchFlag new_flag)
 
static bool blender::draw::mesh_batch_cache_valid (Object &object, Mesh &mesh)
 
static void blender::draw::mesh_batch_cache_init (Object &object, Mesh &mesh)
 
static MeshBatchCacheblender::draw::mesh_batch_cache_get (Mesh &mesh)
 
static void blender::draw::mesh_batch_cache_check_vertex_group (MeshBatchCache &cache, const DRW_MeshWeightState *wstate)
 
static void blender::draw::mesh_batch_cache_request_surface_batches (MeshBatchCache &cache)
 
static void blender::draw::mesh_batch_cache_discard_shaded_tri (MeshBatchCache &cache)
 
static void blender::draw::mesh_batch_cache_discard_uvedit (MeshBatchCache &cache)
 
static void blender::draw::mesh_batch_cache_discard_uvedit_select (MeshBatchCache &cache)
 
static void blender::draw::mesh_buffer_list_clear (MeshBufferList *mbuflist)
 
static void blender::draw::mesh_buffer_cache_clear (MeshBufferCache *mbc)
 
static void blender::draw::mesh_batch_cache_free_subdiv_cache (MeshBatchCache &cache)
 
Expose via BKE callbacks
void blender::draw::DRW_mesh_batch_cache_validate (Object &object, Mesh &mesh)
 
void blender::draw::DRW_mesh_batch_cache_dirty_tag (Mesh *mesh, eMeshBatchDirtyMode mode)
 
void blender::draw::DRW_mesh_batch_cache_free (void *batch_cache)
 
Public API
static void blender::draw::texpaint_request_active_uv (MeshBatchCache &cache, Object &object, Mesh &mesh)
 
static void blender::draw::request_active_and_default_color_attributes (const Object &object, const Mesh &mesh, DRW_Attributes &attributes)
 
void blender::draw::DRW_mesh_get_attributes (const Object &object, const Mesh &mesh, const GPUMaterial *const *gpumat_array, int gpumat_array_len, DRW_Attributes *r_attrs, DRW_MeshCDMask *r_cd_needed)
 
Mesh
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_all_verts (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_all_edges (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_loose_edges (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_weights (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edge_detection (Mesh &mesh, bool *r_is_manifold)
 
blender::gpu::Batch ** blender::draw::DRW_mesh_batch_cache_get_surface_shaded (Object &object, Mesh &mesh, GPUMaterial **gpumat_array, uint gpumat_array_len)
 
blender::gpu::Batch ** blender::draw::DRW_mesh_batch_cache_get_surface_texpaint (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_texpaint_single (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_vertpaint (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_sculpt (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_sculpt_overlays (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_viewer_attribute (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_surface_edges (Object &object, Mesh &mesh)
 
void blender::draw::DRW_mesh_batch_cache_create_requested (TaskGraph &task_graph, Object &ob, Mesh &mesh, const Scene &scene, bool is_paint_mode, bool use_hide)
 
Object Mode Wireframe Overlays
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_wireframes_face (Mesh &mesh)
 
For Image UV Editor
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_mesh_analysis (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_uv_edges (Object &object, Mesh &mesh)
 
For Direct Data Access
int blender::draw::DRW_mesh_material_count_get (const Object &object, const Mesh &mesh)
 
gpu::VertBufblender::draw::DRW_mesh_batch_cache_pos_vertbuf_get (Mesh &mesh)
 
Edit-Mesh Drawing
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_triangles (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_edges (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_vertices (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_vert_normals (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_loop_normals (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_facedots (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edit_skin_roots (Mesh &mesh)
 
Edit-mesh Selection
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_triangles_with_select_id (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_facedots_with_select_id (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edges_with_select_id (Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_verts_with_select_id (Mesh &mesh)
 
UV Image editor API
static void blender::draw::edituv_request_active_uv (MeshBatchCache &cache, Object &object, Mesh &mesh)
 
Edit-mesh UV Editor
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_faces_stretch_area (Object &object, Mesh &mesh, float **tot_area, float **tot_uv_area)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_faces_stretch_angle (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_faces (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_edges (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_verts (Object &object, Mesh &mesh)
 
blender::gpu::Batch * blender::draw::DRW_mesh_batch_cache_get_edituv_facedots (Object &object, Mesh &mesh)
 
Garbage Collection
void blender::draw::DRW_mesh_batch_cache_free_old (Mesh *mesh, int ctime)
 
Grouped batch generation
static void blender::draw::drw_add_attributes_vbo (gpu::Batch *batch, MeshBufferList *mbuflist, DRW_Attributes *attr_used)
 
static void blender::draw::drw_mesh_batch_cache_check_available (TaskGraph &task_graph, Mesh &mesh)
 

Dependencies between buffer and batch

#define BUFFER_INDEX(buff_name)   ((offsetof(MeshBufferList, buff_name) - offsetof(MeshBufferList, vbo)) / sizeof(void *))
 
#define BUFFER_LEN   (sizeof(MeshBufferList) / sizeof(void *))
 
#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)
 
#define _BATCH_MAP5(a, b, c, d, e)   _BATCH_MAP4(a, b, c, d) | _BATCH_MAP1(e)
 
#define _BATCH_MAP6(a, b, c, d, e, f)   _BATCH_MAP5(a, b, c, d, e) | _BATCH_MAP1(f)
 
#define _BATCH_MAP7(a, b, c, d, e, f, g)   _BATCH_MAP6(a, b, c, d, e, f) | _BATCH_MAP1(g)
 
#define _BATCH_MAP8(a, b, c, d, e, f, g, h)   _BATCH_MAP7(a, b, c, d, e, f, g) | _BATCH_MAP1(h)
 
#define _BATCH_MAP9(a, b, c, d, e, f, g, h, i)   _BATCH_MAP8(a, b, c, d, e, f, g, h) | _BATCH_MAP1(i)
 
#define _BATCH_MAP10(a, b, c, d, e, f, g, h, i, j)   _BATCH_MAP9(a, b, c, d, e, f, g, h, i) | _BATCH_MAP1(j)
 
#define BATCH_MAP(...)   VA_NARGS_CALL_OVERLOAD(_BATCH_MAP, __VA_ARGS__)
 
#define TRIS_PER_MAT_INDEX   BUFFER_LEN
 
static constexpr DRWBatchFlag blender::draw::batches_that_use_buffer (const int buffer_index)
 
static void blender::draw::mesh_batch_cache_discard_surface_batches (MeshBatchCache &cache)
 
static void blender::draw::mesh_batch_cache_clear (MeshBatchCache &cache)
 
static void blender::draw::mesh_batch_cache_discard_batch (MeshBatchCache &cache, const DRWBatchFlag batch_map)
 
BLI_INLINE bool blender::draw::mesh_cd_layers_type_overlap (DRW_MeshCDMask a, DRW_MeshCDMask b)
 
BLI_INLINE bool blender::draw::mesh_cd_layers_type_equal (DRW_MeshCDMask a, DRW_MeshCDMask b)
 
BLI_INLINE void blender::draw::mesh_cd_layers_type_merge (DRW_MeshCDMask *a, DRW_MeshCDMask b)
 
BLI_INLINE void blender::draw::mesh_cd_layers_type_clear (DRW_MeshCDMask *a)
 
static void blender::draw::mesh_cd_calc_edit_uv_layer (const Mesh &, DRW_MeshCDMask *cd_used)
 
static void blender::draw::mesh_cd_calc_active_uv_layer (const Object &object, const Mesh &mesh, DRW_MeshCDMask &cd_used)
 
static void blender::draw::mesh_cd_calc_active_mask_uv_layer (const Object &object, const Mesh &mesh, DRW_MeshCDMask &cd_used)
 
static DRW_MeshCDMask blender::draw::mesh_cd_calc_used_gpu_layers (const Object &object, const Mesh &mesh, const GPUMaterial *const *gpumat_array, int gpumat_array_len, DRW_Attributes *attributes)
 

Detailed Description

Mesh API for render engines.

Definition in file draw_cache_impl_mesh.cc.

Macro Definition Documentation

◆ _BATCH_MAP1

#define _BATCH_MAP1 ( a)    batches_that_use_buffer(BUFFER_INDEX(a))

Definition at line 80 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP10

#define _BATCH_MAP10 ( a,
b,
c,
d,
e,
f,
g,
h,
i,
j )   _BATCH_MAP9(a, b, c, d, e, f, g, h, i) | _BATCH_MAP1(j)

Definition at line 89 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP2

#define _BATCH_MAP2 ( a,
b )   _BATCH_MAP1(a) | _BATCH_MAP1(b)

Definition at line 81 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP3

#define _BATCH_MAP3 ( a,
b,
c )   _BATCH_MAP2(a, b) | _BATCH_MAP1(c)

Definition at line 82 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP4

#define _BATCH_MAP4 ( a,
b,
c,
d )   _BATCH_MAP3(a, b, c) | _BATCH_MAP1(d)

Definition at line 83 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP5

#define _BATCH_MAP5 ( a,
b,
c,
d,
e )   _BATCH_MAP4(a, b, c, d) | _BATCH_MAP1(e)

Definition at line 84 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP6

#define _BATCH_MAP6 ( a,
b,
c,
d,
e,
f )   _BATCH_MAP5(a, b, c, d, e) | _BATCH_MAP1(f)

Definition at line 85 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP7

#define _BATCH_MAP7 ( a,
b,
c,
d,
e,
f,
g )   _BATCH_MAP6(a, b, c, d, e, f) | _BATCH_MAP1(g)

Definition at line 86 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP8

#define _BATCH_MAP8 ( a,
b,
c,
d,
e,
f,
g,
h )   _BATCH_MAP7(a, b, c, d, e, f, g) | _BATCH_MAP1(h)

Definition at line 87 of file draw_cache_impl_mesh.cc.

◆ _BATCH_MAP9

#define _BATCH_MAP9 ( a,
b,
c,
d,
e,
f,
g,
h,
i )   _BATCH_MAP8(a, b, c, d, e, f, g, h) | _BATCH_MAP1(i)

Definition at line 88 of file draw_cache_impl_mesh.cc.

◆ BATCH_MAP

◆ BUFFER_INDEX

#define BUFFER_INDEX ( buff_name)    ((offsetof(MeshBufferList, buff_name) - offsetof(MeshBufferList, vbo)) / sizeof(void *))

◆ BUFFER_LEN

#define BUFFER_LEN   (sizeof(MeshBufferList) / sizeof(void *))

Definition at line 78 of file draw_cache_impl_mesh.cc.

◆ TRIS_PER_MAT_INDEX