@ -428,6 +428,71 @@ extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API DestroyPssrContext(ui
UNITY_LOG ( s_Log , " Destroyed PSSR context " ) ;
}
extern " C " void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API DispatchPssr ( const pssr_dispatch_params_t * params )
{
if ( params - > contextIndex < 0 | | params - > contextIndex > = MaxNumContexts )
{
std : : stringstream msg ;
msg < < " Invalid PSSR context index: " < < params - > contextIndex ;
UNITY_LOG_ERROR ( s_Log , msg . str ( ) . c_str ( ) ) ;
return ;
}
PssrContext & context = s_contexts [ params - > contextIndex ] ;
if ( context . mfsrContext = = nullptr )
return ;
// How we obtain a command buffer to dispatch to depends on which graphics API we're using in Unity
sce : : Agc : : DrawCommandBuffer * cmd = nullptr ;
if ( s_RendererType = = kUnityGfxRendererPS5 )
{
auto * gfxc = ( sce : : Agc : : Gnmp : : LightweightGfxContext * ) s_GraphicsPS5 - > GetGfxContext ( ) ;
cmd = & gfxc - > m_agcCtx . m_dcb ;
}
else if ( s_RendererType = = kUnityGfxRendererPS5NGGC )
{
Core : : BasicContext & ctx = context . agcContext . reset ( ) ;
cmd = & ctx . m_dcb ;
}
cmd - > pushMarker ( " Dispatch MFSR " ) ;
DispatchMfsrParameters dispatchParams = { } ;
dispatchParams . init ( ) ;
dispatchParams . m_outputColor = params - > outputColor ;
dispatchParams . m_color = params - > color ;
dispatchParams . m_motionVectors = params - > motionVectors ;
dispatchParams . m_prevDepth = params - > prevDepth ;
dispatchParams . m_depth = params - > depth ;
dispatchParams . m_exposure = params - > exposure ;
dispatchParams . m_reactiveMask = params - > reactiveMask ;
dispatchParams . m_prevMotionVectors = params - > prevMotionVectors ;
dispatchParams . m_preExposure = params - > preExposure ;
dispatchParams . m_projectionNoJitter = params - > camProjectionNoJitter ;
dispatchParams . m_camForward = params - > camForward ;
dispatchParams . m_camUp = params - > camUp ;
dispatchParams . m_camRight = params - > camRight ;
dispatchParams . m_camPosD = params - > camPosition ;
dispatchParams . m_nearZ = params - > camNear ;
dispatchParams . m_farZ = params - > camFar ;
dispatchParams . m_renderWidth = params - > renderWidth ;
dispatchParams . m_renderHeight = params - > renderHeight ;
dispatchParams . m_jitter = params - > jitter ;
dispatchParams . m_motionVectorScale = params - > motionVectorScale ;
dispatchParams . m_motionVectorGamma = 1.0f ;
dispatchParams . m_reset = params - > resetHistory ! = 0 ;
dispatchParams . m_flags = params - > flags ;
dispatchMfsr ( context . mfsrContext , cmd , & dispatchParams ) ;
cmd - > popMarker ( ) ;
if ( s_RendererType = = kUnityGfxRendererPS5NGGC )
{
s_GraphicsAgcPS5 - > SubmitGraphics ( cmd - > getSubmitPointer ( ) , cmd - > getSubmitSize ( ) ) ;
}
}
// Plugin function to handle a specific rendering event
static void UNITY_INTERFACE_API OnRenderEventAndData ( int eventID , void * data )
{
@ -452,67 +517,7 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void* data)
case 1 : // Execute PSSR
{
auto * params = ( pssr_dispatch_params_t * ) data ;
if ( params - > contextIndex < 0 | | params - > contextIndex > = MaxNumContexts )
{
std : : stringstream msg ;
msg < < " Invalid PSSR context index: " < < params - > contextIndex ;
UNITY_LOG_ERROR ( s_Log , msg . str ( ) . c_str ( ) ) ;
break ;
}
PssrContext & context = s_contexts [ params - > contextIndex ] ;
if ( context . mfsrContext = = nullptr )
break ;
// How we obtain a command buffer to dispatch to depends on which graphics API we're using in Unity
sce : : Agc : : DrawCommandBuffer * cmd = nullptr ;
if ( s_RendererType = = kUnityGfxRendererPS5 )
{
auto * gfxc = ( sce : : Agc : : Gnmp : : LightweightGfxContext * ) s_GraphicsPS5 - > GetGfxContext ( ) ;
cmd = & gfxc - > m_agcCtx . m_dcb ;
}
else if ( s_RendererType = = kUnityGfxRendererPS5NGGC )
{
Core : : BasicContext & ctx = context . agcContext . reset ( ) ;
cmd = & ctx . m_dcb ;
}
cmd - > pushMarker ( " Dispatch MFSR " ) ;
DispatchMfsrParameters dispatchParams = { } ;
dispatchParams . init ( ) ;
dispatchParams . m_outputColor = params - > outputColor ;
dispatchParams . m_color = params - > color ;
dispatchParams . m_motionVectors = params - > motionVectors ;
dispatchParams . m_prevDepth = params - > prevDepth ;
dispatchParams . m_depth = params - > depth ;
dispatchParams . m_exposure = params - > exposure ;
dispatchParams . m_reactiveMask = params - > reactiveMask ;
dispatchParams . m_prevMotionVectors = params - > prevMotionVectors ;
dispatchParams . m_preExposure = params - > preExposure ;
dispatchParams . m_projectionNoJitter = params - > camProjectionNoJitter ;
dispatchParams . m_camForward = params - > camForward ;
dispatchParams . m_camUp = params - > camUp ;
dispatchParams . m_camRight = params - > camRight ;
dispatchParams . m_camPosD = params - > camPosition ;
dispatchParams . m_nearZ = params - > camNear ;
dispatchParams . m_farZ = params - > camFar ;
dispatchParams . m_renderWidth = params - > renderWidth ;
dispatchParams . m_renderHeight = params - > renderHeight ;
dispatchParams . m_jitter = params - > jitter ;
dispatchParams . m_motionVectorScale = params - > motionVectorScale ;
dispatchParams . m_motionVectorGamma = 1.0f ;
dispatchParams . m_reset = params - > resetHistory ! = 0 ;
dispatchParams . m_flags = params - > flags ;
dispatchMfsr ( context . mfsrContext , cmd , & dispatchParams ) ;
cmd - > popMarker ( ) ;
if ( s_RendererType = = kUnityGfxRendererPS5NGGC )
{
s_GraphicsAgcPS5 - > SubmitGraphics ( cmd - > getSubmitPointer ( ) , cmd - > getSubmitSize ( ) ) ;
}
DispatchPssr ( params ) ;
break ;
}
case 2 : // Destroy PSSR context