Monday, March 31, 2008

DRI2 Direct Rendering

I just committed the last bit of DRI2 work for now to the xserver, mesa and xf86-video-intel repos. This work enables direct rendering to redirected windows:

So what's going on in this screenshot? Totem is playing the trailer from the new blender open movie project, Big Buck Bunny. While this looks to be a great follow-up to their previous movie, Elephants Dream, the interesting thing here is that it's playing using textured video under the batchbuffer branch of the intel driver, backed by the kernel video memory manager (TTM). Traditionally the X video extension (Xv) has been implemented by an overlay mechanism that lets the driver configure the hardware to scan out the pixels in the video area from a different buffer, doing color conversion and scaling on the fly. In other words, as the hardware scans through video memory to send the pixels to the monitor, it flips to read from a different buffer as it enters the window that shows the video. It's a fairly simple mechanism and it's cheap to implement in hardware, but it doesn't work for redirected windows. Textured video uses the 3D hardware to do scaling and color conversion, and since that is just regular 3D rendering, it can be redirected just fine, as seen in the screenshot. The textured video work was done by Eric Anholt and it's been in the intel driver for a while now - what's new here is that it runs under DRI2.

Also in this screenshot we have good old glxgears and MacSlows cool RGBA GLX demo. Both of these GLX applications are doing direct rendering to redirected windows. The main motivation behind the DRI2 work was to get redirected, accelerated rendering working. The first step got AIGLX (indirect rendering) working, and with this last bit, direct rendering now also works. The RGBA demo further demonstrates that we can now create a window with an RGBA visual and render to it from OpenGL and the compositing manager (in this case compiz) will composite it and blend it correctly with the rest of the desktop contents.

With Xv and Open GL finally working under composite, the intel driver is in pretty good shape. We're getting closer to a point where we can ship with a compositing manager enabled by default. In Fedora 9, we're shipping all this as a technology preview kind-of thing. DRI2 still has a number of crashers that I'm chasing and it's very new code. There will be an xorg.conf option or similar that will enable the batchbuffer branch of the intel driver and the DRI2 infrastructure. Hopefully by the time Fedora 10 comes out, it will be on by default.