Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_mesh.c
| Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_uvedit.h" | #include "ED_uvedit.h" | ||||
| #include "draw_cache_extract.h" | #include "draw_cache_extract.h" | ||||
| #include "draw_cache_extract_mesh_private.h" | |||||
| #include "draw_cache_inline.h" | #include "draw_cache_inline.h" | ||||
| #include "draw_cache_impl.h" /* own include */ | #include "draw_cache_impl.h" /* own include */ | ||||
| #include "mesh_extractors/extract_mesh.h" | |||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| /** \name Dependencies between buffer and batch | /** \name Dependencies between buffer and batch | ||||
| * \{ */ | * \{ */ | ||||
| /* clang-format off */ | /* clang-format off */ | ||||
| #define _BUFFER_INDEX(buff_name) ((offsetof(MeshBufferCache, buff_name) - offsetof(MeshBufferCache, vbo)) / sizeof(void *)) | #define _BUFFER_INDEX(buff_name) ((offsetof(MeshBufferCache, buff_name) - offsetof(MeshBufferCache, vbo)) / sizeof(void *)) | ||||
| ▲ Show 20 Lines • Show All 733 Lines • ▼ Show 20 Lines | case BKE_MESH_BATCH_DIRTY_SELECT_PAINT: | ||||
| break; | break; | ||||
| case BKE_MESH_BATCH_DIRTY_ALL: | case BKE_MESH_BATCH_DIRTY_ALL: | ||||
| cache->is_dirty = true; | cache->is_dirty = true; | ||||
| break; | break; | ||||
| case BKE_MESH_BATCH_DIRTY_SHADING: | case BKE_MESH_BATCH_DIRTY_SHADING: | ||||
| mesh_batch_cache_discard_shaded_tri(cache); | mesh_batch_cache_discard_shaded_tri(cache); | ||||
| mesh_batch_cache_discard_uvedit(cache); | mesh_batch_cache_discard_uvedit(cache); | ||||
| break; | break; | ||||
| case BKE_MESH_BATCH_DIRTY_DEFORM: | |||||
| FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) { | |||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.pos_nor); | |||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.lnor); | |||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_pos); | |||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_nor); | |||||
| GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.tris); | |||||
| } | |||||
| batch_map = MDEPS_CREATE_MAP(vbo.pos_nor, vbo.lnor, vbo.fdots_pos, vbo.fdots_nor, ibo.tris); | |||||
| mesh_batch_cache_discard_batch(cache, batch_map); | |||||
| break; | |||||
| case BKE_MESH_BATCH_DIRTY_UVEDIT_ALL: | case BKE_MESH_BATCH_DIRTY_UVEDIT_ALL: | ||||
| mesh_batch_cache_discard_uvedit(cache); | mesh_batch_cache_discard_uvedit(cache); | ||||
| break; | break; | ||||
| case BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT: | case BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT: | ||||
| FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) { | FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) { | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data); | ||||
| } | } | ||||
| Show All 19 Lines | |||||
| static void mesh_buffer_extraction_cache_clear(MeshBufferExtractionCache *extraction_cache) | static void mesh_buffer_extraction_cache_clear(MeshBufferExtractionCache *extraction_cache) | ||||
| { | { | ||||
| MEM_SAFE_FREE(extraction_cache->loose_geom.verts); | MEM_SAFE_FREE(extraction_cache->loose_geom.verts); | ||||
| MEM_SAFE_FREE(extraction_cache->loose_geom.edges); | MEM_SAFE_FREE(extraction_cache->loose_geom.edges); | ||||
| extraction_cache->loose_geom.edge_len = 0; | extraction_cache->loose_geom.edge_len = 0; | ||||
| extraction_cache->loose_geom.vert_len = 0; | extraction_cache->loose_geom.vert_len = 0; | ||||
| MEM_SAFE_FREE(extraction_cache->mat_offsets.tri); | MEM_SAFE_FREE(extraction_cache->poly_sorted.tri_first_index); | ||||
| MEM_SAFE_FREE(extraction_cache->poly_sorted.mat_tri_len); | |||||
| extraction_cache->poly_sorted.visible_tri_len = 0; | |||||
| } | } | ||||
| static void mesh_batch_cache_clear(Mesh *me) | static void mesh_batch_cache_clear(Mesh *me) | ||||
| { | { | ||||
| MeshBatchCache *cache = me->runtime.batch_cache; | MeshBatchCache *cache = me->runtime.batch_cache; | ||||
| if (!cache) { | if (!cache) { | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 965 Lines • Show Last 20 Lines | |||||