Leonida – PC Recompilation of the Xbox Version of GTA 6
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Leonida – PC Recompilation of the Xbox Version of GTA 6
Other languages | Status | How to build | How it works | Want to help? | Credits | License | Discord
其他语言 | 状态 | 如何构建 | 工作原理 | 想要提供帮助? | 制作人员 | 许可协议 | Discord
Leonida is a static recompilation project. The Xbox Series CPU is x86-64 like a PC, so the game’s code is loaded and run natively, and the console’s system software is reimplemented. The console’s precompiled RDNA2 GPU programs are translated to SPIR-V for Vulkan. The game’s models, textures and audio are read from your package. All of this happens on your PC, from your own copy of the game.
Leonida 是一个静态重编译项目。Xbox Series 的 CPU 与 PC 一样采用 x86-64 架构,因此游戏代码可以被加载并原生运行,而主机的系统软件则被重新实现。主机预编译的 RDNA2 GPU 程序会被转换为适用于 Vulkan 的 SPIR-V。游戏的模型、纹理和音频均从你自己的游戏包中读取。所有这些过程都在你的 PC 上,使用你自己的游戏副本完成。
This repository does not contain the game, keys or an executable, and it does not explain how to get them. You need your own copy, with its files already readable on disk. Nothing here decrypts or works around any protection. Everything the build creates (the generated shaders, extracted assets, the runtime folder and your saves) comes from your game and stays on your PC. Never share those files.
本仓库不包含游戏本体、密钥或可执行文件,也不会说明如何获取它们。你需要拥有自己的副本,且文件在磁盘上必须是可读取的。此处的任何内容都不会解密或绕过任何保护措施。构建过程创建的所有内容(生成的着色器、提取的资源、运行时文件夹以及你的存档)均来自你的游戏,并保留在你的 PC 上。请勿分享这些文件。
Discord: https://discord.gg/rexed
Discord: https://discord.gg/rexed
Early. The game does not boot yet. Everything that can be done without the game’s executable is in place, so work on booting can start as soon as one is available to a developer.
处于早期阶段。游戏目前尚无法启动。所有无需游戏可执行文件即可完成的工作均已就绪,因此一旦开发者获得可执行文件,启动相关的工作即可开始。
The table above is written by hand. To measure it on your own checkout (unit and runtime tests, which rows of the translator contract were confirmed on a GPU, measured imports, your corpus counts and, with —github, CI and the D3D- items), run python -I tools/progress_dashboard.py —out
上表为手动编写。若要在你自己的检出版本上进行测量(包括单元测试和运行时测试、在 GPU 上确认的转换器契约行数、测量的导入项、语料库计数,以及使用 —github 参数时的 CI 和 D3D 项目),请运行 python -I tools/progress_dashboard.py --out <仓库外的文件夹> 并打开 progress.html(查看注释)。
Nothing is playable on any platform yet (see Project status). What runs where today:
目前在任何平台上都无法游玩(请参阅“项目状态”)。当前各平台的运行情况如下:
GPU results from every platform are collected in #166; how to run the tests is in docs/testing.md.
各平台的 GPU 测试结果汇总在 #166 中;如何运行测试请参阅 docs/testing.md。
The port isn’t downloaded ready-made. It’s built on your PC from your own copy.
该移植版本并非直接下载现成的。它是在你的 PC 上使用你自己的副本构建的。
It finds your copy of the game by itself: it looks in Downloads, Desktop, Documents (also where Windows keeps them, such as in OneDrive), Games, your home folder and the top of every drive, two folders deep. It recognises the version from a few file sizes, without reading anything large. If you have more than one copy it asks which one, and if it finds none it asks you to paste the folder. Before starting it checks that everything below is installed and that there is enough free space, and it lists anything missing in one go. The result goes to Documents\Leonida. A stopped build continues where it left off.
它会自动查找你的游戏副本:它会扫描“下载”、“桌面”、“文档”(包括 Windows 存储这些文件的位置,如 OneDrive)、“游戏”文件夹、你的主目录以及每个驱动器的根目录(向下两层)。它通过几个文件的大小来识别版本,而无需读取任何大型文件。如果你有多个副本,它会询问使用哪一个;如果找不到,它会要求你粘贴文件夹路径。在开始之前,它会检查下方列出的所有依赖项是否已安装以及是否有足够的剩余空间,并一次性列出所有缺失项。结果将存放在 Documents\Leonida 中。中断的构建可以从上次停止的地方继续。
Your game folder is the one that holds MicrosoftGame.Config and the .rpf archives, as plain files.
你的游戏文件夹是指包含 MicrosoftGame.Config 和 .rpf 归档文件(作为普通文件存在)的目录。
Low disk space: the ~350 GB figure is for the full build. To run the port, —stages check,shaders,runtime needs about 30 GB; the assets stage (~300 GB) is only for the asset tools, and —wav adds several times the Ogg Opus size (the preflight prints this choice when the assets stage is what does not fit). —work and —out can sit on another drive. The runtime maps the package in place, so a read-only package drive needs gta6rt —overlay
磁盘空间不足:约 350 GB 的空间需求适用于完整构建。要运行该移植版本,--stages check,shaders,runtime 大约需要 30 GB;资源阶段(约 300 GB)仅用于资源工具,而 --wav 会增加数倍于 Ogg Opus 的大小(当资源阶段空间不足时,预检程序会打印此选项)。--work 和 --out 可以放在另一个驱动器上。运行时会就地映射包,因此如果包所在的驱动器是只读的,则需要使用 gta6rt --overlay <可写文件夹>;--overlay 是 gta6rt 的选项,而非 make_game.py 的选项。请保留 work/shaders/dxbc/disasm 中的 .s 文件:删除它们以及转换后的 work/shaders/spirv/index.json 可能会导致着色器阶段显示已完成但实际包含零个着色器。当该阶段需要清理时,作为符号链接的 disasm 文件夹会被拒绝。
From a terminal, with the same behaviour and more control:
在终端中,使用相同的行为并获得更多控制权:
—wave64-emulate decides whether wave64 compute and mesh shaders are translated to be exact on any subgroup size (see “Wave64 emulation” in docs/design.md). NVIDIA and Intel GPUs have 32-wide subgroups and need it. The default, auto, asks vulkaninfo (part of the Vulkan SDK) and turns emulation on if any GPU lacks 64-wide subgroups or its subgroup size is unknown. It also checks whether the runtime’s GPU can run compute and mesh shaders 64-wide. With —mesh-compute, only compute subgroup support is needed.
--wave64-emulate 决定是否将 wave64 计算和网格着色器转换为在任何子组大小上都能精确运行(请参阅 docs/design.md 中的“Wave64 模拟”)。NVIDIA 和 Intel GPU 具有 32 宽的子组,因此需要此功能。默认的 auto 选项会查询 vulkaninfo(Vulkan SDK 的一部分),如果任何 GPU 缺少 64 宽子组或其子组大小未知,则会开启模拟。它还会检查运行时的 GPU 是否能以 64 宽运行计算和网格着色器。使用 --mesh-compute 时,仅需计算子组支持。
On AMD’s Windows driver, auto uses native wave64 on RDNA1 and RDNA2 when the runtime’s GPU supports it, even if another GPU is 32-wide or vulkaninfo is unavailable. That driver can crash on emulated LDS code (#857). For RDNA1 cards without mesh support, the decision uses the compute stage, which can run wave64 without native mesh support.
在 AMD 的 Windows 驱动程序上,当运行时的 GPU 支持时,auto 会在 RDNA1 和 RDNA2 上使用原生的 wave64,即使另一个 GPU 是 32 宽的或 vulkaninfo 不可用。该驱动程序在处理模拟的 LDS 代码时可能会崩溃 (#857)。对于不支持网格着色的 RDNA1 显卡,该决策会使用计算阶段,该阶段可以在没有原生网格支持的情况下运行 wave64。
The mode is saved next to the translated shaders, and changing it translates them again. auto can normally reuse previously emulated shaders. The AMD Windows workaround rebuilds those shaders in native mode. Use —wave64-emulate on to force emulation or —wave64-emulate off to force native wave64.
该模式会保存在转换后的着色器旁边,更改它会触发重新转换。auto 通常可以重用之前模拟的着色器。AMD Windows 的变通方法会以原生模式重建这些着色器。使用 --wave64-emulate on 强制开启模拟,或使用 --wave64-emulate off 强制使用原生 wave64。
Four fallback flags are forwarded to the translator the same way, saved next to the translated shaders, and changing them translates them again: —no-float-controls (drop SignedZeroInfNanPreserve, for devices whose pipeline check skips a shader without shaderSignedZeroInfNanPreserveFloat32; needs PR #664’s translator flag), —bary-fallback (read raw barycentrics from an interpolated input, for devices without VK_KHR_fragment_shader_barycentric), —texel-offset-fallback (fold image_sample*_o offsets into the coordinate, for devices without VK_KHR_maintenance8) and —mesh-compute (mesh shaders as compute, for devices without VK_EXT_mesh_shader). Each is documented in docs/design.md.
四个回退标志以相同方式转发给转换器,保存在转换后的着色器旁边,更改它们会触发重新转换:--no-float-controls(丢弃 SignedZeroInfNanPreserve,适用于那些在没有 shaderSignedZeroInfNanPreserveFloat32 的情况下跳过着色器的设备;需要 PR #664 的转换器标志)、--bary-fallback(从插值输入读取原始重心坐标,适用于没有 VK_KHR_fragment_shader_barycentric 的设备)、--texel-offset-fallback(将 image_sample*_o 偏移量折叠到坐标中,适用于没有 VK_KHR_maintenance8 的设备)以及 --mesh-compute(将网格着色器作为计算着色器,适用于没有 VK_EXT_mesh_shader 的设备)。每一项都在 docs/design.md 中有详细说明。
The build records which llvm-mc command and version produced the disassembly. Changing either, or reusing a work folder that predates this record, reruns disassembly and translation while keeping the extracted shader inputs.
构建过程会记录生成反汇编代码的 llvm-mc 命令及其版本。更改其中任何一项,或重用早于此记录的工作文件夹,都会重新运行反汇编和转换过程,同时保留已提取的着色器输入。
The build records which translator sources produced the shaders. A change to those files reruns translation using the saved disassembly. Older work folders need one translation after upgrading to record this information.
构建过程会记录生成着色器的转换器源代码。对这些文件的更改会使用保存的反汇编代码重新运行转换。升级后,旧的工作文件夹需要进行一次转换以记录此信息。
The build also records which decoder (the third_party/rpf9-explorer commit and the tools/rpf9dump sources) exported each archive’s models and textures. When it changes, the assets stage removes that export and makes it again. Older work folders have no record, so their models and textures are exported once more after upgrading.
构建过程还会记录导出每个归档文件模型和纹理的解码器(third_party/rpf9-explorer 提交记录和 tools/rpf9dump 源代码)。当解码器发生变化时,资源阶段会删除该导出内容并重新执行。旧的工作文件夹没有此记录,因此在升级后,其模型和纹理会被再次导出。
Stages run in order: check, shaders, assets, runtime, pipelines (creates
阶段按顺序运行:check(检查)、shaders(着色器)、assets(资源)、runtime(运行时)、pipelines(管道,创建…