《忍者龙剑传 黑之章》(含飓风版中文汉化 vb-zh-x2.1)与《忍者龙剑传》(2004)的非官方 Windows 原生移植。2.2.34。
2.2.34:高刷屏独占全屏不再抖,独占全屏的游戏时钟跟随屏幕
玩家会注意到的变化
- 高刷新率屏幕(120 / 144 / 165 Hz)用独占全屏、开垂直同步时,画面不再一顿一顿(默认开启)。 游戏每秒 60 帧,以前独占全屏沿用桌面的刷新率,在 165 Hz 上每帧停 3、3、3、2 次刷新交替(18 ms 和 12 ms 来回变)。现在进入独占全屏时把屏幕换成同分辨率的 60 Hz(屏幕要支持),每帧正好显示一次。启动器“图形”页新增“垂直同步时用 60 Hz”开关,可以关掉。
- 独占全屏 60 Hz 下,过场影片不再变慢、卡顿。 桌面本来就是 60 Hz、用独占全屏的玩家,在 2.2.33 及之前播放影片时游戏节拍会掉到约 54 Hz,影片明显变慢、频繁卡顿;本版修好了。
- 不受影响:窗口模式、无边框全屏、关掉垂直同步的独占全屏,行为和以前完全一样。
- 代价:高刷屏玩家进出独占全屏(包括 Alt+Tab)要切换显示模式,会多黑约 1.4–1.8 秒;画面要等 60 Hz 的刷新,比 165 Hz 时稍晚几毫秒(按原理推算,未实测)。
改了什么,为什么
- 独占全屏 + 垂直同步时用 60 Hz 模式:桌面刷新率不在 59–61 Hz 时,从显示器支持的模式里找同分辨率、59–61 Hz 的模式(本机 1920×1200 只有 60 和 165 Hz)。创建设备和重置设备都用同一个选择。
black.ini exclusive_60hz(默认 1),日志开头的设置行会写出它的值;--keep-refresh在命令行关掉。 - 独占全屏 60 Hz 时,游戏节拍等屏幕的硬件 vblank:60 Hz 时游戏的节拍原本跟着桌面合成(
DwmFlush),独占全屏下它不可靠:待机演示的影片段(每帧上传 1.3 MB 画面)节拍掉到 53.9 Hz,影片帧 50–65 ms,出现 18 次超过 50 ms 的卡顿,22 秒里只显示了 700 帧(应为约 780 帧)。现在独占全屏改为等屏幕的硬件 vblank(D3DKMTWaitForVerticalBlankEvent,取主显示器所在的适配器,屏幕接在核显、独显渲染时也有效)。窗口模式仍用DwmFlush,其他刷新率仍用计时器。
实测(前台运行,独占全屏 + 垂直同步,待机演示,空缓存,160 秒)
| 情况 | 游戏速度 | 迟到帧 | 超过 50 ms 的卡顿 | 节拍 |
|---|---|---|---|---|
| Iris Xe,60 Hz,以前的同步 | 93.7% | 6.7% | 18 | 第一分钟 53.9 Hz |
| Iris Xe,60 Hz,本版 | 93.7% | 6.7% | 1 | 3600 / 3600 来自屏幕,60.008 Hz |
| Iris Xe,165 Hz(关掉本开关,以前的方式) | 93.7% | 6.8% | 1 | 59.94 Hz 计时器 |
| RTX 3060,60 Hz,本版(屏幕接在核显上) | 93.7% | 6.7% | 1,最差帧 20.9 ms | 60.008 Hz |
| RTX 3060,165 Hz | 93.7% | 6.7% | 1,最差帧 28.1 ms | 计时器 |
- 60 帧部分每一帧都正好一个 vblank(4000 帧里 4000 帧)。
- 设备重置(Alt+Tab、Alt+Enter 走的路径)153 ms,之后仍是 60 Hz;重建设备(驱动出错时)3.6 秒后恢复,仍然同步。
- 窗口模式(165 Hz 桌面):计时器,和以前一样,93.7%,卡顿 1 次。
- 进入独占全屏到出第一帧:Iris Xe 1.4 → 3.0 秒,RTX 3060 2.2 → 4.0 秒(换显示模式)。
- 三种
black.ini都按玩家实际方式验证:没有这一项 → 开、60 Hz;= 1→ 开、60 Hz;= 0→ 关、165 Hz。
排查中弄清的一件事(开发相关)
自动测试原来都带 --background,游戏窗口不会被激活。独占全屏的窗口不在前台时,60 Hz 下每帧会占两个刷新(游戏速度 57–86%,Present 约 20 ms,2 个或 3 个后台缓冲都一样),165 Hz 下则表现为 Present 多花约 5 ms。这是测试方式造成的,玩家的窗口都在前台,不受影响。以后独占全屏都用前台运行测量(2.2.33 发布说明里独占全屏的 Present 耗时因此偏高,但当时的开 / 关对比是同样条件,结论不变)。
种子
- 加入作者 11-17 早上游玩黑之章 4 分钟学到的 12 种绘制状态和 1 个着色器(固定管线的一种贴图组合):绘制状态 8,481 → 8,493,着色器 446 → 447。每份来源都核对为 100% 覆盖。
还没解决、如实说明的
- 2.2.33 的低延迟呈现开启后,开机第 30 帧左右(读开场文件、黑屏阶段)偶尔有一帧 50 多 ms:开时 15 次启动出现 4 次,关时 14 次 0 次。玩家看不到,游戏过程中没有增加卡顿,原因尚未深查。
- 只支持 120 Hz、不支持 60 Hz 的屏幕:保持原样(120 Hz 每帧两次刷新本身是均匀的,但游戏节拍不跟 120 Hz 同步),没有测过。
- AMD、Intel 独显、Steam Deck,以及 G-SYNC / FreeSync 屏幕都没有测过。
测试
- 发布包:Windows Defender 扫描三个程序,无威胁。
- 核显后台跑黑之章 150 秒:版本号 2.2.34,五份种子载入(着色器 447、顶点程序 7 of 7、绘制状态 8,493 全部回放、0 条失败、水波纹贴图 10),没有一帧超过 50 ms,着色器种子覆盖 100%,
present_early 1, exclusive_60hz 1。 - 2004 更新补丁版:顶点程序 7 of 7,绘制状态全部回放,没有一帧超过 50 ms。
- 发布包本身前台独占全屏 + 垂直同步 90 秒:切到 60 Hz,节拍 3600 / 3600 来自屏幕(60.011 Hz),没有一帧超过 50 ms。
源码
本版提交:7c91773(独占全屏 60 Hz 与屏幕 vblank 时钟)、7eeacc0(black.ini 设置与启动器开关)、204ee64(种子)、b4d4ffb(版本号、README)。源码 README 新增 “2.2.34” 一节。
发布包
ngb-hurricane-pc-2.2.34-win32.zip- 大小:3,393,517 字节
- SHA-256:
f2cea480a993393d09a7c508f2077dce9296564cc7c59c3a81fa1985561e0289 - 符号包
ngb-hurricane-pc-2.2.34-win32-symbols.zip:27,800,010 字节 - SHA-256:
eced086301174108aa13216d59eb73724985c82be506bb0a6552b21d970dc52e
作者: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.34.
2.2.34: exclusive fullscreen on a high-refresh screen without judder, its clock from the display
What players will notice
- On a high-refresh screen (120 / 144 / 165 Hz), exclusive fullscreen with V-Sync no longer judders (on by default). The game makes 60 frames a second; exclusive fullscreen kept the desktop's refresh, and at 165 Hz each frame stayed for 3, 3, 3, 2 refreshes in turn (18 ms and 12 ms back and forth). Now entering exclusive fullscreen switches the screen to 60 Hz at the same size (if the screen has it), and each frame is shown exactly once. The launcher's Graphics page has a new "60 Hz with V-Sync" switch to turn it off.
- At 60 Hz in exclusive fullscreen, cutscene movies no longer slow down and stutter. Players with a 60 Hz desktop using exclusive fullscreen had the game's beat fall to about 54 Hz during movies in 2.2.33 and before, the movie visibly slower with frequent stutters; fixed.
- Not affected: windows, borderless fullscreen and exclusive fullscreen with V-Sync off behave exactly as before.
- Costs: on a high-refresh screen, entering or leaving exclusive fullscreen (Alt+Tab too) changes the display mode, about 1.4-1.8 s more of black; a picture waits for a 60 Hz refresh, a few ms later than at 165 Hz (worked out, not measured).
What changed, and why
- Exclusive fullscreen with V-Sync at a 60 Hz mode: when the desktop is outside 59-61 Hz, a mode of the same size at 59-61 Hz is taken from the display's modes (this panel at 1920x1200 has only 60 and 165 Hz). Creating and resetting the device use the same choice.
black.ini exclusive_60hz(1 by default), named in the log's settings line;--keep-refreshturns it off from the command line. - At 60 Hz in exclusive fullscreen the game's beat waits for the display's own vblank: at 60 Hz the beat followed the desktop's composition (
DwmFlush), which is not reliable under an exclusive device: in the attract demo's movie (1.3 MB uploaded a frame) the beat fell to 53.9 Hz, movie frames took 50-65 ms, 18 hitches over 50 ms, 700 frames shown in 22 s instead of about 780. Exclusive fullscreen now waits for the display's vblank (D3DKMTWaitForVerticalBlankEventon the primary display's adapter; it works with the panel on the integrated GPU and the dedicated one rendering). Windows keepDwmFlush, other refresh rates the timer.
Measured (foreground, exclusive with V-Sync, attract demo, empty caches, 160 s)
| Case | Game speed | Late frames | Hitches over 50 ms | Beat |
|---|---|---|---|---|
| Iris Xe, 60 Hz, the old sync | 93.7% | 6.7% | 18 | 53.9 Hz in the first minute |
| Iris Xe, 60 Hz, this release | 93.7% | 6.7% | 1 | 3600 of 3600 from the display, 60.008 Hz |
| Iris Xe, 165 Hz (the switch off, the old way) | 93.7% | 6.8% | 1 | 59.94 Hz timer |
| RTX 3060, 60 Hz, this release (panel on the Iris Xe) | 93.7% | 6.7% | 1, worst frame 20.9 ms | 60.008 Hz |
| RTX 3060, 165 Hz | 93.7% | 6.7% | 1, worst frame 28.1 ms | timer |
- Every frame of the 60 fps part took exactly one vblank (4000 of 4000).
- A device Reset (Alt+Tab's and Alt+Enter's path) took 153 ms and stayed at 60 Hz; a new device (after a driver fault) drew again after 3.6 s, still synced.
- Windowed (165 Hz desktop): the timer as before, 93.7%, 1 hitch.
- Entering exclusive fullscreen to the first frame: Iris Xe 1.4 -> 3.0 s, RTX 3060 2.2 -> 4.0 s (the mode change).
- The three black.ini cases checked the way a player runs: no key -> on, 60 Hz;
= 1-> on, 60 Hz;= 0-> off, 165 Hz.
Found on the way (development)
The automated runs used --background, which leaves the game's window inactive. An inactive exclusive device took two refreshes a frame at 60 Hz (game speed 57-86%, Present about 20 ms, with 2 or 3 back buffers alike) and showed as about 5 ms longer Presents at 165 Hz. A test artifact: players' windows are active. Exclusive fullscreen is measured with foreground runs from now on (2.2.33's notes show exclusive Present times too high for this reason; its on/off comparisons ran under the same conditions and stand).
Seeds
- The author's 4-minute Black play of 11-17 morning: 12 draw states and 1 shader (a fixed-function stage combination) added: draw states 8,481 -> 8,493, shaders 446 -> 447. Each source checked: 100% covered.
Not solved yet, stated as it is
- With 2.2.33's low-latency present on, frame ~30 at start (loading the opening files, a black screen) now and then takes 50-odd ms: 4 of 15 starts with it on, 0 of 14 off. Not visible, no more hitches in play; the cause not looked into further.
- Screens with 120 Hz but no 60 Hz mode keep their refresh (120 Hz shows each frame twice, evenly, but the game's beat does not follow it); not tested.
- AMD and Intel discrete GPUs, the Steam Deck, and G-SYNC / FreeSync screens have not been tested.
Tests
- The package: Windows Defender scan of the three programs, no threats.
- Iris Xe in the background, Black for 150 s: version 2.2.34; all five seeds read (447 shaders, 7 of 7 vertex programs, all 8,493 draw states replayed, none left out, 10 ripple textures); no frame over 50 ms; the shader seed covered everything;
present_early 1, exclusive_60hz 1. - NG2004 title update: vertex programs 7 of 7, all draw states replayed, no frame over 50 ms.
- The package itself in the foreground, exclusive with V-Sync for 90 s: switched to 60 Hz, the beat 3600 of 3600 from the display (60.011 Hz), no frame over 50 ms.
Source
This release's commits: 7c91773 (exclusive 60 Hz and the display-vblank clock), 7eeacc0 (the black.ini setting and the launcher switch), 204ee64 (seeds), b4d4ffb (version, README). The source README has a new 2.2.34 section.
Package
ngb-hurricane-pc-2.2.34-win32.zip- Size: 3,393,517 bytes
- SHA-256:
f2cea480a993393d09a7c508f2077dce9296564cc7c59c3a81fa1985561e0289 - Symbols
ngb-hurricane-pc-2.2.34-win32-symbols.zip: 27,800,010 bytes - SHA-256:
eced086301174108aa13216d59eb73724985c82be506bb0a6552b21d970dc52e
Author: 哈雅布撒 on Bilibili (QQ: 2682557218)