Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APV] Cell streaming system #5731

Merged
merged 108 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
75c954a
Updated MeshGizmo to handle both traingles and lines.
JulienIgnace-Unity Aug 5, 2021
570493f
Fixed cell and brick debug scale
JulienIgnace-Unity Aug 5, 2021
1bfc541
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Aug 11, 2021
53f4f3f
With a null ref exception when applying virtual offset on unloaded sc…
JulienIgnace-Unity Aug 13, 2021
70a3d3d
Fixed an issue causing failure of the bake when multiple scenes are l…
JulienIgnace-Unity Aug 13, 2021
d381f78
Faster new version of debug probes with compute buffers instead of co…
JulienIgnace-Unity Aug 17, 2021
00a460e
Fixed debug probes after domain relaod when using L1
JulienIgnace-Unity Aug 17, 2021
e128c24
Fixed compute buffer probe debug
JulienIgnace-Unity Aug 17, 2021
51eac63
Matched cell debug culling with cell culling used for probe debug.
JulienIgnace-Unity Aug 17, 2021
c3160d6
Revert "Matched cell debug culling with cell culling used for probe d…
JulienIgnace-Unity Aug 17, 2021
31180f1
Fixed per probe culling.
JulienIgnace-Unity Aug 17, 2021
0a7730f
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Aug 18, 2021
78596c7
Revert "Fixed compute buffer probe debug"
JulienIgnace-Unity Aug 18, 2021
72a75b4
Revert "Faster new version of debug probes with compute buffers inste…
JulienIgnace-Unity Aug 18, 2021
1cbd0b5
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Aug 19, 2021
b44cde7
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Aug 19, 2021
f762552
Merge branch 'hd/apv-msic-fixes' of https://github.com/Unity-Technolo…
JulienIgnace-Unity Aug 19, 2021
4c7f031
Cleaning in preparation for streaming
JulienIgnace-Unity Aug 19, 2021
f0d5e5c
More cleanup + Fix debug upon load/unload of cells
JulienIgnace-Unity Aug 19, 2021
4fdb748
Fix GCAlloc
JulienIgnace-Unity Aug 23, 2021
efa24b7
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Aug 24, 2021
e89c332
Add missing update function
JulienIgnace-Unity Aug 25, 2021
8a8b47d
Proper error handling on apv texture allocation failure
JulienIgnace-Unity Aug 25, 2021
c580086
Handle APV index allocation failure
JulienIgnace-Unity Aug 25, 2021
7a7e08e
Small cleanup
JulienIgnace-Unity Aug 25, 2021
a584b9b
Create hidden per scene data
FrancescoC-unity Aug 27, 2021
87fed75
Start using new mode in baking workflow (Need to fix the tmp send data)
FrancescoC-unity Aug 27, 2021
922f827
Remove loading/removal from authoring
FrancescoC-unity Aug 30, 2021
49da9e8
Need to switch branch, move profile data to asset
FrancescoC-unity Aug 31, 2021
7e86ae5
Almost completely get rid of baking reference volume
FrancescoC-unity Aug 31, 2021
a92bf42
remove baking ref from realtime subdiv (but not working :p)
FrancescoC-unity Aug 31, 2021
5221d9b
Precomputed chunk budget for indices and sh pool
JulienIgnace-Unity Aug 31, 2021
fb26eaf
Revert "remove baking ref from realtime subdiv (but not working :p)"
FrancescoC-unity Aug 31, 2021
17fd32e
Remove all probe ref volume authroing from baking, yay!
FrancescoC-unity Aug 31, 2021
809f560
Moving draw gizmo away and remove all reference of authoring from baking
FrancescoC-unity Sep 1, 2021
332ec81
Make sure baking profile is available if required during non baking
FrancescoC-unity Sep 1, 2021
e628d77
Load profile info from the asset
FrancescoC-unity Sep 1, 2021
802547a
Fix dilation refresh
FrancescoC-unity Sep 1, 2021
a59557d
Moved probe pool chunk size constant to ProbeBrickPool
JulienIgnace-Unity Sep 1, 2021
afaf065
Moved internal array to its own class
JulienIgnace-Unity Sep 1, 2021
24fee3a
Removed empty update for now
JulienIgnace-Unity Sep 1, 2021
26328aa
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 1, 2021
ab018ad
Post merge fix
JulienIgnace-Unity Sep 1, 2021
4559ebc
remove some other things
FrancescoC-unity Sep 1, 2021
22d13cf
remove asset
FrancescoC-unity Sep 2, 2021
8f88873
Small rename
FrancescoC-unity Sep 2, 2021
b7c8fc4
Merge branch 'HDRP/new-apv-workflow-backend' of https://github.com/Un…
JulienIgnace-Unity Sep 2, 2021
eb52367
Move field inside EDITOR tags
FrancescoC-unity Sep 2, 2021
520c27c
Post merge fix
JulienIgnace-Unity Sep 2, 2021
1c765d8
Fix issue when no profile is ever loaded (i.e. first time a project i…
FrancescoC-unity Sep 2, 2021
793a308
guards
FrancescoC-unity Sep 2, 2021
a65116c
Merge branch 'HDRP/new-apv-workflow-backend' of https://github.com/Un…
JulienIgnace-Unity Sep 2, 2021
5552a6f
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 3, 2021
e6c7d64
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 6, 2021
6375a26
Streaming V1 (non functional)
JulienIgnace-Unity Sep 8, 2021
1f8526b
Fixed adding the same cells multiple times to the system.
JulienIgnace-Unity Sep 9, 2021
59df65c
Fixed cell sorting
JulienIgnace-Unity Sep 9, 2021
2268168
Fixed wrong unload of unloaded cells.
JulienIgnace-Unity Sep 10, 2021
e2f8bd1
Fixed a mistake in chunk estimation calculation.
JulienIgnace-Unity Sep 10, 2021
50295ab
Moved cell streaing stuff to its own file
JulienIgnace-Unity Sep 13, 2021
467874d
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 13, 2021
7a04814
Merge branch 'hd/apv-cell-streaming' of https://github.com/Unity-Tech…
JulienIgnace-Unity Sep 13, 2021
02e4621
Fixed cell camera distance computation
JulienIgnace-Unity Sep 13, 2021
cdacf4f
GCAlloc hunt 1
JulienIgnace-Unity Sep 14, 2021
771022c
Pool a lot of internal objects to avoid gcallocs
JulienIgnace-Unity Sep 14, 2021
74fd909
Preallocated temporary Color arrays for updating SH textures
JulienIgnace-Unity Sep 14, 2021
933c678
Added various API and tests to DynamicArray
JulienIgnace-Unity Sep 15, 2021
534d049
Quicksort WIP
JulienIgnace-Unity Sep 15, 2021
4b4fcc2
Implemented quicksort
JulienIgnace-Unity Sep 16, 2021
e65b6e6
Reverted wrong change
JulienIgnace-Unity Sep 16, 2021
8fa4822
Moved QuickSort to a class extension and completed doc
JulienIgnace-Unity Sep 16, 2021
c4dfa09
Small improvement to AddRange
JulienIgnace-Unity Sep 16, 2021
be6493f
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 16, 2021
5dd31b7
Post merge fix
JulienIgnace-Unity Sep 16, 2021
d77069c
Update Changelog
JulienIgnace-Unity Sep 16, 2021
9aa5b44
Merge branch 'hd/apv-cell-streaming' of https://github.com/Unity-Tech…
JulienIgnace-Unity Sep 16, 2021
5d2f8df
Merge branch 'hd/dynamic-array-improvements' of https://github.com/Un…
JulienIgnace-Unity Sep 16, 2021
9d56479
Moved internal array to DynamicArray
JulienIgnace-Unity Sep 17, 2021
d162005
Pooled CellInfo to avoid allocation
JulienIgnace-Unity Sep 17, 2021
3cc6639
Split Update of SH texture in several chunks to avoid allocations.
JulienIgnace-Unity Sep 20, 2021
8022bbf
Fixed chunk copy
JulienIgnace-Unity Sep 20, 2021
8f275a6
Fixed Temporary DataLoc lifetime.
JulienIgnace-Unity Sep 20, 2021
c2b8ba4
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 20, 2021
08d6d59
Relax some condition on RemoveRange in DynamicArray
JulienIgnace-Unity Sep 20, 2021
ba00940
Revert MeshGizmo modifications
JulienIgnace-Unity Sep 20, 2021
be16a6a
Restored changed/hidden gizmo when Cells aren't loaded.
JulienIgnace-Unity Sep 20, 2021
287d3fd
Reverted a bit of temp test code.
JulienIgnace-Unity Sep 20, 2021
5e1e4b3
Small Clean
JulienIgnace-Unity Sep 20, 2021
b0197d4
Added a way to disable streaming of cells.
JulienIgnace-Unity Sep 21, 2021
087a401
Fixed hideFlags for pool textures
JulienIgnace-Unity Sep 21, 2021
c81c29d
partial index buffer update to improve performance.
JulienIgnace-Unity Sep 21, 2021
736bfcb
Fixed an issue where cells would stay in internal structures even aft…
JulienIgnace-Unity Sep 21, 2021
7b832eb
Added names to texture allocated for APV
JulienIgnace-Unity Sep 22, 2021
c9f95a3
Removed useless comment
JulienIgnace-Unity Sep 22, 2021
baa9da3
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 22, 2021
adcaa62
Fixed wrong bound for loop
JulienIgnace-Unity Sep 24, 2021
393bc55
Addressed most PR review feedback
JulienIgnace-Unity Sep 24, 2021
6c51d0a
Filled incoming chunks left over space with black.
JulienIgnace-Unity Sep 24, 2021
d30a196
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Sep 27, 2021
9cfac88
Handled the case where not every cell fit in memory when performing d…
JulienIgnace-Unity Oct 7, 2021
0119f3d
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Oct 7, 2021
a532ab5
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Oct 8, 2021
c93e747
Reworked baking to avoid using runtime structure to fill baked assets
JulienIgnace-Unity Oct 8, 2021
8b96607
Moved reference counting into CellInfo
JulienIgnace-Unity Oct 8, 2021
0b2abad
Moved the APV cell streaming options to the HDRP asset.
JulienIgnace-Unity Oct 12, 2021
d70b848
Fixed cleanup of loaded data
JulienIgnace-Unity Oct 12, 2021
18f7ae8
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Oct 18, 2021
a307b05
Merge branch 'master' of https://github.com/Unity-Technologies/Graphi…
JulienIgnace-Unity Oct 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
GCAlloc hunt 1
- Removed RegId (caused garbage when used as key in collections)
- Removed List<Chunk> allocation when adding bricks
- Removed some variable captures in lambdas
  • Loading branch information
JulienIgnace-Unity committed Sep 14, 2021
commit cdacf4fac0559c8b7fff1a054bd60bcf8b5d5b72
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
using UnityEngine.Rendering;
using System.Collections;
using Chunk = UnityEngine.Experimental.Rendering.ProbeBrickPool.BrickChunkAlloc;
using RegId = UnityEngine.Experimental.Rendering.ProbeReferenceVolume.RegId;
using CellInfo = UnityEngine.Experimental.Rendering.ProbeReferenceVolume.CellInfo;
using Cell = UnityEngine.Experimental.Rendering.ProbeReferenceVolume.Cell;

namespace UnityEngine.Experimental.Rendering
{
Expand Down Expand Up @@ -52,7 +53,7 @@ struct ReservedBrick

struct VoxelMeta
{
public RegId id;
public Cell cell;
public List<ushort> brickIndices;
}

Expand All @@ -65,12 +66,15 @@ struct BrickMeta
Vector3Int m_CenterRS; // the anchor in ref space, around which the index is defined. [IMPORTANT NOTE! For now we always have it at 0, so is not passed to the shader, but is kept here until development is active in case we find it useful]

Dictionary<Vector3Int, List<VoxelMeta>> m_VoxelToBricks;
Dictionary<RegId, BrickMeta> m_BricksToVoxels;
Dictionary<Cell, BrickMeta> m_BricksToVoxels;

int m_VoxelSubdivLevel = 3;

bool m_NeedUpdateIndexComputeBuffer;

// Static variable required to avoid allocations inside lambda functions
static Cell g_Cell = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes, can we use the cell index instead to do the checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can but I don't think that would make any difference, would it? It's just comparing references.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would we still need to have the global static thing? I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the static is mandatory because we use lambda for finding stuff. So it would capture the variable and generate gcalloc without it.
I guess we can make functors and set the ref in it to avoid this but it's much more verbose for not a lot of gain (I don't expect this to be run multi-threaded)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you can replace the FindIndex with an old school for loop, it will avoid GC allocs and the static global field.


int SizeOfPhysicalIndexFromBudget(ProbeVolumeTextureMemoryBudget memoryBudget)
{
switch (memoryBudget)
Expand All @@ -96,7 +100,7 @@ internal ProbeBrickIndex(ProbeVolumeTextureMemoryBudget memoryBudget)
m_CenterRS = new Vector3Int(0, 0, 0);

m_VoxelToBricks = new Dictionary<Vector3Int, List<VoxelMeta>>();
m_BricksToVoxels = new Dictionary<RegId, BrickMeta>();
m_BricksToVoxels = new Dictionary<Cell, BrickMeta>();

m_NeedUpdateIndexComputeBuffer = false;

Expand Down Expand Up @@ -260,16 +264,18 @@ internal bool AssignIndexChunksToCell(int bricksCount, ref CellIndexUpdateInfo c
return true;
}

public void AddBricks(RegId id, List<Brick> bricks, List<Chunk> allocations, int allocationSize, int poolWidth, int poolHeight, CellIndexUpdateInfo cellInfo)
public void AddBricks(Cell cell, List<Brick> bricks, List<Chunk> allocations, int allocationSize, int poolWidth, int poolHeight, CellIndexUpdateInfo cellInfo)
{
Debug.Assert(bricks.Count <= ushort.MaxValue, "Cannot add more than 65K bricks per RegId.");
int largest_cell = ProbeReferenceVolume.CellSize(kMaxSubdivisionLevels);

g_Cell = cell;

// create a new copy
BrickMeta bm = new BrickMeta();
bm.voxels = new HashSet<Vector3Int>();
bm.bricks = new List<ReservedBrick>(bricks.Count);
m_BricksToVoxels.Add(id, bm);
m_BricksToVoxels.Add(cell, bm);

int brick_idx = 0;
// find all voxels each brick will touch
Expand Down Expand Up @@ -302,10 +308,10 @@ public void AddBricks(RegId id, List<Brick> bricks, List<Chunk> allocations, int
}

VoxelMeta vm;
int vm_idx = vm_list.FindIndex((VoxelMeta lhs) => lhs.id == id);
int vm_idx = vm_list.FindIndex((VoxelMeta lhs) => lhs.cell == g_Cell);
if (vm_idx == -1) // first time a brick from this id has touched this voxel
{
vm.id = id;
vm.cell = cell;
vm.brickIndices = new List<ushort>(4);
vm_list.Add(vm);
}
Expand All @@ -326,38 +332,42 @@ public void AddBricks(RegId id, List<Brick> bricks, List<Chunk> allocations, int
}
}

public void RemoveBricks(RegId id, CellIndexUpdateInfo cellInfo)
public void RemoveBricks(CellInfo cellInfo)
{
if (!m_BricksToVoxels.ContainsKey(id))
if (!m_BricksToVoxels.ContainsKey(cellInfo.cell))
return;

BrickMeta bm = m_BricksToVoxels[id];
var cellUpdateInfo = cellInfo.updateInfo;

g_Cell = cellInfo.cell;

BrickMeta bm = m_BricksToVoxels[cellInfo.cell];
foreach (var v in bm.voxels)
{
List<VoxelMeta> vm_list = m_VoxelToBricks[v];
int idx = vm_list.FindIndex((VoxelMeta lhs) => lhs.id == id);
int idx = vm_list.FindIndex((VoxelMeta lhs) => lhs.cell == g_Cell);
if (idx >= 0)
{
vm_list.RemoveAt(idx);
if (vm_list.Count > 0)
{
UpdateIndexForVoxel(v, cellInfo);
UpdateIndexForVoxel(v, cellUpdateInfo);
}
else
{
ClearVoxel(v, cellInfo);
ClearVoxel(v, cellUpdateInfo);
m_VoxelToBricks.Remove(v);
}
}
}
m_BricksToVoxels.Remove(id);
m_BricksToVoxels.Remove(cellInfo.cell);

// Clear allocated chunks
for (int i = cellInfo.firstChunkIndex; i < (cellInfo.firstChunkIndex + cellInfo.numberOfChunks); ++i)
for (int i = cellUpdateInfo.firstChunkIndex; i < (cellUpdateInfo.firstChunkIndex + cellUpdateInfo.numberOfChunks); ++i)
{
m_IndexChunks[i] = false;
}
m_AvailableChunkCount += cellInfo.numberOfChunks;
m_AvailableChunkCount += cellUpdateInfo.numberOfChunks;
}

void UpdateIndexForVoxel(Vector3Int voxel, CellIndexUpdateInfo cellInfo)
Expand All @@ -367,7 +377,7 @@ void UpdateIndexForVoxel(Vector3Int voxel, CellIndexUpdateInfo cellInfo)
foreach (var vm in vm_list)
{
// get the list of bricks and indices
List<ReservedBrick> bricks = m_BricksToVoxels[vm.id].bricks;
List<ReservedBrick> bricks = m_BricksToVoxels[vm.cell].bricks;
List<ushort> indcs = vm.brickIndices;
UpdateIndexForVoxel(voxel, bricks, indcs, cellInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ internal class Cell
internal class CellInfo
{
public Cell cell;
public List<Chunk> chunkList;
public RegId regId;
public List<Chunk> chunkList = new List<Chunk>();
public int flatIdxInCellIndices = -1;
public bool loaded = false;
public ProbeBrickIndex.CellIndexUpdateInfo updateInfo;
Expand Down Expand Up @@ -460,41 +459,14 @@ public struct RuntimeResources
public Texture3D L2_3;
}

[DebuggerDisplay("{id}")]
internal struct RegId
{
internal int id;

public bool IsValid() => id != 0;
public void Invalidate() => id = 0;
public static bool operator ==(RegId lhs, RegId rhs) => lhs.id == rhs.id;
public static bool operator !=(RegId lhs, RegId rhs) => lhs.id != rhs.id;
public override bool Equals(object obj)
{
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
{
return false;
}
else
{
RegId p = (RegId)obj;
return p == this;
}
}

public override int GetHashCode() => id;
}

bool m_IsInitialized = false;
int m_ID = 0;
RefVolTransform m_Transform;
int m_MaxSubdivision;
ProbeBrickPool m_Pool;
ProbeBrickIndex m_Index;
ProbeCellIndices m_CellIndices;
List<Chunk> m_TmpSrcChunks = new List<Chunk>();
float[] m_PositionOffsets = new float[ProbeBrickPool.kBrickProbeCountPerDim];
Dictionary<RegId, List<Chunk>> m_Registry = new Dictionary<RegId, List<Chunk>>();
Bounds m_CurrGlobalBounds = new Bounds();

internal Dictionary<int, CellInfo> cells = new Dictionary<int, CellInfo>();
Expand Down Expand Up @@ -1057,11 +1029,12 @@ bool AddBricks(CellInfo cellInfo, ProbeBrickIndex.CellIndexUpdateInfo cellUpdate
var bricks = cell.bricks;

// calculate the number of chunks necessary
int ch_size = ProbeBrickPool.GetChunkSize();
var ch_list = new List<Chunk>((bricks.Count + ch_size - 1) / ch_size);
int chunkSize = ProbeBrickPool.GetChunkSize();
int brickChunksCount = (bricks.Count + chunkSize - 1) / chunkSize;
cellInfo.chunkList.Clear();

// Try to allocate texture space
if (!m_Pool.Allocate(ch_list.Capacity, ch_list))
if (!m_Pool.Allocate(brickChunksCount, cellInfo.chunkList))
return false;

// Create temporary allocation to copy SH data over to main atlas.
Expand All @@ -1070,17 +1043,16 @@ bool AddBricks(CellInfo cellInfo, ProbeBrickIndex.CellIndexUpdateInfo cellUpdate

// copy chunks into pool
m_TmpSrcChunks.Clear();
m_TmpSrcChunks.Capacity = ch_list.Count;
Chunk c;
c.x = 0;
c.y = 0;
c.z = 0;

// currently this code assumes that the texture width is a multiple of the allocation chunk size
for (int i = 0; i < ch_list.Count; i++)
for (int i = 0; i < cellInfo.chunkList.Count; i++)
{
m_TmpSrcChunks.Add(c);
c.x += ch_size * ProbeBrickPool.kBrickProbeCountPerDim;
c.x += chunkSize * ProbeBrickPool.kBrickProbeCountPerDim;
if (c.x >= dataloc.width)
{
c.x = 0;
Expand All @@ -1094,25 +1066,17 @@ bool AddBricks(CellInfo cellInfo, ProbeBrickIndex.CellIndexUpdateInfo cellUpdate
}

// Update pool textures with incoming SH data and ignore any potential frame latency related issues for now.
m_Pool.Update(dataloc, m_TmpSrcChunks, ch_list, m_SHBands);
m_Pool.Update(dataloc, m_TmpSrcChunks, cellInfo.chunkList, m_SHBands);

dataloc.Cleanup();

m_BricksLoaded = true;

// create a registry entry for this request
RegId id;
m_ID++;
id.id = m_ID;
m_Registry.Add(id, ch_list);

// Build index
m_Index.AddBricks(id, bricks, ch_list, ProbeBrickPool.GetChunkSize(), m_Pool.GetPoolWidth(), m_Pool.GetPoolHeight(), cellUpdateInfo);
m_Index.AddBricks(cellInfo.cell, bricks, cellInfo.chunkList, ProbeBrickPool.GetChunkSize(), m_Pool.GetPoolWidth(), m_Pool.GetPoolHeight(), cellUpdateInfo);

// Update CellInfo
cellInfo.regId = id;
cellInfo.updateInfo = cellUpdateInfo;
cellInfo.chunkList = ch_list;
cellInfo.loaded = true;

// Update indirection buffer
Expand All @@ -1127,22 +1091,19 @@ bool AddBricks(CellInfo cellInfo, ProbeBrickIndex.CellIndexUpdateInfo cellUpdate

void ReleaseBricks(CellInfo cellInfo)
{
List<Chunk> ch_list;
if (!m_Registry.TryGetValue(cellInfo.regId, out ch_list))
if (cellInfo.chunkList.Count == 0)
{
Debug.Log("Tried to release bricks with id=" + cellInfo.regId.id + " but no bricks were registered under this id.");
Debug.Log("Tried to release bricks from an empty Cell.");
return;
}

// clean up the index
m_Index.RemoveBricks(cellInfo.regId, cellInfo.updateInfo);
m_Index.RemoveBricks(cellInfo);

// clean up the pool
m_Pool.Deallocate(ch_list);
m_Registry.Remove(cellInfo.regId);
m_Pool.Deallocate(cellInfo.chunkList);

cellInfo.regId = new RegId();
cellInfo.chunkList = null;
cellInfo.chunkList.Clear();
}

/// <summary>
Expand Down