diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_subdiv_modifier.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_modifier.c | 39 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 10 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_subsurf.c | 3 |
5 files changed, 26 insertions, 40 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_modifier.h b/source/blender/blenkernel/BKE_subdiv_modifier.h index e9de7d1532e..4ad17610207 100644 --- a/source/blender/blenkernel/BKE_subdiv_modifier.h +++ b/source/blender/blenkernel/BKE_subdiv_modifier.h @@ -42,18 +42,14 @@ bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh( * \param skip_check_is_last: When true, we assume that the modifier passed is the last enabled * modifier in the stack. */ -bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const struct Scene *scene, - const struct Object *ob, - const struct Mesh *mesh, - const struct SubsurfModifierData *smd, - int required_mode, - bool skip_check_is_last); - bool BKE_subsurf_modifier_can_do_gpu_subdiv(const struct Scene *scene, const struct Object *ob, const struct Mesh *mesh, + const struct SubsurfModifierData *smd, int required_mode); +bool BKE_subsurf_modifier_has_gpu_subdiv(const struct Mesh *mesh); + extern void (*BKE_subsurf_modifier_free_gpu_cache_cb)(struct Subdiv *subdiv); /** diff --git a/source/blender/blenkernel/intern/subdiv_modifier.c b/source/blender/blenkernel/intern/subdiv_modifier.c index 3692a3cc4f7..e43da956ce5 100644 --- a/source/blender/blenkernel/intern/subdiv_modifier.c +++ b/source/blender/blenkernel/intern/subdiv_modifier.c @@ -3,6 +3,8 @@ #include "BKE_subdiv_modifier.h" +#include "BLI_session_uuid.h" + #include "MEM_guardedalloc.h" #include "DNA_mesh_types.h" @@ -105,12 +107,11 @@ bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(const SubsurfMod return subsurf_modifier_use_autosmooth_or_split_normals(smd, mesh); } -bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const Scene *scene, - const Object *ob, - const Mesh *mesh, - const SubsurfModifierData *smd, - int required_mode, - bool skip_check_is_last) +bool BKE_subsurf_modifier_can_do_gpu_subdiv(const Scene *scene, + const Object *ob, + const Mesh *mesh, + const SubsurfModifierData *smd, + int required_mode) { if ((U.gpu_flag & USER_GPU_FLAG_SUBDIVISION_EVALUATION) == 0) { return false; @@ -122,33 +123,17 @@ bool BKE_subsurf_modifier_can_do_gpu_subdiv_ex(const Scene *scene, return false; } - if (!skip_check_is_last) { - ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode); - if (md != (const ModifierData *)smd) { - return false; - } + ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode); + if (md != (const ModifierData *)smd) { + return false; } return is_subdivision_evaluation_possible_on_gpu(); } -bool BKE_subsurf_modifier_can_do_gpu_subdiv(const Scene *scene, - const Object *ob, - const Mesh *mesh, - int required_mode) +bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh) { - ModifierData *md = modifier_get_last_enabled_for_mode(scene, ob, required_mode); - - if (!md) { - return false; - } - - if (md->type != eModifierType_Subsurf) { - return false; - } - - return BKE_subsurf_modifier_can_do_gpu_subdiv_ex( - scene, ob, mesh, (SubsurfModifierData *)md, required_mode, true); + return BLI_session_uuid_is_generated(&mesh->runtime.subsurf_session_uuid); } void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = NULL; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 080ec50e0fb..65c42545a77 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1357,7 +1357,6 @@ bool BLO_write_file(Main *mainvar, /* Remapping of relative paths to new file location. */ if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { - if (remap_mode == BLO_WRITE_PATH_REMAP_RELATIVE) { /* Make all relative as none of the existing paths can be relative in an unsaved document. */ if (relbase_valid == false) { @@ -1396,6 +1395,13 @@ bool BLO_write_file(Main *mainvar, } if (remap_mode != BLO_WRITE_PATH_REMAP_NONE) { + /* Some path processing (e.g. with libraries) may use the current `main->filepath`, if this + * is not matching the path currently used for saving, unexpected paths corruptions can + * happen. See T98201. */ + char mainvar_filepath_orig[FILE_MAX]; + STRNCPY(mainvar_filepath_orig, mainvar->filepath); + STRNCPY(mainvar->filepath, filepath); + /* Check if we need to backup and restore paths. */ if (UNLIKELY(use_save_as_copy)) { path_list_backup = BKE_bpath_list_backup(mainvar, path_list_flag); @@ -1420,6 +1426,8 @@ bool BLO_write_file(Main *mainvar, BLI_assert_unreachable(); /* Unreachable. */ break; } + + STRNCPY(mainvar->filepath, mainvar_filepath_orig); } } diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index ee5223af68d..7fdeaf34965 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -1822,9 +1822,7 @@ void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, do_uvcage = !editmesh_eval_final->runtime.is_original; } - const int required_mode = BKE_subsurf_modifier_eval_required_mode(DRW_state_is_scene_render(), - is_editmode); - const bool do_subdivision = BKE_subsurf_modifier_can_do_gpu_subdiv(scene, ob, me, required_mode); + const bool do_subdivision = BKE_subsurf_modifier_has_gpu_subdiv(me); MeshBufferList *mbuflist = &cache->final.buff; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 571e564f583..4201bab0326 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -236,8 +236,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * * assigned at this stage of modifier stack evaluation. */ const bool is_editmode = (mesh->edit_mesh != NULL); const int required_mode = BKE_subsurf_modifier_eval_required_mode(is_render_mode, is_editmode); - if (BKE_subsurf_modifier_can_do_gpu_subdiv_ex( - scene, ctx->object, mesh, smd, required_mode, false)) { + if (BKE_subsurf_modifier_can_do_gpu_subdiv(scene, ctx->object, mesh, smd, required_mode)) { subdiv_cache_cpu_evaluation_settings(ctx, mesh, smd); return result; } |