From 639aac06e858808b031566724161f1bc3458ff21 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 11 Mar 2025 21:46:07 +0100 Subject: [PATCH] Implemented remainder of DX11 support --- FSR2UnityPlugin.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/FSR2UnityPlugin.cpp b/FSR2UnityPlugin.cpp index 92b32a6..33fa9b6 100644 --- a/FSR2UnityPlugin.cpp +++ b/FSR2UnityPlugin.cpp @@ -352,7 +352,21 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data) FfxFsr2DispatchDescription dispatchDescription{}; - if (s_GraphicsD3D12 != nullptr) + if (s_GraphicsD3D11 != nullptr) + { + ID3D11DeviceContext* ctx = nullptr; + s_GraphicsD3D11->GetDevice()->GetImmediateContext(&ctx); + dispatchDescription.commandList = ctx; + + dispatchDescription.color = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.colorInput.image); + dispatchDescription.depth = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.depth.image); + dispatchDescription.motionVectors = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.motionVectors.image); + dispatchDescription.exposure = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.exposureTexture.image); + dispatchDescription.reactive = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.reactiveMask.image); + dispatchDescription.transparencyAndComposition = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.transparencyMask.image); + dispatchDescription.output = ffxGetResourceDX11(&feature.upscalingContext, (ID3D11Resource*)feature.textureTable.colorOutput.image, nullptr, FFX_RESOURCE_STATE_UNORDERED_ACCESS); + } + else if (s_GraphicsD3D12 != nullptr) { UnityGraphicsD3D12RecordingState state; s_GraphicsD3D12->CommandRecordingState(&state); @@ -484,7 +498,11 @@ static void UNITY_INTERFACE_API OnSetTextureEvent(int eventID, void* data) // This way we can use the texture slot value simply as a pointer offset into the texture table FSR2TextureDesc* textureDesc = ((FSR2TextureDesc*)&feature.textureTable) + textureSlot; - if (s_GraphicsD3D12 != nullptr) + if (s_GraphicsD3D11 != nullptr) + { + textureDesc->image = (intptr_t)s_GraphicsD3D11->TextureFromNativeTexture((UnityTextureID)params->textureID); + } + else if (s_GraphicsD3D12 != nullptr) { textureDesc->image = (intptr_t)s_GraphicsD3D12->TextureFromNativeTexture((UnityTextureID)params->textureID); }