Fix T96283: last disabled subsurf is used for GPU subdivision
When more than one, consecutive, subdivision modifier is used on a Mesh, the last subsurf modifier is used for GPU subdivision even though it might be disabled. This is because retrieving the last subsurf modifier in the draw code did not check whether the modifier was disabled or not. To fix this, the session UUID of the modifier which delegated evaluation to the GPU code is cached and used in the draw to select the right subsurf modifier. Differential Revision: https://developer.blender.org/D14488
This commit is contained in:
parent
9a8669ac81
commit
68ca12a7fc
Notes:
blender-bot
2023-02-13 16:03:50 +01:00
Referenced by issue #96283, GPU subdivision: Last subsurf modifier is always used for GPU subdivision, even when disabled.
|
@ -1898,7 +1898,8 @@ static bool draw_subdiv_create_requested_buffers(const Scene *scene,
|
|||
const bool /*use_hide*/,
|
||||
OpenSubdiv_EvaluatorCache *evaluator_cache)
|
||||
{
|
||||
SubsurfModifierData *smd = BKE_object_get_last_subsurf_modifier(ob);
|
||||
SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(
|
||||
BKE_modifiers_findby_session_uuid(ob, &mesh->runtime.subsurf_session_uuid));
|
||||
BLI_assert(smd);
|
||||
|
||||
const bool is_final_render = DRW_state_is_scene_render();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "DNA_ID.h"
|
||||
#include "DNA_customdata_types.h"
|
||||
#include "DNA_defs.h"
|
||||
#include "DNA_session_uuid_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -120,11 +121,12 @@ typedef struct Mesh_Runtime {
|
|||
*/
|
||||
char wrapper_type_finalize;
|
||||
|
||||
int subsurf_resolution;
|
||||
/**
|
||||
* Settings for lazily evaluating the subdivision on the CPU if needed. These are
|
||||
* set in the modifier when GPU subdivision can be performed.
|
||||
*/
|
||||
SessionUUID subsurf_session_uuid;
|
||||
int subsurf_resolution;
|
||||
char subsurf_apply_render;
|
||||
char subsurf_use_optimal_display;
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ static void subdiv_cache_cpu_evaluation_settings(const ModifierEvalContext *ctx,
|
|||
me->runtime.subsurf_apply_render = (ctx->flag & MOD_APPLY_RENDER) != 0;
|
||||
me->runtime.subsurf_resolution = mesh_settings.resolution;
|
||||
me->runtime.subsurf_use_optimal_display = mesh_settings.use_optimal_display;
|
||||
me->runtime.subsurf_session_uuid = smd->modifier.session_uuid;
|
||||
}
|
||||
|
||||
/* Modifier itself. */
|
||||
|
|
Loading…
Reference in New Issue