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-06-13 16:21:05 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-06-14 15:54:25 +0300
commitca9d65cc97ba8e872a0ef456e51dacadd06e237e (patch)
tree146e6457b8bc16563cb528ce2d43c5c93506e0db /source/blender/blenkernel/BKE_subdiv_modifier.h
parent4e96d71ddba8a5879337833ff7d63de12cf719a8 (diff)
Fix T98813: crash with GPU subdiv in edit mode and instanced geometry
Instancing with geometry nodes uses just the evaluated Mesh, and ignores the Object that it came from. That meant that it would try to look up the subsurf modifier on the instancer object which does not have the subsurf modifier. Instead of storing a session UUID and looking up the modifier data, store a point to the subsurf modifier runtime data. Unlike the modifier data, this runtime data is preserved across depsgraph CoW. It must be for the subdiv descriptor contained in it to stay valid along with the draw cache. As a bonus, this moves various Mesh_Runtime variables into the subsurf runtime data, reducing memory usage for meshes not using subdivision surfaces. Also fixes T98693, issues with subdivision level >= 8 due to integer overflow. Differential Revision: https://developer.blender.org/D15184
Diffstat (limited to 'source/blender/blenkernel/BKE_subdiv_modifier.h')
-rw-r--r--source/blender/blenkernel/BKE_subdiv_modifier.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_modifier.h b/source/blender/blenkernel/BKE_subdiv_modifier.h
index 4ad17610207..271026d4253 100644
--- a/source/blender/blenkernel/BKE_subdiv_modifier.h
+++ b/source/blender/blenkernel/BKE_subdiv_modifier.h
@@ -7,6 +7,8 @@
#pragma once
+#include "BKE_subdiv.h"
+
#include "BLI_sys_types.h"
#ifdef __cplusplus
@@ -24,9 +26,30 @@ struct Subdiv;
struct SubdivSettings;
struct SubsurfModifierData;
-void BKE_subsurf_modifier_subdiv_settings_init(struct SubdivSettings *settings,
- const struct SubsurfModifierData *smd,
- bool use_render_params);
+/* Runtime subsurf modifier data, cached in modifier on evaluated meshes. */
+typedef struct SubsurfRuntimeData {
+ /* Subdivision settings, exists before descriptor or mesh wrapper is created. */
+ SubdivSettings settings;
+
+ /* Cached subdivision surface descriptor, with topology and settings. */
+ struct Subdiv *subdiv;
+ bool set_by_draw_code;
+
+ /* Cached mesh wrapper data, to be used for GPU subdiv or lazy evaluation on CPU. */
+ bool has_gpu_subdiv;
+ int resolution;
+ bool use_optimal_display;
+ bool calc_loop_normals;
+ bool use_loop_normals;
+
+ /* Cached from the draw code for stats display. */
+ int stats_totvert;
+ int stats_totedge;
+ int stats_totpoly;
+ int stats_totloop;
+} SubsurfRuntimeData;
+
+bool BKE_subsurf_modifier_runtime_init(struct SubsurfModifierData *smd, bool use_render_params);
bool BKE_subsurf_modifier_use_custom_loop_normals(const struct SubsurfModifierData *smd,
const struct Mesh *mesh);
@@ -57,12 +80,7 @@ extern void (*BKE_subsurf_modifier_free_gpu_cache_cb)(struct Subdiv *subdiv);
* which matches settings and topology.
*/
struct Subdiv *BKE_subsurf_modifier_subdiv_descriptor_ensure(
- const struct SubsurfModifierData *smd,
- const struct SubdivSettings *subdiv_settings,
- const struct Mesh *mesh,
- bool for_draw_code);
-
-struct SubsurfRuntimeData *BKE_subsurf_modifier_ensure_runtime(struct SubsurfModifierData *smd);
+ struct SubsurfRuntimeData *runtime_data, const struct Mesh *mesh, bool for_draw_code);
/**
* Return the #ModifierMode required for the evaluation of the subsurf modifier,