i’m trying to make a little application with transform feedback, i want to capture all (transformed) vertex attributes and want to reuse them the next frame (double-buffered)
capturing variables already works, but i assume the problem is the glsl compiler that “optimizes” the vertex shader and discarts unused variables
as you can see, the fragment shader does some “weird” stuff, i just added a position to “[persuade]” the compiler to not discard the variable, but that’s just for testing purposes[/QUOTE]
Hmm, ok. Since you’re doing transform feedback, why do you even have a fragment shader? I’d get rid of that (that is, only link a vertex shader into your shader program). See if the linker removes position then.
If so, you might consider using glTransformFeedbackVaryings to set the TF outputs instead of the layout qualifiers. Just be sure to call this “before” you link your program. See this: Transform Feedback (OpenGL Wiki)
i tried that --> it works!
but the thing is i want to do a kind of “buffer pingponging”
that means WHILE rendering a triangle, i want to capture the transformed vertex in buffer 2
when done, i use buffer 2 as GL_ARRAY_BUFFER and feed the vertices into the same program again, capturing every thing into buffer 1 (ping-pong)
so the point is i need the fragmentshader (beside 2 VAO, 2 VBO, 2 Xfer feedback objects)
glTransformFeedbackVaryings(…) is exactly what i want to avoid
(used it before, works perfectly)
i also tried to set
#version 450 core
in both shaders (vertex / fragment) --> doesnt work
Ok. Well as far as I know what you’re doing is fine. What GPU/driver/OS is this?
I’d suggest that you double-check the spec just to verify that your/my understanding that this is valid is correct. And assuming so, file a bug report with the company/organization that maintains the drivers you’re using.
For now I guess you can continue to use a work-around similar to what you are using, but just change the expression so it can have no real effect on the resulting color, and yet won’t allow the compiler to optimize it away.