View Full Version : 16 Bit int to save uniform location

10-12-2013, 03:27 PM

to prevent glGetUniformLocation calls for every uniform and every frame, I want to save the uniform location to an unsigned int (after checking for -1 error). It would be _very_ convenient to save this location as 16 Bit wide integer. The OpenGL specification tells me that the return value is 32 Bit wide. Now my question: Is it (very) problematic to use a 16 Bit unsigned int to do this? Do more than 2^16 uniform location even get used (by a rather small app)? Is it possible that the returned int is bigger than 2^16 despite "free" locations < 2^16?


carsten neumann
10-13-2013, 12:51 AM
Implementations are free to pick locations in what ever way they want, so yes it's possible to get large values. In practice the location will usually be some kind of index or offset into storage for uniforms, hence a smallish number. That being said, consider what kind of micro optimization you are doing by using only 16 bit, how many shaders and uniforms do you expect to have? How much memory does this save you? Is it worth your time to even worry about it? ;) ;)