Browse Source

Implemented D3D12 Unity interface bits

fsr2
Nico de Poel 11 months ago
parent
commit
9ac431209e
  1. 21
      FSR3UnityPlugin.cpp

21
FSR3UnityPlugin.cpp

@ -8,7 +8,10 @@
#include "UnityPluginAPI/IUnityLog.h"
#include "UnityPluginAPI/IUnityGraphics.h"
#include "UnityPluginAPI/IUnityRenderingExtensions.h"
//#include "UnityPluginAPI/IUnityGraphicsD3D12.h"
#include <d3d12.h>
#include <dxgi.h>
#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<IUnityGraphicsD3D12v7>();
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;
}
};

Loading…
Cancel
Save