#pragma once #include "UpscalerGraphicsDevice.h" #include "ffx-fsr2-api/ffx_fsr2.h" #include #include "UnityPluginAPI/IUnityGraphicsD3D11.h" struct FSR2Feature { FfxFsr2Context fsr2Context; bool isValid; uint32_t upscaleSizeWidth; uint32_t upscaleSizeHeight; uint32_t flags; uint64_t dispatchFrameValue; FSR3TextureTable textureTable; }; class FSR2Upscaler_DX11 : UpscalerGraphicsDevice { public: FSR2Upscaler_DX11(IUnityInterfaces* unityInterfaces, IUnityGraphicsD3D11* graphicsDevice) : m_GraphicsDevice(graphicsDevice), m_DX11Device(nullptr), m_Fsr2Interface() { } bool Init() override; protected: bool IsValidFeature(FSR2Feature& feature); bool InitFeature(FSR2Feature& feature, const FSR3CommandInitializationData* initData); void SetTexture(FSR3Texture textureType, UnityTextureID textureID, const UnityRenderingExtTextureUpdateParamsV2* params, FSR3TextureDesc* outTextureDesc); void Execute(FSR2Feature& feature, const FSR3CommandExecutionData* execData); void AwaitEndOfFrame(uint64_t frameValue); void DestroyContext(FSR2Feature& feature); void DoShutdown(); private: IUnityGraphicsD3D11* m_GraphicsDevice; FfxDevice m_DX11Device; FfxFsr2Interface m_Fsr2Interface; };