@@ -64,6 +64,15 @@ public static void PostCullBeginCameraRendering(RenderRequestBatcherContext cont
64
64
s_Instance ? . batcher . PostCullBeginCameraRendering ( context ) ;
65
65
}
66
66
67
+
68
+ /// <summary>
69
+ /// Utility function for updating probe data after global ambient probe is set up
70
+ /// </summary>
71
+ public static void OnSetupAmbientProbe ( )
72
+ {
73
+ s_Instance ? . batcher . OnSetupAmbientProbe ( ) ;
74
+ }
75
+
67
76
/// <summary>
68
77
/// Utility function to run an occlusion test in compute to update indirect draws.
69
78
/// This function will dispatch compute shaders to run the given occlusion test and
@@ -445,8 +454,9 @@ private void Dispose()
445
454
446
455
private void OnSceneLoaded ( Scene scene , LoadSceneMode mode )
447
456
{
457
+ // Loaded scene might contain light probes that would affect existing objects. Hence we have to update all probes data.
448
458
if ( mode == LoadSceneMode . Additive )
449
- m_BatchersContext . UpdateAmbientProbeAndGpuBuffer ( RenderSettings . ambientProbe , true ) ;
459
+ m_BatchersContext . UpdateAmbientProbeAndGpuBuffer ( forceUpdate : true ) ;
450
460
}
451
461
452
462
private static void PostPostLateUpdateStatic ( )
@@ -540,22 +550,24 @@ private void OnEndCameraRendering(ScriptableRenderContext context, Camera camera
540
550
541
551
private void PostPostLateUpdate ( )
542
552
{
553
+ m_BatchersContext . UpdateAmbientProbeAndGpuBuffer ( forceUpdate : false ) ;
554
+
543
555
Profiler . BeginSample ( "GPUResidentDrawer.DispatchChanges" ) ;
544
556
var lodGroupTransformData = m_Dispatcher . GetTransformChangesAndClear < LODGroup > ( TransformTrackingType . GlobalTRS , Allocator . TempJob ) ;
545
557
var lodGroupData = m_Dispatcher . GetTypeChangesAndClear < LODGroup > ( Allocator . TempJob , noScriptingArray : true ) ;
546
558
var meshDataSorted = m_Dispatcher . GetTypeChangesAndClear < Mesh > ( Allocator . TempJob , sortByInstanceID : true , noScriptingArray : true ) ;
547
559
var materialData = m_Dispatcher . GetTypeChangesAndClear < Material > ( Allocator . TempJob , noScriptingArray : true ) ;
548
560
Profiler . EndSample ( ) ;
549
561
550
- Profiler . BeginSample ( "GPUResindentDrawer .ProcessMaterials" ) ;
562
+ Profiler . BeginSample ( "GPUResidentDrawer .ProcessMaterials" ) ;
551
563
ProcessMaterials ( materialData . destroyedID ) ;
552
564
Profiler . EndSample ( ) ;
553
565
554
- Profiler . BeginSample ( "GPUResindentDrawer .ProcessMeshes" ) ;
566
+ Profiler . BeginSample ( "GPUResidentDrawer .ProcessMeshes" ) ;
555
567
ProcessMeshes ( meshDataSorted . destroyedID ) ;
556
568
Profiler . EndSample ( ) ;
557
569
558
- Profiler . BeginSample ( "GPUResindentDrawer .ProcessLODGroups" ) ;
570
+ Profiler . BeginSample ( "GPUResidentDrawer .ProcessLODGroups" ) ;
559
571
ProcessLODGroups ( lodGroupData . changedID , lodGroupData . destroyedID , lodGroupTransformData . transformedID ) ;
560
572
Profiler . EndSample ( ) ;
561
573
@@ -564,12 +576,11 @@ private void PostPostLateUpdate()
564
576
meshDataSorted . Dispose ( ) ;
565
577
materialData . Dispose ( ) ;
566
578
567
- Profiler . BeginSample ( "GPUResindentDrawer .ProcessDraws" ) ;
579
+ Profiler . BeginSample ( "GPUResidentDrawer .ProcessDraws" ) ;
568
580
m_MeshRendererDrawer . ProcessDraws ( ) ;
569
581
// Add more drawers here ...
570
582
Profiler . EndSample ( ) ;
571
583
572
- m_BatchersContext . UpdateAmbientProbeAndGpuBuffer ( RenderSettings . ambientProbe ) ;
573
584
m_BatchersContext . UpdateInstanceMotions ( ) ;
574
585
575
586
m_Batcher . UpdateFrame ( ) ;
@@ -610,7 +621,7 @@ private void ProcessLODGroups(NativeArray<int> changedID, NativeArray<int> destr
610
621
611
622
internal void ProcessRenderers ( NativeArray < int > rendererGroupsID )
612
623
{
613
- Profiler . BeginSample ( "GPUResindentDrawer .ProcessMeshRenderers" ) ;
624
+ Profiler . BeginSample ( "GPUResidentDrawer .ProcessMeshRenderers" ) ;
614
625
615
626
var changedInstances = new NativeArray < InstanceHandle > ( rendererGroupsID . Length , Allocator . TempJob , NativeArrayOptions . UninitializedMemory ) ;
616
627
ScheduleQueryRendererGroupInstancesJob ( rendererGroupsID , changedInstances ) . Complete ( ) ;
@@ -624,7 +635,7 @@ internal void ProcessRenderers(NativeArray<int> rendererGroupsID)
624
635
625
636
internal void TransformInstances ( NativeArray < InstanceHandle > instances , NativeArray < Matrix4x4 > localToWorldMatrices )
626
637
{
627
- Profiler . BeginSample ( "GPUResindentDrawer .TransformInstances" ) ;
638
+ Profiler . BeginSample ( "GPUResidentDrawer .TransformInstances" ) ;
628
639
629
640
m_BatchersContext . UpdateInstanceTransforms ( instances , localToWorldMatrices ) ;
630
641
@@ -633,7 +644,7 @@ internal void TransformInstances(NativeArray<InstanceHandle> instances, NativeAr
633
644
634
645
internal void FreeInstances ( NativeArray < InstanceHandle > instances )
635
646
{
636
- Profiler . BeginSample ( "GPUResindentDrawer .FreeInstances" ) ;
647
+ Profiler . BeginSample ( "GPUResidentDrawer .FreeInstances" ) ;
637
648
638
649
m_Batcher . DestroyInstances ( instances ) ;
639
650
m_BatchersContext . FreeInstances ( instances ) ;
@@ -643,17 +654,9 @@ internal void FreeInstances(NativeArray<InstanceHandle> instances)
643
654
644
655
internal void FreeRendererGroupInstances ( NativeArray < int > rendererGroupIDs )
645
656
{
646
- if ( rendererGroupIDs . Length == 0 )
647
- return ;
648
-
649
- Profiler . BeginSample ( "GPUResindentDrawer.FreeRendererGroupInstances" ) ;
650
-
651
- var instances = new NativeList < InstanceHandle > ( rendererGroupIDs . Length , Allocator . TempJob ) ;
652
- ScheduleQueryRendererGroupInstancesJob ( rendererGroupIDs , instances ) . Complete ( ) ;
653
- m_Batcher . DestroyInstances ( instances . AsArray ( ) ) ;
654
- instances . Dispose ( ) ;
657
+ Profiler . BeginSample ( "GPUResidentDrawer.FreeRendererGroupInstances" ) ;
655
658
656
- m_BatchersContext . FreeRendererGroupInstances ( rendererGroupIDs ) ;
659
+ m_Batcher . FreeRendererGroupInstances ( rendererGroupIDs ) ;
657
660
658
661
Profiler . EndSample ( ) ;
659
662
}
0 commit comments