《忍者龙剑传 黑之章》(含飓风版中文汉化 vb-zh-x2.1)与《忍者龙剑传》(2004)的非官方 Windows 原生移植。2.2.33。
2.2.33:低延迟呈现,种子去重,2004 进种子
玩家会注意到的变化
- 操作更跟手:从按下按键到画面出来,快了约 14 ms(默认开启)。 游戏按主机的节拍每秒 60 帧:每帧开头读手柄,算好、画好,再等下一个节拍。以前画好的帧也要等到节拍那一刻才送去显示,白等十几毫秒;现在画完立刻送去显示,再等节拍。游戏自己的节奏、速度完全不变,只是画面出来得更早。启动器“图形”页新增“低延迟呈现”开关,可以关掉回到以前的方式。
- 2004 第一次进场景更顺:种子里加入了作者游玩 2004 第 1 章和第 2 章前半的数据。
- 种子小了一半,启动回放更快:以前同一种画法因为镜头角度不同被重复记录了很多次,现在合并了(黑之章 16,679 条 → 6,818 种),而且 2004 和黑之章能共用其中一部分。
- 更新到本版后,游戏会把旧版本本地学到的绘制状态清掉重新学(和每次换版本一样),种子会覆盖已经收录的内容。
低延迟呈现(实测)
做法参照 ngbrecomp 0.9.70 的呈现方式(docs/TECHNICAL.md「Presentation」)。测的是“游戏读到手柄输入”到“画面送出”的时间(中位数):
| 情况 | 以前 | 现在 |
|---|---|---|
| 窗口模式,核显 Iris Xe / 独显 RTX 3060,默认 3× 和高画质 4× / 8× | 16.2–16.9 ms | 2.3–2.6 ms |
| 独占全屏 165 Hz,垂直同步开或关 | 约 18 ms | 8.1–8.5 ms |
| 2004(更新补丁版) | 17.5 ms | 1.5 ms |
- 没有变的:迟到帧(各组都是 6.7%,是待机演示里本来就有的加载和影片)、游戏速度、30 帧影片的节奏(每局多等一个节拍的影片帧 3.25 → 2.25,没有变多)。
- 帧时间:窗口模式平均持平或更低(核显 4× 4.91 → 4.44 ms)。
- 小代价:窗口模式下呈现间隔的抖动多约 0.15 ms,桌面合成按屏幕刷新显示,看不出来;独占全屏下 99% 帧时间 20 → 24 ms,是 Present 等翻页的时间挪到了等节拍之前,没有因此多出迟到帧。
- 没有采用的方案:ngbrecomp 还有“在帧开始后固定时间呈现”(pace_target)。实测只降到 4–12 ms,而且独占全屏每局多出 60–160 个迟到帧。
- 怎么确认开着:日志
logs\black.log开头的settings:行写着present_early 1。实测三种black.ini:没有这一项(老玩家升级)→ 开,2.4 ms;present_early = 1→ 开,2.2 ms;present_early = 0→ 关,16 ms。
种子去重:为什么 2004 的种子和黑之章一条都对不上
作者玩了 2004 后发现,学到的 2,958 条绘制状态和黑之章的种子一条都不重合,觉得不对劲。查下来原因是:每条记录里带着“观察矩阵和世界矩阵中哪些元素恰好是 0 或 1”,而它们随镜头朝向和物体摆放变化(比如镜头刚好水平、模型没有旋转),同一种画法就被记成了很多条。
- 投影矩阵和纹理矩阵的 0/1 结构确实影响驱动生成的程序(2.2.31 时实测过),保留;观察矩阵和世界矩阵改成按普通仿射矩阵记录,读旧文件时也这样合并。
- 驱动真的不需要它们吗?待机演示、空缓存、交替各跑 4 次:只回放合并后的 6,818 种,驱动当场编译的绘制次数不比回放 16,679 条多(核显每局 26 vs 33 次,独显 20 vs 23 次),进区域那一帧和最差帧也一样。
- 本版程序加新种子 对 2.2.32:核显交替各 5 次,平均帧 4.61 / 4.65 ms,超过 50 ms 的卡顿 1.2 / 1.2 次,启动回放 192 / 201 ms;独显各 4 次,4.16 / 4.13 ms,卡顿 0 / 0 次。
- 合并后:2004 的绘制状态有 32% 与黑之章共用(之前 0%)。
种子现在的内容
- 绘制状态 8,481(黑之章 6,818 + 作者 2004 第 1 章与第 2 章前半 + 之后一段黑之章)
- 着色器 446(新增 2004 游玩里的 5 个)
- 贴图池 194 种尺寸、游戏顶点程序 7、水波纹贴图 10
- 每份原始数据都用
--check核对为 100% 覆盖。2004 更新补丁版启动时 8,481 条全部回放,0 条失败。
也查过的(这次没有采用或不适用)
- FLIPEX(窗口 / 无边框的翻页呈现):高刷新率屏幕上 60 帧的抖动来自屏幕固定 165 Hz(每帧停 3、3、3、2 次刷新),FLIPEX 一样对齐刷新,解决不了;性能只快约 0.3 ms 一帧(核显 Present 1.17 → 0.86 ms),代价是改窗口大小要重建设备。只有开了 G-SYNC / FreeSync 的屏幕可能受益,本机无法验证,暂不采用。消除抖动的办法:把桌面刷新率设成 120 或 60 Hz,或用独占全屏、关垂直同步(会撕裂)。
- NVIDIA“线程优化”关闭:独显交替各 3 次,帧时间、卡顿、慢绘制都没有差别(两组里驱动的工作线程都在,这个设置对 D3D9 是否生效无法确认)。
参照 ngbrecomp 的部分
- 低延迟呈现参照 ngbrecomp 0.9.70 的呈现方式(
docs/TECHNICAL.md「Presentation」:在游戏 Swap 时呈现,不等 vblank)。本项目在 D3D9 上重新实现,并逐项实测了窗口和独占全屏;它的固定时间呈现(pace_target)也试过,在本项目的独占全屏下会多出迟到帧,没有采用。
玩家可以帮忙补种子
在游戏文件夹的 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
请在更新到新版本之前交,因为换版本时本地学到的绘制状态会被清掉。2004、黑之章第 5 章以后、AMD 和 Intel 独显的数据尤其有用。
测试
- 发布包:Windows Defender 扫描三个程序,无威胁。
- 核显上用空缓存跑 150 秒:版本号 2.2.33;五份种子都载入(着色器 446、顶点程序 7 of 7、绘制状态 8,481 全部回放、0 条失败、水波纹贴图 10 张来自种子);
present_early 1,读输入到呈现 1.2–2.5 ms;着色器种子覆盖 100%。唯一一次超过 50 ms 是开机第 32 帧读开场文件时(51 ms,测试和作者正在玩的游戏同时运行)。 - 2004 更新补丁版:顶点程序 7 of 7,绘制状态全部回放,
present_early 1。 - 低延迟呈现的全部对比:核显 / 独显 × 默认 / 高画质 × 窗口,以及独占全屏垂直同步开 / 关,共 60 次运行(数据见上)。
源码
本版提交:1c1a87d(种子去重 + 新种子)、7b340ad(低延迟呈现)、5210fe4(默认开启 + 启动器开关)、7deff9f(版本号、README)。源码 README 新增 “2.2.33” 一节,记录每项改动和全部实测数据。
发布包
ngb-hurricane-pc-2.2.33-win32.zip- 大小:3,385,032 字节
- SHA-256:
25c6d09a8b651d384973955c833dc09e52890c6c332ffdc8722233f2f86ec612 - 符号包
ngb-hurricane-pc-2.2.33-win32-symbols.zip:27,133,245 字节 - SHA-256:
deae46f11f488ae8321fb0739f25fe24b661fa8617a0925fd9b63583f4376e0e
作者: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.33.
2.2.33: low-latency present, the seed's duplicates gone, NG2004 in the seed
What players will notice
- Controls feel more direct: about 14 ms less from a press to the picture (on by default). The game runs on the console's beat, 60 frames a second: each frame reads the pad at its start, is worked out and drawn, then waits for the next beat. A finished frame also waited for that beat before it went to the screen, a dozen milliseconds for nothing; now it goes as soon as it is drawn and the wait comes after. The game's own timing and speed are exactly as before; only the picture comes out sooner. The launcher's Graphics page has a new "Low-latency present" switch to go back to the old way.
- NG2004's first visits are smoother: the seed now holds the author's play of NG2004 chapter 1 and the first half of chapter 2.
- The seed is half the size and replays faster: one way of drawing was recorded many times over for different camera angles; those are merged now (Black's 16,679 records -> 6,818 states), and NG2004 and Black share part of them.
- After updating, the game drops the draw states learned by the old version and learns them again (as with every new version); the seed covers what it holds.
Low-latency present (measured)
After ngbrecomp 0.9.70's presentation (docs/TECHNICAL.md "Presentation"). Measured: from the game reading the pad to the picture going out (median):
| Case | Before | Now |
|---|---|---|
| windowed, Iris Xe / RTX 3060, default 3x and high 4x / 8x | 16.2-16.9 ms | 2.3-2.6 ms |
| exclusive fullscreen at 165 Hz, vsync on or off | about 18 ms | 8.1-8.5 ms |
| NG2004 (title update) | 17.5 ms | 1.5 ms |
- Unchanged: late frames (6.7% in every set: the attract demo's own loads and movie), game speed, the 30 fps movie's pacing (movie frames a beat late per run 3.25 -> 2.25, not more).
- Frame time: windowed the average is the same or lower (Iris Xe 4x 4.91 -> 4.44 ms).
- Small costs: windowed, the presents' spacing varies about 0.15 ms more, which the desktop's composition on the refresh hides; exclusive, the p99 frame time is 20 -> 24 ms (the Present's wait for its flip now comes before the beat's wait), with no frame later for it.
- Not taken: ngbrecomp's present at a steady time after the frame's start (pace_target) gave 4-12 ms only, and exclusive 60-160 more late frames a run.
- How to tell it is on: the
settings:line at the top oflogs\black.logsayspresent_early 1. Three black.ini cases checked: no key (a player updating) -> on, 2.4 ms;present_early = 1-> on, 2.2 ms;present_early = 0-> off, 16 ms.
The seed's duplicates: why NG2004's play matched none of Black's seed
After playing NG2004, the author noticed that none of its 2,958 learned draw states matched Black's seed and found that odd. The cause: each record held which elements of the view and world matrices were exactly 0 or 1, and these follow the camera and the object (an upright camera, an unturned model), so one way of drawing was recorded many times.
- The projection and texture matrices' 0/1 structure does shape the driver's program (measured for 2.2.31) and stays; the view and world matrices are recorded as a plain affine matrix's now, and older files are merged the same way when read.
- Do the drivers really not need them? Attract demo, empty caches, 4 interleaved runs each: replaying only the merged 6,818 left no more draws for the driver to build than the 16,679 (Iris Xe 26 against 33 a run, RTX 3060 20 against 23); the area entry and the worst frames the same.
- This build with the new seed against 2.2.32: Iris Xe 5 interleaved runs each, average frame 4.61 / 4.65 ms, hitches over 50 ms 1.2 / 1.2, start replay 192 / 201 ms; RTX 3060 4 each, 4.16 / 4.13 ms, hitches 0 / 0.
- Merged, 32% of NG2004's draw states are Black's too (0% before).
The seeds now
- 8,481 draw states (Black's 6,818 + the author's NG2004 chapter 1 and first half of chapter 2 + more Black)
- 446 shaders (5 new from the NG2004 play)
- 194 texture-pool shapes, the game's 7 vertex programs, 10 ripple textures
- Each source checked with
--check: 100% covered. NG2004's title update replays all 8,481 at start, none left out.
Also looked into (not taken, or not applicable)
- FLIPEX (flip presentation for windowed / borderless): the 60 fps judder on a high-refresh display comes from the display's fixed 165 Hz (frames held 3, 3, 3, 2 refreshes); FLIPEX aligns to the refresh too and cannot fix it. It is only about 0.3 ms a frame faster (Iris Xe Present 1.17 -> 0.86 ms), and resizing the window would need a device reset. Only displays with G-SYNC / FreeSync might gain, which could not be tested here; not taken for now. To remove the judder: set the desktop to 120 or 60 Hz, or use exclusive fullscreen with vsync off (tears).
- NVIDIA "Threaded optimization" off: RTX 3060, 3 interleaved runs each: no difference in frame time, hitches or slow draws (the driver's worker thread was there either way; whether the setting applies to D3D9 could not be told).
What follows ngbrecomp
- The low-latency present follows ngbrecomp 0.9.70's presentation (
docs/TECHNICAL.md"Presentation": present at the game's Swap, not at the vblank). Reimplemented here on D3D9 and measured windowed and exclusive; its steady-time present (pace_target) was tried too and gave more late frames under this project's exclusive fullscreen, so it was not taken.
Players can help complete the seeds
Add a line args = --vsh-record "<game folder>\vsh_record.bin" --hitch-detail to launcher.ini in the game folder and play as usual. Then hand these to 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. NG2004, Black chapter 5 onwards, and AMD and Intel discrete cards are 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: version 2.2.33; all five seeds read (446 shaders, 7 of 7 vertex programs, all 8,481 draw states replayed with none left out, 10 ripple textures from the seed);
present_early 1, pad read to Present 1.2-2.5 ms; the shader seed covered everything. The one frame over 50 ms was frame 32 at boot reading the opening files (51 ms, with the author's own game running at the same time). - NG2004 title update: vertex programs 7 of 7, all draw states replayed,
present_early 1. - The low-latency present's full comparison: Iris Xe / RTX 3060 x default / high quality x windowed, and exclusive fullscreen with vsync on / off, 60 runs (figures above).
Source
This release's commits: 1c1a87d (the seed's duplicates + new seeds), 7b340ad (low-latency present), 5210fe4 (on by default + the launcher switch), 7deff9f (version, README). The source README has a new 2.2.33 section with every change and every measurement.
Package
ngb-hurricane-pc-2.2.33-win32.zip- Size: 3,385,032 bytes
- SHA-256:
25c6d09a8b651d384973955c833dc09e52890c6c332ffdc8722233f2f86ec612 - Symbols
ngb-hurricane-pc-2.2.33-win32-symbols.zip: 27,133,245 bytes - SHA-256:
deae46f11f488ae8321fb0739f25fe24b661fa8617a0925fd9b63583f4376e0e
Author: 哈雅布撒 on Bilibili (QQ: 2682557218)