BAGL
October 5, 2005 5:05 am hackingA few days ago I started working on a new GObject-based framework for doing general stuff on the GPU. It’s in the very early stages so far, and basically allows render-to-texture and readback of the textures. It’s not very portable yet, in a couple different ways. Right now the test programs require X11, and won’t work on Windows or Mac. That’s pretty minor, is easily fixed, and doesn’t really matter that much anyway. It’s also not very portable between different types of video cards yet, since it depends upon FBOs (and makes use of PBOs if they’re available). And while I was at it, I don’t check for support of rectangular, non-power-of-two textures since any video card that does FBOs and PBOs will also support that. So, basically this code will currently only run on NVIDIA cards.
I’m just now about to start working on the shader support. There are two possible approaches here. The first is to find the best existing shader and use it. The second approach is to have some general data structure describing the shader, select a shader target, and generate the source for it (GLSL, HLSL, ARBvp/ARBfp assemblies, etc) at runtime. This is sort of
what libsh does, although since it’s a C++ template metaprogramming library it generates the source at compile time. The obvious advantage of this approach is that you jump through a few extra hoops to write your shader, and it gets generated into any target you want and you don’t have to write it multiple times. The obvious disadvantage is just that it’s hard to implement, and that it conceivably doesn’t generate the highest-performing shader code. For my purposes, I don’t necessarily need the highest-performing shader code so this isn’t a problem. However, I also don’t care that strongly about the multiple targets. I’d be willing to write one shader a couple times to support different GPUs if necessary (e.g., one shader for SM3.0 and one for everything else). Also, I’d rather go with the easier-to-implement approach so I can have something working sooner rather than later.
This is my first step to World Domination!