From 2bbb5d3a91d6e3c295c1c3bd016637721eb59391 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Tue, 21 Jun 2022 20:49:08 -0700 Subject: [PATCH 1/3] Enable Multi-Frame-Rendering OutFlags --- Vulkanator.r | 5 ++--- source/Vulkanator.cpp | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Vulkanator.r b/Vulkanator.r index 996ed7b..05a5209 100644 --- a/Vulkanator.r +++ b/Vulkanator.r @@ -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 { diff --git a/source/Vulkanator.cpp b/source/Vulkanator.cpp index e027b7d..26b71fe 100644 --- a/source/Vulkanator.cpp +++ b/source/Vulkanator.cpp @@ -67,7 +67,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( From c8a88262ae420ac13626b6f00ec3404f5b55865b Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Tue, 21 Jun 2022 21:01:09 -0700 Subject: [PATCH 2/3] Update Debug Message Callback formatting Colors and message classification. Now these messages show up in the Debug Console when attached to a debugger! --- source/VulkanUtils.cpp | 87 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/source/VulkanUtils.cpp b/source/VulkanUtils.cpp index 21c525c..4a7e716 100644 --- a/source/VulkanUtils.cpp +++ b/source/VulkanUtils.cpp @@ -2,6 +2,7 @@ #include "vulkan/vulkan.hpp" #include +#include #include #include @@ -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: @@ -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 From 8c9c5038ced09f56b881a4eec1467d0183a31dcb Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Tue, 21 Jun 2022 21:37:49 -0700 Subject: [PATCH 3/3] 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. --- include/Vulkanator.hpp | 4 ++++ source/Vulkanator.cpp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/Vulkanator.hpp b/include/Vulkanator.hpp index 0b56f95..e81087a 100644 --- a/include/Vulkanator.hpp +++ b/include/Vulkanator.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #define PF_DEEP_COLOR_AWARE 1 #include @@ -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 = {}; diff --git a/source/Vulkanator.cpp b/source/Vulkanator.cpp index 26b71fe..1d7d0ef 100644 --- a/source/Vulkanator.cpp +++ b/source/Vulkanator.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -1189,9 +1190,37 @@ PF_Err SmartRender( // Lock global handle Vulkanator::GlobalParams* GlobalParam = reinterpret_cast(*in_data->global_data); - Vulkanator::SequenceParams* SequenceParam - = reinterpret_cast(*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( + *in_data->sequence_data ); + } + else + { + AEFX_SuiteScoper seqdata_suite + = AEFX_SuiteScoper( + in_data, kPFEffectSequenceDataSuite, + kPFEffectSequenceDataSuiteVersion1, out_data + ); + + PF_ConstHandle const_seq; + seqdata_suite->PF_GetConstSequenceData(in_data->effect_ref, &const_seq); + + SequenceParam = const_cast( + (const Vulkanator::SequenceParams*)*const_seq + ); + } + Vulkanator::RenderParams* FrameParam = reinterpret_cast( extra->input->pre_render_data