Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-04-18 18:25:04 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-04-19 16:19:43 +0300
commit973e64cf9cb23b91e329ebac9a0f4c69647edf20 (patch)
tree8d9b1ce47b8d7d646f65e3b3c8040bc5b72ec2bb /source/blender/draw/intern/draw_cache_impl_mesh.c
parent0ebf43b4d0a955469a8b7544089c07370781cf88 (diff)
DRW: Make shaded batch validation more correct
This is in order to support garbage collection of unused Custom data layer uploaded to the GPU. Actual Garbage Collection is not added by this commit.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_mesh.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 630cbd20319..6b43fbed49f 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -4198,16 +4198,16 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(Mesh *me,
BLI_assert(gpumat_array_len == cache->mat_len);
- bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_used, cd_needed);
- if (!cd_overlap) {
- 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)) {
mesh_cd_extract_auto_layers_names_and_srgb(me,
cache->cd_needed,
&cache->auto_layer_names,
&cache->auto_layer_is_srgb,
&cache->auto_layer_len);
}
+
if (auto_layer_names) {
*auto_layer_names = cache->auto_layer_names;
*auto_layer_is_srgb = cache->auto_layer_is_srgb;
@@ -4733,6 +4733,18 @@ void DRW_mesh_batch_cache_create_requested(
drw_mesh_weight_state_clear(&wstate);
}
+ /* Optimization : Only create orco layer if mesh is deformed. */
+ if (cache->cd_needed.orco != 0) {
+ CustomData *cd_vdata = (me->edit_mesh) ? &me->edit_mesh->bm->vdata : &me->vdata;
+ if (CustomData_get_layer(cd_vdata, CD_ORCO) != NULL && ob->modifiers.first != NULL) {
+ /* Orco layer is needed. */
+ }
+ else if (cache->cd_needed.tan_orco == 0) {
+ /* Skip orco calculation if not needed by tangent generation. */
+ cache->cd_needed.orco = 0;
+ }
+ }
+
/* Verify that all surface batches have needed attribute layers. */
/* TODO(fclem): We could be a bit smarter here and only do it per material. */
bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_used, cache->cd_needed);
@@ -4929,15 +4941,7 @@ void DRW_mesh_batch_cache_create_requested(
DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_vcol);
}
if (cache->cd_used.orco != 0) {
- /* OPTI : Only do that if there is modifiers that modify orcos. */
- CustomData *cd_vdata = (me->edit_mesh) ? &me->edit_mesh->bm->vdata : &me->vdata;
- if (CustomData_get_layer(cd_vdata, CD_ORCO) != NULL && ob->modifiers.first != NULL) {
- DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_orco);
- }
- else if (cache->cd_used.tan_orco == 0) {
- /* Skip orco calculation if not needed by tangent generation. */
- cache->cd_used.orco = 0;
- }
+ DRW_vbo_request(cache->surf_per_mat[i], &cache->ordered.loop_orco);
}
}
}