-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
System information is now fetched off-thread and only supplied when it's fetched and a call to `RenderSystem#assertInInitPhase` is skipped with an `Integer` comparison. This saves ~500ms on my system.
- Loading branch information
1 parent
208dce1
commit 7211243
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...rc/main/java/io/github/steveplays28/blinkload/mixin/client/blaze3d/platform/GLXMixin.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,42 @@ | ||
package io.github.steveplays28.blinkload.mixin.client.blaze3d.platform; | ||
|
||
import com.mojang.blaze3d.platform.GLX; | ||
import io.github.steveplays28.blinkload.util.ThreadUtil; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.gl.GlDebug; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import oshi.SystemInfo; | ||
import oshi.hardware.CentralProcessor; | ||
|
||
import java.util.Locale; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(GLX.class) | ||
public class GLXMixin { | ||
@Shadow | ||
private static String cpuInfo; | ||
|
||
@Inject(method = "_init", at = @At(value = "NEW", target = "()Loshi/SystemInfo;"), cancellable = true) | ||
private static void blinkload$optimizeSystemInfoFetch(int debugVerbosity, boolean debugSync, @NotNull CallbackInfo ci) { | ||
CompletableFuture.supplyAsync(() -> { | ||
CentralProcessor centralProcessor = new SystemInfo().getHardware().getProcessor(); | ||
return String.format( | ||
Locale.ROOT, "%dx %s", centralProcessor.getLogicalProcessorCount(), | ||
centralProcessor.getProcessorIdentifier().getName() | ||
).replaceAll("\\s+", " "); | ||
}, ThreadUtil.getGLXInitializerThreadPoolExecutor()).whenComplete((string, throwable) -> cpuInfo = string); | ||
|
||
if (debugVerbosity > 0) { | ||
GlDebug.enableDebug(debugVerbosity, debugSync); | ||
} | ||
|
||
ci.cancel(); | ||
} | ||
} |
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