From c010b6aa28e4a6ee8197c78febec494a9fdeae5b Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Thu, 7 Sep 2023 13:13:32 +0200 Subject: [PATCH] Renamed Pipelines to Passes --- Assets/Scripts/Core/Fsr2Context.cs | 78 +++++++++---------- .../Core/{Fsr2Pipeline.cs => Fsr2Pass.cs} | 36 ++++----- ...{Fsr2Pipeline.cs.meta => Fsr2Pass.cs.meta} | 0 3 files changed, 57 insertions(+), 57 deletions(-) rename Assets/Scripts/Core/{Fsr2Pipeline.cs => Fsr2Pass.cs} (92%) rename Assets/Scripts/Core/{Fsr2Pipeline.cs.meta => Fsr2Pass.cs.meta} (100%) diff --git a/Assets/Scripts/Core/Fsr2Context.cs b/Assets/Scripts/Core/Fsr2Context.cs index bb6c5de..5c8975c 100644 --- a/Assets/Scripts/Core/Fsr2Context.cs +++ b/Assets/Scripts/Core/Fsr2Context.cs @@ -39,14 +39,14 @@ namespace FidelityFX private Fsr2.ContextDescription _contextDescription; 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(); @@ -92,31 +92,31 @@ namespace FidelityFX Constants.displaySize = _contextDescription.DisplaySize; _resources.Create(_contextDescription); - CreatePipelines(); + CreatePasses(); } - private void CreatePipelines() + private void CreatePasses() { - _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() { - 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(); @@ -230,19 +230,19 @@ namespace FidelityFX } // Compute luminance pyramid - _computeLuminancePyramidPipeline.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); + _computeLuminancePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); // Reconstruct previous depth - _reconstructPreviousDepthPipeline.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); + _reconstructPreviousDepthPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); // Depth clip - _depthClipPipeline.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); + _depthClipPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); // Create locks - _lockPipeline.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); + _lockPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); // Accumulate - _accumulatePipeline.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchDstX, dispatchDstY); + _accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchDstX, dispatchDstY); if (dispatchParams.EnableSharpening) { @@ -254,7 +254,7 @@ namespace FidelityFX const int threadGroupWorkRegionDimRcas = 16; int threadGroupsX = (Screen.width + 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; @@ -281,7 +281,7 @@ namespace FidelityFX GenReactiveConsts.flags = (uint)dispatchParams.Flags; 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) @@ -296,7 +296,7 @@ namespace FidelityFX TcrAutoGenConsts.autoReactiveMax = dispatchParams.AutoReactiveMax; 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) @@ -356,7 +356,7 @@ namespace FidelityFX constants.frameIndex++; // Shading change usage of the SPD mip levels - constants.lumaMipLevelToUse = Fsr2Pipeline.ShadingChangeMipLevel; + constants.lumaMipLevelToUse = Fsr2Pass.ShadingChangeMipLevel; float mipDiv = 2 << constants.lumaMipLevelToUse; constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv); @@ -594,13 +594,13 @@ namespace FidelityFX bufferRef = null; } - private static void DestroyPipeline(ref Fsr2Pipeline pipeline) + private static void DestroyPass(ref Fsr2Pass pass) { - if (pipeline == null) + if (pass == null) return; - pipeline.Dispose(); - pipeline = null; + pass.Dispose(); + pass = null; } } } diff --git a/Assets/Scripts/Core/Fsr2Pipeline.cs b/Assets/Scripts/Core/Fsr2Pass.cs similarity index 92% rename from Assets/Scripts/Core/Fsr2Pipeline.cs rename to Assets/Scripts/Core/Fsr2Pass.cs index c0aafd8..23b8e6c 100644 --- a/Assets/Scripts/Core/Fsr2Pipeline.cs +++ b/Assets/Scripts/Core/Fsr2Pass.cs @@ -30,7 +30,7 @@ namespace FidelityFX /// This loosely matches the FfxPipelineState struct from the original FSR2 codebase, wrapped in an object-oriented blanket. /// These classes are responsible for loading compute shaders, managing temporary resources, binding resources to shader kernels and dispatching said shaders. /// - internal abstract class Fsr2Pipeline: IDisposable + internal abstract class Fsr2Pass: IDisposable { internal const int ShadingChangeMipLevel = 4; // This matches the FFX_FSR2_SHADING_CHANGE_MIP_LEVEL define @@ -43,7 +43,7 @@ namespace FidelityFX protected virtual bool AllowFP16 => true; - protected Fsr2Pipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + protected Fsr2Pass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) { ContextDescription = contextDescription; Resources = resources; @@ -115,11 +115,11 @@ namespace FidelityFX } } - internal class Fsr2ComputeLuminancePyramidPipeline : Fsr2Pipeline + internal class Fsr2ComputeLuminancePyramidPass : Fsr2Pass { private readonly ComputeBuffer _spdConstants; - public Fsr2ComputeLuminancePyramidPipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer spdConstants) + public Fsr2ComputeLuminancePyramidPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer spdConstants) : base(contextDescription, resources, constants) { _spdConstants = spdConstants; @@ -144,9 +144,9 @@ namespace FidelityFX } } - internal class Fsr2ReconstructPreviousDepthPipeline : Fsr2Pipeline + internal class Fsr2ReconstructPreviousDepthPass : Fsr2Pass { - public Fsr2ReconstructPreviousDepthPipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr2ReconstructPreviousDepthPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { LoadComputeShader("FSR2/ffx_fsr2_reconstruct_previous_depth_pass"); @@ -172,9 +172,9 @@ namespace FidelityFX } } - internal class Fsr2DepthClipPipeline : Fsr2Pipeline + internal class Fsr2DepthClipPass : Fsr2Pass { - public Fsr2DepthClipPipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr2DepthClipPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { LoadComputeShader("FSR2/ffx_fsr2_depth_clip_pass"); @@ -207,9 +207,9 @@ namespace FidelityFX } } - internal class Fsr2LockPipeline : Fsr2Pipeline + internal class Fsr2LockPass : Fsr2Pass { - public Fsr2LockPipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr2LockPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { LoadComputeShader("FSR2/ffx_fsr2_lock_pass"); @@ -224,7 +224,7 @@ namespace FidelityFX } } - internal class Fsr2AccumulatePipeline : Fsr2Pipeline + internal class Fsr2AccumulatePass : Fsr2Pass { private const string SharpeningKeyword = "FFX_FSR2_OPTION_APPLY_SHARPENING"; @@ -235,7 +235,7 @@ namespace FidelityFX private readonly LocalKeyword _sharpeningKeyword; #endif - public Fsr2AccumulatePipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) + public Fsr2AccumulatePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants) : base(contextDescription, resources, constants) { LoadComputeShader("FSR2/ffx_fsr2_accumulate_pass"); @@ -294,11 +294,11 @@ namespace FidelityFX } } - internal class Fsr2RcasPipeline : Fsr2Pipeline + internal class Fsr2RcasPass : Fsr2Pass { private readonly ComputeBuffer _rcasConstants; - public Fsr2RcasPipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) + public Fsr2RcasPass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer rcasConstants) : base(contextDescription, resources, constants) { _rcasConstants = rcasConstants; @@ -322,11 +322,11 @@ namespace FidelityFX } } - internal class Fsr2GenerateReactivePipeline : Fsr2Pipeline + internal class Fsr2GenerateReactivePass : Fsr2Pass { private readonly ComputeBuffer _generateReactiveConstants; - public Fsr2GenerateReactivePipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer generateReactiveConstants) + public Fsr2GenerateReactivePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer generateReactiveConstants) : base(contextDescription, resources, null) { _generateReactiveConstants = generateReactiveConstants; @@ -354,11 +354,11 @@ namespace FidelityFX } } - internal class Fsr2TcrAutogeneratePipeline : Fsr2Pipeline + internal class Fsr2TcrAutogeneratePass : Fsr2Pass { private readonly ComputeBuffer _tcrAutogenerateConstants; - public Fsr2TcrAutogeneratePipeline(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) + public Fsr2TcrAutogeneratePass(Fsr2.ContextDescription contextDescription, Fsr2Resources resources, ComputeBuffer constants, ComputeBuffer tcrAutogenerateConstants) : base(contextDescription, resources, constants) { _tcrAutogenerateConstants = tcrAutogenerateConstants; diff --git a/Assets/Scripts/Core/Fsr2Pipeline.cs.meta b/Assets/Scripts/Core/Fsr2Pass.cs.meta similarity index 100% rename from Assets/Scripts/Core/Fsr2Pipeline.cs.meta rename to Assets/Scripts/Core/Fsr2Pass.cs.meta