@@ -356,6 +356,22 @@ internal NativeBitArray GetValidIndexScratchpadArray(int minLightCount)
356356 return m_IsValidIndexScratchpadArray ;
357357 }
358358
359+ internal NativeArray < int > GetShadowIndicesScratchpadArray ( int minLightCount )
360+ {
361+ if ( m_ShadowIndicesScratchpadArray . IsCreated && m_ShadowIndicesScratchpadArray . Length < minLightCount )
362+ {
363+ m_ShadowIndicesScratchpadArray . Dispose ( ) ;
364+ m_ShadowIndicesScratchpadArray = default ;
365+ }
366+
367+ if ( ! m_ShadowIndicesScratchpadArray . IsCreated )
368+ {
369+ m_ShadowIndicesScratchpadArray = new NativeArray < int > ( minLightCount , Allocator . Persistent ) ;
370+ }
371+
372+ return m_ShadowIndicesScratchpadArray . GetSubArray ( 0 , minLightCount ) ;
373+ }
374+
359375#if UNITY_EDITOR
360376 internal NativeArray < int > GetShadowRequestCountsScratchpad ( int requestCount )
361377 {
@@ -370,7 +386,7 @@ internal NativeArray<int> GetShadowRequestCountsScratchpad(int requestCount)
370386 m_ShadowRequestCountsScratchpad = new NativeArray < int > ( requestCount , Allocator . Persistent ) ;
371387 }
372388
373- return m_ShadowRequestCountsScratchpad ;
389+ return m_ShadowRequestCountsScratchpad . GetSubArray ( 0 , requestCount ) ;
374390 }
375391#endif
376392
@@ -596,6 +612,7 @@ internal struct LightEntityInfo
596612 private NativeList < ShadowIndicesAndVisibleLightData > m_VisibleLightsAndIndicesBuffer = new NativeList < ShadowIndicesAndVisibleLightData > ( Allocator . Persistent ) ;
597613 private NativeList < ShadowIndicesAndVisibleLightData > m_SplitVisibleLightsAndIndicesBuffer = new NativeList < ShadowIndicesAndVisibleLightData > ( Allocator . Persistent ) ;
598614 private NativeBitArray m_IsValidIndexScratchpadArray = new NativeBitArray ( 256 , Allocator . Persistent ) ;
615+ private NativeArray < int > m_ShadowIndicesScratchpadArray ;
599616#if UNITY_EDITOR
600617 NativeArray < int > m_ShadowRequestCountsScratchpad ;
601618#endif
@@ -655,6 +672,26 @@ private void RemoveAtSwapBackArrays(int removeIndexAt)
655672
656673 private void DeleteArrays ( )
657674 {
675+ if ( m_IsValidIndexScratchpadArray . IsCreated )
676+ {
677+ m_IsValidIndexScratchpadArray . Dispose ( ) ;
678+ m_IsValidIndexScratchpadArray = default ;
679+ }
680+
681+ if ( m_ShadowIndicesScratchpadArray . IsCreated )
682+ {
683+ m_ShadowIndicesScratchpadArray . Dispose ( ) ;
684+ m_ShadowIndicesScratchpadArray = default ;
685+ }
686+
687+
688+ #if UNITY_EDITOR
689+ if ( m_ShadowRequestCountsScratchpad . IsCreated )
690+ {
691+ m_ShadowRequestCountsScratchpad . Dispose ( ) ;
692+ m_ShadowRequestCountsScratchpad = default ;
693+ }
694+ #endif
658695 if ( m_Capacity == 0 )
659696 return ;
660697
@@ -680,25 +717,13 @@ private void DeleteArrays()
680717 m_VisibleLightsAndIndicesBuffer = default ;
681718 m_SplitVisibleLightsAndIndicesBuffer . Dispose ( ) ;
682719 m_SplitVisibleLightsAndIndicesBuffer = default ;
683- if ( m_IsValidIndexScratchpadArray . IsCreated )
684- {
685- m_IsValidIndexScratchpadArray . Dispose ( ) ;
686- m_IsValidIndexScratchpadArray = default ;
687- }
688-
689-
690- #if UNITY_EDITOR
691- if ( m_ShadowRequestCountsScratchpad . IsCreated )
692- {
693- m_ShadowRequestCountsScratchpad . Dispose ( ) ;
694- m_ShadowRequestCountsScratchpad = default ;
695- }
696- #endif
697720
698721 m_HDShadowRequestStorage . Dispose ( ) ;
699722 m_HDShadowRequestStorage = default ;
700723 m_HDShadowRequestIndicesStorage . Dispose ( ) ;
701724 m_HDShadowRequestIndicesStorage = default ;
725+ m_CachedViewPositionsStorage . Dispose ( ) ;
726+ m_CachedViewPositionsStorage = default ;
702727 m_FrustumPlanesStorage . Dispose ( ) ;
703728 m_FrustumPlanesStorage = default ;
704729 m_HDShadowRequestsCreated = false ;
0 commit comments