mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Cheaper mantle writer close
- close reads each window slot before the atomic swap instead of swapping all 5,929 slots - terrain-ready flags live with the terrain access and exist only on content writers
This commit is contained in:
1 parent
e31113aaa2
commit
df299bb97d
1 file changed
+6
-7
@@ -93,10 +93,6 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
@Getter(AccessLevel.NONE)
|
@Getter(AccessLevel.NONE)
|
||||||
private final ThreadLocal<ObjectPlacementCapture> objectPlacementCapture = new ThreadLocal<>();
|
private final ThreadLocal<ObjectPlacementCapture> objectPlacementCapture = new ThreadLocal<>();
|
||||||
@Getter(AccessLevel.NONE)
|
@Getter(AccessLevel.NONE)
|
||||||
@EqualsAndHashCode.Exclude
|
|
||||||
@ToString.Exclude
|
|
||||||
private final boolean[] terrainReady;
|
|
||||||
@Getter(AccessLevel.NONE)
|
|
||||||
@Setter(AccessLevel.NONE)
|
@Setter(AccessLevel.NONE)
|
||||||
@EqualsAndHashCode.Exclude
|
@EqualsAndHashCode.Exclude
|
||||||
@ToString.Exclude
|
@ToString.Exclude
|
||||||
@@ -155,7 +151,6 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
// boxed per-block map lookup on the placement and carve hot paths.
|
// boxed per-block map lookup on the placement and carve hot paths.
|
||||||
this.windowSide = (this.radius * 2) + 1;
|
this.windowSide = (this.radius * 2) + 1;
|
||||||
this.window = new AtomicReferenceArray<>(windowSide * windowSide);
|
this.window = new AtomicReferenceArray<>(windowSide * windowSide);
|
||||||
this.terrainReady = new boolean[windowSide * windowSide];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -894,9 +889,9 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TerrainAccess access = terrainAccess;
|
TerrainAccess access = terrainAccess;
|
||||||
if (access != null && !terrainReady[index]) {
|
if (access != null && !access.ready[index]) {
|
||||||
access.ensure(chunk, cx, cz);
|
access.ensure(chunk, cx, cz);
|
||||||
terrainReady[index] = true;
|
access.ready[index] = true;
|
||||||
}
|
}
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
@@ -1543,6 +1538,9 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
for (int index = 0; index < window.length(); index++) {
|
for (int index = 0; index < window.length(); index++) {
|
||||||
|
if (window.get(index) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
MantleChunk<Matter> chunk = window.getAndSet(index, null);
|
MantleChunk<Matter> chunk = window.getAndSet(index, null);
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
chunk.release();
|
chunk.release();
|
||||||
@@ -1554,6 +1552,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
|||||||
private final MantleComponent[] components;
|
private final MantleComponent[] components;
|
||||||
private final ChunkContext context;
|
private final ChunkContext context;
|
||||||
private final IrisComplex complex;
|
private final IrisComplex complex;
|
||||||
|
private final boolean[] ready = new boolean[window.length()];
|
||||||
|
|
||||||
private TerrainAccess(MantleComponent[] components, ChunkContext context, IrisComplex complex) {
|
private TerrainAccess(MantleComponent[] components, ChunkContext context, IrisComplex complex) {
|
||||||
this.components = components;
|
this.components = components;
|
||||||
|
|||||||
Reference in new issue
Block a user