|
|
@ -8,7 +8,10 @@ |
|
|
#include "UnityPluginAPI/IUnityLog.h"
|
|
|
#include "UnityPluginAPI/IUnityLog.h"
|
|
|
#include "UnityPluginAPI/IUnityGraphics.h"
|
|
|
#include "UnityPluginAPI/IUnityGraphics.h"
|
|
|
#include "UnityPluginAPI/IUnityRenderingExtensions.h"
|
|
|
#include "UnityPluginAPI/IUnityRenderingExtensions.h"
|
|
|
//#include "UnityPluginAPI/IUnityGraphicsD3D12.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <d3d12.h>
|
|
|
|
|
|
#include <dxgi.h>
|
|
|
|
|
|
#include "UnityPluginAPI/IUnityGraphicsD3D12.h"
|
|
|
|
|
|
|
|
|
#include "FSR3UnityTypes.h"
|
|
|
#include "FSR3UnityTypes.h"
|
|
|
|
|
|
|
|
|
@ -17,6 +20,7 @@ static const int32_t BaseEventId = 0; |
|
|
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; |
|
|
|
|
|
static IUnityGraphicsD3D12v7* s_GraphicsD3D12 = nullptr; |
|
|
static UnityGfxRenderer s_RendererType = kUnityGfxRendererNull; |
|
|
static UnityGfxRenderer s_RendererType = kUnityGfxRendererNull; |
|
|
|
|
|
|
|
|
static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType eventType); |
|
|
static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType eventType); |
|
|
@ -59,23 +63,30 @@ static void UNITY_INTERFACE_API OnGraphicsDeviceEvent(UnityGfxDeviceEventType ev |
|
|
case kUnityGfxDeviceEventInitialize: |
|
|
case kUnityGfxDeviceEventInitialize: |
|
|
{ |
|
|
{ |
|
|
s_RendererType = s_Graphics->GetRenderer(); |
|
|
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<IUnityGraphicsD3D12v7>(); |
|
|
|
|
|
if (s_GraphicsD3D12 == nullptr) |
|
|
|
|
|
{ |
|
|
|
|
|
UNITY_LOG_ERROR(s_Log, "Could not obtain D3D12 Graphics interface!"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case kUnityGfxDeviceEventShutdown: |
|
|
case kUnityGfxDeviceEventShutdown: |
|
|
{ |
|
|
{ |
|
|
|
|
|
s_GraphicsD3D12 = nullptr; |
|
|
s_RendererType = kUnityGfxRendererNull; |
|
|
s_RendererType = kUnityGfxRendererNull; |
|
|
//TODO: user graphics API code to call on graphics device shutdown.
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case kUnityGfxDeviceEventBeforeReset: |
|
|
case kUnityGfxDeviceEventBeforeReset: |
|
|
{ |
|
|
{ |
|
|
//TODO: user graphics API code to call before graphics device reset.
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
case kUnityGfxDeviceEventAfterReset: |
|
|
case kUnityGfxDeviceEventAfterReset: |
|
|
{ |
|
|
{ |
|
|
//TODO: user graphics API code to call after graphics device reset.
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|