|
|
|
@ -10,6 +10,7 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
public static bool IsSupported => UnityEngine.PS5.Utility.isTrinityMode && PluginInitialized; |
|
|
|
|
|
|
|
private static readonly bool PluginInitialized; |
|
|
|
private static uint _currentContext; |
|
|
|
|
|
|
|
private PSSRPlugin.DispatchParams _dispatchParams; |
|
|
|
private IntPtr _dispatchParamsBuffer; |
|
|
|
@ -32,7 +33,8 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
} |
|
|
|
|
|
|
|
PluginInitialized = true; |
|
|
|
} |
|
|
|
_currentContext = 0; |
|
|
|
} |
|
|
|
|
|
|
|
public override void CreateContext(PostProcessRenderContext context, Upscaling config) |
|
|
|
{ |
|
|
|
@ -43,7 +45,7 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
} |
|
|
|
|
|
|
|
PSSRPlugin.InitParams initParams; |
|
|
|
initParams.contextIndex = 0; |
|
|
|
initParams.contextIndex = _currentContext; |
|
|
|
initParams.displayWidth = (uint)config.UpscaleSize.x; |
|
|
|
initParams.displayHeight = (uint)config.UpscaleSize.y; |
|
|
|
initParams.maxRenderWidth = (uint)config.MaxRenderSize.x; |
|
|
|
@ -71,8 +73,10 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
if (_contextInitialized) |
|
|
|
{ |
|
|
|
_dispatchParams.contextIndex = 0; |
|
|
|
_dispatchParams.contextIndex = _currentContext; |
|
|
|
Marshal.StructureToPtr(_dispatchParams, _dispatchParamsBuffer, false); |
|
|
|
|
|
|
|
_currentContext = (_currentContext + 1) % PSSRPlugin.MaxNumContexts; |
|
|
|
|
|
|
|
// Destroying the context from the render thread reduces the risk of race conditions causing crashes
|
|
|
|
var cmd = new CommandBuffer(); |
|
|
|
@ -139,7 +143,7 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
if (SystemInfo.usesReversedZBuffer) flags |= PSSRPlugin.OptionFlags.ReverseDepth; |
|
|
|
if (config.exposureSource == Upscaling.ExposureSource.Auto) flags |= PSSRPlugin.OptionFlags.AutoExposure; |
|
|
|
|
|
|
|
_dispatchParams.contextIndex = 0; |
|
|
|
_dispatchParams.contextIndex = _currentContext; |
|
|
|
_dispatchParams.color = ToNativePtr(_inputColor); |
|
|
|
_dispatchParams.depth = ToNativePtr(_inputDepth[frameIndex]); |
|
|
|
_dispatchParams.prevDepth = ToNativePtr(_inputDepth[frameIndex ^ 1]); |
|
|
|
@ -191,6 +195,8 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
private static class PSSRPlugin |
|
|
|
{ |
|
|
|
public static readonly uint MaxNumContexts = 4; |
|
|
|
|
|
|
|
private const string LibraryName = "PSSRPlugin.prx"; |
|
|
|
|
|
|
|
[DllImport(LibraryName)] |
|
|
|
|