Older devices (A16 and earlier): a start-to-finish guide for the Legacy Device Pack

docs/LEGACY_DEVICES.md explains why older chips need an extra texture pack, how to build the astcenc encoder, the three commands that make the pack from your own game files, how to build the App with it and where the folder goes on the phone. The README links to it from the performance section and the status table. astc_pack.py now names the output folder "Legacy Device Pack", the name the App asks for.
This commit is contained in:
jhaizhou
2026-10-13 19:23:29 +08:00
parent 2b270ff76e
commit b50b976523
7 changed files with 159 additions and 5 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ All at once: `python3 -m pip install pillow numpy lz4 capstone unicorn` (`./setu
| Tool | Used for | Official site |
|---|---|---|
| astcenc | Converting textures for older devices without BC texture support | <https://github.com/ARM-software/astc-encoder> |
| astcenc | Converting textures for older devices without BC texture support (A16 and earlier); built from source — how to build it and the whole procedure are in [LEGACY_DEVICES.md](LEGACY_DEVICES.md). We use v5.2.0 | <https://github.com/ARM-software/astc-encoder> |
| hactool | Needed by `dm/tools/extract_game.sh` to extract files from your game package; not needed if your game files are already prepared some other way. We tested with upstream commit `1d64a83` | <https://github.com/SciresM/hactool> |
## Extra tools for on-device and verification scripts
+1 -1
View File
@@ -39,7 +39,7 @@ English: [DEPENDENCIES.md](DEPENDENCIES.md)
| 工具 | 用来做什么 | 官方地址 |
|---|---|---|
| astcenc | 给不支持 BC 贴图格式的旧机型转换贴图 | <https://github.com/ARM-software/astc-encoder> |
| astcenc | 给不支持 BC 贴图格式的旧机型(A16 及更早)转换贴图;从源码编,编法与整条做法见 [LEGACY_DEVICES.zh-CN.md](LEGACY_DEVICES.zh-CN.md)。我们用的是 v5.2.0 | <https://github.com/ARM-software/astc-encoder> |
| hactool | 用 `dm/tools/extract_game.sh` 从你的游戏包取文件时要用;游戏文件已经用别的办法备好时不用装。我们实测用的是上游提交 `1d64a83` | <https://github.com/SciresM/hactool> |
## 真机与验证脚本额外需要
+75
View File
@@ -0,0 +1,75 @@
# Older devices (A16 and earlier chips): making the texture pack
中文:[LEGACY_DEVICES.zh-CN.md](LEGACY_DEVICES.zh-CN.md)
The iPhone 14 family, iPhone 15 / 15 Plus and earlier models can play; they just need one more step: a **Legacy Device Pack** made from your own game files and placed on the phone. This page covers it from start to finish.
## Why the extra step
Almost all of the game's textures use BC compression. Apple GPUs support that format only from the A17 Pro (iPhone 15 Pro) on; earlier chips cannot read it. The answer is to convert those textures offline, on a computer, into ASTC, which these devices do support — the picture is the same picture. Textures are game content, so we cannot provide this pack; it can only be generated on your own computer from your own game files.
**Which devices need it**: the App decides this itself at launch, so there is no table to consult. A device that needs it shows "Supplementary Pack Required"; if it shows "Device Not Supported" instead, the App was built without the part that goes with the pack — rebuild it as in step 4 below.
## What you need
- The "with a Mac" route (see "Getting started" on the front page), with `./setup.sh` finished.
- The **astcenc** encoder (Arm's open-source texture encoder, Apache 2.0). Build it from source, which takes a minute or two:
```bash
brew install cmake
git clone https://github.com/ARM-software/astc-encoder
cmake -S astc-encoder -B astc-encoder/b -DASTCENC_ISA_NEON=ON -DCMAKE_BUILD_TYPE=Release
cmake --build astc-encoder/b -j
export ASTCENC=$PWD/astc-encoder/b/Source/astcenc-neon
```
We use v5.2.0.
- Disk: about 3 GB (1.6 GB of intermediate files, 1.0 GB for the pack).
## Steps
Run these from the repository root, inside the Python environment that setup prepared. `D` is an output directory of your choice and `R` is the game resource directory:
```bash
source ~/dm-work/build/cache/dm/venv/bin/activate
R=~/dm-work/data/switch/3.3.94012/Update/RomFS
D=~/dm-work/out/legacy_pack
python3 dm/tools/astc_pack.py "$R" "$D/work" --preset thorough # 1 transcode, about 8 minutes (all cores of a Mac)
python3 dm/tools/casc_overlay.py pack "$R" "$D/pack" "$D/work/repl.tsv" 0-8 # 2 write the data archive, about half a minute
python3 dm/tools/astc_pack.py finalize "$D/pack" # 3 finalize: sizes and checksum
```
Afterwards `$D/pack` contains:
- `Legacy Device Pack/`: **the folder for the phone** (holding `manifest.json` and `data/00-00000008.data`, about 1.0 GB).
- `pack.json`: the size and SHA-256 of this pack; the next step builds it into the App so the phone can verify the pack.
4. **Build the App with it**:
```bash
cd dm/ios && DM_ASTC_PACK="$D/pack" ./run.sh build
```
An App built without this variable only says "Device Not Supported" on older devices.
5. **Install** as usual (`./run.sh install` or Xcode).
6. **Put the pack on the phone**: in the Files app open "On My iPhone → D2R Mobile" and copy the **whole** `Legacy Device Pack` folder into it, at the same level as the game resource folder. Finder works too (connect the phone → Files → D2R Mobile). Then open the game.
## Things to know
- **The pack and the App are a matched pair.** The App checks the pack on the phone against the SHA-256 in `pack.json`; if you regenerate the pack, rebuild the App with the new `$D/pack`. The same game files, the same astcenc version and the same preset (`--preset thorough`) produce a byte-identical pack, so normally there is nothing to redo.
- If the folder was not copied completely, is in the wrong place, or does not match the App, the App says which it is in the dialog.
- The game resource folder is still needed as usual (see [GAME_FILES.md](GAME_FILES.md)); the pack is an additional folder, not a replacement.
- This route currently needs a Mac and Xcode. The no-Xcode shell does not carry the older-device part in this version yet.
## What it does (if you are curious)
- It converts the BC3 textures, about 27,000 of them and the great majority of all textures; each is converted block by block to ASTC 4×4 with the file size unchanged. The game itself understands ASTC, so only the format changes and nothing about how the game reads textures.
- The few other BC formats, small in volume, are not converted here; the program decodes them at run time on these devices.
- Every texture is compared with the original for fidelity during conversion, with the results in `$D/work/quality.tsv`; the median for colour and material textures is about 60 dB, with no visible difference.
## In practice
The lowest device we measured is the iPhone 14 Pro Max (A16, 6 GB of RAM), running at 60 fps. During internal testing this route was completed by users on A16 devices.
+75
View File
@@ -0,0 +1,75 @@
# 老机型(A16 及更早的芯片):贴图包怎么做
English: [LEGACY_DEVICES.md](LEGACY_DEVICES.md)
iPhone 14 系列、iPhone 15 / 15 Plus 以及更早的机型可以玩,只是多一步:要用你自己的游戏文件做一份**老机型贴图包**,放进手机。这一页从头讲到尾。
## 为什么要多这一步
游戏的贴图绝大多数用的是 BC 压缩格式。苹果的显卡从 A17 Pro(iPhone 15 Pro)起才支持这种格式,更早的芯片不认。做法是在电脑上把这些贴图离线转成这些机型支持的 ASTC 格式,画面是同一份画面。贴图是游戏内容,所以这个包不能由我们提供,只能用你自己的游戏文件在你自己的电脑上生成。
**哪些机型需要**:App 启动时自己会判断,不用查表。需要的机型会弹「需要老机型补充包」(补充包就是这里说的贴图包);如果弹的是「暂不支持本机型」,说明这个 App 构建时没有带上贴图包的配套部分——照下面第 4 步重新构建即可。
## 需要什么
- 走「有 Mac」那条路(见首页「开始使用」):`./setup.sh` 已经跑完。
- 编码器 **astcenc**(ARM 的开源贴图编码器,Apache 2.0 许可)。从源码编一份,约一两分钟:
```bash
brew install cmake
git clone https://github.com/ARM-software/astc-encoder
cmake -S astc-encoder -B astc-encoder/b -DASTCENC_ISA_NEON=ON -DCMAKE_BUILD_TYPE=Release
cmake --build astc-encoder/b -j
export ASTCENC=$PWD/astc-encoder/b/Source/astcenc-neon
```
我们用的是 v5.2.0。
- 磁盘:约 3 GB(转码的中间文件 1.6 GB,贴图包 1.0 GB)。
## 步骤
在仓库根目录执行,先进入 setup 准备好的 Python 环境。`D` 是你选的输出目录,`R` 是游戏资源目录:
```bash
source ~/dm-work/build/cache/dm/venv/bin/activate
R=~/dm-work/data/switch/3.3.94012/Update/RomFS
D=~/dm-work/out/legacy_pack
python3 dm/tools/astc_pack.py "$R" "$D/work" --preset thorough # 1 转码,约 8 分钟(Mac 全核)
python3 dm/tools/casc_overlay.py pack "$R" "$D/pack" "$D/work/repl.tsv" 0-8 # 2 写成数据档,约半分钟
python3 dm/tools/astc_pack.py finalize "$D/pack" # 3 收尾:算大小与校验值
```
做完后 `$D/pack` 里有:
- `Legacy Device Pack/`:**给手机用的文件夹**(里面是 `manifest.json` 和 `data/00-00000008.data`,约 1.0 GB)。
- `pack.json`:这份贴图包的大小与 SHA-256,下一步构建 App 时会带进去,用来在手机上核对。
4. **带着它构建 App**:
```bash
cd dm/ios && DM_ASTC_PACK="$D/pack" ./run.sh build
```
不带这个变量构建出来的 App,在老机型上只会提示「暂不支持本机型」。
5. **装机**,和平常一样(`./run.sh install` 或用 Xcode)。
6. **把贴图包放进手机**:在「文件」App 里打开「我的 iPhone → D2R Mobile」,把 `Legacy Device Pack` 这个文件夹**整个**拷进去,和游戏资源文件夹放在同一层。用 Finder 也可以(连上手机 → 文件 → D2R Mobile)。然后打开游戏。
## 要注意的
- **贴图包和 App 是配对的**。App 按 `pack.json` 里的 SHA-256 核对手机上的贴图包;重新生成过贴图包,就要用新的 `$D/pack` 重新构建 App。同一份游戏文件、同一版 astcenc、同一档(`--preset thorough`)生成的包是逐字节相同的,所以平时不需要重做。
- 文件夹没拷完、拷错了位置、或者和 App 不配套,App 会在弹框里直接说是哪一种。
- 游戏资源文件夹照常要放(见 [GAME_FILES.zh-CN.md](GAME_FILES.zh-CN.md));贴图包是另外加的一个文件夹,不是替换。
- 这条路目前要用 Mac 和 Xcode 构建。「不用 Xcode」的壳这一版还不带老机型的配套部分。
## 它做了什么(想了解的话)
- 转的是 BC3 格式的贴图,约 2.7 万张,占全部贴图的绝大多数;每张逐块转成 ASTC 4×4,文件大小不变。游戏本身认得 ASTC,所以只是换了格式,没有改游戏的读取方式。
- 其余几种量很小的 BC 格式不在这里转,由程序在这些机型上运行时解开。
- 转码时每张贴图都和原图比过清晰度,结果写在 `$D/work/quality.tsv`;颜色和材质贴图的中位数约 60 dB,肉眼看不出差别。
## 实际情况
最低实测机型是 iPhone 14 Pro Max(A16,6 GB 内存),60 帧运行。这条路在内测阶段由 A16 机型的用户走通过。