Skip to content

Commit

Permalink
New Sodium + FMA!
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 1, 2024
1 parent b6f3ce5 commit d46ea2d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ val MINECRAFT_VERSION by extra { "1.21" }
val NEOFORGE_VERSION by extra { "21.0.143" }
val FABRIC_LOADER_VERSION by extra { "0.15.11" }
val FABRIC_API_VERSION by extra { "0.100.4+1.21" }
val SODIUM_FILE by extra { "sodium-fabric-0.6.0-snapshot+mc1.21-local.jar" }
val SODIUM_FILE by extra { "sodium-LOADER-0.6.0-alpha.3+mc1.21.jar" }

// https://semver.org/
val MOD_VERSION by extra { "1.8.0" }
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
modCompileOnly("io.github.douira:glsl-transformer:2.0.1")
modCompileOnly("org.anarres:jcpp:1.4.14")

modCompileOnly(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE)))
modCompileOnly(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "fabric"))))

modCompileOnly(files(rootDir.resolve("DHApi.jar")))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.irisshaders.iris.shadows.frustum.BoxCuller;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.world.phys.AABB;
import org.joml.Math;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import org.joml.Vector3f;
Expand Down Expand Up @@ -324,34 +323,17 @@ protected int isVisible(double minX, double minY, double minZ, double maxX, doub
* @return 0 if nothing is visible, 1 if everything is visible, 2 if only some corners are visible.
*/
protected int checkCornerVisibility(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
float outsideBoundX;
float outsideBoundY;
float outsideBoundZ;

for (int i = 0; i < planeCount; ++i) {
Vector4f plane = this.planes[i];

// Check if plane is inside or intersecting.
// This is ported from JOML's FrustumIntersection.

if (plane.x() < 0) {
outsideBoundX = minX;
} else {
outsideBoundX = maxX;
}

if (plane.y() < 0) {
outsideBoundY = minY;
} else {
outsideBoundY = maxY;
}

if (plane.z() < 0) {
outsideBoundZ = minZ;
} else {
outsideBoundZ = maxZ;
}
float outsideBoundX = (plane.x() < 0) ? minX : maxX;
float outsideBoundY = (plane.y() < 0) ? minY : maxY;
float outsideBoundZ = (plane.z() < 0) ? minZ : maxZ;

// Use Math.fma for the dot product calculation to get vectorization (sorry old Intel users)
if (Math.fma(plane.x(), outsideBoundX, Math.fma(plane.y(), outsideBoundY, plane.z() * outsideBoundZ)) < -plane.w()) {
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void useShadowTaskrList(RenderSectionManager instance, @NotNull Map<Chun
}

@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager;createTerrainRenderList(Lnet/minecraft/client/Camera;Lnet/caffeinemc/mods/sodium/client/render/viewport/Viewport;IZ)V", shift = At.Shift.AFTER), cancellable = true)
private void cancelIfShadow(Camera camera, Viewport viewport, int frame, boolean spectator, CallbackInfo ci) {
private void cancelIfShadow(Camera camera, Viewport viewport, boolean spectator, CallbackInfo ci) {
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) ci.cancel();
}

Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies {
modImplementation("org.anarres:jcpp:1.4.14")
include("org.anarres:jcpp:1.4.14")

modImplementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE)))
modImplementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "fabric"))))

modCompileOnly(files(rootDir.resolve("DHApi.jar")))

Expand Down
11 changes: 6 additions & 5 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
val MINECRAFT_VERSION: String by rootProject.extra
val NEOFORGE_VERSION: String by rootProject.extra
val MOD_VERSION: String by rootProject.extra
val SODIUM_FILE: String by rootProject.extra

base {
archivesName = "iris-neoforge"
Expand Down Expand Up @@ -63,8 +64,6 @@ neoForge {

val localRuntime = configurations.create("localRuntime")

val SODIUM_PATH = "sodium-neoforge-0.6.0-snapshot+mc1.21-local.jar"

dependencies {
compileOnly(project(":common"))

Expand All @@ -78,10 +77,12 @@ dependencies {
jarJar("org.anarres:jcpp:[1.4.14,1.4.15]") {
isTransitive = false
}
if (!rootDir.resolve("custom_sodium").resolve(SODIUM_PATH).exists()) {
throw IllegalStateException("Sodium jar doesn't exist!!! It needs to be at $SODIUM_PATH")

if (!rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "neoforge")).exists()) {
throw IllegalStateException("Sodium jar doesn't exist!!! It needs to be at $SODIUM_FILE")
}
implementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_PATH)))

implementation(files(rootDir.resolve("custom_sodium").resolve(SODIUM_FILE.replace("LOADER", "neoforge"))))

compileOnly(files(rootDir.resolve("DHApi.jar")))
}
Expand Down

0 comments on commit d46ea2d

Please sign in to comment.