Compare commits

...
21 changed files with 1460 additions and 116 deletions

No files matched your search

@@ -53,8 +53,23 @@ public final class SystemProperties {
public static final double FLYBY_SPEED = parseDouble("angelica.flyby.speed"); // Travel speed in blocks per tick
public static final boolean FLYBY_EXIT_WHEN_DONE = Boolean.getBoolean("angelica.flyby.exitWhenDone");
public static final long FLYBY_TIME_OF_DAY = Math.floorMod(Long.getLong("angelica.flyby.timeOfDay", 6000L), 24000L);
public static final boolean FLYBY_FREEZE_ENTITIES = !"false".equalsIgnoreCase(System.getProperty("angelica.flyby.freezeEntities", "true"));
public static final long FLYBY_SEED = Long.getLong("angelica.flyby.seed", 0xA9CE71CAL); // 0 leaves the world RNG alone
public static final String FLYBY_MOBS = System.getProperty("angelica.flyby.mobs", "");
public static final int FLYBY_CHUNK_WAIT_TIMEOUT_TICKS = Integer.getInteger("angelica.flyby.chunkWaitTimeoutTicks", 2400);
public static final boolean FLYBY_FLY_ROUTE_WHILE_LOADING = Boolean.getBoolean("angelica.flyby.flyRouteWhileLoading");
public static final boolean FLYBY_FREEZE_BLOCK_TICKS = !"false".equalsIgnoreCase(System.getProperty("angelica.flyby.freezeBlockTicks", "true"));
public static final boolean FLYBY_MEASURED_WINDOW_ONLY = Boolean.getBoolean("angelica.flyby.measuredWindowOnly");
public static final int FLYBY_RUNS = Integer.getInteger("angelica.flyby.runs", 1);
public static final int FLYBY_COOLDOWN_TICKS = Integer.getInteger("angelica.flyby.cooldownTicks", 600);
public static final boolean FLYBY_RELOAD_RENDERER = !"false".equalsIgnoreCase(System.getProperty("angelica.flyby.reloadRenderer", "true"));
public static final boolean FLYBY_DISCARD_WORLD_CHANGES = !"false".equalsIgnoreCase(System.getProperty("angelica.flyby.discardWorldChanges", "true"));
public static final String FLYBY_TRACY_TOOLS_DIR = System.getProperty("angelica.flyby.tracyToolsDir", "");
public static final String FLYBY_TRACE_DIR = System.getProperty("angelica.flyby.traceDir", "tracy");
public static final int FLYBY_TRACY_MEMORY_PERCENT = Math.clamp(Integer.getInteger("angelica.flyby.tracyMemoryPercent", 50), 1, 999);
// Debug
private static final boolean DEBUG_TOOLING_PROP = Boolean.getBoolean("angelica.debug.tooling");
public static final boolean LWJGL_DEBUG = Boolean.getBoolean("org.lwjgl.util.Debug");
public static final boolean DEBUG_MARKERS = Boolean.getBoolean("angelica.debug.markers");
public static final boolean DEBUG_F3_DETAIL = Boolean.getBoolean("angelica.debug.f3Detail");
@@ -126,6 +141,10 @@ public final class SystemProperties {
}
}
public static boolean debugTooling() {
return DEBUG_TOOLING_PROP || isDeobf();
}
public static boolean isDeobf() {
return Launch.blackboard != null && Boolean.TRUE.equals(Launch.blackboard.get("fml.deobfuscatedEnvironment"));
}
@@ -28,12 +28,18 @@ public final class CaptureGate {
private CaptureGate() {}
public static volatile boolean suppressed;
public static void refresh() {
markersThisFrame = gateValue(FORCED, TOOL_ATTACHED, Tracy.isConnected());
markersThisFrame = gateValue(FORCED, TOOL_ATTACHED, Tracy.isConnected(), suppressed);
}
static boolean gateValue(boolean forced, boolean toolAttached, boolean tracyConnected) {
return forced || toolAttached || tracyConnected;
return gateValue(forced, toolAttached, tracyConnected, false);
}
static boolean gateValue(boolean forced, boolean toolAttached, boolean tracyConnected, boolean suppressed) {
return !suppressed && (forced || toolAttached || tracyConnected);
}
public static boolean enabledAtStartup() {
@@ -494,9 +494,7 @@ public final class GLDebug {
@Override
public void popGroup() {
if (depth - 1 < 0) {
throw new RuntimeException("Stack underflow");
}
if (depth == 0) return;
BackendManager.RENDER_BACKEND.popDebugGroup();
depth--;
groupStack[depth] = null;
@@ -31,6 +31,17 @@ class CaptureGateTest {
assertTrue(CaptureGate.gateValue(false, false, true));
}
@Test
void suppressionBeatsEveryReasonToBeOn() {
assertFalse(CaptureGate.gateValue(true, true, true, true));
}
@Test
void suppressionOffLeavesTheGateAlone() {
assertTrue(CaptureGate.gateValue(false, false, true, false));
assertFalse(CaptureGate.gateValue(false, false, false, false));
}
@Test
void envDetectionMatchesRenderDocVariables() {
assertTrue(CaptureGate.detectFromEnv(k -> "RENDERDOC_CAPTURE_KEYPRESS".equals(k) ? "1" : null));
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.commands;
// Debug commands adapted from Beddium by Ven and FalsePattern
import com.gtnewhorizons.angelica.config.SystemProperties;
import com.gtnewhorizons.angelica.debug.ChunkDebugMinimap;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRoute;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
@@ -33,7 +34,7 @@ public class AngelicaCommand extends CommandBase {
@Override
public int getRequiredPermissionLevel() {
return 2; // op
return 0;
}
@Override
@@ -95,8 +96,14 @@ public class AngelicaCommand extends CommandBase {
return;
}
if (FlybyRunner.cannotRun()) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED
+ "[Angelica] Flyby is singleplayer only!!"));
return;
}
if (args.length < 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE + "Usage: /angelica flyby <" + FlybyRoute.ids() + "|cancel> [length] [blocksPerTick]"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE + "Usage: /angelica flyby <" + FlybyRoute.ids() + "|cancel> [length] [blocksPerTick] [Pig*24@10]"));
for (FlybyRoute r : FlybyRoute.values()) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + " " + r.id() + " - default " + r.defaultLength() + " " + r.lengthUnit()));
}
@@ -111,31 +118,57 @@ public class AngelicaCommand extends CommandBase {
}
int length = 0;
if (args.length >= 3) {
try {
length = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[Angelica] Not a length: " + args[2]));
return;
}
}
double speed = 0.0D;
if (args.length >= 4) {
String mobs = "";
boolean confirmed = false;
int numbersSeen = 0;
for (int i = 2; i < args.length; i++) {
final String arg = args[i];
if ("confirm".equalsIgnoreCase(arg)) {
confirmed = true;
continue;
}
if (arg.indexOf('*') > 0) {
mobs = mobs.isEmpty() ? arg : mobs + "," + arg;
continue;
}
try {
speed = Double.parseDouble(args[3]);
if (numbersSeen == 0) {
length = Integer.parseInt(arg);
} else if (numbersSeen == 1) {
speed = Double.parseDouble(arg);
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[Angelica] Too many numbers: " + arg));
return;
}
numbersSeen++;
} catch (NumberFormatException e) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[Angelica] Not a speed: " + args[3]));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED
+ "[Angelica] Expected a number or a mob group like Pig*24@10, got: " + arg));
return;
}
}
FlybyRunner.INSTANCE.start(route, length, 0, speed);
final int used = length > 0 ? length : route.defaultLength();
if (!mobs.isEmpty() && !SystemProperties.FLYBY_DISCARD_WORLD_CHANGES && !confirmed) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED
+ "[Angelica] '" + mobs + "' kills every non-player entity in every loaded dimension."));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED
+ "[Angelica] angelica.flyby.discardWorldChanges is off, so this will be written to the save."));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW
+ "[Angelica] Add 'confirm' to the end of the command to run."));
return;
}
final String chosenMobs = mobs.isEmpty() ? SystemProperties.FLYBY_MOBS : mobs;
FlybyRunner.INSTANCE.start(route, used, SystemProperties.FLYBY_WARMUP_TICKS, speed, chosenMobs);
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "[Angelica] " + EnumChatFormatting.WHITE
+ "Flyby started: " + route.id() + " for " + used + " " + route.lengthUnit()
+ " at " + route.speedOr(speed) + " b/t"
+ " (" + route.toTicks(used, speed) + " ticks)"));
+ " (" + route.toTicks(used, speed) + " ticks)"
+ ", seed=" + (SystemProperties.FLYBY_SEED == 0L ? "off" : Long.toHexString(SystemProperties.FLYBY_SEED))
+ ", freezeEntities=" + SystemProperties.FLYBY_FREEZE_ENTITIES
+ ", mobs=" + (chosenMobs.isEmpty() ? "none" : chosenMobs)));
}
private void sendHelp(ICommandSender sender) {
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,112 @@
package com.gtnewhorizons.angelica.debug.flyby;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.backend.BackendManager;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
import net.coderbot.iris.Iris;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;
import org.lwjgl.opengl.GL11;
import java.lang.management.ManagementFactory;
import java.lang.management.GarbageCollectorMXBean;
import java.util.ArrayList;
import java.util.List;
/**
* List all settings that could affect a Tracy profile.
*/
final class FlybySettings {
private FlybySettings() {}
static String describe() {
final Minecraft mc = Minecraft.getMinecraft();
final GameSettings gs = mc.gameSettings;
final SodiumGameOptions options = ClientProxy.options();
final List<String> parts = new ArrayList<>(40);
parts.add("backend=" + backendName());
parts.add("gpu=" + glString(GL11.GL_RENDERER));
parts.add("driver=" + glString(GL11.GL_VERSION));
parts.add("cpus=" + Runtime.getRuntime().availableProcessors());
parts.add("window=" + mc.displayWidth + "x" + mc.displayHeight);
parts.add("renderDistance=" + gs.renderDistanceChunks);
parts.add("guiScale=" + gs.guiScale);
parts.add("fov=" + gs.fovSetting);
parts.add("fancyGraphics=" + gs.fancyGraphics);
parts.add("ambientOcclusion=" + gs.ambientOcclusion);
parts.add("mipmapLevels=" + gs.mipmapLevels);
parts.add("particles=" + gs.particleSetting);
parts.add("anaglyph=" + gs.anaglyph);
parts.add("fbo=" + gs.fboEnable);
parts.add("shaders=" + shaderPackName());
parts.add("chunkBuilderThreads=" + options.performance.chunkBuilderThreads);
parts.add("asyncOcclusion=" + options.performance.asyncOcclusionMode);
parts.add("occlusionCulling=" + options.performance.useOcclusionCulling);
parts.add("entityCulling=" + options.performance.useEntityCulling);
parts.add("tesrCulling=" + options.performance.sectionGatedTesrCulling);
parts.add("fogOcclusion=" + options.performance.useFogOcclusion);
parts.add("translucencySorting=" + options.performance.translucencySorting);
parts.add("deferChunkUpdates=" + options.performance.alwaysDeferChunkUpdates);
parts.add("compactVertexFormat=" + options.performance.useCompactVertexFormat);
parts.add("renderPassOptimization=" + options.performance.useRenderPassOptimization);
parts.add("renderAhead=" + options.performance.cpuRenderAheadLimit);
parts.add("multidraw=" + options.advanced.useChunkMultidraw + "/" + options.advanced.multiDrawMode);
parts.add("uploadStrategy=" + options.advanced.streamingUploadStrategy);
parts.add("deferredBatching=" + options.advanced.enableDeferredBatching);
parts.add("vao=" + options.advanced.useVertexArrayObjects);
parts.add("grassQuality=" + options.quality.grassQuality);
parts.add("smoothLighting=" + options.quality.useCeleritasSmoothLighting);
parts.add("textureFilter=" + SodiumGameOptions.effectiveTextureFilterMode());
parts.add("java=" + System.getProperty("java.version"));
parts.add("maxHeap=" + (Runtime.getRuntime().maxMemory() >> 20) + "M");
parts.add("gc=" + garbageCollectors());
return String.join(" ", parts);
}
static String tag(String description) {
return String.format("%08x", description.hashCode());
}
private static String glString(int pname) {
try {
final String value = BackendManager.RENDER_BACKEND.getString(pname);
return value == null ? "unknown" : value.replace(' ', '-');
} catch (RuntimeException | LinkageError e) {
return "unknown";
}
}
private static String backendName() {
try {
return BackendManager.RENDER_BACKEND.getName();
} catch (RuntimeException | LinkageError e) {
return "unknown";
}
}
private static String shaderPackName() {
if (!AngelicaConfig.enableIris) return "iris-disabled";
try {
if (Iris.getIrisConfig() == null || !Iris.getIrisConfig().areShadersEnabled()) return "off";
final String name = Iris.getCurrentPackName();
return name == null ? "none" : name;
} catch (RuntimeException | LinkageError e) {
return "unknown";
}
}
private static String garbageCollectors() {
final List<String> names = new ArrayList<>(4);
for (GarbageCollectorMXBean bean : ManagementFactory.getGarbageCollectorMXBeans()) {
names.add(bean.getName().replace(' ', '-'));
}
return names.isEmpty() ? "unknown" : String.join("+", names);
}
}
@@ -0,0 +1,164 @@
package com.gtnewhorizons.angelica.debug.flyby;
import com.gtnewhorizons.angelica.config.SystemProperties;
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
import net.minecraft.client.Minecraft;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
/**
* Runs tracy-capture and makes .tracy files.
*/
final class TracyCaptureProcess {
private static final Logger LOGGER = LogManager.getLogger("Angelica/Flyby");
private static final String TOOL_NAME = "tracy-capture";
private static final long SAVE_TIMEOUT_MS = 180_000L;
private static final int PID_POLLS = 40;
private static final long PID_POLL_MS = 50L;
private Boolean configured;
private File tool;
private File traceDir;
private File pidFile;
private String stamp;
private Process process;
private File traceFile;
boolean isConfigured() {
if (this.configured == null) this.configured = resolve();
return this.configured;
}
private boolean resolve() {
final String toolsDir = SystemProperties.FLYBY_TRACY_TOOLS_DIR;
if (toolsDir.isEmpty()) return false;
if (System.getProperty("os.name", "").toLowerCase(Locale.ROOT).contains("win")) {
LOGGER.error("angelica.flyby.tracyToolsDir is set, but the Windows side isn't set up yet. Might do later.");
return false;
}
if (!Tracy.ENABLED) {
LOGGER.error("angelica.flyby.tracyToolsDir is set but the Tracy backend is off. Add -Dangelica.tracy=true.");
return false;
}
final File candidate = new File(toolsDir, TOOL_NAME);
if (!candidate.canExecute()) {
LOGGER.error("No executable {} in '{}'.", TOOL_NAME, toolsDir);
return false;
}
final File dir = resolveTraceDir();
if (!dir.isDirectory() && !dir.mkdirs()) {
LOGGER.error("Could not create the trace folder '{}', per-run capture is off", dir);
return false;
}
this.tool = candidate;
this.traceDir = dir;
this.stamp = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.ROOT).format(new Date());
LOGGER.info("Capturing every run with {} into {}", candidate, dir);
return true;
}
private static File resolveTraceDir() {
final File configured = new File(SystemProperties.FLYBY_TRACE_DIR);
return configured.isAbsolute() ? configured : new File(Minecraft.getMinecraft().mcDataDir, SystemProperties.FLYBY_TRACE_DIR);
}
void start(String route, int run, int runs) {
if (this.process != null || !isConfigured()) return;
this.traceFile = nextTraceFile(route, run, runs);
this.pidFile = new File(this.traceDir, this.traceFile.getName() + ".pid");
try {
final ProcessBuilder builder = new ProcessBuilder("sh", "-c",
"echo $$ > \"$0\"; exec \"$1\" -a 127.0.0.1 -o \"$2\" -f -m \"$3\"",
this.pidFile.getAbsolutePath(), this.tool.getAbsolutePath(), this.traceFile.getAbsolutePath(),
String.valueOf(SystemProperties.FLYBY_TRACY_MEMORY_PERCENT));
builder.redirectErrorStream(true);
builder.redirectOutput(ProcessBuilder.Redirect.appendTo(new File(this.traceDir, TOOL_NAME + ".log")));
this.process = builder.start();
LOGGER.info("Capturing run {}/{} to {}", run, runs, this.traceFile.getName());
} catch (IOException e) {
LOGGER.error("Could not launch " + TOOL_NAME, e);
this.configured = Boolean.FALSE;
this.process = null;
}
}
void stop() {
final Process running = this.process;
if (running == null) return;
this.process = null;
final String pid = readPid();
if (pid == null) {
LOGGER.error("{} never wrote its pid, so {} cannot be saved", TOOL_NAME, this.traceFile);
running.destroy();
return;
}
try {
new ProcessBuilder("kill", "-INT", pid).start().waitFor();
if (!running.waitFor(SAVE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
LOGGER.error("{} did not finish saving {} within {}s", TOOL_NAME, this.traceFile, SAVE_TIMEOUT_MS / 1000L);
running.destroyForcibly();
return;
}
} catch (IOException e) {
LOGGER.error("Could not stop " + TOOL_NAME, e);
return;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
} finally {
if (!this.pidFile.delete()) this.pidFile.deleteOnExit();
}
final long bytes = this.traceFile.length();
if (bytes == 0L) {
LOGGER.error("{} exited but {} is empty, check {}", TOOL_NAME, this.traceFile, new File(this.traceDir, TOOL_NAME + ".log"));
} else {
LOGGER.info("Saved {} ({} MB)", this.traceFile.getName(), bytes >> 20);
}
}
private String readPid() {
for (int poll = 0; poll < PID_POLLS; poll++) {
if (this.pidFile.isFile()) {
try {
final String pid = Files.readString(this.pidFile.toPath()).trim();
if (!pid.isEmpty()) return pid;
} catch (IOException ignored) {
}
}
try {
Thread.sleep(PID_POLL_MS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return null;
}
}
return null;
}
private File nextTraceFile(String route, int run, int runs) {
final String base = route + "-" + this.stamp + "-run" + run + "of" + runs;
File file = new File(this.traceDir, base + ".tracy");
for (int copy = 2; file.exists(); copy++) {
file = new File(this.traceDir, base + "-" + copy + ".tracy");
}
return file;
}
}
@@ -212,12 +212,6 @@ public final class AngelicaClientTweaker implements IFMLLoadingPlugin, IEarlyMix
* Returns the appropriate name according to current environment's obfuscation
*/
public static String obf(String deobf, String obf) {
if (OBF_ENV == null) {
throw new IllegalStateException("Obfuscation state has been accessed too early!");
}
if (OBF_ENV) {
return obf;
}
return deobf;
return isObfEnv() ? obf : deobf;
}
}
@@ -242,6 +242,26 @@ public enum Mixins implements IMixins {
, "celeritas.debug.MixinGLDebug"
)
),
ANGELICA_FLYBY_FREEZE(new MixinBuilder("Freeze entity AI for the flyby benchmark")
.setPhase(Phase.EARLY)
.setApplyIf(() -> SystemProperties.debugTooling() && SystemProperties.FLYBY_FREEZE_ENTITIES)
.addClientMixins("angelica.debug.MixinWorld_FlybyFreeze", "angelica.debug.MixinEntityLivingBase_FlybyFreeze")
),
ANGELICA_FLYBY_FREEZE_BLOCK_TICKS(new MixinBuilder("Freeze block ticks for flyby benchmarks")
.setPhase(Phase.EARLY)
.setApplyIf(() -> SystemProperties.debugTooling() && SystemProperties.FLYBY_FREEZE_BLOCK_TICKS)
.addClientMixins("angelica.debug.MixinWorldServer_FlybyFreeze")
),
ANGELICA_FLYBY_SEED(new MixinBuilder("Lets the flyby benchmark seed the world's random tick counter")
.setPhase(Phase.EARLY)
.setApplyIf(() -> SystemProperties.debugTooling() && SystemProperties.FLYBY_SEED != 0L)
.addClientMixins("angelica.debug.MixinWorld_UpdateLCG")
),
ANGELICA_FLYBY_DISCARD_WORLD_CHANGES(new MixinBuilder("Prevent world saving so runs start in the same exact conditions")
.setPhase(Phase.EARLY)
.setApplyIf(() -> SystemProperties.debugTooling() && SystemProperties.FLYBY_DISCARD_WORLD_CHANGES)
.addClientMixins("angelica.debug.MixinSaveHandler_FlybyDiscard", "angelica.debug.MixinAnvilChunkLoader_FlybyDiscard")
),
ANGELICA_DYNAMIC_LIGHTS(new MixinBuilder()
.setPhase(Phase.EARLY)
.setApplyIf(() -> AngelicaConfig.enableDynamicLights)
@@ -0,0 +1,5 @@
package com.gtnewhorizons.angelica.mixins.interfaces;
public interface WorldRandomTickAccessor {
void angelica$setUpdateLCG(int value);
}
@@ -47,6 +47,7 @@ import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
import com.gtnewhorizons.angelica.rendering.tesr.AngelicaTesrMeshCache;
import com.gtnewhorizons.angelica.config.CompatConfig;
import com.gtnewhorizons.angelica.config.ConfigMigrator;
import com.gtnewhorizons.angelica.config.SystemProperties;
import com.gtnewhorizons.angelica.debug.F3Direction;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import com.gtnewhorizons.angelica.debug.FrametimeGraph;
@@ -58,7 +59,6 @@ import com.gtnewhorizons.angelica.glsm.backend.VSyncMode;
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
import com.gtnewhorizons.angelica.iris.IrisGLSMBridge;
import com.gtnewhorizons.angelica.loading.AngelicaClientTweaker;
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
import com.gtnewhorizons.angelica.render.CloudRenderer;
import com.gtnewhorizons.angelica.render.EmissiveTextureAutoloader;
@@ -98,12 +98,6 @@ import net.coderbot.iris.client.IrisDebugScreenHandler;
public final class ClientProxy extends CommonProxy {
/**
* So you don't need to be in a dev env to have access to the commands.
* Do not commit with this set to true.
*/
private static final boolean FORCE_DEBUG_MODE = false;
public static BlockError blockError;
public static final ManagedEnum<AnimationMode> animationsMode = new ManagedEnum<>(AnimationMode.VISIBLE_ONLY);
private static final Logger LOGGER = LogManager.getLogger("Angelica");
@@ -199,10 +193,11 @@ public final class ClientProxy extends CommonProxy {
}
// Debug tooling
if (FORCE_DEBUG_MODE || !AngelicaClientTweaker.isObfEnv()) {
if (SystemProperties.debugTooling()) {
ClientCommandHandler.instance.registerCommand(new AngelicaCommand());
FMLCommonHandler.instance().bus().register(FlybyRunner.INSTANCE);
MinecraftForge.EVENT_BUS.register(FlybyRunner.INSTANCE);
FlybyRunner.INSTANCE.startFromProperties();
}
}
@@ -22,7 +22,13 @@ import org.embeddedt.embeddium.impl.gl.device.CommandList;
import org.embeddedt.embeddium.impl.render.chunk.ChunkRenderMatrices;
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
import org.embeddedt.embeddium.impl.render.chunk.RenderSection;
import org.embeddedt.embeddium.impl.render.chunk.ChunkUpdateType;
import org.embeddedt.embeddium.impl.render.chunk.lists.ChunkRebuildLists;
import org.embeddedt.embeddium.impl.render.chunk.lists.RenderListManager;
import org.embeddedt.embeddium.impl.render.chunk.compile.executor.ChunkBuilder;
import org.embeddedt.embeddium.impl.render.chunk.RenderSectionManager;
import org.embeddedt.embeddium.impl.render.chunk.data.BuiltRenderSectionData;
import org.embeddedt.embeddium.impl.render.chunk.occlusion.VisibilityEncoding;
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderTask;
import org.embeddedt.embeddium.impl.render.chunk.lists.SectionTicker;
@@ -91,6 +97,52 @@ public class AngelicaRenderSectionManager extends RenderSectionManager {
this.cameraPosition.set(x, y, z);
}
private boolean isChunkNotLoaded(int chunkX, int chunkZ) {
return this.world.getChunkFromChunkCoords(chunkX, chunkZ).isEmpty();
}
public int getPendingMeshUpdates() {
final ChunkBuilder builder = getBuilder();
return pendingIn(renderListManager)
+ sectionsRequestingUpdate.size()
+ builder.getScheduledJobCount()
+ builder.getBusyThreadCount();
}
public String describePendingMeshUpdates() {
final ChunkBuilder builder = getBuilder();
return "rebuildList=" + pendingIn(renderListManager)
+ " requesting=" + sectionsRequestingUpdate.size()
+ " queued=" + builder.getScheduledJobCount()
+ " busy=" + builder.getBusyThreadCount()
+ " (shadowList=" + (shadowRenderListManager != null ? pendingIn(shadowRenderListManager) : 0) + ", not waited on)";
}
private static int pendingIn(RenderListManager manager) {
final ChunkRebuildLists lists = manager.getRebuildLists();
return lists.getUpdateCount(ChunkUpdateType.INITIAL_BUILD)
+ lists.getUpdateCount(ChunkUpdateType.REBUILD)
+ lists.getUpdateCount(ChunkUpdateType.IMPORTANT_REBUILD)
+ (lists.hasAdditionalUpdates() ? 1 : 0);
}
private static final BuiltRenderSectionData UNLOADED_CHUNK_DATA = unloadedChunkData();
private static BuiltRenderSectionData unloadedChunkData() {
final BuiltRenderSectionData data = new BuiltRenderSectionData();
data.hasBlockGeometry = false;
data.visibilityData = VisibilityEncoding.NULL;
return data;
}
@Override
protected boolean updateSectionInfo(RenderSection section, BuiltRenderSectionData data) {
if (data == RenderSection.EMPTY_DATA && isChunkNotLoaded(section.getChunkX(), section.getChunkZ())) {
data = UNLOADED_CHUNK_DATA;
}
return super.updateSectionInfo(section, data);
}
@Override
public void update(Viewport positionedViewport, int frame, boolean spectator) {
if (isInShadowPass()) {
@@ -264,6 +264,11 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
}
private CameraState lastMainCameraState;
private boolean pendingReload;
public void requestReload() {
this.pendingReload = true;
}
@Override
public void setupTerrain(Viewport viewport, CameraState cameraState, int frame, boolean spectator, boolean updateChunksImmediately) {
@@ -273,6 +278,12 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
return;
}
if (this.pendingReload && !renderSectionManager.isInShadowPass()) {
this.pendingReload = false;
renderSectionManager.finishAllGraphUpdates();
this.reload();
}
renderSectionManager.setCameraPosition(transform.x, transform.y, transform.z);
this.useEntityCulling = ClientProxy.options().performance.useEntityCulling;
@@ -15,6 +15,7 @@ import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.settings.GameSettings;
import org.embeddedt.embeddium.impl.render.frame.RenderAheadManager;
import org.lwjgl.input.Keyboard;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
@@ -82,7 +83,8 @@ public abstract class MixinMinecraft {
}
FpsReducer.evaluateFrame();
final int capHz = FpsReducer.effectiveCap(gameSettings.limitFramerate, theWorld == null && currentScreen != null);
final int capHz = FlybyRunner.pacingSuppressed() ? 0
: FpsReducer.effectiveCap(gameSettings.limitFramerate, theWorld == null && currentScreen != null);
AngelicaMod.proxy.putFrametime(FramePacer.endFrame(capHz, angelica$renderAheadWait));
return !FramePacer.pacedLastFrame();
}
@@ -0,0 +1,22 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* Prevent world saves.
*/
@Mixin(AnvilChunkLoader.class)
public abstract class MixinAnvilChunkLoader_FlybyDiscard {
@Inject(method = "saveChunk", at = @At("HEAD"), cancellable = true)
private void angelica$flybyDiscardChunk(World world, Chunk chunk, CallbackInfo ci) {
if (FlybyRunner.worldChangesDiscarded()) ci.cancel();
}
}
@@ -0,0 +1,23 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import net.minecraft.util.DamageSource;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.EntityLivingBase;
/**
* Make mobs invulnerable when frozen. They die if in a wall or due to entity cramming.
*/
@Mixin(EntityLivingBase.class)
public abstract class MixinEntityLivingBase_FlybyFreeze {
@Inject(method = "attackEntityFrom", at = @At("HEAD"), cancellable = true)
private void angelica$flybyInvulnerable(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (FlybyRunner.entitiesFrozen()) {
cir.setReturnValue(false);
}
}
}
@@ -0,0 +1,33 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* Don't corrupt player data and positions.
*/
@Mixin(SaveHandler.class)
public abstract class MixinSaveHandler_FlybyDiscard {
@Inject(method = "writePlayerData", at = @At("HEAD"), cancellable = true)
private void angelica$flybyDiscardPlayer(EntityPlayer player, CallbackInfo ci) {
if (FlybyRunner.worldChangesDiscarded()) ci.cancel();
}
@Inject(method = "saveWorldInfoWithPlayer", at = @At("HEAD"), cancellable = true)
private void angelica$flybyDiscardLevelWithPlayer(WorldInfo info, NBTTagCompound playerData, CallbackInfo ci) {
if (FlybyRunner.worldChangesDiscarded()) ci.cancel();
}
@Inject(method = "saveWorldInfo", at = @At("HEAD"), cancellable = true)
private void angelica$flybyDiscardLevel(WorldInfo info, CallbackInfo ci) {
if (FlybyRunner.worldChangesDiscarded()) ci.cancel();
}
}
@@ -0,0 +1,22 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
/**
* Stop blocks from ticking.
*/
@Mixin(WorldServer.class)
public abstract class MixinWorldServer_FlybyFreeze {
@Redirect(
method = "func_147456_g",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getNeedsRandomTick()Z"))
private boolean angelica$skipRandomBlockTicks(ExtendedBlockStorage storage) {
return !FlybyRunner.blockTicksFrozen() && storage.getNeedsRandomTick();
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.debug.flyby.FlybyRunner;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* Freeze anything but the player for better, more reproducible runs.
*/
@Mixin(World.class)
public abstract class MixinWorld_FlybyFreeze {
@Inject(method = "updateEntityWithOptionalForce", at = @At("HEAD"), cancellable = true)
private void angelica$flybyFreeze(Entity entity, boolean force, CallbackInfo ci) {
if (FlybyRunner.entitiesFrozen() && !(entity instanceof EntityPlayer)) {
ci.cancel();
}
}
}
@@ -0,0 +1,14 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.debug;
import com.gtnewhorizons.angelica.mixins.interfaces.WorldRandomTickAccessor;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(World.class)
public interface MixinWorld_UpdateLCG extends WorldRandomTickAccessor {
@Accessor("updateLCG")
@Override
void angelica$setUpdateLCG(int value);
}