posted February 12th, 2008
The Speed Edition continues. This release is more focused on bug fixes, but also features some speed ups and an unfortunate speed regression (one speedup is still too buggy to be used).
The Black Screen and Image Loading
Several people reported that opening images resulted in a black canvas. I have been unable to reproduce this problem, even on the same hardware, which as you may imagine, is a nightmare. The bug involves uploading images to the GPU. If this screws up, OpenGL creates a solid black texture.
However, the affect code had to be rewritten anyway, so there’s a good chance this bug has been fixed. If not, there’s significantly more robust error checking here and (finally) Naked light can send in bug reports, which should make this bug easier to catch.
For the good news, loading images is significantly faster. The actual transport from RAM to VRAM is literally about two orders of magnitude faster, which is absolutely ridiculous.
There’s just one major bottleneck left here, which is “cleansing” images into GPU-friendly data. Specifically, there’s errors with alpha premultiplication, but long story short, the speedup here has temporarily been turned off (as it was in Beta 2.0, too) so that you get a slower but more correct image in all instances.
Leopard Graphics Update
The Leopard Graphics Update that shipped yesterday has a disastrous bug in it. I’ve put together a small hack to work around this last night, and aside from that, the update’s great. The most notable difference is in the dock: without any code changes on my part, this is incredibly smooth and snappy at all times. Previously, I’d found the dock to be hit or miss: at random it would be slow and stuttery.
I don’t know the details of the Leopard Graphics Update, as Apple is characteristically vague about it:
I do know that it:
- contains updated GPU drivers
- contains updated OpenGL code, and
- contains significantly updated raw image support, including the updates for Aperture 2.0.
So, there’s enough changes that I’m requiring this update. This Naked light release, and all future releases, require Mac OS X 10.5.2 and the Leopard Graphics Update.
Right now it rather uglily crashes without the update. Future versions will have a kinder warning.
One of the most time-consuming parts of this update was involved in multi-threading more parts of Naked light. The rendering of individual documents now runs on their own thread, as does texture uploading. This introduces some nice speed increases, although not in the way you would think if you were a programmer.
Core Animation and Core Image aren’t very multi-threading friendly, despite what Apple’s marketing department would have you believe. Basically, Core Image has to render on the main thread, and Core Animation locks up the main thread while you’re rendering. So Naked light can’t take advantage of multiple processors here. (Although this wouldn’t be a huge win anyway as the GPU, not the CPU, is Naked light’s bottleneck when rendering.)
The speed ups here come from not having to switch OpenGL “contexts”—which are basically all the state information that OpenGL tracks to render scenes. Context switches are one of the slowest operations in OpenGL, and using a separate thread for each context let’s us avoid this. Another OpenGL bottleneck—changing the GLSL shader—is also avoided by doing this.
The other benefit of this is robustness. OpenGL contexts aren’t threadsafe, but Naked light has multiple threads that may need to access OpenGL for different reasons—generally for texture uploading. By putting each context on its own thread, I can upload textures on one thread and be rendering on another. This is another huge speedup win, but more importantly, simplifies the code and most likely stops a few crashers.
The One Speed Regression
One of the speedups introduced in Beta 2.0 was, for lack of an existing term, structure caching. Basically, Naked light would save the OpenGL shaders associated with the structure of your composition, which allowed you to make non-structural adjustments (like changing values in the Inspector) without having to recompile.
This is still incomplete, and the half-done version caused significant errors, typically with either the wrong image (or no image) showing up after a fairly short period of use. I’m hoping to get all the significant crashers and rendering bugs fixed by Beta 3.0, so anything that causes more errors needs to get turned off for the moment.
This is one of the most important speedups, and disabling it has slowed Naked light down a bit. When this is up and working for real, this is going to be the single most important speedup, so it’s next on the To-Do list.
Get it here: Naked light Beta 2.1.
Naked light Beta 2.1 requires OS X 10.5.2 and the Leopard Graphics Update.