unsafe static void InvokeOnPerformCulling(BatchRendererGroup group, ref BatchRendererCullingOutput context, ref LODParameters lodParameters) { NativeArray <Plane> cullingPlanes = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <Plane>(context.cullingPlanes, context.cullingPlanesCount, Allocator.Invalid); NativeArray <BatchVisibility> batchVisibility = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <BatchVisibility>(context.batchVisibility, context.batchVisibilityCount, Allocator.Invalid); NativeArray <int> visibleIndices = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <int>(context.visibleIndices, context.visibleIndicesCount, Allocator.Invalid); NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref cullingPlanes, AtomicSafetyHandle.Create()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref batchVisibility, AtomicSafetyHandle.Create()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref visibleIndices, AtomicSafetyHandle.Create()); try { context.cullingJobsFence = group.m_PerformCulling(group, new BatchCullingContext(cullingPlanes, batchVisibility, visibleIndices, lodParameters)); } finally { JobHandle.ScheduleBatchedJobs(); //@TODO: Check that the no jobs using the buffers have been scheduled that are not returned here... AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle(cullingPlanes)); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle(batchVisibility)); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle(visibleIndices)); } }
private unsafe static void InvokeOnPerformCulling(BatchRendererGroup group, ref BatchRendererCullingOutput context, ref LODParameters lodParameters) { NativeArray <Plane> nativeArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <Plane>((void *)context.cullingPlanes, context.cullingPlanesCount, Allocator.Invalid); NativeArray <BatchVisibility> nativeArray2 = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <BatchVisibility>((void *)context.batchVisibility, context.batchVisibilityCount, Allocator.Invalid); NativeArray <int> nativeArray3 = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <int>((void *)context.visibleIndices, context.visibleIndicesCount, Allocator.Invalid); NativeArray <int> nativeArray4 = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray <int>((void *)context.visibleIndicesY, context.visibleIndicesCount, Allocator.Invalid); NativeArrayUnsafeUtility.SetAtomicSafetyHandle <Plane>(ref nativeArray, AtomicSafetyHandle.Create()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle <BatchVisibility>(ref nativeArray2, AtomicSafetyHandle.Create()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle <int>(ref nativeArray3, AtomicSafetyHandle.Create()); NativeArrayUnsafeUtility.SetAtomicSafetyHandle <int>(ref nativeArray4, AtomicSafetyHandle.Create()); try { context.cullingJobsFence = group.m_PerformCulling(group, new BatchCullingContext(nativeArray, nativeArray2, nativeArray3, nativeArray4, lodParameters, context.cullingMatrix, context.nearPlane)); } finally { JobHandle.ScheduleBatchedJobs(); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle <Plane>(nativeArray)); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle <BatchVisibility>(nativeArray2)); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle <int>(nativeArray3)); AtomicSafetyHandle.Release(NativeArrayUnsafeUtility.GetAtomicSafetyHandle <int>(nativeArray4)); } }