You've already forked LuckyWorld
fixed build issues, added binaries, and updated the AsyncLoadingScreen plugin directory
This commit is contained in:
@ -0,0 +1,72 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class FFXRHIBackend : ModuleRules
|
||||
{
|
||||
public FFXRHIBackend(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(ModuleDirectory, "../fidelityfx-sdk/ffx-api/src"),
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"Projects",
|
||||
"RenderCore",
|
||||
"Renderer",
|
||||
"RHI",
|
||||
"CoreUObject",
|
||||
"FFXFSR3Api",
|
||||
"FFXOpticalFlowApi",
|
||||
"FFXFrameInterpolationApi",
|
||||
"FFXShared",
|
||||
"FFXFSR3Settings"
|
||||
}
|
||||
);
|
||||
|
||||
BuildVersion Version;
|
||||
if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
|
||||
{
|
||||
if (Version.MajorVersion == 5 && Version.MinorVersion >= 0)
|
||||
{
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"RHICore",
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PrecompileForTargets = PrecompileTargetsType.Any;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "FFXRHIBackend.h"
|
||||
|
||||
#include "FFXShared.h"
|
||||
#include "FFXFSR3.h"
|
||||
#include "FFXOpticalFlowApi.h"
|
||||
#include "FFXFrameInterpolationApi.h"
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
#include "Windows/AllowWindowsPlatformTypes.h"
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4191 )
|
||||
#else
|
||||
#define _countof(a) (sizeof(a)/sizeof(*(a)))
|
||||
#define strcpy_s(a, b) strcpy(a, b)
|
||||
#define FFX_GCC 1
|
||||
#endif
|
||||
THIRD_PARTY_INCLUDES_START
|
||||
|
||||
#include "ffx_provider.h"
|
||||
#if UE_VERSION_OLDER_THAN(5, 0, 0)
|
||||
#undef TRY
|
||||
#define TRY(_expr) \
|
||||
{ ffxReturnCode_t _rc = (_expr); if (_rc != FFX_API_RETURN_OK) return _rc; }
|
||||
#endif
|
||||
#include "ffx_api.cpp"
|
||||
#include "ffx_provider_framegeneration.cpp"
|
||||
#include "ffx_provider_fsr3upscale.cpp"
|
||||
#include "validation.cpp"
|
||||
|
||||
THIRD_PARTY_INCLUDES_END
|
||||
#if PLATFORM_WINDOWS
|
||||
#pragma warning( pop )
|
||||
#include "Windows/HideWindowsPlatformTypes.h"
|
||||
#else
|
||||
#undef _countof
|
||||
#undef strcpy_s
|
||||
#undef FFX_GCC
|
||||
#endif
|
1598
Plugins/FSR3-550/FSR3/Source/FFXRHIBackend/Private/FFXRHIBackend.cpp
Normal file
1598
Plugins/FSR3-550/FSR3/Source/FFXRHIBackend/Private/FFXRHIBackend.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,51 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "FFXRHIBackendModule.h"
|
||||
#include "FFXRHIBackend.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "ShaderCore.h"
|
||||
|
||||
IMPLEMENT_MODULE(FFXRHIBackendModule, FFXRHIBackend)
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FFXRHIBackend"
|
||||
|
||||
static FFXRHIBackend sRHIBackennd;
|
||||
|
||||
void FFXRHIBackendModule::StartupModule()
|
||||
{
|
||||
FString PluginFSR3ShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("FSR3"))->GetBaseDir(), TEXT("Source/fidelityfx-hlsl"));
|
||||
AddShaderSourceDirectoryMapping(TEXT("/ThirdParty/FFX"), PluginFSR3ShaderDir);
|
||||
FString PluginShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("FSR3"))->GetBaseDir(), TEXT("Shaders"));
|
||||
AddShaderSourceDirectoryMapping(TEXT("/Plugin/FFX"), PluginShaderDir);
|
||||
}
|
||||
|
||||
void FFXRHIBackendModule::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
IFFXSharedBackend* FFXRHIBackendModule::GetBackend()
|
||||
{
|
||||
return &sRHIBackennd;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
@ -0,0 +1,72 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "FFXRHIBackendShaders.h"
|
||||
|
||||
#include "ShaderCompilerCore.h"
|
||||
#if UE_VERSION_AT_LEAST(5, 2, 0)
|
||||
#include "DataDrivenShaderPlatformInfo.h"
|
||||
#endif
|
||||
|
||||
bool FFXGlobalShader::ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
||||
{
|
||||
#if UE_VERSION_AT_LEAST(5, 1, 0)
|
||||
bool const bWaveOps = FDataDrivenShaderPlatformInfo::GetSupportsWaveOperations(Parameters.Platform) == ERHIFeatureSupport::RuntimeGuaranteed;
|
||||
#elif UE_VERSION_AT_LEAST(5, 0, 0)
|
||||
bool const bWaveOps = RHISupportsWaveOperations(Parameters.Platform);
|
||||
#else
|
||||
bool const bWaveOps = FDataDrivenShaderPlatformInfo::GetSupportsWaveOperations(Parameters.Platform) || (Parameters.Platform == SP_PCD3D_SM5);
|
||||
#endif
|
||||
return IsFeatureLevelSupported(Parameters.Platform, ERHIFeatureLevel::SM5) && bWaveOps && IsPCPlatform(Parameters.Platform);
|
||||
}
|
||||
|
||||
void FFXGlobalShader::ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment, bool bPreferWave64)
|
||||
{
|
||||
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
||||
|
||||
OutEnvironment.CompilerFlags.Add(CFLAG_AllowTypedUAVLoads);
|
||||
OutEnvironment.CompilerFlags.Add(CFLAG_WaveOperations);
|
||||
if (Parameters.Platform == SP_PCD3D_SM5)
|
||||
{
|
||||
OutEnvironment.CompilerFlags.Add(CFLAG_ForceDXC);
|
||||
}
|
||||
|
||||
OutEnvironment.SetDefine(TEXT("FFX_GPU"), 1);
|
||||
OutEnvironment.SetDefine(TEXT("FFX_HLSL"), 1);
|
||||
|
||||
#if UE_VERSION_AT_LEAST(5, 0, 0)
|
||||
OutEnvironment.SetDefine(TEXT("UNREAL_VERSION"), 5);
|
||||
#else
|
||||
OutEnvironment.SetDefine(TEXT("UNREAL_VERSION"), 4);
|
||||
#endif
|
||||
|
||||
#if UE_VERSION_AT_LEAST(5, 1, 0)
|
||||
if (bPreferWave64
|
||||
#if UE_VERSION_AT_LEAST(5, 4, 0)
|
||||
&& FDataDrivenShaderPlatformInfo::GetSupportsWave64(Parameters.Platform))
|
||||
#else
|
||||
&& IsFeatureLevelSupported(Parameters.Platform, ERHIFeatureLevel::SM6))
|
||||
#endif
|
||||
{
|
||||
OutEnvironment.SetDefine(TEXT("FFX_PREFER_WAVE64"), TEXT("[WaveSize(64)]"));
|
||||
}
|
||||
#endif
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "FFXRHIBackendSubPass.h"
|
||||
|
||||
static TMap<FfxEffect, CreateFFXPassFunc>& GetFFXPassFactory()
|
||||
{
|
||||
static TMap<FfxEffect, CreateFFXPassFunc> FFXPassFactory;
|
||||
return FFXPassFactory;
|
||||
}
|
||||
|
||||
void RegisterFFXPass(FfxEffect Effect, CreateFFXPassFunc Func)
|
||||
{
|
||||
GetFFXPassFactory().Add(Effect, Func);
|
||||
}
|
||||
|
||||
IFFXRHIBackendSubPass* GetFFXPass(FfxEffect Effect, FfxPass pass, uint32_t permutationOptions, const FfxPipelineDescription* desc, FfxPipelineState* outPipeline, bool bSupportHalf, bool bPreferWave64)
|
||||
{
|
||||
IFFXRHIBackendSubPass* SubPass = nullptr;
|
||||
|
||||
CreateFFXPassFunc* Func = GetFFXPassFactory().Find(Effect);
|
||||
if (Func)
|
||||
{
|
||||
SubPass = (*Func)(pass, permutationOptions, desc, outPipeline, bSupportHalf, bPreferWave64);
|
||||
}
|
||||
return SubPass;
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FFXSharedBackend.h"
|
||||
#if PLATFORM_WINDOWS
|
||||
#include "Windows/AllowWindowsPlatformTypes.h"
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4191 )
|
||||
#else
|
||||
#define _countof(a) (sizeof(a)/sizeof(*(a)))
|
||||
#define strcpy_s(a, b) strcpy(a, b)
|
||||
#define FFX_GCC 1
|
||||
#endif
|
||||
THIRD_PARTY_INCLUDES_START
|
||||
#if UE_VERSION_AT_LEAST(5, 3, 0)
|
||||
#include <bit>
|
||||
#endif
|
||||
#include "FidelityFX/host/ffx_interface.h"
|
||||
THIRD_PARTY_INCLUDES_END
|
||||
#if PLATFORM_WINDOWS
|
||||
#pragma warning( pop )
|
||||
#include "Windows/HideWindowsPlatformTypes.h"
|
||||
#else
|
||||
#undef _countof
|
||||
#undef strcpy_s
|
||||
#undef FFX_GCC
|
||||
#endif
|
||||
#if UE_VERSION_AT_LEAST(5, 2, 0)
|
||||
#include "RHIResources.h"
|
||||
#else
|
||||
#include "RHI.h"
|
||||
#endif
|
||||
#include "RendererInterface.h"
|
||||
#include "RenderGraphDefinitions.h"
|
||||
#include "RenderGraphBuilder.h"
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_RHI 0x0000004u
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// The maximum number of resources that can be allocated.
|
||||
//-------------------------------------------------------------------------------------
|
||||
#define FFX_RHI_MAX_RESOURCE_COUNT (256)
|
||||
#define FFX_MAX_BLOCK_RESOURCE_COUNT (64)
|
||||
#define FFX_MAX_BLOCK_COUNT (4)
|
||||
#define FFX_MAX_JOB_COUNT (128)
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// State data for the FFX SDK backend that manages mapping resources between UE & FFX SDK.
|
||||
//-------------------------------------------------------------------------------------
|
||||
struct FFXRHIBACKEND_API FFXBackendState
|
||||
{
|
||||
struct Resource
|
||||
{
|
||||
uint32 EffectId;
|
||||
FRHIResource* Resource;
|
||||
FfxResourceDescription Desc;
|
||||
TRefCountPtr<IPooledRenderTarget>* RT;
|
||||
FRDGTexture* RDG;
|
||||
TRefCountPtr<FRDGPooledBuffer>* PooledBuffer;
|
||||
} Resources[FFX_RHI_MAX_RESOURCE_COUNT];
|
||||
|
||||
struct Block
|
||||
{
|
||||
uint64 ResourceMask;
|
||||
uint64 DynamicMask;
|
||||
} Blocks[FFX_MAX_BLOCK_COUNT];
|
||||
|
||||
uint8 StagingRingBuffer[FFX_ALIGN_UP(FFX_CONSTANT_BUFFER_RING_BUFFER_SIZE, sizeof(uint32_t))];
|
||||
uint32 StagingRingBufferBase;
|
||||
|
||||
FfxGpuJobDescription Jobs[FFX_MAX_JOB_COUNT];
|
||||
uint32 NumJobs;
|
||||
ERHIFeatureLevel::Type FeatureLevel;
|
||||
FfxDevice device;
|
||||
uint32 EffectIndex;
|
||||
|
||||
uint32 AllocEffect();
|
||||
uint32 GetEffectId(uint32 Index);
|
||||
void SetEffectId(uint32 Index, uint32 EffectId);
|
||||
|
||||
uint32 AllocIndex();
|
||||
void MarkDynamic(uint32 Index);
|
||||
uint32 GetDynamicIndex();
|
||||
bool IsValidIndex(uint32 Index);
|
||||
void FreeIndex(uint32 Index);
|
||||
|
||||
uint32 AddResource(FRHIResource* Resource, FfxResourceType Type, TRefCountPtr<IPooledRenderTarget>* RT, FRDGTexture* RDG, TRefCountPtr<FRDGPooledBuffer>* PooledBuffer);
|
||||
|
||||
FRHIResource* GetResource(uint32 Index);
|
||||
|
||||
FRDGTextureRef GetOrRegisterExternalTexture(FRDGBuilder& GraphBuilder, uint32 Index);
|
||||
|
||||
FRDGTexture* GetRDGTexture(FRDGBuilder& GraphBuilder, uint32 Index);
|
||||
|
||||
FRDGBufferRef GetRDGBuffer(FRDGBuilder& GraphBuilder, uint32 Index);
|
||||
|
||||
TRefCountPtr<IPooledRenderTarget> GetPooledRT(uint32 Index);
|
||||
|
||||
FfxResourceType GetType(uint32 Index);
|
||||
|
||||
void RemoveResource(uint32 Index);
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// FFX-style functions for the RHI backend to help setup the FSR3 library.
|
||||
//-------------------------------------------------------------------------------------
|
||||
extern FfxErrorCode ffxGetInterfaceUE(FfxInterface* outInterface, void* scratchBuffer, size_t scratchBufferSize);
|
||||
extern size_t ffxGetScratchMemorySizeUE();
|
||||
extern FfxResource ffxGetResourceFromUEResource(FfxInterface* backendInterface, FRDGTexture* rdgRes, FfxResourceStates state = FFX_RESOURCE_STATE_COMPUTE_READ);
|
||||
|
||||
class FFXRHIBACKEND_API FFXRHIBackend : public IFFXSharedBackend
|
||||
{
|
||||
FFXSharedAllocCallbacks AllocCbs;
|
||||
public:
|
||||
FFXRHIBackend();
|
||||
virtual ~FFXRHIBackend();
|
||||
|
||||
void OnViewportCreatedHandler_SetCustomPresent();
|
||||
void OnBeginDrawHandler();
|
||||
|
||||
ffxReturnCode_t ffxCreateContext(ffxContext* context, ffxCreateContextDescHeader* desc) final;
|
||||
ffxReturnCode_t ffxDestroyContext(ffxContext* context) final;
|
||||
ffxReturnCode_t ffxConfigure(ffxContext* context, const ffxConfigureDescHeader* desc) final;
|
||||
ffxReturnCode_t ffxQuery(ffxContext* context, ffxQueryDescHeader* desc) final;
|
||||
ffxReturnCode_t ffxDispatch(ffxContext* context, const ffxDispatchDescHeader* desc) final;
|
||||
|
||||
void Init() final;
|
||||
EFFXBackendAPI GetAPI() const final;
|
||||
void SetFeatureLevel(ffxContext* context, ERHIFeatureLevel::Type FeatureLevel) final;
|
||||
FfxSwapchain GetSwapchain(void* swapChain) final;
|
||||
FfxApiResource GetNativeResource(FRHITexture* Texture, FfxApiResourceState State) final;
|
||||
FfxApiResource GetNativeResource(FRDGTexture* Texture, FfxApiResourceState State) final;
|
||||
FfxCommandList GetNativeCommandBuffer(FRHICommandListImmediate& RHICmdList, FRHITexture* Texture) final;
|
||||
FfxShaderModel GetSupportedShaderModel() final;
|
||||
bool IsFloat16Supported() final;
|
||||
void ForceUAVTransition(FRHICommandListImmediate& RHICmdList, FRHITexture* OutputTexture, ERHIAccess Access) final;
|
||||
void UpdateSwapChain(ffxContext* Context, ffxConfigureDescFrameGeneration& Desc) final;
|
||||
void UpdateSwapChain(ffxContext* Context, ffxConfigureDescFrameGeneration& Desc, ffxConfigureDescFrameGenerationRegisterDistortionFieldResource& DescDistortion) final;
|
||||
FfxApiResource GetInterpolationOutput(FfxSwapchain SwapChain) final;
|
||||
void* GetInterpolationCommandList(FfxSwapchain SwapChain) final;
|
||||
void RegisterFrameResources(FRHIResource* FIResources, uint64 FrameID) final;
|
||||
bool GetAverageFrameTimes(float& AvgTimeMs, float& AvgFPS) final;
|
||||
void CopySubRect(FfxCommandList CmdList, FfxApiResource Src, FfxApiResource Dst, FIntPoint OutputExtents, FIntPoint OutputPoint) final;
|
||||
void Flush(FRHITexture* Tex, FRHICommandListImmediate& RHICmdList) final;
|
||||
};
|
@ -0,0 +1,36 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#include "FFXSharedBackend.h"
|
||||
|
||||
class FFXRHIBackendModule : public IFFXSharedBackendModule
|
||||
{
|
||||
public:
|
||||
// IModuleInterface implementation
|
||||
void StartupModule() override;
|
||||
void ShutdownModule() override;
|
||||
|
||||
IFFXSharedBackend* GetBackend() final;
|
||||
};
|
@ -0,0 +1,44 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FFXRHIBackend.h"
|
||||
#include "GlobalShader.h"
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Permutation variables for FFX shaders.
|
||||
//-------------------------------------------------------------------------------------
|
||||
class FFX_UseHalf : SHADER_PERMUTATION_BOOL("FFX_HALF");
|
||||
class FFX_PreferWave64 : SHADER_PERMUTATION_BOOL("_FFX_PREFER_WAVE64_");
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Common base class for the FFX shaders that handles the permutation support.
|
||||
//-------------------------------------------------------------------------------------
|
||||
class FFXRHIBACKEND_API FFXGlobalShader : public FGlobalShader
|
||||
{
|
||||
public:
|
||||
FFXGlobalShader() = default;
|
||||
FFXGlobalShader(const ShaderMetaType::CompiledShaderInitializerType Init) : FGlobalShader(Init) {}
|
||||
|
||||
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters);
|
||||
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment, bool bPreferWave64);
|
||||
};
|
@ -0,0 +1,132 @@
|
||||
// This file is part of the FidelityFX Super Resolution 3.1 Unreal Engine Plugin.
|
||||
//
|
||||
// Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "FFXRHIBackend.h"
|
||||
#include "RHIResources.h"
|
||||
#include "RendererInterface.h"
|
||||
#include "RenderGraphDefinitions.h"
|
||||
#include "RenderGraphBuilder.h"
|
||||
#include "RenderGraphUtils.h"
|
||||
#include "GlobalShader.h"
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Each FFX subpass implements this common interface to hide the internal details
|
||||
//-------------------------------------------------------------------------------------
|
||||
class IFFXRHIBackendSubPass
|
||||
{
|
||||
public:
|
||||
virtual ~IFFXRHIBackendSubPass() {}
|
||||
virtual void SetupPipeline(const FfxPipelineDescription* desc, FfxPipelineState* outPipeline, bool bSupportHalf) = 0;
|
||||
virtual void Dispatch(FRDGBuilder& GraphBuilder, FFXBackendState* Context, const FfxGpuJobDescription* job) = 0;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// The TFFXRHIBackendSubPass template reduces the boilerplate required for each pass.
|
||||
// The template handles binding resources & issuing the pass through RDG.
|
||||
//-------------------------------------------------------------------------------------
|
||||
template <typename TShaderClass>
|
||||
class TFFXRHIBackendSubPass : public IFFXRHIBackendSubPass
|
||||
{
|
||||
TCHAR const* Name;
|
||||
|
||||
public:
|
||||
typename TShaderClass::FPermutationDomain Permutation;
|
||||
|
||||
TFFXRHIBackendSubPass(TCHAR const* InName, const FfxPipelineDescription* desc, FfxPipelineState* outPipeline, bool bSupportHalf)
|
||||
: Name(InName)
|
||||
{
|
||||
SetupPipeline(desc, outPipeline, bSupportHalf);
|
||||
}
|
||||
|
||||
virtual ~TFFXRHIBackendSubPass()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SetupPipeline(const FfxPipelineDescription* desc, FfxPipelineState* outPipeline, bool bSupportHalf) override
|
||||
{
|
||||
outPipeline->srvTextureCount = TShaderClass::GetNumBoundSRVs();
|
||||
outPipeline->uavTextureCount = TShaderClass::GetNumBoundUAVs();
|
||||
outPipeline->constCount = TShaderClass::GetNumConstants();
|
||||
|
||||
for (uint32 i = 0; i < outPipeline->srvTextureCount && i < FFX_MAX_NUM_SRVS; i++)
|
||||
{
|
||||
outPipeline->srvTextureBindings[i].slotIndex = i;
|
||||
outPipeline->srvTextureBindings[i].resourceIdentifier = TShaderClass::GetBoundSRVs()[i];
|
||||
FCStringWide::Strcpy(outPipeline->srvTextureBindings[i].name, 63, TShaderClass::GetBoundSRVNames()[i]);
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < outPipeline->uavTextureCount && i < FFX_MAX_NUM_UAVS; i++)
|
||||
{
|
||||
outPipeline->uavTextureBindings[i].slotIndex = i;
|
||||
outPipeline->uavTextureBindings[i].resourceIdentifier = TShaderClass::GetBoundUAVs()[i];
|
||||
FCStringWide::Strcpy(outPipeline->uavTextureBindings[i].name, 63, TShaderClass::GetBoundUAVNames()[i]);
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < outPipeline->constCount && i < FFX_MAX_NUM_CONST_BUFFERS; i++)
|
||||
{
|
||||
outPipeline->constantBufferBindings[i].slotIndex = i;
|
||||
outPipeline->constantBufferBindings[i].resourceIdentifier = TShaderClass::GetBoundCBs()[i];
|
||||
FCStringWide::Strcpy(outPipeline->constantBufferBindings[i].name, 63, TShaderClass::GetBoundCBNames()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Dispatch(FRDGBuilder& GraphBuilder, FFXBackendState* Context, const FfxGpuJobDescription* job) override
|
||||
{
|
||||
TShaderMapRef<TShaderClass> ComputeShader(GetGlobalShaderMap(Context->FeatureLevel), Permutation);
|
||||
|
||||
FIntVector DispatchCount(job->computeJobDescriptor.dimensions[0], job->computeJobDescriptor.dimensions[1], job->computeJobDescriptor.dimensions[2]);
|
||||
typename TShaderClass::FParameters* Parameters = GraphBuilder.AllocParameters<typename TShaderClass::FParameters>();
|
||||
TShaderClass::BindParameters(GraphBuilder, Context, job, Parameters);
|
||||
|
||||
ClearUnusedGraphResources(ComputeShader, Parameters);
|
||||
|
||||
GraphBuilder.AddPass(
|
||||
FRDGEventName(Name),
|
||||
Parameters,
|
||||
ERDGPassFlags::Compute,
|
||||
[Parameters, ComputeShader, DispatchCount](FRHIComputeCommandList& RHICmdList)
|
||||
{
|
||||
FComputeShaderUtils::Dispatch(RHICmdList, ComputeShader, *Parameters, DispatchCount);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// These functions instantiate the actual passes.
|
||||
//-------------------------------------------------------------------------------------
|
||||
typedef IFFXRHIBackendSubPass* (*CreateFFXPassFunc)(FfxPass pass, uint32_t permutationOptions, const FfxPipelineDescription*, FfxPipelineState*, bool, bool);
|
||||
extern FFXRHIBACKEND_API void RegisterFFXPass(FfxEffect Effect, CreateFFXPassFunc Func);
|
||||
|
||||
template<FfxEffect Effect, CreateFFXPassFunc Func>
|
||||
class FFXRHIBackendRegisterEffect
|
||||
{
|
||||
static FFXRHIBackendRegisterEffect sSelf;
|
||||
public:
|
||||
FFXRHIBackendRegisterEffect()
|
||||
{
|
||||
RegisterFFXPass(Effect, Func);
|
||||
}
|
||||
};
|
||||
|
||||
extern FFXRHIBACKEND_API IFFXRHIBackendSubPass* GetFFXPass(FfxEffect effect, FfxPass pass, uint32_t permutationOptions, const FfxPipelineDescription* desc, FfxPipelineState* outPipeline, bool bSupportHalf, bool bPreferWave64);
|
Reference in New Issue
Block a user