@ -71,16 +71,11 @@ namespace UnityEngine.Rendering.PostProcessing
if ( _contextInitialized )
{
_dispatchParams . contextIndex = _currentContext ;
Marshal . StructureToPtr ( _dispatchParams , _dispatchParamsBuffer , false ) ;
// Rotate between contexts to reduce the risk of race conditions between old and new contexts
uint previousContext = _currentContext ;
_currentContext = ( _currentContext + 1 ) % PSSRPlugin . MaxNumContexts ;
// Destroying the context from the render thread reduces the risk of race conditions causing crashes
var cmd = new CommandBuffer ( ) ;
cmd . IssuePluginEventAndData ( PSSRPlugin . GetRenderEventAndDataFunc ( ) , 2 , _dispatchParamsBuffer ) ;
Graphics . ExecuteCommandBuffer ( cmd ) ;
cmd . Release ( ) ;
PSSRPlugin . DestroyPssrContext ( previousContext ) ;
_contextInitialized = false ;
}
@ -206,7 +201,7 @@ namespace UnityEngine.Rendering.PostProcessing
public static extern int CreatePssrContext ( ref InitParams initParams , out IntPtr outputColorTexturePtr ) ;
[DllImport(LibraryName)]
public static extern void DestroyPssrContext ( ) ;
public static extern void DestroyPssrContext ( uint contextIndex ) ;
[Serializable, StructLayout(LayoutKind.Sequential)]
public struct InitParams