From 77510755bfb18ceeeda59be43ec571a94551e2e1 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 4 Oct 2026 01:27:45 +0200 Subject: [PATCH] Capture effective terrain quality and shader state at benchmark boundaries --- README.md | 6 +- docs/terrain-measurements.md | 37 ++++++++++++ .../client/DistantTerrainSettings.java | 46 +++++++++++++++ .../dev/horizonlab/client/HorizonClient.java | 51 ++++++++++++---- .../dev/horizonlab/client/ShaderSettings.java | 28 +++++++++ .../src/main/resources/fabric.mod.json | 2 +- .../client/DistantTerrainSettingsTest.java | 59 +++++++++++++++++++ packs/START-HERE.txt | 7 +++ packs/mods.lock.json | 2 +- tests/test_packs.py | 16 +++++ tools/Compare-Benchmarks.html | 19 +++++- tools/build_mod.py | 3 + tools/compare_benchmarks.py | 18 +++++- 13 files changed, 277 insertions(+), 17 deletions(-) create mode 100644 docs/terrain-measurements.md create mode 100644 mods/horizon-lab/src/main/java/dev/horizonlab/client/DistantTerrainSettings.java create mode 100644 mods/horizon-lab/src/main/java/dev/horizonlab/client/ShaderSettings.java create mode 100644 mods/horizon-lab/src/test/java/dev/horizonlab/client/DistantTerrainSettingsTest.java diff --git a/README.md b/README.md index 325627cac..a58864662 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Client-first performance research for Minecraft Java **26.3**, preserving vanill ## Play on your Mac -Download **horizon-mac-starter-0.11.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials. +Download **horizon-mac-starter-0.12.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials. Use native **Java 25 ARM64**, maximum heap **6144 MiB**, minimum **512 MiB** on your 16 GB M2 Pro. Prism can download Java automatically. Start at 1280×800 or 1920×1200; full Retina resolution is a larger GPU workload. [START-HERE.txt](packs/START-HERE.txt) has details. The same `.mrpack` files import into Prism on Windows and Linux. @@ -33,6 +33,10 @@ Distant LOD is simplified terrain. Nearby blocks retain full detail. Initial gen The optional `queue-wait` pack yields during pending distant-terrain debounce retries; `adaptive-queue` combines it with the existing controllers. [Queue experiment and measurement limits](docs/debounce-queue.md). +Version 0.12 captures effective distant-terrain quality, radius, worker budgets, +Iris state and field of view. Start/end snapshots flag changed visual settings; +[measurement details](docs/terrain-measurements.md) explain their limits. + Version 0.11 adds combined foreground-first OpenGL/Vulkan profiles with a 120 FPS adaptive goal, plus explicit collector experiments and GC measurement guidance. See [combined controls](docs/foreground-first.md), [Vulkan on your Mac](docs/vulkan.md) diff --git a/docs/terrain-measurements.md b/docs/terrain-measurements.md new file mode 100644 index 000000000..9d3314fdd --- /dev/null +++ b/docs/terrain-measurements.md @@ -0,0 +1,37 @@ +# Capture terrain quality as well as speed + +Version 0.12 adds effective DH configuration to frame reports: LOD radius, +horizontal/vertical quality, maximum horizontal resolution, renderer mode, +rendering enable setting, transparency, shading, ambient occlusion, LOD-only +mode, camera quality falloff, worker count and runtime ratio. It reads the +actual public API values, including active overrides. Pack names and TOML files +alone do not establish which settings reached the running game. + +Reports also capture configured field of view and optional Iris enabled state. +An enabled Iris pack's name is included when available. Iris is queried through +its public API; missing or incompatible APIs are marked unavailable, rather than +assumed disabled. Other shader frameworks are not observed by this adapter. + +Visual settings are read at recording start and finish. The final snapshot is +stored in `visual_settings_end`; `visual_settings_changed` lists detected changes. +The viewer and strict CLI flag these runs as mismatched. An adaptive runtime-ratio +change is expected and is displayed separately; it is not treated as a visual +quality change. Snapshots cannot detect a change that was restored before the +end. Keep settings fixed and avoid menus during the actual comparison. + +The comparison tools check captured DH/Iris quality fields, and report different +worker budgets or controller settings as experiment variables. Older reports +without these fields show unknown quality/shader equivalence. A vanilla baseline +without DH versus a distant-terrain profile intentionally has different visual +work: inspect that difference rather than presenting it as equal draw settings. + +These are configuration observations, not counts of visible geometry, completed +terrain or GPU timings. A 128-chunk configured radius does not prove every chunk +has generated or drawn. Warm-up, world/route equivalence, occlusion, terrain cache, +weather, actual visual detail and external shader frameworks still need testing. +Base FOV does not capture every transient sprint/zoom camera effect. + +The adapter reads at capture boundaries on the owning client thread. It performs +no per-frame polling and changes no settings. Tests exercise the pinned upstream +API contracts, effective overrides, absent/unavailable APIs and comparison +mismatches. Game smoke checks validate the actual captured values separately. diff --git a/mods/horizon-lab/src/main/java/dev/horizonlab/client/DistantTerrainSettings.java b/mods/horizon-lab/src/main/java/dev/horizonlab/client/DistantTerrainSettings.java new file mode 100644 index 000000000..28c9e7c56 --- /dev/null +++ b/mods/horizon-lab/src/main/java/dev/horizonlab/client/DistantTerrainSettings.java @@ -0,0 +1,46 @@ +package dev.horizonlab.client; + +import com.seibel.distanthorizons.api.DhApi; +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfig; +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue; +import java.util.LinkedHashMap; +import java.util.Map; + +/** Read effective API values once at capture boundaries; never change terrain settings. */ +final class DistantTerrainSettings { + private DistantTerrainSettings() {} + + static Map read() { return read(DhApi.Delayed.configs); } + + static Map read(IDhApiConfig configs) { + if (configs == null) return Map.of("dh_capture_status", "unavailable"); + Map values = new LinkedHashMap<>(); + try { + var graphics = configs.graphics(); + put(values, "dh_rendering_enabled", graphics.renderingEnabled()); + put(values, "dh_renderer_mode", graphics.renderingMode()); + put(values, "dh_lod_radius_chunks", graphics.chunkRenderDistance()); + put(values, "dh_horizontal_quality", graphics.horizontalQuality()); + put(values, "dh_vertical_quality", graphics.verticalQuality()); + put(values, "dh_max_horizontal_resolution", graphics.maxHorizontalResolution()); + put(values, "dh_transparency", graphics.transparency()); + put(values, "dh_lod_shading", graphics.lodShading()); + put(values, "dh_lod_only_mode", graphics.lodOnlyMode()); + put(values, "dh_camera_quality_dropoff", graphics.useCameraPositionForQualityDropOff()); + put(values, "dh_ambient_occlusion", graphics.ambientOcclusion().enabled()); + put(values, "dh_thread_count", configs.multiThreading().threadCount()); + put(values, "dh_runtime_ratio", configs.multiThreading().threadRuntimeRatio()); + values.put("dh_capture_status", "available"); + return values; + } catch (RuntimeException | LinkageError unavailable) { + // Missing/changed APIs must not look like disabled rendering or a zero distance. + return Map.of("dh_capture_status", "unavailable"); + } + } + + private static void put(Map target, String name, IDhApiConfigValue setting) { + Object value = setting.getValue(); // Includes active overrides; getTrueValue reads only the user base. + if (value == null) throw new IllegalStateException("Unavailable configuration value"); + target.put(name, value instanceof Enum choice ? choice.name() : value); + } +} diff --git a/mods/horizon-lab/src/main/java/dev/horizonlab/client/HorizonClient.java b/mods/horizon-lab/src/main/java/dev/horizonlab/client/HorizonClient.java index 0f361ecf7..5582a17a6 100644 --- a/mods/horizon-lab/src/main/java/dev/horizonlab/client/HorizonClient.java +++ b/mods/horizon-lab/src/main/java/dev/horizonlab/client/HorizonClient.java @@ -97,6 +97,23 @@ public final class HorizonClient implements ClientModInitializer { context.put("wakeable_idle_wait", dev.horizonlab.mixin.HorizonMixinPlugin.debounceWaitEnabled()); context.put("dispatch_retry_backoff", dev.horizonlab.mixin.HorizonMixinPlugin.dispatchRetryEnabled()); context.put("adaptive_target_fps", targetFps); + context.putAll(visualSettings(client)); + var device = RenderSystem.getDevice().getDeviceInfo(); + context.put("gpu", device.name()); + context.put("graphics_backend", device.backendName()); + context.put("graphics_driver", device.driverInfo()); + context.put("mods", FabricLoader.getInstance().getAllMods().stream() + .map(mod -> mod.getMetadata().getId() + "@" + mod.getMetadata().getVersion().getFriendlyString()) + .sorted().toList()); + frames = new Recording(label, "frames", output, seconds, context); + previousStart = 0; + if (client.getSingleplayerServer() != null) HorizonLab.startTicks(label, seconds, output, profile); + message("Recording " + seconds + " seconds. Close chat, keep the game focused, and run your route."); + return 1; + } + + private static Map visualSettings(Minecraft client) { + Map context = new LinkedHashMap<>(); context.put("render_distance", client.options.renderDistance().get()); context.put("simulation_distance", client.options.simulationDistance().get()); context.put("vsync", client.options.enableVsync().get()); @@ -104,10 +121,6 @@ public final class HorizonClient implements ClientModInitializer { context.put("fps_limit_unlimited", client.options.framerateLimit().get() >= Options.UNLIMITED_FRAMERATE_CUTOFF); context.put("framebuffer_width", client.getWindow().getWidth()); context.put("framebuffer_height", client.getWindow().getHeight()); - var device = RenderSystem.getDevice().getDeviceInfo(); - context.put("gpu", device.name()); - context.put("graphics_backend", device.backendName()); - context.put("graphics_driver", device.driverInfo()); context.put("graphics_preset", client.options.graphicsPreset().get().toString()); context.put("ambient_occlusion", client.options.ambientOcclusion().get()); context.put("improved_transparency", client.options.improvedTransparency().get()); @@ -117,14 +130,14 @@ public final class HorizonClient implements ClientModInitializer { context.put("particles", client.options.particles().get().toString()); context.put("clouds", client.options.cloudStatus().get().toString()); context.put("cloud_range", client.options.cloudRange().get()); - context.put("mods", FabricLoader.getInstance().getAllMods().stream() - .map(mod -> mod.getMetadata().getId() + "@" + mod.getMetadata().getVersion().getFriendlyString()) - .sorted().toList()); - frames = new Recording(label, "frames", output, seconds, context); - previousStart = 0; - if (client.getSingleplayerServer() != null) HorizonLab.startTicks(label, seconds, output, profile); - message("Recording " + seconds + " seconds. Close chat, keep the game focused, and run your route."); - return 1; + context.put("fov", client.options.fov().get()); + var loader = FabricLoader.getInstance(); + if (loader.isModLoaded("distanthorizons")) { + try { context.putAll(DistantTerrainSettings.read()); } + catch (RuntimeException | LinkageError unavailable) { context.put("dh_capture_status", "unavailable"); } + } else context.put("dh_capture_status", "not_installed"); + context.putAll(ShaderSettings.read(loader.isModLoaded("iris"))); + return context; } public static void frameStart() { @@ -164,6 +177,20 @@ public final class HorizonClient implements ClientModInitializer { frames = null; previousStart = 0; HorizonLab.finishTicks(); + Map end = visualSettings(Minecraft.getInstance()); + java.util.List changed = new java.util.ArrayList<>(); + for (var setting : end.entrySet()) { + // Adaptive duty cycle is expected to change; visual quality changes are separate. + if (!setting.getKey().equals("dh_runtime_ratio") + && !java.util.Objects.equals(recording.context.get(setting.getKey()), setting.getValue())) + changed.add(setting.getKey()); + } + for (String setting : recording.context.keySet()) { + if ((setting.startsWith("dh_") || setting.startsWith("iris_")) && !end.containsKey(setting)) + changed.add(setting); + } + recording.context.put("visual_settings_end", end); + recording.context.put("visual_settings_changed", changed); Reports.write(recording.finish()).whenComplete((path, error) -> { if (error != null) HorizonLab.LOGGER.error("Frame report failed", error); else { diff --git a/mods/horizon-lab/src/main/java/dev/horizonlab/client/ShaderSettings.java b/mods/horizon-lab/src/main/java/dev/horizonlab/client/ShaderSettings.java new file mode 100644 index 000000000..ec59f63ed --- /dev/null +++ b/mods/horizon-lab/src/main/java/dev/horizonlab/client/ShaderSettings.java @@ -0,0 +1,28 @@ +package dev.horizonlab.client; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** Optional Iris reflection keeps baseline clients independent of shader-mod classes. */ +final class ShaderSettings { + private ShaderSettings() {} + + static Map read(boolean irisPresent) { + if (!irisPresent) return Map.of("iris_capture_status", "not_installed", "iris_shaders_enabled", false); + try { + Class api = Class.forName("net.irisshaders.iris.api.v0.IrisApi"); + Object instance = api.getMethod("getInstance").invoke(null); + boolean enabled = (Boolean) api.getMethod("isShaderPackInUse").invoke(instance); + Map result = new LinkedHashMap<>(); + result.put("iris_capture_status", "available"); + result.put("iris_shaders_enabled", enabled); + if (enabled) { + Class iris = Class.forName("net.irisshaders.iris.Iris"); + result.put("iris_shader_pack", iris.getMethod("getCurrentPackName").invoke(null)); + } + return result; + } catch (ReflectiveOperationException | RuntimeException | LinkageError unavailable) { + return Map.of("iris_capture_status", "unavailable"); + } + } +} diff --git a/mods/horizon-lab/src/main/resources/fabric.mod.json b/mods/horizon-lab/src/main/resources/fabric.mod.json index 5f677c3d8..eaf4711c6 100644 --- a/mods/horizon-lab/src/main/resources/fabric.mod.json +++ b/mods/horizon-lab/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "horizonlab", - "version": "0.11.0", + "version": "0.12.0", "name": "Horizon Lab", "description": "Client frame pacing and server tick measurements for reproducible optimization experiments.", "authors": [ diff --git a/mods/horizon-lab/src/test/java/dev/horizonlab/client/DistantTerrainSettingsTest.java b/mods/horizon-lab/src/test/java/dev/horizonlab/client/DistantTerrainSettingsTest.java new file mode 100644 index 000000000..984a830cf --- /dev/null +++ b/mods/horizon-lab/src/test/java/dev/horizonlab/client/DistantTerrainSettingsTest.java @@ -0,0 +1,59 @@ +package dev.horizonlab.client; + +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfig; +import com.seibel.distanthorizons.api.interfaces.config.IDhApiConfigValue; +import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiAmbientOcclusionConfig; +import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiGraphicsConfig; +import com.seibel.distanthorizons.api.interfaces.config.client.IDhApiMultiThreadingConfig; +import com.seibel.distanthorizons.api.enums.config.*; +import com.seibel.distanthorizons.api.enums.rendering.*; +import java.lang.reflect.Proxy; +import java.util.Map; + +public final class DistantTerrainSettingsTest { + @SuppressWarnings("unchecked") + private static T proxy(Class type, java.lang.reflect.InvocationHandler handler) { + return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, handler); + } + + private static IDhApiConfigValue effective(Object value) { + return proxy(IDhApiConfigValue.class, (p, method, args) -> { + if (method.getName().equals("getValue")) return value; + throw new AssertionError("Capture must read effective overrides, never mutate settings: " + method); + }); + } + + private static void check(boolean condition) { if (!condition) throw new AssertionError(); } + + public static void main(String[] args) { + Map settings = Map.ofEntries( + Map.entry("renderingEnabled", true), Map.entry("renderingMode", EDhApiRendererMode.DEFAULT), + Map.entry("chunkRenderDistance", 256), Map.entry("horizontalQuality", EDhApiHorizontalQuality.MEDIUM), + Map.entry("verticalQuality", EDhApiVerticalQuality.HIGH), Map.entry("maxHorizontalResolution", EDhApiMaxHorizontalResolution.BLOCK), + Map.entry("transparency", EDhApiTransparency.COMPLETE), Map.entry("lodShading", EDhApiLodShading.AUTO), + Map.entry("lodOnlyMode", false), Map.entry("useCameraPositionForQualityDropOff", true)); + var ao = proxy(IDhApiAmbientOcclusionConfig.class, (p, method, values) -> effective(true)); + var graphics = proxy(IDhApiGraphicsConfig.class, (p, method, values) -> + method.getName().equals("ambientOcclusion") ? ao : effective(settings.get(method.getName()))); + var threading = proxy(IDhApiMultiThreadingConfig.class, (p, method, values) -> + effective(method.getName().equals("threadCount") ? (Object) 2 : 0.05)); + var configs = proxy(IDhApiConfig.class, (p, method, values) -> + method.getName().equals("graphics") ? graphics : threading); + Map result = DistantTerrainSettings.read(configs); + check(result.get("dh_capture_status").equals("available")); + check(result.get("dh_lod_radius_chunks").equals(256)); + check(result.get("dh_horizontal_quality").equals("MEDIUM")); + check(result.get("dh_vertical_quality").equals("HIGH")); + check(result.get("dh_runtime_ratio").equals(0.05)); + check(result.get("dh_thread_count").equals(2)); + check(DistantTerrainSettings.read(null).equals(Map.of("dh_capture_status", "unavailable"))); + var missing = proxy(IDhApiConfig.class, (p, method, values) -> { throw new UnsupportedOperationException(); }); + check(DistantTerrainSettings.read(missing).equals(Map.of("dh_capture_status", "unavailable"))); + var changedApi = proxy(IDhApiConfig.class, (p, method, values) -> { throw new NoSuchMethodError(); }); + check(DistantTerrainSettings.read(changedApi).equals(Map.of("dh_capture_status", "unavailable"))); + check(ShaderSettings.read(false).equals(Map.of("iris_capture_status", "not_installed", "iris_shaders_enabled", false))); + // Test classpath deliberately omits Iris; it must report unavailable rather than assume disabled. + check(ShaderSettings.read(true).equals(Map.of("iris_capture_status", "unavailable"))); + System.out.println("Effective terrain settings and absent/unsupported shader APIs checked."); + } +} diff --git a/packs/START-HERE.txt b/packs/START-HERE.txt index 93eca26c3..a330369e3 100644 --- a/packs/START-HERE.txt +++ b/packs/START-HERE.txt @@ -142,3 +142,10 @@ from their publishers with pinned hashes. No decompiled Minecraft is distributed Source, build commands and measured validation: https://github.com/ludovic111/minecraft-optimization-lab + +TERRAIN / SHADER COMPARISONS +Version 0.12 records actual DH radius/quality, worker count/duty cycle, Iris state +and field of view at capture boundaries. If visual settings changed, the viewer +flags the run. Older reports without these fields cannot establish quality +equivalence. Snapshots cannot detect a change that was restored before the end, +and do not prove that all requested distant terrain finished rendering. diff --git a/packs/mods.lock.json b/packs/mods.lock.json index fa968e982..09f26a89a 100644 --- a/packs/mods.lock.json +++ b/packs/mods.lock.json @@ -3,7 +3,7 @@ "minecraft": "26.3", "java_major": 25, "fabric_loader": "0.19.5", - "pack_version": "0.11.0", + "pack_version": "0.12.0", "options_data_version": 5023, "projects": { "sodium": { diff --git a/tests/test_packs.py b/tests/test_packs.py index cb85c5b20..38a6653e1 100644 --- a/tests/test_packs.py +++ b/tests/test_packs.py @@ -158,6 +158,22 @@ class ComparisonTests(unittest.TestCase): result = compare_benchmarks.compare(baseline, candidate) self.assertTrue(any("not captured" in warning for warning in result["warnings"])) + def test_terrain_quality_and_shader_changes_cannot_look_like_equal_workloads(self): + baseline = self.report() + baseline.update(dh_capture_status="available", dh_lod_radius_chunks=128, dh_horizontal_quality="MEDIUM", + iris_capture_status="available", iris_shaders_enabled=False, dh_thread_count=2) + candidate = copy.deepcopy(baseline) + candidate.update(dh_lod_radius_chunks=256, iris_shaders_enabled=True, iris_shader_pack="Example pack", + dh_thread_count=1, visual_settings_changed=["render_distance"]) + result = compare_benchmarks.compare(baseline, candidate) + self.assertTrue(any("dh_lod_radius_chunks" in field for field in result["mismatches"])) + self.assertTrue(any("iris_shaders_enabled" in field for field in result["mismatches"])) + self.assertTrue(any("dh_thread_count differs" in warning for warning in result["warnings"])) + self.assertTrue(any("changed between capture boundaries" in warning for warning in result["warnings"])) + legacy = self.report() + result = compare_benchmarks.compare(legacy, copy.deepcopy(legacy)) + self.assertTrue(any("terrain configuration was not captured" in warning for warning in result["warnings"])) + if __name__ == "__main__": unittest.main() diff --git a/tools/Compare-Benchmarks.html b/tools/Compare-Benchmarks.html index 010ac675f..892c610c3 100644 --- a/tools/Compare-Benchmarks.html +++ b/tools/Compare-Benchmarks.html @@ -30,7 +30,7 @@