@ -39,18 +39,18 @@ namespace FidelityFX.FSR3
private Fsr3Upscaler . ContextDescription _contextDescription ;
private CommandBuffer _commandBuffer ;
private Fsr3UpscalerPass _prepareInputsPass ;
private Fsr3UpscalerPass _lumaPyramidPass ;
private Fsr3UpscalerPass _shadingChangePyramidPass ;
private Fsr3UpscalerPass _shadingChangePass ;
private Fsr3UpscalerPass _prepareReactivityPass ;
private Fsr3UpscalerPass _lumaInstabilityPass ;
private Fsr3UpscalerPass _accumulatePass ;
private Fsr3UpscalerPass _sharpenPass ;
private Fsr3UpscalerPass _generateReactivePass ;
private Fsr3UpscalerPass _tcrAutogeneratePass ;
private Fsr3UpscalerPrepareInputsP ass _prepareInputsPass ;
private Fsr3UpscalerLumaPyramid Pass _lumaPyramidPass ;
private Fsr3UpscalerShadingChangePyramid Pass _shadingChangePyramidPass ;
private Fsr3UpscalerShadingChange Pass _shadingChangePass ;
private Fsr3UpscalerPrepareReactivityP ass _prepareReactivityPass ;
private Fsr3UpscalerLumaInstability Pass _lumaInstabilityPass ;
private Fsr3UpscalerAccumulate Pass _accumulatePass ;
private Fsr3UpscalerSharpen Pass _sharpenPass ;
private Fsr3UpscalerGenerateReactive Pass _generateReactivePass ;
private Fsr3UpscalerTcrAutogenerate Pass _tcrAutogeneratePass ;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
private Fsr3UpscalerPass _debugViewPass ;
private Fsr3UpscalerDebugView Pass _debugViewPass ;
#endif
private readonly Fsr3UpscalerResources _resources = new Fsr3UpscalerResources ( ) ;
@ -69,7 +69,7 @@ namespace FidelityFX.FSR3
private readonly CustomSampler _sampler = CustomSampler . Create ( "FSR3 Upscaler" ) ;
public void Create ( Fsr3Upscaler . ContextDescription contextDescription )
public void Create ( in Fsr3Upscaler . ContextDescription contextDescription )
{
_contextDescription = contextDescription ;
_commandBuffer = new CommandBuffer { name = "FSR3 Upscaler" } ;
@ -138,7 +138,7 @@ namespace FidelityFX.FSR3
}
}
public void Dispatch ( Fsr3Upscaler . DispatchDescription dispatchParams )
public void Dispatch ( in Fsr3Upscaler . DispatchDescription dispatchParams )
{
_commandBuffer . Clear ( ) ;
Dispatch ( dispatchParams , _commandBuffer ) ;
@ -199,7 +199,7 @@ namespace FidelityFX.FSR3
if ( ! dispatchParams . Reactive . IsValid ) dispatchParams . Reactive = new ResourceView ( _resources . DefaultReactive ) ;
if ( ! dispatchParams . TransparencyAndComposition . IsValid ) dispatchParams . TransparencyAndComposition = new ResourceView ( _resources . DefaultReactive ) ;
Fsr3UpscalerResources . CreateAliasableResources ( commandBuffer , _contextDescription , dispatchParams ) ;
Fsr3UpscalerResources . CreateAliasableResources ( commandBuffer , _contextDescription ) ;
SetupConstants ( dispatchParams , resetAccumulation ) ;
@ -233,7 +233,7 @@ namespace FidelityFX.FSR3
}
// FSR3: need to clear here since we need the content of this surface for frame interpolation, so clearing in the lock pass is not an option
bool depthInverted = ( _contextDescription . Flags & Fsr3Upscaler . InitializationFlags . EnableDepthInverted ) = = Fsr3Upscaler . InitializationFlags . EnableDepthInverted ;
bool depthInverted = ( _contextDescription . Flags & Fsr3Upscaler . InitializationFlags . EnableDepthInverted ) ! = 0 ;
commandBuffer . SetRenderTarget ( _resources . ReconstructedPrevNearestDepth ) ;
commandBuffer . ClearRenderTarget ( false , true , depthInverted ? Color . clear : Color . white ) ;
@ -289,14 +289,14 @@ namespace FidelityFX.FSR3
commandBuffer . EndSample ( _sampler ) ;
}
public void GenerateReactiveMask ( Fsr3Upscaler . GenerateReactiveDescription dispatchParams )
public void GenerateReactiveMask ( in Fsr3Upscaler . GenerateReactiveDescription dispatchParams )
{
_commandBuffer . Clear ( ) ;
GenerateReactiveMask ( dispatchParams , _commandBuffer ) ;
Graphics . ExecuteCommandBuffer ( _commandBuffer ) ;
}
public void GenerateReactiveMask ( Fsr3Upscaler . GenerateReactiveDescription dispatchParams , CommandBuffer commandBuffer )
public void GenerateReactiveMask ( in Fsr3Upscaler . GenerateReactiveDescription dispatchParams , CommandBuffer commandBuffer )
{
const int threadGroupWorkRegionDim = 8 ;
int dispatchSrcX = ( dispatchParams . RenderSize . x + ( threadGroupWorkRegionDim - 1 ) ) / threadGroupWorkRegionDim ;
@ -309,10 +309,10 @@ namespace FidelityFX.FSR3
genReactiveConsts . flags = ( uint ) dispatchParams . Flags ;
_generateReactiveConstants . UpdateBufferData ( commandBuffer ) ;
( ( Fsr3UpscalerGenerateReactivePass ) _generateReactivePass ) . ScheduleDispatch ( commandBuffer , dispatchParams , dispatchSrcX , dispatchSrcY ) ;
_generateReactivePass . ScheduleDispatch ( commandBuffer , dispatchParams , dispatchSrcX , dispatchSrcY ) ;
}
private void GenerateTransparencyCompositionReactive ( Fsr3Upscaler . DispatchDescription dispatchParams , CommandBuffer commandBuffer , int frame Index )
private void GenerateTransparencyCompositionReactive ( in Fsr3Upscaler . DispatchDescription dispatchParams , CommandBuffer commandBuffer , int bu ffe rIndex)
{
const int threadGroupWorkRegionDim = 8 ;
int dispatchSrcX = ( dispatchParams . RenderSize . x + ( threadGroupWorkRegionDim - 1 ) ) / threadGroupWorkRegionDim ;
@ -325,10 +325,10 @@ namespace FidelityFX.FSR3
tcrAutoGenConsts . autoReactiveMax = dispatchParams . AutoReactiveMax ;
_tcrAutogenerateConstants . UpdateBufferData ( commandBuffer ) ;
_tcrAutogeneratePass . ScheduleDispatch ( commandBuffer , dispatchParams , frame Index , dispatchSrcX , dispatchSrcY ) ;
_tcrAutogeneratePass . ScheduleDispatch ( commandBuffer , dispatchParams , bu ffe rIndex, dispatchSrcX , dispatchSrcY ) ;
}
private void SetupConstants ( Fsr3Upscaler . DispatchDescription dispatchParams , bool resetAccumulation )
private void SetupConstants ( in Fsr3Upscaler . DispatchDescription dispatchParams , bool resetAccumulation )
{
ref Fsr3Upscaler . UpscalerConstants constants = ref _upscalerConstants . Value ;
@ -408,13 +408,13 @@ namespace FidelityFX.FSR3
constants . frameIndex + = 1.0f ;
}
private void SetupRcasConstants ( Fsr3Upscaler . DispatchDescription dispatchParams )
private void SetupRcasConstants ( in Fsr3Upscaler . DispatchDescription dispatchParams )
{
int sharpnessIndex = Mathf . RoundToInt ( Mathf . Clamp01 ( dispatchParams . Sharpness ) * ( RcasConfigs . Length - 1 ) ) ;
_rcasConstants . Value = RcasConfigs [ sharpnessIndex ] ;
}
private void SetupSpdConstants ( Fsr3Upscaler . DispatchDescription dispatchParams , out Vector2Int dispatchThreadGroupCount )
private void SetupSpdConstants ( in Fsr3Upscaler . DispatchDescription dispatchParams , out Vector2Int dispatchThreadGroupCount )
{
// Downsample
ref Fsr3Upscaler . SpdConstants spdConstants = ref _spdConstants . Value ;
@ -423,7 +423,7 @@ namespace FidelityFX.FSR3
spdConstants . renderSizeY = ( uint ) dispatchParams . RenderSize . y ;
}
private void DebugCheckDispatch ( Fsr3Upscaler . DispatchDescription dispatchParams )
private void DebugCheckDispatch ( in Fsr3Upscaler . DispatchDescription dispatchParams )
{
if ( ! dispatchParams . Color . IsValid )
{