Lately I'm getting some
error C6020: Constant register limit exceeded at variable; more than 1024 registers needed to compile program
errors during compilation of a GLSL vertex shader, probably because of the number of uniform variables and I'm trying to figure out a way of estimating/calculating the number of registers required in the shader based on the uniforms that I have defined. Is there any guide or rule for that?
For example, am I correct to assume that variables up to vec4 in size require 1 register and mat4 require 4 registers? Are there any rules for this purpose?
Graphics hardware is simply too diverse for any such estimation. Even your seemingly simple assumption:
variables up to vec4 in size require 1 register and mat4 require 4 registers?
That's not correct on a lot of modern hardware. It used to be, but that was years ago. Especially if you're talking about individual uniform
variables; compilers can play all kinds of games with them.
There is no even remotely accurate way of estimating the number of such resources consumed by a piece of GLSL code. You can count the number of uniform components your code uses, but that's because OpenGL tells you how to do it. Beyond that, there's nothing you can do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With