《忍者龙剑传 黑之章》(含飓风版中文汉化 vb-zh-x2.1)与《忍者龙剑传》(2004)的非官方 Windows 原生移植。2.2.32。
2.2.32:种子补全,新玩家第一次启动的最后一处卡顿,所有图形设置逐一彻查
玩家会注意到的变化
- 新玩家第一次启动不再在过场前卡一下。 过场开始前,游戏要在 CPU 上算 10 张水波纹贴图,第一次约 40 ms 一帧。2.2.31 只缓存给第二次以后用,现在随包附带。
- 第 3–4 章第一次进入时更顺:种子里加入了作者实际游玩第 1–4 章录下的数据。
- 开 MSAA 抗锯齿的玩家:以前种子对开 MSAA 的玩家大多对不上,他们会把种子里已有的状态重新学一遍;现在种子对所有 MSAA 设置都有效。
- 2004 装了飓风包(更新补丁版 1.06.04)的玩家:游戏自己的顶点程序以前在这个版本上不在种子里,第一次进场景时要现编,现在补上了。
- 2004 冷启动时用存档里的音量:以前 2004 每次启动音量都回到默认,改过音量的玩家每次在标题都会被问“要套用声音设置的更改吗?”;黑之章 2.2.31 已经修过,这次 2004 也修了。
- 接缝填补默认关闭(作者的决定)。启动器“图形”页可以打开。已经设置过的老玩家保持原来的选择。
- 代价:每次启动约多 0.1 秒(回放更多的状态);游戏过程中的帧时间不变。
改了什么,为什么
- 水波纹贴图种子(
cpu_textures.bin)。这是游戏代码根据参数和常量算出来的波纹数据,不是代码,也不是美术素材(作者同意随包附带)。启动时先读种子,再读玩家自己的缓存;存盘时不重复写种子里已有的条目。黑之章 5 个镜像版本、2004 光盘版和更新补丁版的常量完全相同,共用同一组 10 张贴图。
实测(空缓存,独显,各 2 次):超过 33 ms 的帧每次 1 帧 → 0;最差帧 40–41 → 28.6 / 32.2 ms。 - MSAA 下的绘制状态按不开 MSAA 的形式记录。 开 MSAA 时,画面画在多重采样目标上,深度缓冲换成 D24S8,界面绘制还会关掉一个 MSAA 渲染状态,所以记录全都和种子不同。
先用实验确认驱动程序不区分 MSAA:开 MSAA 2x,只回放“不开 MSAA 的形式”时,进区域同样不卡(独显 0 帧超过 33 ms;完全不回放时 3 帧);核显没有差别(Intel 会把程序存在磁盘缓存里)。
修复后:开 MSAA 跑待机演示只学到 19 种新状态,不开时 20 种。一份开 MSAA 的第 1–4 章录制里,有 4,417 种其实种子已有。合并工具也会按同样规则换算旧录制。 - 移植层自己的着色器全部收进种子。 这些着色器按设置不同只用到其中一部分,比如 MSAA 复制、不同倍数下的缩放滤镜,以前测试时没录到的 12 个现在一次性生成收进去。其中缩放滤镜
AT 5超出显卡指令上限(655 > 512),程序本来就会改用旧缩放滤镜,种子里记的是它“编不了”的结果,避免每次启动都去试编。 - 2004 更新补丁版的顶点程序。 生成种子时没有给工具这个版本,所以 7 个程序在这个版本上一个都找不到;补上后 7 of 7。种子里只存位置和哈希,不含游戏代码。
- 2004 冷启动音量。 2004 有和黑之章完全相同的问题,但它的指令用 8 位偏移,存档里音量的位置也不同(+0x37 而不是 +0x87),原来的特征码匹配不上;而且 2004 的程序原来被当成附带程序,没有装这个补丁。现在特征码兼容两种写法,音量位置从后面共同的指令推算。2004 光盘版(0x1BA930)、更新补丁版(0x1CB750)、黑之章 6 个镜像各只匹配一处;2004 的下载器和更新程序不装。
--no-saved-volumes可恢复主机原样。
实测:在 2004 里把音乐音量改成 39,下次冷启动读到的是 39(之前是 60),标题不再询问(作者确认)。 - 新种子。 着色器 429 → 441、绘制状态 8,339 → 16,679、贴图池 137 → 194 种尺寸(24 MB 上限)、顶点程序 7 个(含 2004 更新补丁版的位置)、水波纹贴图 10 张。来源:标题、待机演示、作者游玩第 1–2 章和第 1–4 章(开 MSAA 2x)。每份原始数据用
--check核对,都是 100% 覆盖。- 启动代价(空缓存,到第 60 帧):RTX 3060 约 2.97 → 3.09 s,Iris Xe 约 2.19 → 2.28 s。
- 游戏过程(核显,新旧种子交替各 3 次):中位数 2.73 / 2.99 / 2.74 → 2.75 / 2.74 / 2.77 ms,p99 不变,超过 33 ms 的帧都是 0。
彻查记录(都有实测,供以后追溯)
- 所有图形设置逐一从空缓存跑待机演示: MSAA 2/4/8、柔和阴影关、FXAA 关、接缝填补开、渲染倍数 1/2/8、原生分辨率、特效原尺寸、阴影 1/16、画面比例 21:9/16:10/4:3、各向异性 16、垂直同步、性能显示。结果:游戏着色器 0 个现编,0 次超过 50 ms 的卡顿;每次运行的设置都在日志里核实过。
(第一轮扫描因为测试用的后台模式不读black.ini,所有设置其实都是默认值,结果已作废;加了--set之后重跑。) - 偶发小顿: 回放之后,每 170 秒仍有 10–20 次 1–11 ms 的绘制调用,个别帧 20–32 ms(掉一帧),0 帧超过 33 ms,几乎都是固定管线绘制。已经排除:
- 种子缺状态:全部是“启动时回放过”的状态。
- 贴图刚上传:多数是几百帧以前上传的,最慢那次没绑贴图。
- 显卡降频:用
nvidia-smi锁到 1,800 MHz 照样出现,此时显卡占用只有 10–20%。 - 驱动程序缓存溢出:只回放用到的 1,865 种和回放全部 16,679 种结果一样。
判断为 NVIDIA 驱动内部的行为。作为对照,完全不回放时是 50 次、3 帧超过 33 ms。
- 扫描中几次偶发的 50–108 ms 卡顿: 用同样设置重跑 6 次都没有出现,默认设置跑二十多次也从未出现,属于测试期间的系统干扰。
- 性能显示: 真正开着时,面板第一次绘制 3.4 ms,之后每帧 0.011 ms,不造成卡顿。
新的测试参数(开发用,玩家不需要)
--set 键=值:从命令行给任何一项black.ini设置,后台测试模式下也生效。日志的设置行现在也写出柔和阴影和 MSAA。--compile-port-shaders:启动时把移植层所有着色器版本编进缓存,用来做种子。--hitch-detail现在会写出每个慢绘制的状态是否回放过、所绑贴图上次上传距今几帧。
参照 ngbrecomp 的部分
- 冷启动套用存档音量参照的是 ngbrecomp 0.9.54 #182(
src/sound_boot.c,针对黑之章)。本版把同样的做法推广到 2004,2004 部分是本项目自己定位的。 - 已看过 ngbrecomp 最新的 0.9.69 / 0.9.70:帧插值(#226,实验性)本版没有采用;鬼彻 1、3 级收刀无声(#229)在本项目同样存在,待作者决定是否修正。
玩家可以帮忙补种子
在游戏文件夹的 launcher.ini 里加一行 args = --vsh-record "<游戏文件夹>\vsh_record.bin" --hitch-detail,然后正常玩。玩完把这几样交给作者:
cache\shaders\、cache\draw_states.bin、cache\texture_pool.txt、cache\cpu_textures.binvsh_record.binlogs\black.log
请在更新到新版本之前交,因为换版本时本地学到的绘制状态会被清掉。AMD 和 Intel 独显的数据尤其有用。
测试
- 发布包:Windows Defender 扫描三个程序,无威胁。
- 核显上用空缓存跑 150 秒:版本号正确,五份种子都载入(着色器 441、顶点程序 7 of 7、贴图池 194、绘制状态 16,679、水波纹贴图 10 张来自种子),没有一帧超过 50 ms,着色器种子覆盖率 100%。
- 2004 更新补丁版:顶点程序 7 of 7,冷启动音量生效。
源码
本版提交:586953c、74d1a25、fc86182、2c360c0、9d5a9c7、352cfb7、1a98c15、688e3e6、8dfd813,以及 e495c0f(版本号、README)。源码 README 新增 “2.2.32” 一节,记录每项改动和全部排查数据。
发布包
ngb-hurricane-pc-2.2.32-win32.zip- 大小:3,434,217 字节
- SHA-256:
22af056d6fafa31d94503df3fb04b3cd65c28b3d08f91b53aa3e1758832862c2 - 符号包
ngb-hurricane-pc-2.2.32-win32-symbols.zip:27,103,225 字节 - SHA-256:
af9afdb7f9d804c0d6bad9c80b8a750a3f00bb9be2ef3bff8ad141474c652f36
作者:b站 哈雅布撒(QQ:2682557218)
English
An unofficial native Windows port of Ninja Gaiden Black (including the Hurricane Chinese translation vb-zh-x2.1) and Ninja Gaiden (2004). 2.2.32.
2.2.32: the seeds completed, a new player's last first-start spike, every graphics setting checked
What players will notice
- A new player's first start no longer stutters before a cutscene. Before a cutscene the game computes 10 ripple textures on the CPU; the first time, that is a frame of about 40 ms. 2.2.31 kept them only for later starts; now they ship in the package.
- Chapters 3-4 are smoother the first time: the seeds now hold the author's recorded play of chapters 1-4.
- Players with MSAA anti-aliasing: the seeds mostly did not match for them before, so they learned the seed's states again. The seeds now work at every MSAA setting.
- NG2004 with the Hurricane Packs (title update 1.06.04): the game's own vertex programs were not in the seed for this version and compiled the first time a scene showed them; now they are.
- NG2004 applies its saved volumes at a cold start: before, 2004 reset the volumes to the defaults at every start, and a player who had changed them was asked "Apply changes to the sound settings?" at the title every time. Black was fixed in 2.2.31; now 2004 is too.
- Seam fill is off by default (the author's choice). It can be turned on on the launcher's Graphics page. Players who already set it keep their choice.
- The cost: about 0.1 s longer at every start (more states replayed). Frame times in play are unchanged.
What changed, and why
- Ripple texture seed (
cpu_textures.bin). This is data the game's code computes from its arguments and constants: not code, not art (the author agreed to ship it). The seed is read first, then the player's own file; entries already in the seed are not written to the player's file again. The five Black builds and NG2004's disc and title update have identical constants and share the same 10 textures.
Measured (empty cache, RTX 3060, twice each): frames over 33 ms 1 a run -> 0; worst frame 40-41 -> 28.6 / 32.2 ms. - Draw states under MSAA are recorded as without MSAA. With MSAA the frame draws to a multisampled target, the depth buffer becomes D24S8, and the 2D turns an MSAA render state off, so every record differed from the seed's.
An experiment first confirmed that the drivers' programs do not depend on MSAA: with MSAA 2x, replaying only the non-MSAA forms kept the area entry just as smooth (RTX 3060: no frame over 33 ms; 3 without any replay). On the Iris Xe there was no difference (Intel keeps its programs in a disk cache).
Since the fix: the attract demo with MSAA learns 19 new states, 20 without. A chapters 1-4 recording made with MSAA had 4,417 states the seed already held. The merge tool converts older recordings by the same rule. - Every one of the port's own shaders is now in the seed. Each setting uses only some of them (MSAA's copy, the resolves at other render scales). The 12 the test runs never reached are now compiled at once and added. Box resolve AT 5 goes past the GPU's instruction limit (655 > 512) and falls back to the old resolve, as designed; the seed records that it does not compile, so no start tries again.
- NG2004's title update in the vertex program seed. That program was never given to the tool, so none of the 7 programs was found in it; now 7 of 7. The seed holds only places and hashes, no game code.
- NG2004's cold-start volumes. 2004 has exactly Black's problem, but its instructions use 8-bit displacements and the volumes sit elsewhere in its save (+0x37, not +0x87), so Black's signature did not match; and 2004's programs were treated as bundled ones, which do not get this patch. The signature now takes both encodings and works the offsets out from the instructions that follow. One place each in the 2004 disc (0x1BA930), the title update (0x1CB750) and the six Black builds; 2004's downloader and updater are left alone.
--no-saved-volumeskeeps the console's way.
Measured: music set to 39 in 2004 read back as 39 at the next cold start (60 before), and the title no longer asked (confirmed by the author). - New seeds. Shaders 429 -> 441, draw states 8,339 -> 16,679, texture pool 137 -> 194 shapes (the 24 MB cap), 7 vertex programs (now with the title update's places), 10 ripple textures. Sources: the title, the attract demo, and the author's plays of chapters 1-2 and 1-4 (MSAA 2x). Each source checked with
--check: 100%.- Start-up cost (empty cache, to frame 60): RTX 3060 about 2.97 -> 3.09 s, Iris Xe about 2.19 -> 2.28 s.
- In play (Iris Xe, old and new seeds interleaved, 3 runs each): median 2.73 / 2.99 / 2.74 -> 2.75 / 2.74 / 2.77 ms, p99 unchanged, no frame over 33 ms either way.
What was looked into (each measured, for tracing later)
- Every graphics setting, each run from an empty cache through the attract demo: MSAA 2/4/8, soft shadows off, FXAA off, seam fill on, render scale 1/2/8, native resolution, effects at Xbox size, shadows 1/16, 21:9 / 16:10 / 4:3, anisotropic 16, vsync, the overlay. Result: no game shader compiled, no frame over 50 ms; each run's settings checked in its log.
(A first sweep ran every configuration with the defaults, because the background test mode reads no black.ini. It was withdrawn and rerun once--setexisted.) - Small hitches left: after the replay, 10-20 draw calls of 1-11 ms per 170 s remain, now and then making a frame of 20-32 ms (one dropped), never one over 33 ms; nearly all are fixed-function draws. Ruled out:
- states the replay missed: every one was "replayed at start";
- new textures: most were uploaded hundreds of frames before, and the slowest had none bound;
- low GPU clocks: locked at 1,800 MHz with
nvidia-smi, they stayed, with the GPU 10-20% busy; - the driver's program cache overflowing: replaying only the 1,865 states used gave the same result as all 16,679.
Taken as the NVIDIA driver's own work. For comparison, with no replay at all: 50 of them and 3 frames over 33 ms.
- A few 50-108 ms hitches during the sweep: none in 6 reruns of those settings, and none in 20+ default runs; interference during the tests.
- The performance overlay: really on, its first draw took 3.4 ms and later frames 0.011 ms; it causes no hitch.
New test options (development; players need none)
--set key=value: any black.ini setting from the command line, also in background test runs. The settings line in the log now gives soft shadows and MSAA too.--compile-port-shaders: every variant of the port's own shaders compiled into the cache at start, for the seed.--hitch-detailnow says whether each slow draw's state was replayed at start, and how many frames ago its textures were uploaded.
What follows ngbrecomp
- Applying the saved volumes at a cold start follows ngbrecomp 0.9.54 #182 (
src/sound_boot.c, for Black). This release carries the same approach to 2004; the 2004 places were located by this project. - ngbrecomp's latest, 0.9.69 / 0.9.70, was reviewed: frame interpolation (#226, experimental) is not taken in this release. The Kitetsu's missing sheathe sound at levels 1 and 3 (#229) also happens here; whether to fix it is for the author to decide.
Players can help complete the seeds
Add args = --vsh-record "<game folder>\vsh_record.bin" --hitch-detail to launcher.ini in the game folder and play as usual. Then give the author:
cache\shaders\,cache\draw_states.bin,cache\texture_pool.txt,cache\cpu_textures.binvsh_record.binlogs\black.log
Please hand them over before updating to a new version: a new version drops the draw states learned locally. Data from AMD and Intel discrete cards is especially welcome.
Tests
- The package: Windows Defender scan of the three programs, no threats.
- On the Iris Xe from an empty cache for 150 s: the right version; all five seeds read (441 shaders, 7 of 7 vertex programs, 194 texture shapes, 16,679 draw states, 10 ripple textures from the seed); no frame over 50 ms; the shader seed covered everything.
- NG2004 title update: vertex programs 7 of 7, cold-start volumes applied.
Source
This release's commits: 586953c, 74d1a25, fc86182, 2c360c0, 9d5a9c7, 352cfb7, 1a98c15, 688e3e6, 8dfd813, and e495c0f (version, README). The source README has a new 2.2.32 section with every change and every measurement.
Package
ngb-hurricane-pc-2.2.32-win32.zip- Size: 3,434,217 bytes
- SHA-256:
22af056d6fafa31d94503df3fb04b3cd65c28b3d08f91b53aa3e1758832862c2 - Symbols
ngb-hurricane-pc-2.2.32-win32-symbols.zip: 27,103,225 bytes - SHA-256:
af9afdb7f9d804c0d6bad9c80b8a750a3f00bb9be2ef3bff8ad141474c652f36
Author: 哈雅布撒 on Bilibili (QQ: 2682557218)