Skip to content

Commit

Permalink
Implement Naive Single-Frame-Rendering within MFR
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Wunkolo committed Jun 22, 2022
1 parent 3bbcedc commit 95feb76
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/Vulkanator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <array>
#include <cmath>
#include <cstdint>
#include <mutex>

#define PF_DEEP_COLOR_AWARE 1
#include <AEConfig.h>
Expand All @@ -20,6 +21,9 @@ namespace Vulkanator
// See GlobalSetup and GlobalSetdown
struct GlobalParams
{
// Global synchronization(bad)
std::mutex GlobalLock;

// Vulkan
vk::UniqueInstance Instance = {};
vk::UniqueDevice Device = {};
Expand Down
32 changes: 30 additions & 2 deletions source/Vulkanator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <array>
#include <span>

#include <AEFX_SuiteHelper.h>
#include <AEGP_SuiteHandler.h>
#include <AE_EffectCB.h>
#include <AE_EffectCBSuites.h>
Expand Down Expand Up @@ -726,6 +727,8 @@ PF_Err SequenceSetup(
= static_cast<Vulkanator::GlobalParams*>(
suites.HandleSuite1()->host_lock_handle(in_data->global_data));

std::scoped_lock Lock(GlobalParam->GlobalLock);

// Cleanup previous sequence datas
if( auto SequenceParam = reinterpret_cast<Vulkanator::SequenceParams*>(
out_data->sequence_data);
Expand Down Expand Up @@ -1127,9 +1130,34 @@ PF_Err SmartRender(
// Lock global handle
Vulkanator::GlobalParams* GlobalParam
= reinterpret_cast<Vulkanator::GlobalParams*>(*in_data->global_data);
Vulkanator::SequenceParams* SequenceParam
= reinterpret_cast<Vulkanator::SequenceParams*>(

std::scoped_lock Lock(GlobalParam->GlobalLock);

// Vulkanator::SequenceParams const* SequenceParam = nullptr;
Vulkanator::SequenceParams* SequenceParam = nullptr;

// If MFR is enabled, then `in_data->sequence_data` is null and we must use
// the suites to get sequence data. If MFR is disabled, or when running on a
// pre-MFR After Effects, then `in_data->sequence_data` has valid date
if( in_data->sequence_data )
{
SequenceParam = reinterpret_cast<Vulkanator::SequenceParams*>(
*in_data->sequence_data);
}
else
{
AEFX_SuiteScoper<PF_EffectSequenceDataSuite1> seqdata_suite
= AEFX_SuiteScoper<PF_EffectSequenceDataSuite1>(
in_data, kPFEffectSequenceDataSuite,
kPFEffectSequenceDataSuiteVersion1, out_data);

PF_ConstHandle const_seq;
seqdata_suite->PF_GetConstSequenceData(in_data->effect_ref, &const_seq);

SequenceParam = const_cast<Vulkanator::SequenceParams*>(
(const Vulkanator::SequenceParams*)*const_seq);
}

Vulkanator::RenderParams* FrameParam
= reinterpret_cast<Vulkanator::RenderParams*>(
extra->input->pre_render_data);
Expand Down

0 comments on commit 95feb76

Please sign in to comment.