Shaders and the 1024-register limit

So, in a shader of mine I’ve recently bumped up against there being a limit to the number of registers available.

Specifically, I’m seeing the following error:

(0) : error C6020: Constant register limit exceeded at duration; more than 1024 registers needed to compile program

(Where “duration” is one of my uniforms; the error repeats for other such.)

Now, this is caused by a rather large array used in the shader, and it’s easy enough for me to just reduce the size of this array.

However, I want to ask: is there the potential for this to yet become an issue on other systems? Might there be some with register limits of 512, or even 256…?

(For reference, the array stores data on a particle system: 13 pieces of floating-point data per particle, and a maximum of 75 particles (previously 80 particles).)

To access a larger array of data in a shader, you’ll need to use some sort of buffer object. Unfortunately, I don’t have enough time at the moment for a deeper explanation, but I believe the gist of your options are:

  • Use a uniform buffer object or texture buffer object
  • Use compute shaders and image load/store
  • Use a vertex buffer and transform feedback

I mean, I’m fine with the amount of data that I have at the moment–I’m just worried that I’ll encounter a machine on which even that amount is too much!

Is that a reasonable worry–or can I be assured that all machines that I’m likely to run the program on will have at least 1024 registers available…?

As to other strategies, thank you for the list! I can investigate those if I do indeed turn out to be using an unsafe number of registers! :slight_smile:

1 Like

I think, you should be fine because the 1024 limit is in the opengl spec since 3.0.
Page 390:

Okay, and that seems to be from 2008, which is promising.

But when did implementations of 3.0 become ubiquitous, and are pre-3.0 systems still used much in gaming…?

I did check the Steam Hardware Survey, but while they have a section for DirectX, to my frustration they don’t seem to have one for OpenGL… (And Wikipedia doesn’t seem to have information on the matter in their article, while a quick Google/DuckDuckGo search didn’t turn up anything useful-looking.)

Unless you want to specifically target potatoes, OpenGL 3.3 is a very easy, reasonable target. A device that doesn’t support OpenGL 3.0 is probably not powerful enough to even run a shader of that size in a reasonable time.

I’ve thought about raising the minimum requirement for simplepbr for similar reasons: just because a GPU is technically capable of running the shaders, that doesn’t mean it can run them at an acceptable framerate.

1 Like

Ah, that is reassuring indeed–thank you!

Okay, good: I can then proceed as I am, I believe. :slight_smile: