Patching Marathon, GPU Branching

After a patching marathon, I’ve finally completed my conversion of Desaxismundi’s 55 Maths Surfaces into individual GLSL patches. That’s 55 patches, each with 13 connections…
You can do the maths if you like; all I know is that’s a lot of little yellow leads. This program is going to give me RSI…

I did manage to keep things relatively tidy, by grouping the GLSL patches into 6 Macros. Demultiplexer patches were used to switch on the appropriate macro, then enable the correct GLSL patch within the active macro. I initially attempted the switching using JavaScript, but it turned out to be easier to achieve using Demultiplexers and some very simple maths.

The reason for all this is that, after making a few enquiries, I’ve discovered that graphics hardware tends to have ‘issues’ with branching logic. Apparently, some GPUs actually evaluate the result of both (or all) results, then chooses which result to use. This meant that in the case of some of the surface shaders I’d put together previously, the GPU was attempting to compute 10 different positions for each vertex- which is obviously not a Good Thing, in terms of efficiency. It seemed the only safe solution was to separate each surface calculation into its own discrete GLSL shader patch. Hence my patching hell….

The result, however, promises to be well worth the effort. The composition certainly seems to run a lot more smoothly now. It’s looking good. The only thing left to do is to iron-out the massive scale differences between some of the surfaces, probably by applying a second transform matrix to the result of the vertex position calculation. I think I’ll hold off on that for the moment, though.


0 Responses to “Patching Marathon, GPU Branching”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


February 2008
« Jan   Mar »


Blog Stats

  • 481,663 hits

%d bloggers like this: