Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_mesh.c
| Show First 20 Lines • Show All 777 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| MeshBatchCache *cache = mesh_batch_cache_get(me); | MeshBatchCache *cache = mesh_batch_cache_get(me); | ||||
| DRW_MeshCDMask cd_needed = mesh_cd_calc_used_gpu_layers(me, gpumat_array, gpumat_array_len); | DRW_MeshCDMask cd_needed = mesh_cd_calc_used_gpu_layers(me, gpumat_array, gpumat_array_len); | ||||
| BLI_assert(gpumat_array_len == cache->mat_len); | BLI_assert(gpumat_array_len == cache->mat_len); | ||||
| mesh_cd_layers_type_merge(&cache->cd_needed, cd_needed); | mesh_cd_layers_type_merge(&cache->cd_needed, cd_needed); | ||||
| if (!mesh_cd_layers_type_overlap(cache->cd_used, cd_needed)) { | /* The update of the `auto_layer_` fields isn't triggered when the `surface_shaded` | ||||
| * uses the exact same cd's as the `surface` batch. The `rebuild_auto_layer_names` | |||||
| * is set when a surface batch is requested. So when the shaded batch is requested | |||||
| * the `auto_layer_` fields are forced to be updated. */ | |||||
| if (cache->rebuild_auto_layer_names || !mesh_cd_layers_type_overlap(cache->cd_used, cd_needed)) { | |||||
fclem: What I would prefer, store the cd mask the layer names were generated against. Just reset the… | |||||
| mesh_cd_extract_auto_layers_names_and_srgb(me, | mesh_cd_extract_auto_layers_names_and_srgb(me, | ||||
| cache->cd_needed, | cache->cd_needed, | ||||
| &cache->auto_layer_names, | &cache->auto_layer_names, | ||||
| &cache->auto_layer_is_srgb, | &cache->auto_layer_is_srgb, | ||||
| &cache->auto_layer_len); | &cache->auto_layer_len); | ||||
| cache->rebuild_auto_layer_names = false; | |||||
| } | } | ||||
| mesh_batch_cache_add_request(cache, MBC_SURF_PER_MAT); | mesh_batch_cache_add_request(cache, MBC_SURF_PER_MAT); | ||||
| if (auto_layer_names) { | if (auto_layer_names) { | ||||
| *auto_layer_names = cache->auto_layer_names; | *auto_layer_names = cache->auto_layer_names; | ||||
| *auto_layer_is_srgb = cache->auto_layer_is_srgb; | *auto_layer_is_srgb = cache->auto_layer_is_srgb; | ||||
| *auto_layer_count = cache->auto_layer_len; | *auto_layer_count = cache->auto_layer_len; | ||||
| ▲ Show 20 Lines • Show All 414 Lines • ▼ Show 20 Lines | if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) { | ||||
| DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor); | DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor); | ||||
| DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.pos_nor); | DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.pos_nor); | ||||
| if (cache->cd_used.uv != 0) { | if (cache->cd_used.uv != 0) { | ||||
| DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.uv); | DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.uv); | ||||
| } | } | ||||
| if (cache->cd_used.vcol != 0) { | if (cache->cd_used.vcol != 0) { | ||||
| DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.vcol); | DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.vcol); | ||||
| } | } | ||||
| cache->rebuild_auto_layer_names = true; | |||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) { | if (DRW_batch_requested(cache->batch.all_verts, GPU_PRIM_POINTS)) { | ||||
| DRW_vbo_request(cache->batch.all_verts, &mbufcache->vbo.pos_nor); | DRW_vbo_request(cache->batch.all_verts, &mbufcache->vbo.pos_nor); | ||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) { | if (DRW_batch_requested(cache->batch.all_edges, GPU_PRIM_LINES)) { | ||||
| DRW_ibo_request(cache->batch.all_edges, &mbufcache->ibo.lines); | DRW_ibo_request(cache->batch.all_edges, &mbufcache->ibo.lines); | ||||
| DRW_vbo_request(cache->batch.all_edges, &mbufcache->vbo.pos_nor); | DRW_vbo_request(cache->batch.all_edges, &mbufcache->vbo.pos_nor); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines | |||||
What I would prefer, store the cd mask the layer names were generated against. Just reset the mask to 0 if the names are discarded.
Much more descriptive and less error prone.