Browse Source

Merge branch 'master' into swapchain

# Conflicts:
#	src/FSR3UnityPlugin.cpp
#	src/FSR3UnityTypes.h
swapchain
Nico de Poel 10 months ago
parent
commit
97e220af24
  1. 23
      src/FSR3UnityPlugin.cpp
  2. 4
      src/FSR3UnityTypes.h

23
src/FSR3UnityPlugin.cpp

@ -11,8 +11,6 @@
#include "SwapChainTrampoline.h" #include "SwapChainTrampoline.h"
static const int32_t BaseEventId = 313;
static IUnityInterfaces* s_UnityInterfaces = nullptr; static IUnityInterfaces* s_UnityInterfaces = nullptr;
static IUnityLog* s_Log = nullptr; static IUnityLog* s_Log = nullptr;
static IUnityGraphics* s_Graphics = nullptr; static IUnityGraphics* s_Graphics = nullptr;
@ -22,6 +20,7 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev
static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data); static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data);
static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data); static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data);
static int32_t s_BaseEventId = 0;
static IUpscaler* s_Upscaler = nullptr; static IUpscaler* s_Upscaler = nullptr;
static IUnityGraphicsD3D12v7* s_GraphicsD3D12 = nullptr; static IUnityGraphicsD3D12v7* s_GraphicsD3D12 = nullptr;
@ -33,6 +32,8 @@ extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnit
s_Log = unityInterfaces->Get<IUnityLog>(); s_Log = unityInterfaces->Get<IUnityLog>();
s_Graphics = unityInterfaces->Get<IUnityGraphics>(); s_Graphics = unityInterfaces->Get<IUnityGraphics>();
s_BaseEventId = s_Graphics->ReserveEventIDRange((int)ePluginEventCount);
s_Graphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent); s_Graphics->RegisterDeviceEventCallback(OnGraphicsDeviceEvent);
// Run OnGraphicsDeviceEvent(initialize) manually on plugin load // Run OnGraphicsDeviceEvent(initialize) manually on plugin load
@ -90,13 +91,13 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev
eventConfig.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_DontCare; eventConfig.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_DontCare;
eventConfig.flags = kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission | kUnityD3D12EventConfigFlag_FlushCommandBuffers | kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState; eventConfig.flags = kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission | kUnityD3D12EventConfigFlag_FlushCommandBuffers | kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState;
eventConfig.ensureActiveRenderTextureIsBound = false; eventConfig.ensureActiveRenderTextureIsBound = false;
graphicsD3D12->ConfigureEvent(BaseEventId + FSR3PluginEvent::eExecute, &eventConfig);
graphicsD3D12->ConfigureEvent(s_BaseEventId + FSR3PluginEvent::eExecute, &eventConfig);
UnityD3D12PluginEventConfig eventConfigSC{}; UnityD3D12PluginEventConfig eventConfigSC{};
eventConfigSC.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_Allow; eventConfigSC.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_Allow;
eventConfigSC.flags = kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission | kUnityD3D12EventConfigFlag_FlushCommandBuffers | kUnityD3D12EventConfigFlag_SyncWorkerThreads; eventConfigSC.flags = kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission | kUnityD3D12EventConfigFlag_FlushCommandBuffers | kUnityD3D12EventConfigFlag_SyncWorkerThreads;
eventConfigSC.ensureActiveRenderTextureIsBound = false; eventConfigSC.ensureActiveRenderTextureIsBound = false;
graphicsD3D12->ConfigureEvent(BaseEventId + FSR3PluginEvent::eSwapChain, &eventConfigSC);
graphicsD3D12->ConfigureEvent(s_BaseEventId + FSR3PluginEvent::eSwapChain, &eventConfigSC);
break; break;
} }
case kUnityGfxRendererVulkan: case kUnityGfxRendererVulkan:
@ -114,7 +115,7 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev
eventConfig.graphicsQueueAccess = kUnityVulkanGraphicsQueueAccess_DontCare; eventConfig.graphicsQueueAccess = kUnityVulkanGraphicsQueueAccess_DontCare;
eventConfig.flags = kUnityVulkanEventConfigFlag_EnsurePreviousFrameSubmission | kUnityVulkanEventConfigFlag_FlushCommandBuffers | kUnityVulkanEventConfigFlag_SyncWorkerThreads | kUnityVulkanEventConfigFlag_ModifiesCommandBuffersState; eventConfig.flags = kUnityVulkanEventConfigFlag_EnsurePreviousFrameSubmission | kUnityVulkanEventConfigFlag_FlushCommandBuffers | kUnityVulkanEventConfigFlag_SyncWorkerThreads | kUnityVulkanEventConfigFlag_ModifiesCommandBuffersState;
eventConfig.renderPassPrecondition = kUnityVulkanRenderPass_EnsureInside; eventConfig.renderPassPrecondition = kUnityVulkanRenderPass_EnsureInside;
graphicsVulkan->ConfigureEvent(BaseEventId + FSR3PluginEvent::eExecute, &eventConfig);
graphicsVulkan->ConfigureEvent(s_BaseEventId + FSR3PluginEvent::eExecute, &eventConfig);
break; break;
} }
} }
@ -292,7 +293,7 @@ extern "C" bool UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_GetRenderResolu
extern "C" int32_t UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_GetBaseEventId() extern "C" int32_t UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API AMDUP_GetBaseEventId()
{ {
return BaseEventId;
return s_BaseEventId;
} }
// Plugin function to handle a specific rendering event // Plugin function to handle a specific rendering event
@ -302,27 +303,27 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
return; return;
// User rendering code // User rendering code
switch (eventID)
switch (eventID - s_BaseEventId)
{ {
case BaseEventId + FSR3PluginEvent::eDestroyFeature:
case FSR3PluginEvent::eDestroyFeature:
{ {
uint32_t featureSlot = (uint32_t)(intptr_t)data; uint32_t featureSlot = (uint32_t)(intptr_t)data;
s_Upscaler->DestroyFeature(featureSlot); s_Upscaler->DestroyFeature(featureSlot);
break; break;
} }
case BaseEventId + FSR3PluginEvent::eExecute:
case FSR3PluginEvent::eExecute:
{ {
auto* execData = (FSR3CommandExecutionData*)data; auto* execData = (FSR3CommandExecutionData*)data;
s_Upscaler->Execute(execData); s_Upscaler->Execute(execData);
break; break;
} }
case BaseEventId + FSR3PluginEvent::ePostExecute:
case FSR3PluginEvent::ePostExecute:
{ {
auto* execData = (FSR3CommandExecutionData*)data; auto* execData = (FSR3CommandExecutionData*)data;
s_Upscaler->PostExecute(execData); s_Upscaler->PostExecute(execData);
break; break;
} }
case BaseEventId + FSR3PluginEvent::eInit:
case FSR3PluginEvent::eInit:
{ {
auto* initData = (FSR3CommandInitializationData*)data; auto* initData = (FSR3CommandInitializationData*)data;
s_Upscaler->InitFeature(initData); s_Upscaler->InitFeature(initData);

4
src/FSR3UnityTypes.h

@ -6,7 +6,9 @@ enum FSR3PluginEvent : int32_t
eExecute, eExecute,
ePostExecute, ePostExecute,
eInit, eInit,
eSwapChain
eSwapChain,
ePluginEventCount
}; };
enum FSR3Quality: int32_t enum FSR3Quality: int32_t

Loading…
Cancel
Save