diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset index d92183cc..4101ffb1 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/Default Lens Flare (SRP).asset @@ -19,6 +19,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 1 lensFlareTexture: {fileID: 0} uniformScale: 15 @@ -27,9 +34,9 @@ MonoBehaviour: m_Count: 5 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 1, g: 1, b: 1, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -216,6 +223,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.05 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.3 @@ -224,9 +238,9 @@ MonoBehaviour: m_Count: 5 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.49673662, g: 0.8679245, b: 0.55442125, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -431,6 +445,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.1 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.35 @@ -439,9 +460,9 @@ MonoBehaviour: m_Count: 4 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.9245283, g: 0.6026995, b: 0.5552984, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -655,6 +676,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.1 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 0.3 @@ -663,9 +691,9 @@ MonoBehaviour: m_Count: 2 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.9245283, g: 0.6026995, b: 0.5552984, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -852,6 +880,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.03 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 1.5 @@ -860,9 +895,9 @@ MonoBehaviour: m_Count: 4 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 0.65088975, b: 1, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -1049,6 +1084,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 2 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.015 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 2 @@ -1057,9 +1099,9 @@ MonoBehaviour: m_Count: 3 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 1, b: 0.7484353, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 @@ -1246,6 +1288,13 @@ MonoBehaviour: positionOffset: {x: 0, y: 0} angularOffset: 0 translationScale: {x: 1, y: 1} + ringThickness: 0.25 + hoopFactor: 1 + noiseAmplitude: 1 + noiseFrequency: 1 + noiseSpeed: 0 + shapeCutOffSpeed: 0 + shapeCutOffRadius: 10 m_LocalIntensity: 0.008 lensFlareTexture: {fileID: 2800000, guid: da47326d6c6190a4e8793de9a26bf176, type: 3} uniformScale: 2 @@ -1254,9 +1303,9 @@ MonoBehaviour: m_Count: 3 preserveAspectRatio: 0 rotation: 0 - tintConst: 1 + tintColorType: 0 tint: {r: 0.34509802, g: 1, b: 0.7484353, a: 0.5} - tintRadial: + tintGradient: k__BackingField: 4 m_Gradient: serializedVersion: 2 diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 8b5ff482..d46d9f6c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -2461,7 +2461,7 @@ namespace UnityEngine.Rendering.HighDefinition name: string.Format("{0}_CameraColorBufferMipChain{1}", viewName, frameIndex)); } - void ReleaseHistoryBuffer() + public void ReleaseHistoryBuffer() //WW1MOD : Make public { m_HistoryRTSystem.ReleaseAll(); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs index 7da17920..f878608b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR2/Fsr2Context.cs @@ -34,10 +34,10 @@ namespace FidelityFX.FSR2 public class Fsr2Context { private const int MaxQueuedFrames = 16; - + private Fsr2.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; - + private Fsr2Pass _computeLuminancePyramidPass; private Fsr2Pass _reconstructPreviousDepthPass; private Fsr2Pass _depthClipPass; @@ -56,7 +56,7 @@ namespace FidelityFX.FSR2 private ComputeBuffer _spdConstantsBuffer; private readonly Fsr2.SpdConstants[] _spdConstantsArray = { new Fsr2.SpdConstants() }; private ref Fsr2.SpdConstants SpdConsts => ref _spdConstantsArray[0]; - + private ComputeBuffer _rcasConstantsBuffer; private readonly Fsr2.RcasConstants[] _rcasConstantsArray = new Fsr2.RcasConstants[1]; private ref Fsr2.RcasConstants RcasConsts => ref _rcasConstantsArray[0]; @@ -77,7 +77,7 @@ namespace FidelityFX.FSR2 { _contextDescription = contextDescription; _commandBuffer = new CommandBuffer { name = "FSR2" }; - + _upscalerConstantsBuffer = CreateConstantBuffer(); _spdConstantsBuffer = CreateConstantBuffer(); _rcasConstantsBuffer = CreateConstantBuffer(); @@ -87,9 +87,9 @@ namespace FidelityFX.FSR2 // Set defaults _firstExecution = true; _resourceFrameIndex = 0; - + UpscalerConsts.displaySize = _contextDescription.DisplaySize; - + _resources.Create(_contextDescription); CreatePasses(); } @@ -105,7 +105,7 @@ namespace FidelityFX.FSR2 _generateReactivePass = new Fsr2GenerateReactivePass(_contextDescription, _resources, _generateReactiveConstantsBuffer); _tcrAutogeneratePass = new Fsr2TcrAutogeneratePass(_contextDescription, _resources, _upscalerConstantsBuffer, _tcrAutogenerateConstantsBuffer); } - + public void Destroy() { DestroyPass(ref _tcrAutogeneratePass); @@ -116,9 +116,9 @@ namespace FidelityFX.FSR2 DestroyPass(ref _depthClipPass); DestroyPass(ref _reconstructPreviousDepthPass); DestroyPass(ref _computeLuminancePyramidPass); - + _resources.Destroy(); - + DestroyConstantBuffer(ref _tcrAutogenerateConstantsBuffer); DestroyConstantBuffer(ref _generateReactiveConstantsBuffer); DestroyConstantBuffer(ref _rcasConstantsBuffer); @@ -138,17 +138,17 @@ namespace FidelityFX.FSR2 Dispatch(dispatchParams, _commandBuffer); Graphics.ExecuteCommandBuffer(_commandBuffer); } - + public void Dispatch(Fsr2.DispatchDescription dispatchParams, CommandBuffer commandBuffer) { if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableDebugChecking) != 0) { DebugCheckDispatch(dispatchParams); } - + if (dispatchParams.UseTextureArrays) commandBuffer.EnableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); - + if (_firstExecution) { commandBuffer.SetRenderTarget(_resources.LockStatus[0]); @@ -156,7 +156,7 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.LockStatus[1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); } - + int frameIndex = _resourceFrameIndex % 2; bool resetAccumulation = dispatchParams.Reset || _firstExecution; _firstExecution = false; @@ -164,7 +164,7 @@ namespace FidelityFX.FSR2 // If auto exposure is enabled use the auto exposure SRV, otherwise what the app sends if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) dispatchParams.Exposure = new ResourceView(_resources.AutoExposure); - else if (!dispatchParams.Exposure.IsValid) + else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); if (dispatchParams.EnableAutoReactive) @@ -181,16 +181,16 @@ namespace FidelityFX.FSR2 } else if (_resources.AutoReactive != null) { - // Destroy the auto-TCR resources if we don't use the feature + // Destroy the auto-TCR resources if we don't use the feature _resources.DestroyTcrAutogenResources(); } - + if (!dispatchParams.Reactive.IsValid) dispatchParams.Reactive = new ResourceView(_resources.DefaultReactive); if (!dispatchParams.TransparencyAndComposition.IsValid) dispatchParams.TransparencyAndComposition = new ResourceView(_resources.DefaultReactive); Fsr2Resources.CreateAliasableResources(commandBuffer, _contextDescription, dispatchParams); - + SetupConstants(dispatchParams, resetAccumulation); - + // Reactive mask bias const int threadGroupWorkRegionDim = 8; int dispatchSrcX = (UpscalerConsts.renderSize.x + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim; @@ -203,7 +203,7 @@ namespace FidelityFX.FSR2 { commandBuffer.SetRenderTarget(_resources.LockStatus[frameIndex ^ 1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); - + commandBuffer.SetRenderTarget(_resources.InternalUpscaled[frameIndex ^ 1]); commandBuffer.ClearRenderTarget(false, true, Color.clear); @@ -213,7 +213,7 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.SceneLuminance); commandBuffer.ClearRenderTarget(false, true, Color.clear); - + // Auto exposure always used to track luma changes in locking logic commandBuffer.SetRenderTarget(_resources.AutoExposure); commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); @@ -222,15 +222,15 @@ namespace FidelityFX.FSR2 commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter); commandBuffer.ClearRenderTarget(false, true, Color.clear); } - + // 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 & Fsr2.InitializationFlags.EnableDepthInverted) == Fsr2.InitializationFlags.EnableDepthInverted; commandBuffer.SetRenderTarget(Fsr2ShaderIDs.UavReconstructedPrevNearestDepth); commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); - + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); - + // Initialize constant buffers data commandBuffer.SetBufferData(_upscalerConstantsBuffer, _upscalerConstantsArray); commandBuffer.SetBufferData(_spdConstantsBuffer, _spdConstantsArray); @@ -242,7 +242,7 @@ namespace FidelityFX.FSR2 dispatchParams.Reactive = new ResourceView(_resources.AutoReactive); dispatchParams.TransparencyAndComposition = new ResourceView(_resources.AutoComposition); } - + // Compute luminance pyramid _computeLuminancePyramidPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchThreadGroupCount.x, dispatchThreadGroupCount.y); @@ -263,18 +263,18 @@ namespace FidelityFX.FSR2 // Compute the constants SetupRcasConstants(dispatchParams); commandBuffer.SetBufferData(_rcasConstantsBuffer, _rcasConstantsArray); - + // Dispatch RCAS const int threadGroupWorkRegionDimRcas = 16; - int threadGroupsX = (Screen.width + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; - int threadGroupsY = (Screen.height + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; + int threadGroupsX = (_contextDescription.DisplaySize.x + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; + int threadGroupsY = (_contextDescription.DisplaySize.y + threadGroupWorkRegionDimRcas - 1) / threadGroupWorkRegionDimRcas; _sharpenPass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, threadGroupsX, threadGroupsY); } _resourceFrameIndex = (_resourceFrameIndex + 1) % MaxQueuedFrames; Fsr2Resources.DestroyAliasableResources(commandBuffer); - + commandBuffer.DisableShaderKeyword("UNITY_FSR_TEXTURE2D_X_ARRAY"); } @@ -296,7 +296,7 @@ namespace FidelityFX.FSR2 GenReactiveConsts.binaryValue = dispatchParams.BinaryValue; GenReactiveConsts.flags = (uint)dispatchParams.Flags; commandBuffer.SetBufferData(_generateReactiveConstantsBuffer, _generateReactiveConstantsArray); - + ((Fsr2GenerateReactivePass)_generateReactivePass).ScheduleDispatch(commandBuffer, dispatchParams, dispatchSrcX, dispatchSrcY); } @@ -311,14 +311,14 @@ namespace FidelityFX.FSR2 TcrAutoGenConsts.autoReactiveScale = dispatchParams.AutoReactiveScale; TcrAutoGenConsts.autoReactiveMax = dispatchParams.AutoReactiveMax; commandBuffer.SetBufferData(_tcrAutogenerateConstantsBuffer, _tcrAutogenerateConstantsArray); - + _tcrAutogeneratePass.ScheduleDispatch(commandBuffer, dispatchParams, frameIndex, dispatchSrcX, dispatchSrcY); } private void SetupConstants(Fsr2.DispatchDescription dispatchParams, bool resetAccumulation) { ref Fsr2.UpscalerConstants constants = ref UpscalerConsts; - + constants.jitterOffset = dispatchParams.JitterOffset; constants.renderSize = dispatchParams.RenderSize; constants.maxRenderSize = _contextDescription.MaxRenderSize; @@ -332,16 +332,16 @@ namespace FidelityFX.FSR2 // Compute params to enable device depth to view space depth computation in shader constants.deviceToViewDepth = SetupDeviceDepthToViewSpaceDepthParams(dispatchParams); - + // To be updated if resource is larger than the actual image size constants.downscaleFactor = new Vector2((float)constants.renderSize.x / _contextDescription.DisplaySize.x, (float)constants.renderSize.y / _contextDescription.DisplaySize.y); constants.previousFramePreExposure = constants.preExposure; constants.preExposure = (dispatchParams.PreExposure != 0) ? dispatchParams.PreExposure : 1.0f; - + // Motion vector data Vector2Int motionVectorsTargetSize = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDisplayResolutionMotionVectors) != 0 ? constants.displaySize : constants.renderSize; constants.motionVectorScale = dispatchParams.MotionVectorScale / motionVectorsTargetSize; - + // Compute jitter cancellation if ((_contextDescription.Flags & Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation) != 0) { @@ -362,7 +362,7 @@ namespace FidelityFX.FSR2 else if (jitterPhaseCountDelta < 0) constants.jitterPhaseCount--; } - + // Convert delta time to seconds and clamp to [0, 1] constants.deltaTime = Mathf.Clamp01(dispatchParams.FrameTimeDelta); @@ -378,7 +378,7 @@ namespace FidelityFX.FSR2 constants.lumaMipDimensions.x = (int)(constants.maxRenderSize.x / mipDiv); constants.lumaMipDimensions.y = (int)(constants.maxRenderSize.y / mipDiv); } - + private Vector4 SetupDeviceDepthToViewSpaceDepthParams(Fsr2.DispatchDescription dispatchParams) { bool inverted = (_contextDescription.Flags & Fsr2.InitializationFlags.EnableDepthInverted) != 0; @@ -399,7 +399,7 @@ namespace FidelityFX.FSR2 Vector4 matrixElemC = new Vector4(q, -1.0f - Mathf.Epsilon, q, 0.0f + Mathf.Epsilon); Vector4 matrixElemE = new Vector4(q * min, -min - Mathf.Epsilon, q * min, max); - + // Revert x and y coords float aspect = (float)dispatchParams.RenderSize.x / dispatchParams.RenderSize.y; float cotHalfFovY = Mathf.Cos(0.5f * dispatchParams.CameraFovAngleVertical) / Mathf.Sin(0.5f * dispatchParams.CameraFovAngleVertical); @@ -422,7 +422,7 @@ namespace FidelityFX.FSR2 { RectInt rectInfo = new RectInt(0, 0, dispatchParams.RenderSize.x, dispatchParams.RenderSize.y); SpdSetup(rectInfo, out dispatchThreadGroupCount, out var workGroupOffset, out var numWorkGroupsAndMips); - + // Downsample ref Fsr2.SpdConstants spdConstants = ref SpdConsts; spdConstants.numWorkGroups = (uint)numWorkGroupsAndMips.x; @@ -456,22 +456,22 @@ namespace FidelityFX.FSR2 { Debug.LogError("Color resource is null"); } - + if (!dispatchParams.Depth.IsValid) { Debug.LogError("Depth resource is null"); } - + if (!dispatchParams.MotionVectors.IsValid) { Debug.LogError("MotionVectors resource is null"); } - + if (!dispatchParams.Output.IsValid) { Debug.LogError("Output resource is null"); } - + if (dispatchParams.Exposure.IsValid && (_contextDescription.Flags & Fsr2.InitializationFlags.EnableAutoExposure) != 0) { Debug.LogWarning("Exposure resource provided, however auto exposure flag is present"); @@ -529,7 +529,7 @@ namespace FidelityFX.FSR2 Debug.LogWarning("EnableDepthInfinite and EnableDepthInverted present, yet CameraNear != float.MaxValue"); } } - + if (dispatchParams.CameraFar < 0.075f) { Debug.LogWarning("EnableDepthInverted present, CameraFar value is very low which may result in depth separation artefacting"); @@ -595,17 +595,17 @@ namespace FidelityFX.FSR2 new Fsr2.RcasConstants(1064229695u, 997604214u), new Fsr2.RcasConstants(1065353216u, 1006648320), }; - + private static ComputeBuffer CreateConstantBuffer() where TConstants: struct { return new ComputeBuffer(1, Marshal.SizeOf(), ComputeBufferType.Constant); } - + private static void DestroyConstantBuffer(ref ComputeBuffer bufferRef) { if (bufferRef == null) return; - + bufferRef.Release(); bufferRef = null; } @@ -614,7 +614,7 @@ namespace FidelityFX.FSR2 { if (pass == null) return; - + pass.Dispose(); pass = null; } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs index a54d9e76..e8775667 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -185,7 +185,7 @@ namespace FidelityFX.FSR3 // 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.FrameInfo); + dispatchParams.Exposure = new ResourceView(_resources.FrameInfo[frameIndex]); else if (!dispatchParams.Exposure.IsValid) dispatchParams.Exposure = new ResourceView(_resources.DefaultExposure); @@ -236,8 +236,8 @@ namespace FidelityFX.FSR3 commandBuffer.ClearRenderTarget(false, true, Color.clear); // Auto exposure always used to track luma changes in locking logic - commandBuffer.SetRenderTarget(_resources.FrameInfo); - commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); + commandBuffer.SetRenderTarget(_resources.FrameInfo[frameIndex ^ 1]); + commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f)); // Reset atomic counter to 0 commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter); @@ -249,6 +249,9 @@ namespace FidelityFX.FSR3 commandBuffer.SetRenderTarget(_resources.ReconstructedPrevNearestDepth); commandBuffer.ClearRenderTarget(false, true, depthInverted ? Color.clear : Color.white); + commandBuffer.SetRenderTarget(Fsr3ShaderIDs.UavNewLocks); + commandBuffer.ClearRenderTarget(false, true, Color.clear); + // Auto exposure SetupSpdConstants(dispatchParams, out var dispatchThreadGroupCount); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs index 00a634e2..5ebfa0cf 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerPass.cs @@ -155,9 +155,10 @@ namespace FidelityFX.FSR3 { commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepth, Fsr3ShaderIDs.UavIntermediate); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo[frameIndex ^ 1]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdAtomicCount, Resources.SpdAtomicCounter); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFrameInfo, Resources.FrameInfo); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavFrameInfo, Resources.FrameInfo[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip0, Resources.SpdMips, 0); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip1, Resources.SpdMips, 1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.UavSpdMip2, Resources.SpdMips, 2); @@ -273,7 +274,7 @@ namespace FidelityFX.FSR3 commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvInputExposure, exposure.RenderTarget, exposure.MipLevel, exposure.SubElement); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedReactiveMasks, Fsr3ShaderIDs.UavDilatedReactiveMasks); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvDilatedMotionVectors, Resources.DilatedVelocity); - commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo); + commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFrameInfo, Resources.FrameInfo[frameIndex]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvLumaHistory, Resources.LumaHistory[frameIndex ^ 1]); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvFarthestDepthMip1, Fsr3ShaderIDs.UavFarthestDepthMip1); commandBuffer.SetComputeTextureParam(ComputeShader, KernelIndex, Fsr3ShaderIDs.SrvCurrentLuma, Resources.Luma[frameIndex]); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs index d10bd96b..b894ba25 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Runtime/FSR3/Fsr3UpscalerResources.cs @@ -40,10 +40,10 @@ namespace FidelityFX.FSR3 public RenderTexture DilatedVelocity; public RenderTexture DilatedDepth; public RenderTexture ReconstructedPrevNearestDepth; - public RenderTexture FrameInfo; public RenderTexture AutoReactive; public RenderTexture AutoComposition; + public readonly RenderTexture[] FrameInfo = new RenderTexture[2]; public readonly RenderTexture[] Accumulation = new RenderTexture[2]; public readonly RenderTexture[] Luma = new RenderTexture[2]; public readonly RenderTexture[] InternalUpscaled = new RenderTexture[2]; @@ -107,8 +107,7 @@ namespace FidelityFX.FSR3 ReconstructedPrevNearestDepth.Create(); // Resource FSR3UPSCALER_FrameInfo: FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R32G32B32A32_FLOAT, FFX_RESOURCE_FLAGS_NONE - FrameInfo = new RenderTexture(1, 1, 0, GraphicsFormat.R32G32B32A32_SFloat) { name = "FSR3UPSCALER_FrameInfo", enableRandomWrite = true }; - FrameInfo.Create(); + CreateDoubleBufferedResource(FrameInfo, "FSR3UPSCALER_FrameInfo", Vector2Int.one, GraphicsFormat.R32G32B32A32_SFloat); // Resources FSR3UPSCALER_Accumulation1/2: FFX_RESOURCE_USAGE_RENDERTARGET | FFX_RESOURCE_USAGE_UAV, FFX_SURFACE_FORMAT_R8_UNORM, FFX_RESOURCE_FLAGS_NONE CreateDoubleBufferedResource(Accumulation, "FSR3UPSCALER_Accumulation", maxRenderSize, GraphicsFormat.R8_UNorm); @@ -194,8 +193,8 @@ namespace FidelityFX.FSR3 DestroyResource(InternalUpscaled); DestroyResource(Luma); DestroyResource(Accumulation); + DestroyResource(FrameInfo); - DestroyResource(ref FrameInfo); DestroyResource(ref ReconstructedPrevNearestDepth); DestroyResource(ref DilatedDepth); DestroyResource(ref DilatedVelocity); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl index 0d6b67df..dd678b0c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/ffx_fsr3upscaler_luma_pyramid_pass.hlsl @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -22,6 +22,7 @@ #define FSR3UPSCALER_BIND_SRV_CURRENT_LUMA 0 #define FSR3UPSCALER_BIND_SRV_FARTHEST_DEPTH 1 +#define FSR3UPSCALER_BIND_SRV_FRAME_INFO 2 #define FSR3UPSCALER_BIND_UAV_SPD_GLOBAL_ATOMIC 0 #define FSR3UPSCALER_BIND_UAV_FRAME_INFO 1 diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h index 084d4d37..73b5ad69 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_accumulate.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -52,7 +52,7 @@ void RectifyHistory( const FfxFloat32 fReactiveFactor = ffxPow(params.fReactiveMask, 1.0f / 2.0f); const FfxFloat32 fShadingChangeFactor = params.fShadingChange; const FfxFloat32 fBoxScaleT = ffxMax(fVecolityFactor, ffxMax(fDistanceFactor, ffxMax(fAccumulationFactor, ffxMax(fReactiveFactor, fShadingChangeFactor)))); - + const FfxFloat32 fBoxScale = ffxLerp(3.0f, 1.0f, fBoxScaleT); const FfxFloat32x3 fScaledBoxVec = data.clippingBox.boxVec * FfxFloat32x3(1.7f, 1.0f, 1.0f) * fBoxScale; @@ -148,7 +148,7 @@ void Accumulate(FfxInt32x2 iPxHrPos) if (params.bIsExistingSample && !params.bIsNewSample) { ReprojectHistoryColor(params, data); } - + UpdateLockStatus(params, data); ComputeBaseAccumulationWeight(params, data); @@ -169,5 +169,5 @@ void Accumulate(FfxInt32x2 iPxHrPos) #if FFX_FSR3UPSCALER_OPTION_APPLY_SHARPENING == 0 StoreUpscaledOutput(iPxHrPos, data.fHistoryColor); #endif - StoreNewLocks(iPxHrPos, 0); + //StoreNewLocks(iPxHrPos, 0); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h index c545579e..e86e41e4 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR/Shaders/shaders/fsr3upscaler/ffx_fsr3upscaler_luma_pyramid.h @@ -1,7 +1,7 @@ // This file is part of the FidelityFX SDK. // // Copyright (C) 2024 Advanced Micro Devices, Inc. -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights @@ -95,7 +95,7 @@ void SpdStore(FfxInt32x2 pix, FfxFloat32x4 outValue, FfxUInt32 index, FfxUInt32 if (all(FFX_EQUAL(pix, FfxInt32x2(0, 0)))) { - FfxFloat32x4 frameInfo = LoadFrameInfo(); + FfxFloat32x4 frameInfo = FrameInfo(); const FfxFloat32 fSceneAvgLuma = outValue[LUMA]; const FfxFloat32 fPrevLogLuma = frameInfo[FRAME_INFO_LOG_LUMA]; FfxFloat32 fLogLuma = outValue[LOG_LUMA]; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs index 4fc4d953..ffce7e2c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR2UpscalerPlugin.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using FidelityFX; using FidelityFX.FSR2; +using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 { @@ -63,6 +64,8 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 private readonly Fsr2.DispatchDescription _dispatchDescription = new(); private readonly FSR2CommandInitializationData _initData; + private Texture2DArray _clearTextureArray; + internal FSR2UpscalerContext(in FSR2CommandInitializationData initSettings) { _initData = initSettings; @@ -88,21 +91,30 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 Flags = flags, Shaders = assets.shaders, }); + + _clearTextureArray = new Texture2DArray(1, 1, TextureXR.slices, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None); + for (int i = 0; i < TextureXR.slices; ++i) _clearTextureArray.SetPixels(new[] { Color.clear, }, i); + _clearTextureArray.Apply(); } internal void Destroy() { + CoreUtils.Destroy(_clearTextureArray); + _context.Destroy(); } public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) { + bool useTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + ResourceView clearTexture = useTextureArrays ? new ResourceView(_clearTextureArray) : new ResourceView(); + _dispatchDescription.Color = new ResourceView(textures.colorInput); _dispatchDescription.Depth = new ResourceView(textures.depth); _dispatchDescription.MotionVectors = new ResourceView(textures.motionVectors); - _dispatchDescription.Exposure = new ResourceView(textures.exposureTexture); - _dispatchDescription.Reactive = new ResourceView(textures.biasColorMask); - _dispatchDescription.TransparencyAndComposition = new ResourceView(textures.transparencyMask); + _dispatchDescription.Exposure = textures.exposureTexture != null ? new ResourceView(textures.exposureTexture) : new ResourceView(); + _dispatchDescription.Reactive = textures.biasColorMask != null ? new ResourceView(textures.biasColorMask) : clearTexture; + _dispatchDescription.TransparencyAndComposition = textures.transparencyMask != null ? new ResourceView(textures.transparencyMask) : clearTexture; _dispatchDescription.Output = new ResourceView(textures.colorOutput); _dispatchDescription.JitterOffset = new Vector2(executeData.jitterOffsetX, executeData.jitterOffsetY); @@ -118,7 +130,7 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR2 _dispatchDescription.CameraFar = executeData.cameraFar; _dispatchDescription.CameraFovAngleVertical = executeData.cameraFovAngleVertical; _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity - _dispatchDescription.UseTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + _dispatchDescription.UseTextureArrays = useTextureArrays; _context.Dispatch(_dispatchDescription, cmd); } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs index 77f55b64..5f43217b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/Upscalers/FSR3UpscalerPlugin.cs @@ -1,6 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using FidelityFX; using FidelityFX.FSR3; +using UnityEngine.Experimental.Rendering; +#if UNITY_STANDALONE_WIN +using AMDUP = UnityEngine.AMD; +#endif namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 { @@ -13,6 +18,7 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 public static bool EnableDebugView { get; set; } = false; private Fsr3UpscalerAssets _assets; + private bool _nativePluginLoaded; public override string name => "FSR 3.1"; @@ -20,10 +26,33 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 public override bool includesSharpening => true; - public override bool supportsAlpha => true; + public override bool supportsAlpha => !_nativePluginLoaded; // Managed Unity port has alpha upscaling built-in, the native AMD implementation doesn't public override bool Load() { + // Guess we're using native plugins after all! + // On Windows with supported graphics APIs, we use a drop-in replacement for Unity's plugin that implements FSR 3.1 through AMD's upgradable FidelityFX API. + // This allows AMD's GPU driver to hijack the plugin and transparently upgrade our implementation to FSR4 on supported graphics cards! + _nativePluginLoaded = false; +#if UNITY_STANDALONE_WIN + if (!Application.isEditor && SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows && SystemInfo.graphicsDeviceType is GraphicsDeviceType.Direct3D12 or GraphicsDeviceType.Vulkan) + { + try + { + if (AMDUP.AMDUnityPlugin.IsLoaded() || AMDUP.AMDUnityPlugin.Load()) + { + _nativePluginLoaded = AMDUP.GraphicsDevice.device != null || AMDUP.GraphicsDevice.CreateGraphicsDevice() != null; + if (_nativePluginLoaded) + return true; + } + } + catch (DllNotFoundException) + { + _nativePluginLoaded = false; + } + } +#endif + if (_assets != null) return true; @@ -31,18 +60,39 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 return _assets != null; } - public override bool IsLoaded() => _assets != null; + public override bool IsLoaded() => _nativePluginLoaded || _assets != null; public override UpscalerContext CreateContext(in FSR2CommandInitializationData initSettings) { - var context = new FSR3UpscalerContext(in initSettings); - context.Init(_assets); - return context; +#if UNITY_STANDALONE_WIN + if (_nativePluginLoaded) + { + var context = new FSR3NativeUpscalerContext(in initSettings); + context.Init(); + return context; + } + else +#endif + { + var context = new FSR3UpscalerContext(in initSettings); + context.Init(_assets); + return context; + } } public override void DestroyContext(UpscalerContext context) { - ((FSR3UpscalerContext)context).Destroy(); + switch (context) + { +#if UNITY_STANDALONE_WIN + case FSR3NativeUpscalerContext nativeContext: + nativeContext.Destroy(); + break; +#endif + case FSR3UpscalerContext managedContext: + managedContext.Destroy(); + break; + } } public override bool GetRenderResolutionFromQualityMode(FSR2Quality qualityMode, uint displayWidth, uint displayHeight, out uint renderWidth, out uint renderHeight) @@ -65,6 +115,8 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 private readonly Fsr3Upscaler.DispatchDescription _dispatchDescription = new(); private readonly FSR2CommandInitializationData _initData; + private Texture2DArray _clearTextureArray; + internal FSR3UpscalerContext(in FSR2CommandInitializationData initSettings) { _initData = initSettings; @@ -90,21 +142,30 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 Flags = flags, Shaders = assets.shaders, }); + + _clearTextureArray = new Texture2DArray(1, 1, TextureXR.slices, GraphicsFormat.R32G32_SFloat, TextureCreationFlags.None); + for (int i = 0; i < TextureXR.slices; ++i) _clearTextureArray.SetPixels(new[] { Color.clear, }, i); + _clearTextureArray.Apply(); } internal void Destroy() { + CoreUtils.Destroy(_clearTextureArray); + _context.Destroy(); } public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) { + bool useTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + ResourceView clearTexture = useTextureArrays ? new ResourceView(_clearTextureArray) : new ResourceView(); + _dispatchDescription.Color = new ResourceView(textures.colorInput); _dispatchDescription.Depth = new ResourceView(textures.depth); _dispatchDescription.MotionVectors = new ResourceView(textures.motionVectors); - _dispatchDescription.Exposure = new ResourceView(textures.exposureTexture); - _dispatchDescription.Reactive = new ResourceView(textures.biasColorMask); - _dispatchDescription.TransparencyAndComposition = new ResourceView(textures.transparencyMask); + _dispatchDescription.Exposure = textures.exposureTexture != null ? new ResourceView(textures.exposureTexture) : new ResourceView(); + _dispatchDescription.Reactive = textures.biasColorMask != null ? new ResourceView(textures.biasColorMask) : clearTexture; + _dispatchDescription.TransparencyAndComposition = textures.transparencyMask != null ? new ResourceView(textures.transparencyMask) : clearTexture; _dispatchDescription.Output = new ResourceView(textures.colorOutput); _dispatchDescription.JitterOffset = new Vector2(executeData.jitterOffsetX, executeData.jitterOffsetY); @@ -122,9 +183,85 @@ namespace UnityEngine.Rendering.HighDefinition.AMD.FSR3 _dispatchDescription.CameraFovAngleVertical = executeData.cameraFovAngleVertical; _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity _dispatchDescription.Flags = FSR3UpscalerPlugin.EnableDebugView ? Fsr3Upscaler.DispatchFlags.DrawDebugView : 0; - _dispatchDescription.UseTextureArrays = TextureXR.useTexArray && textures.colorInput.dimension == TextureDimension.Tex2DArray; + _dispatchDescription.UseTextureArrays = useTextureArrays; _context.Dispatch(_dispatchDescription, cmd); } } + +#if UNITY_STANDALONE_WIN + public class FSR3NativeUpscalerContext : UpscalerContext + { + private AMDUP.FSR2Context _nativeContext; + private readonly FSR2CommandInitializationData _initData; + + internal FSR3NativeUpscalerContext(in FSR2CommandInitializationData initSettings) + { + _initData = initSettings; + } + + internal void Init() + { + AMDUP.FSR2CommandInitializationData initSettings = new() + { + maxRenderSizeWidth = _initData.maxRenderSizeWidth, + maxRenderSizeHeight = _initData.maxRenderSizeHeight, + displaySizeWidth = _initData.displaySizeWidth, + displaySizeHeight = _initData.displaySizeHeight, + ffxFsrFlags = (AMDUP.FfxFsr2InitializationFlags)_initData.ffxFsrFlags, + }; + + CommandBuffer cmd = new(); + _nativeContext = AMDUP.GraphicsDevice.device.CreateFeature(cmd, in initSettings); + Graphics.ExecuteCommandBuffer(cmd); + cmd.Release(); + } + + internal void Destroy() + { + if (_nativeContext == null) + return; + + CommandBuffer cmd = new(); + AMDUP.GraphicsDevice.device.DestroyFeature(cmd, _nativeContext); + Graphics.ExecuteCommandBuffer(cmd); + cmd.Release(); + + _nativeContext = null; + } + + public override void Execute(CommandBuffer cmd, in FSR2CommandExecutionData executeData, in FSR2TextureTable textures) + { + ref var execData = ref _nativeContext.executeData; + execData.jitterOffsetX = executeData.jitterOffsetX; + execData.jitterOffsetY = executeData.jitterOffsetY; + execData.MVScaleX = executeData.MVScaleX; + execData.MVScaleY = executeData.MVScaleY; + execData.renderSizeWidth = executeData.renderSizeWidth; + execData.renderSizeHeight = executeData.renderSizeHeight; + execData.enableSharpening = executeData.enableSharpening; + execData.sharpness = executeData.sharpness; + execData.frameTimeDelta = executeData.frameTimeDelta; + execData.preExposure = executeData.preExposure; + execData.reset = executeData.reset; + execData.cameraNear = executeData.cameraNear; + execData.cameraFar = executeData.cameraFar; + execData.cameraFovAngleVertical = executeData.cameraFovAngleVertical; + + AMDUP.FSR2TextureTable textureTable = new() + { + colorInput = textures.colorInput, + depth = textures.depth, + motionVectors = textures.motionVectors, + exposureTexture = textures.exposureTexture, + biasColorMask = textures.biasColorMask, + reactiveMask = textures.reactiveMask, + transparencyMask = textures.transparencyMask, + colorOutput = textures.colorOutput, + }; + + AMDUP.GraphicsDevice.device.ExecuteFSR2(cmd, _nativeContext, in textureTable); + } + } +#endif } diff --git a/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef b/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef index adb75e25..c9e16102 100644 --- a/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Editor/TMP/Unity.TextMeshPro.Editor.Tests.asmdef @@ -1,17 +1,27 @@ { "name": "Unity.TextMeshPro.Editor.Tests", + "rootNamespace": "", "references": [ "Unity.TextMeshPro", - "Unity.TextMeshPro.Editor" + "Unity.TextMeshPro.Editor", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], "includePlatforms": [ "Editor" ], - "excludePlatforms": [] + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs b/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs index 5f87c3cc..c9b2a08e 100644 --- a/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs +++ b/Packages/com.unity.ugui/Tests/Editor/UGUI/UI/PropertyDrawers/PropertyDrawerTests.cs @@ -51,7 +51,7 @@ public class PropertyDrawerTests static PropertyDrawerTestsWindow window; [UnitySetUp] - [MenuItem("Tests/Open Property Drawer Test Window")] + // WW1MOD: Disabled this menu item [MenuItem("Tests/Open Property Drawer Test Window")] public static IEnumerator SetUp() { VisualTreeBindingsUpdater.disableBindingsThrottling = true; diff --git a/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef b/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef index 8900ceb9..e7ceab95 100644 --- a/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef +++ b/Packages/com.unity.ugui/Tests/Editor/UGUI/UnityEditor.UI.EditorTests.asmdef @@ -1,14 +1,26 @@ { "name": "UnityEditor.UI.EditorTests", + "rootNamespace": "", "references": [ "UnityEditor.UI", - "UnityEngine.UI" - ], - "optionalUnityReferences": [ - "TestAssemblies" + "UnityEngine.UI", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], "includePlatforms": [ "Editor" ], - "excludePlatforms": [] -} + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef b/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef index f0c5260e..d3c8be29 100644 --- a/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Runtime/TMP/Unity.TextMeshPro.Tests.asmdef @@ -1,14 +1,24 @@ { "name": "Unity.TextMeshPro.Tests", + "rootNamespace": "", "references": [ - "Unity.TextMeshPro" + "Unity.TextMeshPro", + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" ], - "optionalUnityReferences": [ - "TestAssemblies" - ], - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], "includePlatforms": [], - "excludePlatforms": [] + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" + ], + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef b/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef index b598da30..73f23750 100644 --- a/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef +++ b/Packages/com.unity.ugui/Tests/Runtime/UGUI/UnityEngine.UI.Tests.asmdef @@ -1,5 +1,6 @@ { "name": "UnityEngine.UI.Tests", + "rootNamespace": "", "references": [ "UnityEngine.UI", "UnityEngine.TestRunner", @@ -14,7 +15,8 @@ ], "autoReferenced": false, "defineConstraints": [ - "UNITY_INCLUDE_TESTS" + "UNITY_INCLUDE_TESTS", + "UGUI_TESTS_ENABLED" ], "versionDefines": [ { @@ -39,4 +41,4 @@ } ], "noEngineReferences": false -} +} \ No newline at end of file