Frage

I want to do something like this in my geometry shader:

uniform int maxOutputVert;

layout(points) in;
layout(points, max_vertices=maxOutputVert) out;

However I get error while compiling it:

Error: error(#132) Syntax error: 'maxOutputVert' parse error

and shader won't compile.

I could understand that it might be too hard for memory management if that variable would change in each shader run, but here it would be constant thorough single drawing call, because uniforms are constant. It also fails if I define some integer constant right in shader and use it as max_vertices count:

const int a = 5;
layout(points, max_vertices=a) out;

Same error is generated. So is there way to do this or do I simply have to put a number inside that call or it won't compile. If the second is the case, how can I assure that I won't exceed the maximum output number queried inside main process by:

glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &maxoutput);

Edit: Sorry for I forgot to mention I'm using ATI/AMD and the Catalyst version is 2010.1105.19.41785 (it's the most stable I've tried...)

War es hilfreich?

Lösung

The shader layout is something determined at compilation time, and it cannot be parametized like this. For each difference in layout you need a own shader. So what you can do is, modify the shader sourcecode before upload. Something like this:

Start with a template shader source:

uniform int maxOutputVert;

layout(points) in;
layout(points, max_vertices=$MAXOUTPUTVERTICES$) out;

And before submitting this as to glShaderSource, replace the string $MAXOUTPUTVERTICES$ with the number.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top