Reputation: 115
When I try to link my Geometry Shader it throws the following error:
0(76) : error C5041: cannot locate suitable resource to bind variable "triTable". Possibly large array.
In reference to this array declared in the shader:
const int triTable[256][16] =
{ { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
{ 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
{ 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 },
...
...
...
{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } };
The array is quite large. Does this have to do with the array being just too big to declare within the shader, or is there some other problem?
Upvotes: 2
Views: 2011
Reputation: 1169
You have several options:
Upvotes: 0
Reputation: 6196
Triangle data is not meant to be in constants (or uniforms).
Yes, the data is to big to fit in the array. There are hardware contraints on uniform data, and other types of data when using OpenGL.
Preferably you should put your triangle data into a vertex array object and render using it, but if for some reason you want to have the triangle data available for every invocation of the shader you can get this functionality by encoding your vertices into an texture instead of an uniform array, and then just fetch from the texture inside your shader.
In general, textures solve the problem of needing a large amount of constant data between shader invocations.
Note that you can get float texture formats which is probably what you would use for vertex data.
Upvotes: 3