@ -1,4 +1,4 @@
// Copyright (c) 2023 Nico de Poel
// Copyright (c) 2024 Nico de Poel
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// of this software and associated documentation files (the "Software"), to deal
@ -31,22 +31,34 @@ namespace FidelityFX
/// </summary>
/// </summary>
internal class Fsr3UpscalerResources
internal class Fsr3UpscalerResources
{
{
public Texture2D LanczosLut ;
public Texture2D DefaultExposure ;
public Texture2D DefaultExposure ;
public Texture2D DefaultReactive ;
public Texture2D DefaultReactive ;
public Texture2D LanczosLut ;
public Texture2D MaximumBiasLut ;
public RenderTexture SpdAtomicCounter ;
public RenderTexture SpdAtomicCounter ;
public RenderTexture AutoExposure ;
public RenderTexture SceneLuminance ;
public RenderTexture SpdMips ;
public RenderTexture DilatedVelocity ;
public RenderTexture DilatedDepth ;
public RenderTexture ReconstructedPrevNearestDepth ;
public RenderTexture FrameInfo ;
public RenderTexture AutoReactive ;
public RenderTexture AutoReactive ;
public RenderTexture AutoComposition ;
public RenderTexture AutoComposition ;
public readonly RenderTexture [ ] DilatedMotionVectors = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] LockStatus = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] Accumulation = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] Luma = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] InternalUpscaled = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] InternalUpscaled = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] LumaHistory = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] LumaHistory = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] PrevPreAlpha = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] PrevPreAlpha = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] PrevPostAlpha = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] PrevPostAlpha = new RenderTexture [ 2 ] ;
// OLD
public Texture2D MaximumBiasLut ;
public RenderTexture AutoExposure ;
public RenderTexture SceneLuminance ;
public readonly RenderTexture [ ] DilatedMotionVectors = new RenderTexture [ 2 ] ;
public readonly RenderTexture [ ] LockStatus = new RenderTexture [ 2 ] ;
public void Create ( Fsr3Upscaler . ContextDescription contextDescription )
public void Create ( Fsr3Upscaler . ContextDescription contextDescription )
{
{
// Generate the data for the LUT
// Generate the data for the LUT
@ -59,11 +71,8 @@ namespace FidelityFX
lanczos2Weights [ currentLanczosWidthIndex ] = y ;
lanczos2Weights [ currentLanczosWidthIndex ] = y ;
}
}
float [ ] maximumBias = new float [ MaximumBiasTextureWidth * MaximumBiasTextureHeight ] ;
for ( int i = 0 ; i < maximumBias . Length ; + + i )
{
maximumBias [ i ] = MaximumBias [ i ] / 2.0f ;
}
Vector2Int maxRenderSize = contextDescription . MaxRenderSize ;
Vector2Int maxRenderSizeDiv2 = maxRenderSize / 2 ;
// Resource FSR3UPSCALER_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE
// Resource FSR3UPSCALER_LanczosLutData: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_SNORM, FFX_RESOURCE_FLAGS_NONE
// R16_SNorm textures are not supported by Unity on most platforms, strangely enough. So instead we use R32_SFloat and upload pre-normalized float data.
// R16_SNorm textures are not supported by Unity on most platforms, strangely enough. So instead we use R32_SFloat and upload pre-normalized float data.
@ -71,35 +80,67 @@ namespace FidelityFX
LanczosLut . SetPixelData ( lanczos2Weights , 0 ) ;
LanczosLut . SetPixelData ( lanczos2Weights , 0 ) ;
LanczosLut . Apply ( ) ;
LanczosLut . Apply ( ) ;
// Resource FSR3UPSCALER_MaximumUpsampleBias: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R16_S NORM, FFX_RESOURCE_FLAGS_NONE
MaximumBiasLut = new Texture2D ( MaximumBiasTextureWidth , MaximumBiasTextureHeight , GraphicsFormat . R32_SFloat , TextureCreationFlags . None ) { name = "FSR3UPSCALER_MaximumUpsampleBias " } ;
MaximumBiasLut . SetPixelData ( maximumBias , 0 ) ;
MaximumBiasLut . Apply ( ) ;
// Resource FSR3UPSCALER_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_U NORM, FFX_RESOURCE_FLAGS_NONE
DefaultReactive = new Texture2D ( 1 , 1 , GraphicsFormat . R8_UNorm , TextureCreationFlags . None ) { name = "FSR3UPSCALER_DefaultReactivityMask " } ;
DefaultReactive . SetPixel ( 0 , 0 , Color . clear ) ;
DefaultReactive . Apply ( ) ;
// Resource FSR3UPSCALER_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
// Resource FSR3UPSCALER_DefaultExposure: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
DefaultExposure = new Texture2D ( 1 , 1 , GraphicsFormat . R32G32_SFloat , TextureCreationFlags . None ) { name = "FSR3UPSCALER_DefaultExposure" } ;
DefaultExposure = new Texture2D ( 1 , 1 , GraphicsFormat . R32G32_SFloat , TextureCreationFlags . None ) { name = "FSR3UPSCALER_DefaultExposure" } ;
DefaultExposure . SetPixel ( 0 , 0 , Color . clear ) ;
DefaultExposure . SetPixel ( 0 , 0 , Color . clear ) ;
DefaultExposure . Apply ( ) ;
DefaultExposure . Apply ( ) ;
// Resource FSR3UPSCALER_DefaultReactivityMask: FFX_RESOURCE_USAGE_READ_ONLY, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE
DefaultReactive = new Texture2D ( 1 , 1 , GraphicsFormat . R8_UNorm , TextureCreationFlags . None ) { name = "FSR3UPSCALER_DefaultReactivityMask" } ;
DefaultReactive . SetPixel ( 0 , 0 , Color . clear ) ;
DefaultReactive . Apply ( ) ;
// Resource FSR3UPSCALER_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
// Resource FSR3UPSCALER_SpdAtomicCounter: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
// Despite what the original FSR3 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal.
// Despite what the original FSR3 codebase says, this resource really isn't aliasable. Resetting this counter to 0 every frame breaks auto-exposure on MacOS Metal.
SpdAtomicCounter = new RenderTexture ( 1 , 1 , 0 , GraphicsFormat . R32_UInt ) { name = "FSR3UPSCALER_SpdAtomicCounter" , enableRandomWrite = true } ;
SpdAtomicCounter = new RenderTexture ( 1 , 1 , 0 , GraphicsFormat . R32_UInt ) { name = "FSR3UPSCALER_SpdAtomicCounter" , enableRandomWrite = true } ;
SpdAtomicCounter . Create ( ) ;
SpdAtomicCounter . Create ( ) ;
// Resource FSR3UPSCALER_SpdMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this.
int mipCount = 1 + Mathf . FloorToInt ( Mathf . Log ( Math . Max ( maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y ) , 2.0f ) ) ;
SpdMips = new RenderTexture ( maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y , 0 , GraphicsFormat . R16G16_SFloat , mipCount ) { name = "FSR3UPSCALER_SpdMips" , enableRandomWrite = true , useMipMap = true , autoGenerateMips = false } ;
SpdMips . Create ( ) ;
// Resource FSR3UPSCALER_DilatedVelocity: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
DilatedVelocity = new RenderTexture ( maxRenderSize . x , maxRenderSize . y , 0 , GraphicsFormat . R16G16_SFloat ) { name = "FSR3UPSCALER_DilatedVelocity" , enableRandomWrite = true } ;
DilatedVelocity . Create ( ) ;
// Resource FSR3UPSCALER_DilatedDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_FLOAT, FFX_RESOURCE_FLAGS_NONE
DilatedDepth = new RenderTexture ( maxRenderSize . x , maxRenderSize . y , 0 , GraphicsFormat . R32_SFloat ) { name = "FSR3UPSCALER_DilatedDepth" , enableRandomWrite = true } ;
DilatedDepth . Create ( ) ;
// Resource FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_NONE
ReconstructedPrevNearestDepth = new RenderTexture ( maxRenderSize . x , maxRenderSize . y , 0 , GraphicsFormat . R32_UInt ) { name = "FSR3UPSCALER_ReconstructedPrevNearestDepth" , enableRandomWrite = true } ;
ReconstructedPrevNearestDepth . Create ( ) ;
// Resource FSR3UPSCALER_FrameInfo: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32B32A32_FLOAT, FFX_RESOURCE_FLAGS_NONE
FrameInfo = new RenderTexture ( 1 , 1 , 0 , GraphicsFormat . R32G32B32A32_SFloat ) { name = "FSR3UPSCALER_FrameInfo" , enableRandomWrite = true } ;
FrameInfo . Create ( ) ;
// Resources FSR3UPSCALER_Accumulation1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( Accumulation , "FSR3UPSCALER_Accumulation" , maxRenderSize , GraphicsFormat . R8_UNorm ) ;
// Resources FSR3UPSCALER_Luma1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( Luma , "FSR3UPSCALER_Luma" , maxRenderSize , GraphicsFormat . R16_SFloat ) ;
// Resources FSR3UPSCALER_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( InternalUpscaled , "FSR3UPSCALER_InternalUpscaled" , contextDescription . MaxUpscaleSize , GraphicsFormat . R16G16B16A16_SFloat ) ;
// Resources FSR3UPSCALER_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( LumaHistory , "FSR3UPSCALER_LumaHistory" , contextDescription . MaxUpscaleSize , GraphicsFormat . R16G16B16A16_SFloat ) ;
//
// OLD
//
// Resource FSR3UPSCALER_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
// Resource FSR3UPSCALER_AutoExposure: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32_FLOAT, FFX_RESOURCE_FLAGS_NONE
AutoExposure = new RenderTexture ( 1 , 1 , 0 , GraphicsFormat . R32G32_SFloat ) { name = "FSR3UPSCALER_AutoExposure" , enableRandomWrite = true } ;
AutoExposure = new RenderTexture ( 1 , 1 , 0 , GraphicsFormat . R32G32_SFloat ) { name = "FSR3UPSCALER_AutoExposure" , enableRandomWrite = true } ;
AutoExposure . Create ( ) ;
AutoExposure . Create ( ) ;
// Resource FSR3UPSCALER_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// Resource FSR3UPSCALER_ExposureMips: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this.
// This is a rather special case: it's an aliasable resource, but because we require a mipmap chain and bind specific mip levels per shader, we can't easily use temporary RTs for this.
int w = contextDescription . MaxRenderSize . x / 2 , h = contextDescription . MaxRenderSize . y / 2 ;
int mipCount = 1 + Mathf . FloorToInt ( Mathf . Log ( Math . Max ( w , h ) , 2.0f ) ) ;
SceneLuminance = new RenderTexture ( w , h , 0 , GraphicsFormat . R16_SFloat , mipCount ) { name = "FSR3UPSCALER_ExposureMips" , enableRandomWrite = true , useMipMap = true , autoGenerateMips = false } ;
mipCount = 1 + Mathf . FloorToInt ( Mathf . Log ( Math . Max ( maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y ) , 2.0f ) ) ;
SceneLuminance = new RenderTexture ( maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y , 0 , GraphicsFormat . R16_SFloat , mipCount ) { name = "FSR3UPSCALER_ExposureMips" , enableRandomWrite = true , useMipMap = true , autoGenerateMips = false } ;
SceneLuminance . Create ( ) ;
SceneLuminance . Create ( ) ;
// Resources FSR3UPSCALER_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
// Resources FSR3UPSCALER_InternalDilatedVelocity1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
@ -107,12 +148,6 @@ namespace FidelityFX
// Resources FSR3UPSCALER_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
// Resources FSR3UPSCALER_LockStatus1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( LockStatus , "FSR3UPSCALER_LockStatus" , contextDescription . MaxUpscaleSize , GraphicsFormat . R16G16_SFloat ) ;
CreateDoubleBufferedResource ( LockStatus , "FSR3UPSCALER_LockStatus" , contextDescription . MaxUpscaleSize , GraphicsFormat . R16G16_SFloat ) ;
// Resources FSR3UPSCALER_InternalUpscaled1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( InternalUpscaled , "FSR3UPSCALER_InternalUpscaled" , contextDescription . MaxUpscaleSize , GraphicsFormat . R16G16B16A16_SFloat ) ;
// Resources FSR3UPSCALER_LumaHistory1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_NONE
CreateDoubleBufferedResource ( LumaHistory , "FSR3UPSCALER_LumaHistory" , contextDescription . MaxUpscaleSize , GraphicsFormat . R8G8B8A8_UNorm ) ;
}
}
public void CreateTcrAutogenResources ( Fsr3Upscaler . ContextDescription contextDescription )
public void CreateTcrAutogenResources ( Fsr3Upscaler . ContextDescription contextDescription )
@ -136,8 +171,32 @@ namespace FidelityFX
// These do not need to persist between frames, but they do need to be available between passes
// These do not need to persist between frames, but they do need to be available between passes
public static void CreateAliasableResources ( CommandBuffer commandBuffer , Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler . DispatchDescription dispatchParams )
public static void CreateAliasableResources ( CommandBuffer commandBuffer , Fsr3Upscaler . ContextDescription contextDescription , Fsr3Upscaler . DispatchDescription dispatchParams )
{
{
Vector2Int display Size = contextDescription . MaxUpscaleSize ;
Vector2Int maxUpscale Size = contextDescription . MaxUpscaleSize ;
Vector2Int maxRenderSize = contextDescription . MaxRenderSize ;
Vector2Int maxRenderSize = contextDescription . MaxRenderSize ;
Vector2Int maxRenderSizeDiv2 = maxRenderSize / 2 ;
// TODO Aliasable: FSR3UPSCALER_IntermediateFp16x1, FSR3UPSCALER_ShadingChange, FSR3UPSCALER_NewLocks, FSR3UPSCALER_DilatedReactiveMasks
// TODO Aliasable but probably not: FSR3UPSCALER_SpdMips, FSR3UPSCALER_FarthestDepthMip1
// FSR3UPSCALER_IntermediateFp16x1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavFarthestDepth , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16_SFloat , 1 , true ) ;
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavLumaInstability , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16_SFloat , 1 , true ) ;
// FSR3UPSCALER_ShadingChange: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavShadingChange , maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y , 0 , default , GraphicsFormat . R8_UNorm , 1 , true ) ;
// FSR3UPSCALER_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavNewLocks , maxUpscaleSize . x , maxUpscaleSize . y , 0 , default , GraphicsFormat . R8_UNorm , 1 , true ) ;
// FSR3UPSCALER_FarthestDepthMip1: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavFarthestDepthMip1 , maxRenderSizeDiv2 . x , maxRenderSizeDiv2 . y , 0 , default , GraphicsFormat . R16_SFloat , 1 , true ) ;
// FSR3UPSCALER_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8B8A8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavDilatedReactiveMasks , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R8G8B8A8_UNorm , 1 , true ) ;
//
// OLD
//
// FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
// FSR3UPSCALER_ReconstructedPrevNearestDepth: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32_UINT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavReconstructedPrevNearestDepth , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R32_UInt , 1 , true ) ;
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavReconstructedPrevNearestDepth , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R32_UInt , 1 , true ) ;
@ -148,14 +207,8 @@ namespace FidelityFX
// FSR3UPSCALER_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// FSR3UPSCALER_LockInputLuma: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavLockInputLuma , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16_SFloat , 1 , true ) ;
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavLockInputLuma , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16_SFloat , 1 , true ) ;
// FSR3UPSCALER_DilatedReactiveMasks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8G8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavDilatedReactiveMasks , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R8G8_UNorm , 1 , true ) ;
// FSR3UPSCALER_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
// FSR3UPSCALER_PreparedInputColor: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R16G16B16A16_FLOAT, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavPreparedInputColor , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16G16B16A16_SFloat , 1 , true ) ;
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavPreparedInputColor , maxRenderSize . x , maxRenderSize . y , 0 , default , GraphicsFormat . R16G16B16A16_SFloat , 1 , true ) ;
// FSR3UPSCALER_NewLocks: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_ALIASABLE
commandBuffer . GetTemporaryRT ( Fsr3ShaderIDs . UavNewLocks , displaySize . x , displaySize . y , 0 , default , GraphicsFormat . R8_UNorm , 1 , true ) ;
}
}
public static void DestroyAliasableResources ( CommandBuffer commandBuffer )
public static void DestroyAliasableResources ( CommandBuffer commandBuffer )
@ -164,9 +217,14 @@ namespace FidelityFX
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavReconstructedPrevNearestDepth ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavDilatedDepth ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavDilatedDepth ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavLockInputLuma ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavLockInputLuma ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavPreparedInputColor ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavPreparedInputColor ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavDilatedReactiveMasks ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavFarthestDepthMip1 ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavNewLocks ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavNewLocks ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavShadingChange ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavLumaInstability ) ;
commandBuffer . ReleaseTemporaryRT ( Fsr3ShaderIDs . UavFarthestDepth ) ;
}
}
private static void CreateDoubleBufferedResource ( RenderTexture [ ] resource , string name , Vector2Int size , GraphicsFormat format )
private static void CreateDoubleBufferedResource ( RenderTexture [ ] resource , string name , Vector2Int size , GraphicsFormat format )
@ -182,15 +240,28 @@ namespace FidelityFX
{
{
DestroyTcrAutogenResources ( ) ;
DestroyTcrAutogenResources ( ) ;
DestroyResource ( LumaHistory ) ;
DestroyResource ( InternalUpscaled ) ;
// OLD
DestroyResource ( LockStatus ) ;
DestroyResource ( LockStatus ) ;
DestroyResource ( DilatedMotionVectors ) ;
DestroyResource ( DilatedMotionVectors ) ;
DestroyResource ( ref SceneLuminance ) ;
DestroyResource ( ref SceneLuminance ) ;
DestroyResource ( ref AutoExposure ) ;
DestroyResource ( ref AutoExposure ) ;
DestroyResource ( ref MaximumBiasLut ) ;
// NEW
DestroyResource ( LumaHistory ) ;
DestroyResource ( InternalUpscaled ) ;
DestroyResource ( Luma ) ;
DestroyResource ( Accumulation ) ;
DestroyResource ( ref FrameInfo ) ;
DestroyResource ( ref ReconstructedPrevNearestDepth ) ;
DestroyResource ( ref DilatedDepth ) ;
DestroyResource ( ref DilatedVelocity ) ;
DestroyResource ( ref SpdMips ) ;
DestroyResource ( ref SpdAtomicCounter ) ;
DestroyResource ( ref DefaultReactive ) ;
DestroyResource ( ref DefaultReactive ) ;
DestroyResource ( ref DefaultExposure ) ;
DestroyResource ( ref DefaultExposure ) ;
DestroyResource ( ref MaximumBiasLut ) ;
DestroyResource ( ref LanczosLut ) ;
DestroyResource ( ref LanczosLut ) ;
}
}
@ -232,27 +303,5 @@ namespace FidelityFX
for ( int i = 0 ; i < resource . Length ; + + i )
for ( int i = 0 ; i < resource . Length ; + + i )
DestroyResource ( ref resource [ i ] ) ;
DestroyResource ( ref resource [ i ] ) ;
}
}
private const int MaximumBiasTextureWidth = 1 6 ;
private const int MaximumBiasTextureHeight = 1 6 ;
private static readonly float [ ] MaximumBias =
{
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.876f , 1.809f , 1.772f , 1.753f , 1.748f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.869f , 1.801f , 1.764f , 1.745f , 1.739f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.976f , 1.841f , 1.774f , 1.737f , 1.716f , 1.71f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.914f , 1.784f , 1.716f , 1.673f , 1.649f , 1.641f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.793f , 1.676f , 1.604f , 1.562f , 1.54f , 1.533f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.802f , 1.619f , 1.536f , 1.492f , 1.467f , 1.454f , 1.449f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.812f , 1.575f , 1.496f , 1.456f , 1.432f , 1.416f , 1.408f , 1.405f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.555f , 1.479f , 1.438f , 1.413f , 1.398f , 1.387f , 1.381f , 1.379f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.812f , 1.555f , 1.474f , 1.43f , 1.404f , 1.387f , 1.376f , 1.368f , 1.363f , 1.362f ,
2.0f , 2.0f , 2.0f , 2.0f , 2.0f , 1.802f , 1.575f , 1.479f , 1.43f , 1.401f , 1.382f , 1.369f , 1.36f , 1.354f , 1.351f , 1.35f ,
2.0f , 2.0f , 1.976f , 1.914f , 1.793f , 1.619f , 1.496f , 1.438f , 1.404f , 1.382f , 1.367f , 1.357f , 1.349f , 1.344f , 1.341f , 1.34f ,
1.876f , 1.869f , 1.841f , 1.784f , 1.676f , 1.536f , 1.456f , 1.413f , 1.387f , 1.369f , 1.357f , 1.347f , 1.341f , 1.336f , 1.333f , 1.332f ,
1.809f , 1.801f , 1.774f , 1.716f , 1.604f , 1.492f , 1.432f , 1.398f , 1.376f , 1.36f , 1.349f , 1.341f , 1.335f , 1.33f , 1.328f , 1.327f ,
1.772f , 1.764f , 1.737f , 1.673f , 1.562f , 1.467f , 1.416f , 1.387f , 1.368f , 1.354f , 1.344f , 1.336f , 1.33f , 1.326f , 1.323f , 1.323f ,
1.753f , 1.745f , 1.716f , 1.649f , 1.54f , 1.454f , 1.408f , 1.381f , 1.363f , 1.351f , 1.341f , 1.333f , 1.328f , 1.323f , 1.321f , 1.32f ,
1.748f , 1.739f , 1.71f , 1.641f , 1.533f , 1.449f , 1.405f , 1.379f , 1.362f , 1.35f , 1.34f , 1.332f , 1.327f , 1.323f , 1.32f , 1.319f ,
} ;
}
}
}
}