Skip to content

Commit

Permalink
Updated Upstream (Paper & Pufferfish)
Browse files Browse the repository at this point in the history
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@a90092e Updated Upstream (CraftBukkit/Spigot) (#7848)
PaperMC/Paper@79e07f3 Fix addPassenger for Marker (#7762)
PaperMC/Paper@182a609 Fix duplicate world keys via createWorld (#7614)
PaperMC/Paper@b6a6544 Provide ComponentSerializer services (#7527)
PaperMC/Paper@3f7fbe3 Fix cb's janky level name in WorldCreator (#7851)
PaperMC/Paper@af3b377 Update ForgeFlower (#7857)
PaperMC/Paper@9667181 Fix OfflinePlayer#getBedSpawnLocation (#7861)
PaperMC/Paper@c123915 Fix FurnaceInventory for smokers and blast furnaces (#7249)
PaperMC/Paper@f7382f5 Remove unneeded UOE when copying biome sources (#7629)
PaperMC/Paper@6b035fd Update default vanilla command perms (#7386)
PaperMC/Paper@f210f67 Update the rewriteForIde for new cb package version (#7242)
PaperMC/Paper@3f7111d Fix EntityEquipment and related javadocs (#7380)
PaperMC/Paper@78e6431 Add default kick msg component (#6886)
PaperMC/Paper@04e1b07 Check HAProxyMessage type is PROXY (#7864)
PaperMC/Paper@00c6ae8 Implement Translatable on CreativeCategory (#7587)
PaperMC/Paper@7602dd2 Sanitize Sent BlockEntity NBT (#7010)
PaperMC/Paper@2d17a50 Add translation keys to GameMode enum (#7081)
PaperMC/Paper@c5caee3 Prevent entity loading causing async lookups (#7553)
PaperMC/Paper@71fe3c6 Add numeric string completion suggestions as int suggestions (#6360)
PaperMC/Paper@b1ac25f Respect x-ray permission in World#refreshChunk (#7214)

Pufferfish Changes:
pufferfish-gg/Pufferfish@6186c1f Updated Upstream (Paper)
pufferfish-gg/Pufferfish@b235d83 Fix regression with SIMD vector sizes not matching 256-bits
pufferfish-gg/Pufferfish@27cb1ac Updated Upstream (Paper)
  • Loading branch information
theomega24 committed Jun 2, 2022
1 parent 61fc0a5 commit 1ba98f8
Show file tree
Hide file tree
Showing 54 changed files with 275 additions and 270 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group = org.purpurmc.purpur
version = 1.18.2-R0.1-SNAPSHOT

paperCommit = 31ccc579b5cab625b8e0c4ee4d521ffb6bf984b2
paperCommit = b1ac25fdb8e2c011cc0b006d0b478e11879a29d8

org.gradle.caching = true
org.gradle.parallel = true
Expand Down
74 changes: 45 additions & 29 deletions patches/api/0001-Pufferfish-API-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,17 @@ index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8e
+}
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
new file mode 100644
index 0000000000000000000000000000000000000000..66244a98901fff4479c50ce955502e2975f804c6
index 0000000000000000000000000000000000000000..93f5d7ca36e043e6c0f959450d38e6946b348eaf
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
@@ -0,0 +1,30 @@
@@ -0,0 +1,40 @@
+package gg.pufferfish.pufferfish.simd;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.IntVector;
+import jdk.incubator.vector.VectorSpecies;
+
+/**
+ * Basically, java is annoying and we have to push this out to its own class.
Expand All @@ -229,19 +233,25 @@ index 0000000000000000000000000000000000000000..66244a98901fff4479c50ce955502e29
+public class SIMDChecker {
+
+ @Deprecated
+ public static boolean canEnable() {
+ public static boolean canEnable(Logger logger) {
+ try {
+ if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18) {
+ return false;
+ } else {
+ SIMDDetection.testRun = true;
+ IntVector oneVector = IntVector.broadcast(IntVector.SPECIES_256, 1);
+ IntVector twoVector = IntVector.broadcast(IntVector.SPECIES_256, 2);
+ IntVector result = oneVector.add(twoVector);
+ if (result.toArray()[0] == 3) {
+ // Vectorization works! Let's enable it!
+ return true;
+
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
+
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
+
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
+ logger.log(Level.WARNING, "SIMD is not properly supported on this system!");
+ return false;
+ }
+
+ return true;
+ }
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
+ return false;
Expand All @@ -250,12 +260,14 @@ index 0000000000000000000000000000000000000000..66244a98901fff4479c50ce955502e29
+}
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
new file mode 100644
index 0000000000000000000000000000000000000000..d5ee3dfde2fed1f1bec49df22ba37ce725de4c2c
index 0000000000000000000000000000000000000000..a84889d3e9cfc4d7ab5f867820a6484c6070711b
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
@@ -0,0 +1,33 @@
@@ -0,0 +1,35 @@
+package gg.pufferfish.pufferfish.simd;
+
+import java.util.logging.Logger;
+
+@Deprecated
+public class SIMDDetection {
+
Expand All @@ -264,9 +276,9 @@ index 0000000000000000000000000000000000000000..d5ee3dfde2fed1f1bec49df22ba37ce7
+ public static boolean testRun = false;
+
+ @Deprecated
+ public static boolean canEnable() {
+ public static boolean canEnable(Logger logger) {
+ try {
+ return SIMDChecker.canEnable();
+ return SIMDChecker.canEnable(logger);
+ } catch (NoClassDefFoundError | Exception ignored) {
+ return false;
+ }
Expand All @@ -289,24 +301,28 @@ index 0000000000000000000000000000000000000000..d5ee3dfde2fed1f1bec49df22ba37ce7
+}
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
new file mode 100644
index 0000000000000000000000000000000000000000..2341b564b6383d5eca5fafe80273e046bfea070e
index 0000000000000000000000000000000000000000..ae2464920c9412ac90b819a540ee58be0741465f
--- /dev/null
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
@@ -0,0 +1,79 @@
@@ -0,0 +1,83 @@
+package gg.pufferfish.pufferfish.simd;
+
+import java.awt.Color;
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.IntVector;
+import jdk.incubator.vector.VectorMask;
+import jdk.incubator.vector.VectorSpecies;
+import org.bukkit.map.MapPalette;
+
+@Deprecated
+public class VectorMapPalette {
+
+ private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
+ private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
+
+ @Deprecated
+ public static void matchColorVectorized(int[] in, byte[] out) {
+ int speciesLength = IntVector.SPECIES_256.length();
+ int speciesLength = I_SPEC.length();
+ int i;
+ for (i = 0; i < in.length - speciesLength; i += speciesLength) {
+ float[] redsArr = new float[speciesLength];
Expand All @@ -321,31 +337,31 @@ index 0000000000000000000000000000000000000000..2341b564b6383d5eca5fafe80273e046
+ bluesArr[j] = (in[i + j] >> 0) & 0xFF;
+ }
+
+ IntVector alphas = IntVector.fromArray(IntVector.SPECIES_256, alphasArr, 0);
+ FloatVector reds = FloatVector.fromArray(FloatVector.SPECIES_256, redsArr, 0);
+ FloatVector greens = FloatVector.fromArray(FloatVector.SPECIES_256, greensArr, 0);
+ FloatVector blues = FloatVector.fromArray(FloatVector.SPECIES_256, bluesArr, 0);
+ IntVector resultIndex = IntVector.zero(IntVector.SPECIES_256);
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(IntVector.SPECIES_256, 0b11111111);
+ IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
+ FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
+ FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
+ FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
+ IntVector resultIndex = IntVector.zero(I_SPEC);
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
+
+ modificationMask = modificationMask.and(alphas.lt(128).not());
+ FloatVector bestDistances = FloatVector.broadcast(FloatVector.SPECIES_256, Float.MAX_VALUE);
+ FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
+
+ for (int c = 4; c < MapPalette.colors.length; c++) {
+ // We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
+ // For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
+ FloatVector compReds = FloatVector.broadcast(FloatVector.SPECIES_256, MapPalette.colors[c].getRed());
+ FloatVector compGreens = FloatVector.broadcast(FloatVector.SPECIES_256, MapPalette.colors[c].getGreen());
+ FloatVector compBlues = FloatVector.broadcast(FloatVector.SPECIES_256, MapPalette.colors[c].getBlue());
+ FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
+ FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
+ FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
+
+ FloatVector rMean = reds.add(compReds).div(2.0f);
+ FloatVector rDiff = reds.sub(compReds);
+ FloatVector gDiff = greens.sub(compGreens);
+ FloatVector bDiff = blues.sub(compBlues);
+
+ FloatVector weightR = rMean.div(256.0f).add(2);
+ FloatVector weightG = FloatVector.broadcast(FloatVector.SPECIES_256, 4.0f);
+ FloatVector weightB = FloatVector.broadcast(FloatVector.SPECIES_256, 255.0f).sub(rMean).div(256.0f).add(2.0f);
+ FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
+ FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
+
+ FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
+
Expand All @@ -356,7 +372,7 @@ index 0000000000000000000000000000000000000000..2341b564b6383d5eca5fafe80273e046
+
+ // Update the result array
+ // We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(IntVector.SPECIES_256).and(modificationMask)); // Update the results
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
+ }
+
+ for (int j = 0; j < speciesLength; j++) {
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0005-Purpur-client-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Purpur client support


diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index e65dc831974ca501f69d2cc43858b838e8866676..65424451fb7fd05d37beb70cb7023b0a5f27dc8b 100644
index 6cd0b10d1dc4506cfb1e4db5e1260cb705566cec..81d8afa7b7ac9b65e3ea2a5e69e7ec5dc7b812b7 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2693,4 +2693,13 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@@ -2698,4 +2698,13 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@Override
Spigot spigot();
// Spigot end
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0010-AFK-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] AFK API


diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 65424451fb7fd05d37beb70cb7023b0a5f27dc8b..24eb17f307c8c6523cd804e8b330c7ae7dfc6404 100644
index 81d8afa7b7ac9b65e3ea2a5e69e7ec5dc7b812b7..a569decc40fff08d0675ffa4ee9e6f54f115ad97 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2701,5 +2701,24 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@@ -2706,5 +2706,24 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @return True if Player uses Purpur Client
*/
public boolean usesPurpurClient();
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0017-Player-invulnerabilities.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Player invulnerabilities


diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 24eb17f307c8c6523cd804e8b330c7ae7dfc6404..7913e9440a1068374a7129dac7cc2a6bc4fb2527 100644
index a569decc40fff08d0675ffa4ee9e6f54f115ad97..4f1213d5c5efb2c415eb22b927936eb932ed3a4a 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2720,5 +2720,26 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@@ -2725,5 +2725,26 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* Reset the idle timer back to 0
*/
void resetIdleTimer();
Expand Down

0 comments on commit 1ba98f8

Please sign in to comment.