3
votes

I need to access a bunch of constant values in my GLSL geometry shader. I tried it this way:

const int lookup[HUGE_NUMBER] = int[HUGE_NUMBER](1,32,...)

This works... for some hardware. On ATI cards I'm getting warnings that the size of my geometry shader may cause poor performance (sounds reasonable). On other cards (NV) the shader won't link because of insufficient memory. Defining constant arrays seems to be a unsupported hack.

So - what's the way to go? I've read of "constant buffers" in the DirectX pipeline. Is there anything similar? Or do I have to use textures?

1
Do you have a reason not to use textures? They're designed to be the GPU lookup-table of choice. - Ben Voigt

1 Answers

5
votes

You can go with at least any of the following interfaces:

  1. Texture
  2. Uniform buffer object
  3. Texture buffer