Skip to content

Commit 95feb76

Browse files
committed
Implement Naive Single-Frame-Rendering within MFR
Using a global mutex to begin de-coupling things bit by bit. Currently renders things fine, thinking it is MFR, but is actually rendering singular frames.
1 parent 3bbcedc commit 95feb76

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

include/Vulkanator.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <array>
44
#include <cmath>
55
#include <cstdint>
6+
#include <mutex>
67

78
#define PF_DEEP_COLOR_AWARE 1
89
#include <AEConfig.h>
@@ -20,6 +21,9 @@ namespace Vulkanator
2021
// See GlobalSetup and GlobalSetdown
2122
struct GlobalParams
2223
{
24+
// Global synchronization(bad)
25+
std::mutex GlobalLock;
26+
2327
// Vulkan
2428
vk::UniqueInstance Instance = {};
2529
vk::UniqueDevice Device = {};

source/Vulkanator.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <array>
88
#include <span>
99

10+
#include <AEFX_SuiteHelper.h>
1011
#include <AEGP_SuiteHandler.h>
1112
#include <AE_EffectCB.h>
1213
#include <AE_EffectCBSuites.h>
@@ -726,6 +727,8 @@ PF_Err SequenceSetup(
726727
= static_cast<Vulkanator::GlobalParams*>(
727728
suites.HandleSuite1()->host_lock_handle(in_data->global_data));
728729

730+
std::scoped_lock Lock(GlobalParam->GlobalLock);
731+
729732
// Cleanup previous sequence datas
730733
if( auto SequenceParam = reinterpret_cast<Vulkanator::SequenceParams*>(
731734
out_data->sequence_data);
@@ -1127,9 +1130,34 @@ PF_Err SmartRender(
11271130
// Lock global handle
11281131
Vulkanator::GlobalParams* GlobalParam
11291132
= reinterpret_cast<Vulkanator::GlobalParams*>(*in_data->global_data);
1130-
Vulkanator::SequenceParams* SequenceParam
1131-
= reinterpret_cast<Vulkanator::SequenceParams*>(
1133+
1134+
std::scoped_lock Lock(GlobalParam->GlobalLock);
1135+
1136+
// Vulkanator::SequenceParams const* SequenceParam = nullptr;
1137+
Vulkanator::SequenceParams* SequenceParam = nullptr;
1138+
1139+
// If MFR is enabled, then `in_data->sequence_data` is null and we must use
1140+
// the suites to get sequence data. If MFR is disabled, or when running on a
1141+
// pre-MFR After Effects, then `in_data->sequence_data` has valid date
1142+
if( in_data->sequence_data )
1143+
{
1144+
SequenceParam = reinterpret_cast<Vulkanator::SequenceParams*>(
11321145
*in_data->sequence_data);
1146+
}
1147+
else
1148+
{
1149+
AEFX_SuiteScoper<PF_EffectSequenceDataSuite1> seqdata_suite
1150+
= AEFX_SuiteScoper<PF_EffectSequenceDataSuite1>(
1151+
in_data, kPFEffectSequenceDataSuite,
1152+
kPFEffectSequenceDataSuiteVersion1, out_data);
1153+
1154+
PF_ConstHandle const_seq;
1155+
seqdata_suite->PF_GetConstSequenceData(in_data->effect_ref, &const_seq);
1156+
1157+
SequenceParam = const_cast<Vulkanator::SequenceParams*>(
1158+
(const Vulkanator::SequenceParams*)*const_seq);
1159+
}
1160+
11331161
Vulkanator::RenderParams* FrameParam
11341162
= reinterpret_cast<Vulkanator::RenderParams*>(
11351163
extra->input->pre_render_data);

0 commit comments

Comments
 (0)