From 99d6aae5e06a3fc9a9a69c433f48f32729776861 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 4 Oct 2026 13:09:45 +0200 Subject: [PATCH] Verify actual cinematic shader activation in private world probes --- .github/workflows/macos-shader-research.yml | 46 +++++++++++++++++++ docs/client-graphics-smoke.md | 4 ++ docs/shader-world-smoke.md | 31 +++++++++++++ .../metrics/ClientGraphicsIntegration.java | 27 +++++++++++ tests/test_fixtures.py | 15 +++++- tools/test_client_graphics.py | 27 +++++++++-- 6 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/macos-shader-research.yml create mode 100644 docs/shader-world-smoke.md diff --git a/.github/workflows/macos-shader-research.yml b/.github/workflows/macos-shader-research.yml new file mode 100644 index 000000000..4656e4057 --- /dev/null +++ b/.github/workflows/macos-shader-research.yml @@ -0,0 +1,46 @@ +name: macOS shader research +on: + workflow_dispatch: +permissions: + contents: read +jobs: + shader-worlds: + runs-on: macos-26 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '25' + - name: Build original mod and private probe dependencies + run: python tools/build_mod.py + - name: Verify required cinematic shaders in OpenGL and Vulkan worlds + run: | + python - <<'PY' + import json, subprocess, sys + from pathlib import Path + observations = [] + for backend in ['opengl', 'vulkan']: + case = ['--profile', 'cinematic', '--backend', backend, '--world', '--shaders'] + result = subprocess.run([sys.executable, 'tools/test_client_graphics.py', '--native-display', *case], capture_output=True, text=True) + print(result.stdout, end='', flush=True) + print(result.stderr, end='', flush=True) + observation = {'case': case, 'exit_code': result.returncode} + if result.returncode: + marker = 'HORIZON_FIXTURE_FAILURE ' + observation['failure'] = [json.loads(line.split(marker, 1)[1]) for line in result.stdout.splitlines() if marker in line] + else: + observation['report'] = json.loads(Path('dist/client-graphics-smoke.json').read_text()) + observations.append(observation) + Path('dist/client-graphics-shader-research.json').write_text(json.dumps(observations, indent=2) + '\n') + sys.exit(int(any(item['exit_code'] for item in observations))) + PY + - name: Retain selected observations including failed cases + if: always() + uses: actions/upload-artifact@v4 + with: + name: macos-shader-observations + path: dist/client-graphics-shader-research.json diff --git a/docs/client-graphics-smoke.md b/docs/client-graphics-smoke.md index 7367cfaab..821663474 100644 --- a/docs/client-graphics-smoke.md +++ b/docs/client-graphics-smoke.md @@ -118,3 +118,7 @@ Overrides use separate runtime folders. The shipped profiles retain their configured preferences. These probes make no FPS, CPU/RAM reduction, hardware-GPU compatibility or M2 Pro performance claim. Actual-world performance comparisons still use the [Mac first-test procedure](mac-first-test.md). + +For a shader-enabled world rather than a disabled shader configuration, use the +separate [cinematic shader probe](shader-world-smoke.md). It requires actual Iris +runtime activation and the pinned pack identity. diff --git a/docs/shader-world-smoke.md b/docs/shader-world-smoke.md new file mode 100644 index 000000000..4c73719a5 --- /dev/null +++ b/docs/shader-world-smoke.md @@ -0,0 +1,31 @@ +# Optional shader world probe + +The cinematic pack starts with shaders disabled. A world rendering successfully +with that profile does not establish that its optional shader pack works. +The separate manual **macOS shader research** workflow explicitly enables the +pinned Complementary Reimagined pack in private cinematic instances and probes +OpenGL and Vulkan independently. + +The probe uses Iris's runtime API through the recorder's existing read-only +inspection. Success requires available shader status, an active shader pack, +the exact pinned pack identity, focused world gameplay without an overlay, +nonuniform framebuffer readback, saved world data and a clean exit. A disabled, +unavailable or different pack fails even if ordinary world pixels look valid. +Arbitrary runtime pack names and paths are not exported. + +```sh +python3 tools/build_mod.py +python3 tools/test_client_graphics.py --native-display --profile cinematic --backend opengl --world --shaders +python3 tools/test_client_graphics.py --native-display --profile cinematic --backend vulkan --world --shaders +``` + +Shader instances use separate runtime folders and a 6 GiB maximum heap. Other +graphics probes keep their 3 GiB budget. The fixture reports the actual maximum +heap and observed shader status. Playable packs and their shader defaults are +unchanged. Full logs, PNGs, world files, assets and shader ZIPs stay private. + +The research workflow runs both cases and retains selected failed outcomes. +It fails if either case fails and remains separate from required OpenGL CI. +This is a short initialization/readback/save check, not a shader FPS, physical +M2 GPU, exhaustive visual quality or distant-terrain completion benchmark. +Recorded outcomes are added after real probes finish. diff --git a/mods/horizon-lab/src/test/java/dev/horizonlab/metrics/ClientGraphicsIntegration.java b/mods/horizon-lab/src/test/java/dev/horizonlab/metrics/ClientGraphicsIntegration.java index b7c7515e5..7f0bcb51d 100644 --- a/mods/horizon-lab/src/test/java/dev/horizonlab/metrics/ClientGraphicsIntegration.java +++ b/mods/horizon-lab/src/test/java/dev/horizonlab/metrics/ClientGraphicsIntegration.java @@ -6,6 +6,7 @@ import java.nio.file.Files; import java.security.MessageDigest; import java.util.HashSet; import java.util.HexFormat; +import java.util.Map; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.loader.api.FabricLoader; @@ -25,6 +26,30 @@ public final class ClientGraphicsIntegration implements ClientModInitializer { private int overlayWaitTicks; private final boolean worldMode = Files.exists(FabricLoader.getInstance().getConfigDir().resolve("client-graphics-world.flag")); + @SuppressWarnings("unchecked") + private static void captureShaders(JsonObject result) throws ReflectiveOperationException, java.io.IOException { + // Reuse the production recorder's read-only Iris API inspection. The + // bridge and enabling flag exist solely in this private test fixture. + var method = Class.forName("dev.horizonlab.client.ShaderSettings").getDeclaredMethod("read", boolean.class); + method.setAccessible(true); + var settings = (Map) method.invoke(null, FabricLoader.getInstance().isModLoaded("iris")); + String status = String.valueOf(settings.get("iris_capture_status")); + boolean enabled = Boolean.TRUE.equals(settings.get("iris_shaders_enabled")); + result.addProperty("iris_capture_status", status); + result.addProperty("iris_shaders_enabled", enabled); + var flag = FabricLoader.getInstance().getConfigDir().resolve("client-graphics-shaders.flag"); + boolean required = Files.isRegularFile(flag); + result.addProperty("shader_required", required); + if (required) { + String expected = Files.readString(flag).strip(); + boolean match = expected.equals(settings.get("iris_shader_pack")); + result.addProperty("iris_expected_pack_matches", match); + // Do not export arbitrary pack names or paths from runtime APIs. + if (!status.equals("available") || !enabled) throw new AssertionError("Required shader pack is inactive"); + if (!match) throw new AssertionError("Unexpected active shader pack"); + } + } + @Override public void onInitializeClient() { System.out.println("HORIZON_CLIENT_GRAPHICS_INITIALIZER_READY"); ClientTickEvents.END_CLIENT_TICK.register(client -> { @@ -94,6 +119,8 @@ public final class ClientGraphicsIntegration implements ClientModInitializer { result.addProperty("window_active", client.isWindowActive()); result.addProperty("overlay_present", client.gui.overlay() != null); result.addProperty("overlay_wait_ticks", overlayWaitTicks); + result.addProperty("heap_max_bytes", Runtime.getRuntime().maxMemory()); + captureShaders(result); result.addProperty("framebuffer_width", width); result.addProperty("framebuffer_height", height); result.addProperty("sampled_pixels", samples); diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index 3569f29f6..d7d22986e 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -3,10 +3,23 @@ import subprocess import unittest from tools.test_dispatch import failure_summary -from tools.test_client_graphics import graphics_failure_summary +from tools.test_client_graphics import graphics_failure_summary, validate_shader_report class FixtureDiagnosticTests(unittest.TestCase): + def test_required_shaders_cannot_pass_with_disabled_unknown_or_different_pack(self): + report = {'shader_required': True, 'iris_capture_status': 'available', + 'iris_shaders_enabled': True, 'iris_expected_pack_matches': True} + validate_shader_report(report, True) + for field, bad in [('shader_required', False), ('iris_capture_status', 'unavailable'), + ('iris_shaders_enabled', False), ('iris_shaders_enabled', 'true'), + ('iris_expected_pack_matches', False)]: + with self.subTest(field=field, bad=bad), self.assertRaises(AssertionError): + validate_shader_report({**report, field: bad}, True) + with self.assertRaises(AssertionError): + validate_shader_report({}, True) + validate_shader_report({}, False) + def test_graphics_diagnostics_separate_demo_auth_and_exclude_methods_messages(self): output = '\n'.join([ 'com.mojang.authlib.exceptions.InvalidCredentialsException: private-token', diff --git a/tools/test_client_graphics.py b/tools/test_client_graphics.py index f963687c5..1c6e7f5fc 100644 --- a/tools/test_client_graphics.py +++ b/tools/test_client_graphics.py @@ -56,7 +56,9 @@ def graphics_failure_summary(run, report_count): # exception messages or infer that a separately logged Vulkan code caused it. categories = {'Uniform title readback': 'uniform_readback', 'Incomplete title framebuffer': 'small_framebuffer', - 'Private client graphics readback failed': 'callback_exception'} + 'Private client graphics readback failed': 'callback_exception', + 'Required shader pack is inactive': 'shader_inactive', + 'Unexpected active shader pack': 'unexpected_shader_pack'} result['probe_failure_categories'] = [category for message, category in categories.items() if 'java.lang.AssertionError: ' + message in run.stdout] result['vulkan_error_codes'] = sorted(set(re.findall(r'\bVK_ERROR_[A-Z_0-9]{1,100}\b', run.stdout)))[:16] @@ -72,13 +74,24 @@ def graphics_failure_summary(run, report_count): return result +def validate_shader_report(report, required): + if required and (report.get('shader_required') is not True + or report.get('iris_capture_status') != 'available' + or report.get('iris_shaders_enabled') is not True + or report.get('iris_expected_pack_matches') is not True): + raise AssertionError('Required runtime shader activation was not verified') + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--native-display', action='store_true') parser.add_argument('--profile', action='append', choices=sorted(build_pack.PROFILES)) parser.add_argument('--backend', choices=['opengl', 'vulkan'], help='Override backend in these private instances only') parser.add_argument('--world', action='store_true', help='Create/open a disposable built-in demo world instead of stopping at the title') + parser.add_argument('--shaders', action='store_true', help='Require the pinned cinematic shader pack in a private world instance') args = parser.parse_args() + if args.shaders and (not args.world or args.profile not in [None, ['cinematic']]): + parser.error('--shaders requires --world and the cinematic profile') root = build_pack.ROOT fixture = build_mod.build_integration_fixture('client-graphics', 'dev.horizonlab.metrics.ClientGraphicsIntegration', @@ -87,12 +100,17 @@ def main(): mod = root / 'dist' / f'horizon-lab-{version}.jar' original_hash = hashlib.sha256(mod.read_bytes()).hexdigest() results = [] - for profile in args.profile or ['core-performance', 'm2-balanced']: + for profile in args.profile or (['cinematic'] if args.shaders else ['core-performance', 'm2-balanced']): instance = root / '.local/runtime' / ('client-graphics-' + profile - + ('-override-' + args.backend if args.backend else '') + ('-world' if args.world else '')) + + ('-override-' + args.backend if args.backend else '') + ('-world' if args.world else '') + + ('-shaders' if args.shaders else '')) build_pack.prepare_instance(profile, instance, mod) if args.world: (instance / 'config/client-graphics-world.flag').touch() + if args.shaders: + expected = build_pack.read_lock()['projects']['complementary-reimagined']['filename'] + (instance / 'config/iris.properties').write_text('enableShaders=true\nshaderPack=' + expected + '\n') + (instance / 'config/client-graphics-shaders.flag').write_text(expected + '\n') if args.backend: options = instance / 'options.txt' text, count = re.subn(r'^preferredGraphicsBackend:.*$', @@ -102,7 +120,7 @@ def main(): options.write_text(text) shutil.copy2(fixture, instance / 'mods/client-graphics-fixture.jar') command = [sys.executable, str(root / 'tools/runtime.py'), 'demo', - '--instance', str(instance), '--heap', '3G'] + '--instance', str(instance), '--heap', '6G' if args.shaders else '3G'] if platform.system() == 'Linux' and not args.native_display: command = ['xvfb-run', '-a', *command] try: @@ -122,6 +140,7 @@ def main(): print('HORIZON_FIXTURE_FAILURE ' + json.dumps(diagnostics), flush=True) raise RuntimeError('Graphics probe failed; diagnostics remain private') report = reports[0] + validate_shader_report(report, args.shaders) if report['observed_mode'] != ('world' if args.world else 'title') or report['ready_client_ticks'] < 40: raise AssertionError('Client never reached the requested graphics scene') if report['overlay_present'] is not False: