297 lines
14 KiB
Diff
297 lines
14 KiB
Diff
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Editor/Unity.RenderPipelines.HighDefinition.Editor.asmdef b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Editor/Unity.RenderPipelines.HighDefinition.Editor.asmdef
|
|
index c7bbde5..d1c99c9 100644
|
|
--- a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Editor/Unity.RenderPipelines.HighDefinition.Editor.asmdef
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Editor/Unity.RenderPipelines.HighDefinition.Editor.asmdef
|
|
@@ -10,7 +10,10 @@
|
|
"Unity.VisualEffectGraph.Editor",
|
|
"Unity.PackageManagerDocTools.Editor",
|
|
"Unity.Rendering.Denoising.Runtime",
|
|
- "Unity.RenderPipelines.HighDefinition.Config.Runtime"
|
|
+ "Unity.RenderPipelines.HighDefinition.Config.Runtime",
|
|
+ "com.nvidia.streamline.core.Runtime",
|
|
+ "com.nvidia.streamline.dlssg.Runtime",
|
|
+ "com.nvidia.streamline.reflex.Runtime"
|
|
],
|
|
"includePlatforms": [
|
|
"Editor"
|
|
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDProfileId.cs b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDProfileId.cs
|
|
index f48b1f5..b35411c 100644
|
|
--- a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDProfileId.cs
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDProfileId.cs
|
|
@@ -262,5 +262,7 @@ namespace UnityEngine.Rendering.HighDefinition
|
|
#if ENABLE_VIRTUALTEXTURES
|
|
VTFeedbackDownsample,
|
|
#endif
|
|
+ StreamlineCopyDepthMVecs,
|
|
+ StreamlineCopyHudlessColor,
|
|
}
|
|
}
|
|
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
|
|
index 8ef49b2..6623760 100644
|
|
--- a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
|
|
@@ -100,6 +100,10 @@ namespace UnityEngine.Rendering.HighDefinition
|
|
|
|
var prepassOutput = RenderPrepass(m_RenderGraph, colorBuffer, lightingBuffers.sssBuffer, vtFeedbackBuffer, cullingResults, customPassCullingResults, hdCamera, aovRequest, aovBuffers);
|
|
|
|
+ //NVIDIA Streamline
|
|
+ DLSSGStage1(m_RenderGraph, hdCamera, in prepassOutput);
|
|
+ //NVIDIA Streamline
|
|
+
|
|
// Need this during debug render at the end outside of the main loop scope.
|
|
// Once render graph move is implemented, we can probably remove the branch and this.
|
|
ShadowResult shadowResult = new ShadowResult();
|
|
@@ -358,6 +362,10 @@ namespace UnityEngine.Rendering.HighDefinition
|
|
|
|
SetFinalTarget(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, backBuffer, target.face);
|
|
|
|
+ //NVIDIA Streamline
|
|
+ DLSSGStage2(m_RenderGraph, hdCamera);
|
|
+ //NVIDIA Streamline
|
|
+
|
|
RenderWireOverlay(m_RenderGraph, hdCamera, backBuffer);
|
|
|
|
RenderGizmos(m_RenderGraph, hdCamera, GizmoSubset.PostImageEffects);
|
|
@@ -2067,5 +2075,60 @@ namespace UnityEngine.Rendering.HighDefinition
|
|
cb._OffScreenRendering = enabled ? 1u : 0u;
|
|
cb._OffScreenDownsampleFactor = factor;
|
|
}
|
|
+
|
|
+ //NVIDIA streamline
|
|
+ class DLSSGStage1PassData
|
|
+ {
|
|
+ public HDCamera hdCamera;
|
|
+ public TextureHandle depthBuffer;
|
|
+ public TextureHandle mvecsBuffer;
|
|
+ public int frameCount;
|
|
+ }
|
|
+
|
|
+ void DLSSGStage1(RenderGraph renderGraph, HDCamera hdCamera, in PrepassOutput prepassOutput)
|
|
+ {
|
|
+
|
|
+ using (var builder = renderGraph.AddRenderPass<DLSSGStage1PassData>("Copy DLSSG Depth/MVecs Textures", out var passData, ProfilingSampler.Get(HDProfileId.StreamlineCopyDepthMVecs)))
|
|
+ {
|
|
+ passData.hdCamera = hdCamera;
|
|
+ // Resolved buffers for MSAA. When MSAA is off, they will be the same reference as the buffers above.
|
|
+ passData.depthBuffer = builder.ReadTexture(prepassOutput.resolvedDepthBuffer);
|
|
+ passData.mvecsBuffer = builder.ReadTexture(prepassOutput.resolvedMotionVectorsBuffer);
|
|
+ passData.frameCount = Time.frameCount;
|
|
+
|
|
+ builder.SetRenderFunc(
|
|
+ (DLSSGStage1PassData data, RenderGraphContext ctx) =>
|
|
+ {
|
|
+ HDStreamline.DLSSGTagDepthAndMVecs(ctx.cmd, data.hdCamera, data.depthBuffer, data.mvecsBuffer, data.frameCount); //does blits and sets constants
|
|
+ HDStreamline.StreamlineSetConstants(ctx.cmd, data.hdCamera,data.frameCount);
|
|
+
|
|
+ });
|
|
+ }
|
|
+
|
|
+ }
|
|
+
|
|
+ class DLSSGStage2PassData
|
|
+ {
|
|
+ public HDCamera hdCamera;
|
|
+ public int frameCount;
|
|
+ }
|
|
+
|
|
+ void DLSSGStage2(RenderGraph renderGraph, HDCamera hdCamera)
|
|
+ {
|
|
+ using (var builder = renderGraph.AddRenderPass<DLSSGStage2PassData>("Copy DLSSG Hudless Textures", out var passData, ProfilingSampler.Get(HDProfileId.StreamlineCopyHudlessColor)))
|
|
+ {
|
|
+ passData.hdCamera = hdCamera;
|
|
+ passData.frameCount = Time.frameCount;
|
|
+
|
|
+ builder.SetRenderFunc(
|
|
+ (DLSSGStage2PassData data, RenderGraphContext ctx) =>
|
|
+ {
|
|
+ var colorBuffer = data.hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain);
|
|
+ HDStreamline.DLSSTagHudlessColor(ctx.cmd, data.hdCamera, colorBuffer, data.frameCount);
|
|
+ });
|
|
+ }
|
|
+
|
|
+ }
|
|
+ //NVIDIA streamline
|
|
}
|
|
}
|
|
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs
|
|
new file mode 100644
|
|
index 0000000..f8a3fed
|
|
--- /dev/null
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs
|
|
@@ -0,0 +1,141 @@
|
|
+using System;
|
|
+using System.Collections.Generic;
|
|
+using System.Runtime.CompilerServices;
|
|
+using UnityEngine.Assertions;
|
|
+using UnityEngine.Experimental.Rendering;
|
|
+using UnityEngine.Experimental.Rendering.RenderGraphModule;
|
|
+
|
|
+using NVStreamline;
|
|
+
|
|
+namespace UnityEngine.Rendering.HighDefinition
|
|
+{
|
|
+ class HDStreamline
|
|
+ {
|
|
+ public static void StreamlineSetConstants(CommandBuffer cmdBuffer, HDCamera hdCamera, int frameCount)
|
|
+ {
|
|
+ StreamlineHDRP streamline = hdCamera.camera.GetComponent<StreamlineHDRP>();
|
|
+
|
|
+ if (streamline)
|
|
+ {
|
|
+ if (streamline.StreamlineFeatureAvailable)
|
|
+ {
|
|
+ bool requiresJitter = false; // hdCamera.hdCamera.RequiresCameraJitter(); //doesnt seem to exist in this version of hdrp...
|
|
+ bool isFirstFrame = false; // hdCamera.isFirstFrame;
|
|
+
|
|
+ Vector4 jitter = Vector4.zero;
|
|
+ if (hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing)
|
|
+ {
|
|
+ jitter = hdCamera.taaJitter;
|
|
+ requiresJitter = true;
|
|
+ }
|
|
+ //
|
|
+ //Pass camera, not HDCamera.
|
|
+ streamline.HDRPSetStreamlineConstants(cmdBuffer, hdCamera.camera, requiresJitter, jitter, isFirstFrame, frameCount);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public static void DLSSGTagDepthAndMVecs(CommandBuffer cmdBuffer, HDCamera hdCamera, RTHandle depthRTH, RTHandle mvecsRTH, int frameCount)
|
|
+ {
|
|
+ StreamlineDLSSGHDRP dlssg = hdCamera.camera.GetComponent<StreamlineDLSSGHDRP>();
|
|
+
|
|
+ if (dlssg)
|
|
+ {
|
|
+ if (dlssg.DLSSGFeatureAvailable)
|
|
+ {
|
|
+ if (StreamlineDLSSGCore.DLSSGEnabled)
|
|
+ {
|
|
+
|
|
+
|
|
+ RenderTexture depthTarget = StreamlineDLSSGCore.GetTargetDepthTexture();
|
|
+ RenderTexture mvecsTarget = StreamlineDLSSGCore.GetTargetMVecsTexture();
|
|
+
|
|
+ StreamlineDLSSGCore.HDRPRequestScaleBiasValues(out Vector4 srcScaleBias, out Vector4 dstScaleBias);
|
|
+
|
|
+ CoreUtils.SetRenderTarget(cmdBuffer, mvecsTarget);
|
|
+ HDUtils.BlitQuad(cmdBuffer, mvecsRTH, srcScaleBias, dstScaleBias, 0, true);
|
|
+
|
|
+ CoreUtils.SetRenderTarget(cmdBuffer, depthTarget);
|
|
+ HDUtils.BlitQuad(cmdBuffer, depthRTH, srcScaleBias, dstScaleBias, 0, false);
|
|
+
|
|
+#if false //debug5x3
|
|
+ ComputeShader TESTcs5x3 = dlssg.GetFont5x3Shader();
|
|
+ if (TESTcs5x3 != null)
|
|
+ {
|
|
+ int kernel = TESTcs5x3.FindKernel("Font5x3Draw");
|
|
+
|
|
+ int w = (4 * 6 * 32);
|
|
+ int h = (5 * 32);
|
|
+
|
|
+ Vector4 offsetsh = new Vector4(depthTarget.width / 3, depthTarget.height / 2, 0, 0);
|
|
+
|
|
+ RenderTexture ffs = depthRTH;
|
|
+
|
|
+ cmdBuffer.SetComputeTextureParam(TESTcs5x3, kernel, "_OutputDTexture", depthTarget, 0, RenderTextureSubElement.Color);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_InputValue", (int)frameCount);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_Phase", 0);
|
|
+ cmdBuffer.SetComputeVectorParam(TESTcs5x3, "_Offset", offsetsh);
|
|
+ cmdBuffer.DispatchCompute(TESTcs5x3, kernel, w, h, 1);
|
|
+
|
|
+ cmdBuffer.SetComputeTextureParam(TESTcs5x3, kernel, "_OutputMTexture", mvecsTarget, 0, RenderTextureSubElement.Color);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_InputValue", (int)frameCount);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_Phase", 1);
|
|
+ cmdBuffer.SetComputeVectorParam(TESTcs5x3, "_Offset", offsetsh);
|
|
+ cmdBuffer.DispatchCompute(TESTcs5x3, kernel, w, h, 1);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+
|
|
+ // Don't check for whether DLSSG is enabled or disabled as we always send On/Off and Tags/nullTags
|
|
+ dlssg.SetupDepthAndMVecTextureTags(cmdBuffer,frameCount);
|
|
+ dlssg.HDRPSetupDLSSGFeatureConstants(cmdBuffer, hdCamera.camera,frameCount);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ }
|
|
+
|
|
+ public static void DLSSTagHudlessColor(CommandBuffer cmdBuffer, HDCamera hdCamera, RTHandle hudlessColorRTH, int frameCount)
|
|
+ {
|
|
+ StreamlineDLSSGHDRP dlssg = hdCamera.camera.GetComponent<StreamlineDLSSGHDRP>();
|
|
+
|
|
+ if (dlssg)
|
|
+ {
|
|
+ if (dlssg.DLSSGFeatureAvailable)
|
|
+ {
|
|
+ if (StreamlineDLSSGCore.DLSSGEnabled)
|
|
+ {
|
|
+ StreamlineDLSSGCore.HDRPRequestScaleBiasValues(out Vector4 srcScaleBias, out Vector4 dstScaleBias);
|
|
+
|
|
+ RenderTexture hudlessColorTarget = StreamlineDLSSGCore.GetTargetHudlessColorTexture();
|
|
+
|
|
+ CoreUtils.SetRenderTarget(cmdBuffer, hudlessColorTarget);
|
|
+ HDUtils.BlitQuad(cmdBuffer, hudlessColorRTH, srcScaleBias, dstScaleBias, 0, true);
|
|
+
|
|
+#if false //debug5x3
|
|
+ ComputeShader TESTcs5x3 = dlssg.GetFont5x3Shader();
|
|
+ if (TESTcs5x3 != null)
|
|
+ {
|
|
+ int kernel = TESTcs5x3.FindKernel("Font5x3Draw");
|
|
+
|
|
+ int w = (4 * 6 * 32);
|
|
+ int h = (5 * 32);
|
|
+
|
|
+ Vector4 offsetsh = new Vector4(hudlessColorTarget.width / 3, hudlessColorTarget.height / 2, 0, 0);
|
|
+
|
|
+ cmdBuffer.SetComputeTextureParam(TESTcs5x3, kernel, "_OutputHTexture", hudlessColorTarget, 0, RenderTextureSubElement.Color);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_InputValue", (int)frameCount);
|
|
+ cmdBuffer.SetComputeIntParam(TESTcs5x3, "_Phase", 2);
|
|
+ cmdBuffer.SetComputeVectorParam(TESTcs5x3, "_Offset", offsetsh);
|
|
+ cmdBuffer.DispatchCompute(TESTcs5x3, kernel, w, h, 1);
|
|
+ }
|
|
+#endif
|
|
+ }
|
|
+ // Don't check for whether DLSSG is enabled or disabled as we always send Tags/nullTags
|
|
+ dlssg.SetupHudlessColorTextureTags(cmdBuffer, frameCount);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ }
|
|
+
|
|
+}
|
|
\ No newline at end of file
|
|
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs.meta b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs.meta
|
|
new file mode 100644
|
|
index 0000000..1b306b3
|
|
--- /dev/null
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/RenderPipeline/HDStreamline.cs.meta
|
|
@@ -0,0 +1,11 @@
|
|
+fileFormatVersion: 2
|
|
+guid: 6a74b4e669d466d4d9866791d0be6269
|
|
+MonoImporter:
|
|
+ externalObjects: {}
|
|
+ serializedVersion: 2
|
|
+ defaultReferences: []
|
|
+ executionOrder: 0
|
|
+ icon: {instanceID: 0}
|
|
+ userData:
|
|
+ assetBundleName:
|
|
+ assetBundleVariant:
|
|
diff --git a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/Unity.RenderPipelines.HighDefinition.Runtime.asmdef b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/Unity.RenderPipelines.HighDefinition.Runtime.asmdef
|
|
index 185a101..6d2db5b 100644
|
|
--- a/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/Unity.RenderPipelines.HighDefinition.Runtime.asmdef
|
|
+++ b/src/HDRP/com.unity.render-pipelines.high-definition@14.0.7/Runtime/Unity.RenderPipelines.HighDefinition.Runtime.asmdef
|
|
@@ -7,7 +7,10 @@
|
|
"Unity.Burst",
|
|
"Unity.RenderPipelines.HighDefinition.Config.Runtime",
|
|
"Unity.Rendering.Denoising.Runtime",
|
|
- "Unity.VisualEffectGraph.Runtime"
|
|
+ "Unity.VisualEffectGraph.Runtime",
|
|
+ "com.nvidia.streamline.core.Runtime",
|
|
+ "com.nvidia.streamline.dlssg.Runtime",
|
|
+ "com.nvidia.streamline.reflex.Runtime"
|
|
],
|
|
"includePlatforms": [],
|
|
"excludePlatforms": [],
|