From 9bc90e48533b48ab765d3be3eb615dd470083e43 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 9 Jul 2024 20:41:40 +0200 Subject: [PATCH] Updated dispatching function with new passes and modified buffer clears --- Assets/Scripts/Core/Fsr3UpscalerContext.cs | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Assets/Scripts/Core/Fsr3UpscalerContext.cs b/Assets/Scripts/Core/Fsr3UpscalerContext.cs index d3cf3c7..9617a35 100644 --- a/Assets/Scripts/Core/Fsr3UpscalerContext.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerContext.cs @@ -156,9 +156,13 @@ namespace FidelityFX if (_firstExecution) { - commandBuffer.SetRenderTarget(_resources.LockStatus[0]); + commandBuffer.SetRenderTarget(_resources.Accumulation[0]); commandBuffer.ClearRenderTarget(false, true, Color.clear); - commandBuffer.SetRenderTarget(_resources.LockStatus[1]); + commandBuffer.SetRenderTarget(_resources.Accumulation[1]); + commandBuffer.ClearRenderTarget(false, true, Color.clear); + commandBuffer.SetRenderTarget(_resources.Luma[0]); + commandBuffer.ClearRenderTarget(false, true, Color.clear); + commandBuffer.SetRenderTarget(_resources.Luma[1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); } @@ -168,7 +172,7 @@ namespace FidelityFX // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends if ((_contextDescription.Flags & Fsr3Upscaler.InitializationFlags.EnableAutoExposure) != 0) - dispatchParams.Exposure = new ResourceView(_resources.AutoExposure); + dispatchParams.Exposure = new ResourceView(_resources.FrameInfo); else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); @@ -202,21 +206,20 @@ namespace FidelityFX int dispatchSrcY = (UpscalerConsts.renderSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstX = (_contextDescription.MaxUpscaleSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; int dispatchDstY = (_contextDescription.MaxUpscaleSize.y + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchShadingChangePassX = ((UpscalerConsts.renderSize.x / 2) + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; + int dispatchShadingChangePassY = ((UpscalerConsts.renderSize.y / 2) + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; // Clear reconstructed depth for max depth store if (resetAccumulation) { - commandBuffer.SetRenderTarget(_resources.LockStatus[frameIndex ^ 1]); - commandBuffer.ClearRenderTarget(false, true, Color.clear); - - commandBuffer.SetRenderTarget(_resources.InternalUpscaled[frameIndex ^ 1]); + commandBuffer.SetRenderTarget(_resources.Accumulation[frameIndex ^ 1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); - commandBuffer.SetRenderTarget(_resources.SceneLuminance); + commandBuffer.SetRenderTarget(_resources.SpdMips); commandBuffer.ClearRenderTarget(false, true, Color.clear); // Auto exposure always used to track luma changes in locking logic - commandBuffer.SetRenderTarget(_resources.AutoExposure); + commandBuffer.SetRenderTarget(_resources.FrameInfo); commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f)); // Reset atomic counter to 0 @@ -244,19 +247,13 @@ namespace FidelityFX dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); } - // Compute luminance pyramid - _lumaPyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); - - // Reconstruct previous depth _prepareInputsPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); - - // Depth clip + _lumaPyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); + _shadingChangePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); + _shadingChangePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchShadingChangePassX, dispatchShadingChangePassY); _prepareReactivityPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); - - // Create locks _lumaInstabilityPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); - - // Accumulate + _accumulatePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchDstX, dispatchDstY); if (dispatchParams.EnableSharpening) @@ -271,6 +268,8 @@ namespace FidelityFX int threadGroupsY = (Screen.height + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); } + + // TODO: debug view pass _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames;