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:
authorBrecht Van Lommel <brecht@blender.org>2022-05-17 16:31:37 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-05-17 17:14:15 +0300
commit0609b4bb491eae28b7aff411f54d732b458d6ae9 (patch)
treeecf7b06626f11ae73a0223723e62e5f998222000 /source/blender/blenkernel/intern/subdiv_modifier.c
parentdbc439e41a1aaa17e237ccf058c75ea8975bc79b (diff)
Fix T98052: Eevee / Workbench background render crash with GPU subdivision
The problem is that depsgraph evaluation happens before the OpenGL context is initialized, and so modifier evaluation happens without GPU subdivision. Later the BKE_subsurf_modifier_can_do_gpu_subdiv test in the draw code gives a different result. This just checks if the mesh has information for GPU subdivision in the draw code, and if so uses it. This is only set if the test for supported GPU subdivision passes in the modifier evaluation. Additionally it may be good to perform OpenGL context initialization earlier so background render can take advantage of GPU subdivision, but this is more complicated. Differential Revision: https://developer.blender.org/D14969
Diffstat (limited to 'source/blender/blenkernel/intern/subdiv_modifier.c')
-rw-r--r--source/blender/blenkernel/intern/subdiv_modifier.c39
1 files changed, 12 insertions, 27 deletions
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;