Shader Constants

An important goal of the effect system in Orion Engine is that it can handle many types of shaders and/or effect files, while still remaining to be completely cross-platform.  So far, I believe I can handle HLSL and CgFX effect files quite well.  Another important goal of the effect system is to be able to use the same data files, no matter what shader model is present, and no matter what platform is used.  Basically, our effect files can contain various binary blobs of shader code which can be selected at run-time, based on the platform and/or rendering API that is being used.  For example, we could have D3D10 shaders that get selected if the current video driver is DirectX 10 and/or 11 based.  If we only have DirectX 9, then we can fallback to a technique that uses an earlier shader model.

I’ve been spending a lot of time trying to figure out the best way to abstract the shader management in my video driver, so that it works well with all of the existing API’s such as OpenGL and DirectX.  I think I am pretty much there now.  Unfortunately, there is not one single way that works best for all of the variations.  But I do think I have found a way that is going to work quite well.  The way shader constants are handled seems to have been the hardest part for me to figure out.  When Microsoft designed the new effect system in Direct3D 10, they changed a lot of things from the way Direct3D 9 used to work.  One big difference is, instead of having just one shader constant buffer, now you can have up to 14 of them bound to a single shader at any given time.  This did bring up a lot of issues that I didn’t really expect early on in the design process.  Hopefully, the tough choices I had to make all stand the test of time.

If Microsoft supported Direct3D 10 on Windows XP, then I’d just scrap my entire Direct3D 9 driver and move promptly and directly to version 10.  But no, I feel Microsoft is trying to keep this exclusive to Windows Vista only, thinking that people will upgrade their OS for that reason.  This really kind of pisses me off.  Well, it may be good for them, but this sucks for game developers.  Because now we are forced to maintain and support one additional, totally different, rendering API in our code — if we want to take full advantage of all the graphics capabilities on all of the dominant Windows platforms out there.  This is no easy job, since Direct 3D 10 is so darn much drastically different from Direct3D 9.

Let me tell you first hand, it’s freakin’ hard to keep up with all of the rapid changes in technology.

Rust never sleeps…

About Eric DeBrosse

Lead developer of the Orion Engine.
This entry was posted in Engine Development. Bookmark the permalink.