Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Vulkanator.r
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ resource 'PiPL' (16000) {
},
/* [10] */
AE_Effect_Global_OutFlags {
0x02000000 // 33554432

0x02000000 // 33554432
},
AE_Effect_Global_OutFlags_2 {
0x00001408 // 5128
0x08001408 // 134222856
},
/* [11] */
AE_Effect_Match_Name {
Expand Down
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
87 changes: 78 additions & 9 deletions source/VulkanUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "vulkan/vulkan.hpp"

#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iterator>

Expand Down Expand Up @@ -249,22 +250,75 @@ vk::MemoryHeap GetLargestPhysicalDeviceHeap(
return PhysicalDeviceMemoryProperties.memoryHeaps[HeapIndex];
}

// This function will be called whenever the Vulkan backend has something to say
// about what you are doing How ever you want to handle this, implement it here.
// For now, I put an "ASSERT" whenever there is a warning or error
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessageCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
VkDebugUtilsMessageTypeFlagsEXT MessageType,
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData
std::uint8_t SeverityColor(vk::DebugUtilsMessageSeverityFlagBitsEXT Severity)
{
switch( Severity )
{
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose:
{
// Dark Gray
return 90u;
}
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo:
{
// Light Gray
return 90u;
}
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning:
{
// Light Magenta
return 95u;
}
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eError:
{
// Light red
return 91u;
}
}
// Default Foreground Color
return 39u;
}

std::uint8_t MessageTypeColor(vk::DebugUtilsMessageTypeFlagsEXT MessageType)
{
if( MessageType & vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral )
{
// Dim
return 2u;
}
if( MessageType & vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance )
{
// Bold/Bright
return 1u;
}
if( MessageType & vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation )
{
// Light Gray
return 90u;
}
// Default Foreground Color
return 39u;
}

VkBool32 DebugMessageCallback(
vk::DebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
vk::DebugUtilsMessageTypeFlagsEXT MessageType,
const vk::DebugUtilsMessengerCallbackDataEXT& CallbackData, void* UserData
)
{
switch( vk::DebugUtilsMessageSeverityFlagBitsEXT(MessageSeverity) )
std::fprintf(
stderr, "\033[93m+ \033[%um[%s]: \033[%um%s\033[0m\n",
SeverityColor(MessageSeverity), CallbackData.pMessageIdName,
MessageTypeColor(MessageType), CallbackData.pMessage
);
std::fflush(stderr);

switch( MessageSeverity )
{
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eError:
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning:
{
// Something bad happened! Check message!
const char* Message = CallbackData->pMessage;
assert(0);
}
case vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo:
Expand All @@ -275,4 +329,19 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessageCallback(
}
return VK_FALSE;
}

// This function will be called whenever the Vulkan backend has something to say
// about what you are doing How ever you want to handle this, implement it here.
// For now, I put an "ASSERT" whenever there is a warning or error
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessageCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
VkDebugUtilsMessageTypeFlagsEXT MessageType,
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData
)
{
return DebugMessageCallback(
vk::DebugUtilsMessageSeverityFlagBitsEXT(MessageSeverity),
vk::DebugUtilsMessageTypeFlagsEXT(MessageType), *CallbackData, UserData
);
}
} // namespace VulkanUtils
36 changes: 33 additions & 3 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 @@ -67,7 +68,8 @@ PF_Err GlobalSetup(
out_data->out_flags = PF_OutFlag_DEEP_COLOR_AWARE;
out_data->out_flags2 = PF_OutFlag2_PARAM_GROUP_START_COLLAPSED_FLAG
| PF_OutFlag2_SUPPORTS_SMART_RENDER
| PF_OutFlag2_FLOAT_COLOR_AWARE;
| PF_OutFlag2_FLOAT_COLOR_AWARE
| PF_OutFlag2_SUPPORTS_THREADED_RENDERING;

// Allocate global handle
const PF_Handle GlobalDataHandle = suites.HandleSuite1()->host_new_handle(
Expand Down Expand Up @@ -1188,9 +1190,37 @@ PF_Err SmartRender(
// Lock global handle
Vulkanator::GlobalParams* GlobalParam
= reinterpret_cast<Vulkanator::GlobalParams*>(*in_data->global_data);
Vulkanator::SequenceParams* SequenceParam
= reinterpret_cast<Vulkanator::SequenceParams*>(*in_data->sequence_data

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