Repository navigation
Replace LWJGL 2/OpenGL with native Vulkan renderer (FML 4.0.0) - #5
Open
XMRhapsody0807 wants to merge 22 commits into
Open
XMRhapsody0807 wants to merge 22 commits into
XMRhapsody0807 wants to merge 22 commits into
Conversation
Only dev environments have the named jar on the class path, so /net/minecraft/Minecraft.class was not found in a real install and the static initializer failed with a NullPointerException. Read /atv.class (the obfuscated Minecraft) when the named class is missing, close the stream, and fail with a clear message when neither class is on the class path.
The game keeps calling the LWJGL 2 API unchanged; underneath it now runs on LWJGL 3.4.3 and Vulkan. Rendering and API compatibility - org.lwjgl.opengl/input/openal and Sys are now FML classes: LWJGL 2 API facades with the original descriptors, generated by tools/GenLwjgl2Compat.java and tools/GenLwjgl2OpenAL.java. - The GL facades sit on a GL 1.5 fixed-function emulation on Vulkan (net.xiaoyu233.fml.vulkan: state machine, draw system with client arrays/VBOs/queries/display lists, texture manager, pipelines, render core, swapchain). - GLFW window and input (WindowManager, InputManager); clipboard and link mixins replace the AWT/Desktop paths. OpenAL goes through Java FFM over the bundled OpenAL Soft. Build - LWJGL 3.4.3 core/glfw/vulkan/vma with natives for windows x64 and macOS arm64/x64 (incl. MoltenVK) bundled in the FML jar; the real LWJGL 2 core/platform are excluded, lwjgl_util 2.x stays. - GLSL -> SPIR-V at build time (shaders.gradle, src/shadertool, shaders in src/main/shaders, output under /assets/fml_vulkan/shaders). - Java 25 release, Multi-Release and Enable-Native-Access manifest, updateInstallerJar task, run options (-Pvk.*, -PrunDir, -Pxmx/-Pxms). - Test harness: AutoScript and the vulkan.mixin.test mixins (only active through -Dfml.vulkan.* properties) and a dev-only test bot source set (src/devtest, runClient -Ptestbot) that is never packed into the jar. Launch - NativeExtractor unpacks the natives to <gameDir>/.fml/natives and sets the LWJGL/Vulkan library paths. - MacFirstThread restarts the JVM with -XstartOnFirstThread on macOS. - VulkanConfigLoader maps config/fml-vulkan.properties to fml.vulkan.*. - LaunchDelegate keeps the real LWJGL 2 core jar out of Knot and fails early when an older ASM shadows the one in the FML jar. The installer version json drops the LWJGL 2/guava/ASM 9.3 libraries and adds the JVM arguments (-XstartOnFirstThread on macOS, --enable-native-access). Runtime fixes - FixNetHandler: the multi-block-change guard is a HEAD injection instead of an @overwrite that fails under Mixin 0.8.7 and dropped the extended block ids; PacketMultiBlockChangeMixin injector signature fixed. - Display lists: texture image/sub-image uploads compiled into a list are recorded with a copy of the pixels and replayed. - ConfigEditor.isSupported(): no Swing editor on macOS/headless, the /configs edit command points to the json files and /configs reload. - FML 3.x getters (deprecated) on LanguageResourceReloadEvent and PlayerLoggedInEvent keep mods compiled against 3.x working.
Add native (non-GL-emulation) render path: mixins for GUI, entities, mobs, objects, TESRs and models; GPU command stream and pipeline library; terrain section scheduler, particle fast path, native tessellator. Rework GLState/GLStateImpl, CommandRecorder, texture management and input handling. Add VulkanConfig, shader tooling, devtest/benchtest bots and GlSiteScan tool.
Introduce LayerPresenter and SwapchainInfo, and rework device/swapchain setup and config so frames can be presented through a CAMetalLayer/IOSurface path.
Requeue sections correctly in the scheduler, update snapshots and mesh workers, fix translucent sort order and expose terrain stats for diagnostics.
Show renderer, terrain and frame stats in the F3 screen via VulkanDebugOverlay.
New WaterScene and LightScene, extra bench metrics, PERF_JVM and bench_width/bench_height overrides for runBench; ignore local Claude settings.
Add fpsCap config (default 0 = uncapped), FpsLimit helper, FramePacer limit reason and a Present/VSync/limit line in F3.
Use the fml.gameDir property instead of the process working directory.
Log OptFlags at startup, show Opt line in overlay, add hitch attribution columns and AutoScript test commands.
VK_NV_low_latency2 (Reflex) or VK_AMD_anti_lag when the driver offers it; fml.vulkan.reflex=off|on|boost (default on), F3+L cycles while playing. With Reflex active the driver sleep replaces the software FPS limiter. F3 shows the Reflex state, measured latency and 'FML 4.0.0 build <sha date>' (FML-Build manifest attribute written by shadowJar).
Falls back to icons bundled in the jar when the assets dir has none and adds the 48..256 px sizes the Windows taskbar uses.
MITE sets GL_LINEAR + GL_CLAMP on the lightmap every enableLightmap call; the dynamic texture upload resets it to NEAREST, so smooth light banded in steps.
…e installer LWJGL 3.4.3 natives for linux and linux-arm64 (lwjgl, glfw, vma, openal) are shaded like the Windows and macOS ones; Linux uses the system Vulkan loader (libvulkan.so.1) as Windows does. The installer refuses a client install on a platform without bundled natives instead of failing at the first launch. Native extraction hardening: refuse a symlinked natives directory, replace a symlink planted in place of a library, serialise concurrent launches on a lock file in the directory, and keep a library that is in use only when its SHA-1 still matches (size alone was accepted before).
The preset restart rebuilds 'java <jvm args> -cp <cp> client.Main <args>'. Skip it (and print the flags to add to the launcher instead) when another main class or a jar started the JVM (launcher wrappers, agent bootstraps), when a debugger is attached, or with -Dfml.jvm.relaunch=false.
The default output was an absolute path on one developer machine; it is now build/reports/gl-site-scan (override with -PglScanOut).
…er meshing TerrainDraw records straight into the command stream but did not flush the draw the GL emulation still held back for merging. A mod sky drawn from display lists (Twilight Forest's lower sky disc) could therefore land on top of the terrain, covering ground and water with flat sky colour. beginPass now calls LegacyInterop.beforeRawCommands first. RenderTypeAllowList only let net.minecraft blocks mesh on workers, so every section with a mod block was meshed on the render thread; in a dimension made of mod blocks turning the camera dropped to ~60 fps. Packages listed in fml.vulkan.meshAllowPackages now mesh on workers with any render type.
The phase-1 (GL emulation) pipelines bake depth test/write/compare and cull; recording vkCmdSetDepth*/CullMode while one is bound is invalid. NVIDIA's driver then drew with the dynamic values: a mod sky drawn through the emulation with glDepthMask(false) (Twilight Forest's sky discs) wrote depth and covered water and terrain with flat sky colour, triggered once the inventory GUI had left a native depth-write state behind. The dynamic state now stays dirty until a native pipeline is bound again. Also adds an opt-in render state log (-Dfml.vulkan.stateDump=true: native and emulated state at the world pass start, every 5 s and on GUI screen changes) and a dev-only bench scene (-Dfml.vulkan.tfSkyScene=<dir>) with TF sky/water captures before and after opening the inventory.
Spawns every Twilight Forest boss on a stone floor, kills it with fire damage alone and logs the reward chests and dropped items around it. Dev only.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
中文摘要: 用 LWJGL 3.4.3 + 原生 Vulkan 渲染器替换 LWJGL 2/OpenGL(FML 4.0.0)。窗口/输入改用 GLFW,音频通过 FFM 调用 OpenAL,内置 Windows x64 与 macOS arm64/x64(含 MoltenVK)原生库;需要 Java 25。已在 macOS M5 Max 上完成真实运行测试,Windows 11 (RTX 5080) 经 PCL 用户测试,尚未完全验证。模组兼容性不在本次范围内。
Summary
Replaces the LWJGL 2 / OpenGL rendering stack with a native Vulkan renderer built on LWJGL 3.4.3. Version is plain
4.0.0.What changed
<gameDir>/.fml/natives.debugOverlay=falseinconfig/fml-vulkan.properties).Client.fpsCap(0 = unlimited) and F3 shows the limit reason.--gameDir.MITEReleaseAccessfalls back to the obfuscated Minecraft class (atv).Testing
Note: frames above the display refresh rate are not all visible; these numbers measure render throughput. Windows was not benchmarked.
clientVersionto the version JSON).nextDrawablecapped output at 120 FPS; replaced by the IOSurface layer presentation path.Client.fpsCap, default unlimited) and VSync now defaults to off.--gameDir.Known limitations
Breaking changes
net.xiaoyu233.fishmodloader:fishmodloader:4.0.0).Client.fpsLimit(default 120) is replaced byClient.fpsCap(default 0); the old key is ignored.