@ -39,14 +39,14 @@ namespace FidelityFX
private Fsr2 . ContextDescription _contextDescription ;
private Fsr2 . ContextDescription _contextDescription ;
private CommandBuffer _commandBuffer ;
private CommandBuffer _commandBuffer ;
private Fsr2Pipeline _depthClipPipeline ;
private Fsr2Pipeline _reconstructPreviousDepthPipeline ;
private Fsr2Pipeline _lockPipeline ;
private Fsr2Pipeline _accumulatePipeline ;
private Fsr2Pipeline _rcasPipeline ;
private Fsr2Pipeline _computeLuminancePyramidPipeline ;
private Fsr2Pipeline _generateReactivePipeline ;
private Fsr2Pipeline _tcrAutogeneratePipeline ;
private Fsr2Pass _depthClipPass ;
private Fsr2Pass _reconstructPreviousDepthPass ;
private Fsr2Pass _lockPass ;
private Fsr2Pass _accumulatePass ;
private Fsr2Pass _rcasPass ;
private Fsr2Pass _computeLuminancePyramidPass ;
private Fsr2Pass _generateReactivePass ;
private Fsr2Pass _tcrAutogeneratePass ;
private readonly Fsr2Resources _resources = new Fsr2Resources ( ) ;
private readonly Fsr2Resources _resources = new Fsr2Resources ( ) ;
@ -92,31 +92,31 @@ namespace FidelityFX
Constants . displaySize = _contextDescription . DisplaySize ;
Constants . displaySize = _contextDescription . DisplaySize ;
_resources . Create ( _contextDescription ) ;
_resources . Create ( _contextDescription ) ;
CreatePipelin es ( ) ;
CreatePass es ( ) ;
}
}
private void CreatePipelin es ( )
private void CreatePass es ( )
{
{
_computeLuminancePyramidPipeline = new Fsr2ComputeLuminancePyramidPipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer , _spdConstantsBuffer ) ;
_reconstructPreviousDepthPipeline = new Fsr2ReconstructPreviousDepthPipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_depthClipPipeline = new Fsr2DepthClipPipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_lockPipeline = new Fsr2LockPipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_accumulatePipeline = new Fsr2AccumulatePipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_rcasPipeline = new Fsr2RcasPipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer , _rcasConstantsBuffer ) ;
_generateReactivePipeline = new Fsr2GenerateReactivePipeline ( _contextDescription , _resources , _generateReactiveConstantsBuffer ) ;
_tcrAutogeneratePipeline = new Fsr2TcrAutogeneratePipeline ( _contextDescription , _resources , _fsr2ConstantsBuffer , _tcrAutogenerateConstantsBuffer ) ;
_computeLuminancePyramidPass = new Fsr2ComputeLuminancePyramidPass ( _contextDescription , _resources , _fsr2ConstantsBuffer , _spdConstantsBuffer ) ;
_reconstructPreviousDepthPass = new Fsr2ReconstructPreviousDepthPass ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_depthClipPass = new Fsr2DepthClipPass ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_lockPass = new Fsr2LockPass ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_accumulatePass = new Fsr2AccumulatePass ( _contextDescription , _resources , _fsr2ConstantsBuffer ) ;
_rcasPass = new Fsr2RcasPass ( _contextDescription , _resources , _fsr2ConstantsBuffer , _rcasConstantsBuffer ) ;
_generateReactivePass = new Fsr2GenerateReactivePass ( _contextDescription , _resources , _generateReactiveConstantsBuffer ) ;
_tcrAutogeneratePass = new Fsr2TcrAutogeneratePass ( _contextDescription , _resources , _fsr2ConstantsBuffer , _tcrAutogenerateConstantsBuffer ) ;
}
}
public void Destroy ( )
public void Destroy ( )
{
{
DestroyPipeline ( ref _tcrAutogeneratePipeline ) ;
DestroyPipeline ( ref _generateReactivePipeline ) ;
DestroyPipeline ( ref _computeLuminancePyramidPipeline ) ;
DestroyPipeline ( ref _rcasPipeline ) ;
DestroyPipeline ( ref _accumulatePipeline ) ;
DestroyPipeline ( ref _lockPipeline ) ;
DestroyPipeline ( ref _reconstructPreviousDepthPipeline ) ;
DestroyPipeline ( ref _depthClipPipeline ) ;
DestroyPass ( ref _tcrAutogeneratePass ) ;
DestroyPass ( ref _generateReactivePass ) ;
DestroyPass ( ref _computeLuminancePyramidPass ) ;
DestroyPass ( ref _rcasPass ) ;
DestroyPass ( ref _accumulatePass ) ;
DestroyPass ( ref _lockPass ) ;
DestroyPass ( ref _reconstructPreviousDepthPass ) ;
DestroyPass ( ref _depthClipPass ) ;
_resources . Destroy ( ) ;
_resources . Destroy ( ) ;
@ -230,19 +230,19 @@ namespace FidelityFX
}
}
// Compute luminance pyramid
// Compute luminance pyramid
_computeLuminancePyramidPipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchThreadGroupCount . x , dispatchThreadGroupCount . y ) ;
_computeLuminancePyramidPass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchThreadGroupCount . x , dispatchThreadGroupCount . y ) ;
// Reconstruct previous depth
// Reconstruct previous depth
_reconstructPreviousDepthPipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
_reconstructPreviousDepthPass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
// Depth clip
// Depth clip
_depthClipPipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
_depthClipPass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
// Create locks
// Create locks
_lockPipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
_lockPass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
// Accumulate
// Accumulate
_accumulatePipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchDstX , dispatchDstY ) ;
_accumulatePass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchDstX , dispatchDstY ) ;
if ( dispatchParams . EnableSharpening )
if ( dispatchParams . EnableSharpening )
{
{
@ -254,7 +254,7 @@ namespace FidelityFX
const int threadGroupWorkRegionDimRcas = 1 6 ;
const int threadGroupWorkRegionDimRcas = 1 6 ;
int threadGroupsX = ( Screen . width + threadGroupWorkRegionDimRcas - 1 ) / threadGroupWorkRegionDimRcas ;
int threadGroupsX = ( Screen . width + threadGroupWorkRegionDimRcas - 1 ) / threadGroupWorkRegionDimRcas ;
int threadGroupsY = ( Screen . height + threadGroupWorkRegionDimRcas - 1 ) / threadGroupWorkRegionDimRcas ;
int threadGroupsY = ( Screen . height + threadGroupWorkRegionDimRcas - 1 ) / threadGroupWorkRegionDimRcas ;
_rcasPipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , threadGroupsX , threadGroupsY ) ;
_rcasPass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , threadGroupsX , threadGroupsY ) ;
}
}
_resourceFrameIndex = ( _resourceFrameIndex + 1 ) % MaxQueuedFrames ;
_resourceFrameIndex = ( _resourceFrameIndex + 1 ) % MaxQueuedFrames ;
@ -281,7 +281,7 @@ namespace FidelityFX
GenReactiveConsts . flags = ( uint ) dispatchParams . Flags ;
GenReactiveConsts . flags = ( uint ) dispatchParams . Flags ;
commandBuffer . SetBufferData ( _generateReactiveConstantsBuffer , _generateReactiveConstantsArray ) ;
commandBuffer . SetBufferData ( _generateReactiveConstantsBuffer , _generateReactiveConstantsArray ) ;
( ( Fsr2GenerateReactivePipeline ) _generateReactivePipeline ) . ScheduleDispatch ( commandBuffer , dispatchParams , dispatchSrcX , dispatchSrcY ) ;
( ( Fsr2GenerateReactivePass ) _generateReactivePass ) . ScheduleDispatch ( commandBuffer , dispatchParams , dispatchSrcX , dispatchSrcY ) ;
}
}
private void GenerateTransparencyCompositionReactive ( Fsr2 . DispatchDescription dispatchParams , CommandBuffer commandBuffer , int frameIndex )
private void GenerateTransparencyCompositionReactive ( Fsr2 . DispatchDescription dispatchParams , CommandBuffer commandBuffer , int frameIndex )
@ -296,7 +296,7 @@ namespace FidelityFX
TcrAutoGenConsts . autoReactiveMax = dispatchParams . AutoReactiveMax ;
TcrAutoGenConsts . autoReactiveMax = dispatchParams . AutoReactiveMax ;
commandBuffer . SetBufferData ( _tcrAutogenerateConstantsBuffer , _tcrAutogenerateConstantsArray ) ;
commandBuffer . SetBufferData ( _tcrAutogenerateConstantsBuffer , _tcrAutogenerateConstantsArray ) ;
_tcrAutogeneratePipeline . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
_tcrAutogeneratePass . ScheduleDispatch ( commandBuffer , dispatchParams , frameIndex , dispatchSrcX , dispatchSrcY ) ;
}
}
private void SetupConstants ( Fsr2 . DispatchDescription dispatchParams , bool resetAccumulation )
private void SetupConstants ( Fsr2 . DispatchDescription dispatchParams , bool resetAccumulation )
@ -356,7 +356,7 @@ namespace FidelityFX
constants . frameIndex + + ;
constants . frameIndex + + ;
// Shading change usage of the SPD mip levels
// Shading change usage of the SPD mip levels
constants . lumaMipLevelToUse = Fsr2Pipeline . ShadingChangeMipLevel ;
constants . lumaMipLevelToUse = Fsr2Pass . ShadingChangeMipLevel ;
float mipDiv = 2 < < constants . lumaMipLevelToUse ;
float mipDiv = 2 < < constants . lumaMipLevelToUse ;
constants . lumaMipDimensions . x = ( int ) ( constants . maxRenderSize . x / mipDiv ) ;
constants . lumaMipDimensions . x = ( int ) ( constants . maxRenderSize . x / mipDiv ) ;
@ -594,13 +594,13 @@ namespace FidelityFX
bufferRef = null ;
bufferRef = null ;
}
}
private static void DestroyPipeline ( ref Fsr2Pipeline pipeline )
private static void DestroyPass ( ref Fsr2Pass pass )
{
{
if ( pipeline = = null )
if ( pass = = null )
return ;
return ;
pipeline . Dispose ( ) ;
pipeline = null ;
pass . Dispose ( ) ;
pass = null ;
}
}
}
}
}
}