diff --git a/FSR3UnityPlugin.cpp b/FSR3UnityPlugin.cpp index fc04a0a..4ce8f14 100644 --- a/FSR3UnityPlugin.cpp +++ b/FSR3UnityPlugin.cpp @@ -8,7 +8,10 @@ #include "UnityPluginAPI/IUnityLog.h" #include "UnityPluginAPI/IUnityGraphics.h" #include "UnityPluginAPI/IUnityRenderingExtensions.h" -//#include "UnityPluginAPI/IUnityGraphicsD3D12.h" + +#include +#include +#include "UnityPluginAPI/IUnityGraphicsD3D12.h" #include "FSR3UnityTypes.h" @@ -17,6 +20,7 @@ static const int32_t BaseEventId = 0; static IUnityInterfaces* s_UnityInterfaces = nullptr; static IUnityLog* s_Log = nullptr; static IUnityGraphics* s_Graphics = nullptr; +static IUnityGraphicsD3D12v7* s_GraphicsD3D12 = nullptr; static UnityGfxRenderer s_RendererType = kUnityGfxRendererNull; static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType eventType); @@ -59,23 +63,30 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev case kUnityGfxDeviceEventInitialize: { s_RendererType = s_Graphics->GetRenderer(); - //TODO: user initialization code on graphics device initialization. For example, D3D11 resource creation. + if (s_RendererType != kUnityGfxRendererD3D12) + return; + + s_GraphicsD3D12 = s_UnityInterfaces->Get(); + if (s_GraphicsD3D12 == nullptr) + { + UNITY_LOG_ERROR(s_Log, "Could not obtain D3D12 Graphics interface!"); + return; + } + break; } case kUnityGfxDeviceEventShutdown: { + s_GraphicsD3D12 = nullptr; s_RendererType = kUnityGfxRendererNull; - //TODO: user graphics API code to call on graphics device shutdown. break; } case kUnityGfxDeviceEventBeforeReset: { - //TODO: user graphics API code to call before graphics device reset. break; } case kUnityGfxDeviceEventAfterReset: { - //TODO: user graphics API code to call after graphics device reset. break; } };