-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow lazy-loading chunk section data when using Vector API
- Loading branch information
Showing
9 changed files
with
124 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
worldedit-core/src/main/java/com/fastasyncworldedit/core/internal/simd/VectorFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.fastasyncworldedit.core.internal.simd; | ||
|
||
import com.fastasyncworldedit.core.queue.IBlocks; | ||
import com.sk89q.worldedit.world.block.BlockTypesCache; | ||
import jdk.incubator.vector.ShortVector; | ||
import jdk.incubator.vector.VectorSpecies; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
@ApiStatus.Internal | ||
public class VectorFacade { | ||
private final IBlocks blocks; | ||
private int layer; | ||
private int index; | ||
private char[] data; | ||
|
||
VectorFacade(final IBlocks blocks) { | ||
this.blocks = blocks; | ||
} | ||
|
||
public ShortVector get(VectorSpecies<Short> species) { | ||
if (this.data == null) { | ||
load(); | ||
} | ||
return ShortVector.fromCharArray(species, this.data, this.index); | ||
} | ||
|
||
public ShortVector getOrZero(VectorSpecies<Short> species) { | ||
if (this.data == null) { | ||
return species.zero().reinterpretAsShorts(); | ||
} | ||
return ShortVector.fromCharArray(species, this.data, this.index); | ||
} | ||
|
||
public void setOrIgnore(ShortVector vector) { | ||
if (this.data == null) { | ||
if (vector.eq((short) BlockTypesCache.ReservedIDs.__RESERVED__).allTrue()) { | ||
return; | ||
} | ||
load(); | ||
} | ||
vector.intoCharArray(this.data, this.index); | ||
} | ||
|
||
private void load() { | ||
this.data = this.blocks.load(this.layer); | ||
} | ||
|
||
public void setLayer(int layer) { | ||
this.layer = layer; | ||
this.data = null; | ||
} | ||
|
||
public void setIndex(int index) { | ||
this.index = index; | ||
} | ||
|
||
public void setData(char[] data) { | ||
this.data = data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters