2 questions: VAO and geometry shaders

  1. VAO:

I’m getting really bad performance from VAOs, wich is the greatest version number of OpenGL in wich VAOs are not mandatory? I will use core context of that version (like 6-8% less drawcalls if using VAOs instead of setting states singulary, also because when states are singular you can avoid in average 3/4 of the calls because become redundant, seems that you can easily outperform drivers in that kind of optimization).

  1. Geometry shaders:

Is it possible to emit vertices inside geometry shaders and having those vertices use a vertex format different from the one of the VBO? (says I have particles I just input a set o points (X,Y,Z) and a textureindex (for the texture array) then the geometry shader outputs 4 (or more if want to save some fill rate) vertices and adds to them the UV coordinates wich are easily generated.

Thanks in advance

  1. There is no version of the core profile where you can avoid VAOs. You can bind a VAO at startup and leave it bound in the context for the entire program duration, though. Then you can set vertex states singularly as you did in non-core.

  2. Yes, you can emit any set of varyings you want from a geometry shader, as long as they match up to your fragment shader inputs. However, the more outputs and vertices you produce, the slower the geometry processing will be as fewer invocations of the shader can be run in parallel. It seems like many implementations will pad your output variable to vec4, so for example combining two vec2 outputs into a vec4 output can be beneficial.

You can just run a non core profile. I think nvidia drivers will let you use a core profile without any VAOs. That is not standard conform but just there way to say “fuck VAOs”.
malexander already mentioned the default way to handle this, create and bind a single VAO. That’s what I do, because I work with mesa drivers and need to use a core profile to get GL3.3.
And if available I use ARB_vertex_attrib_binding and ARB_multi_bind. If your layout stays the same you can change all vertex buffer bindings with a single call.

You tell the geometry shader what type (there is only points​, line_strip​, triangle_strip​) and how many you output maximum. (http://www.opengl.org/wiki/Geometry_Shader)

You’ve already got some good responses. Just to add to that, for VAO just use a compatibility profile and never use VAOs if you don’t want to. If you must use core, just gen and bind one VAO, and then blissfully ignore the fact that VAOs even exist.

As to geom shader, …what they said. In the new-style (3.2 “core”, ARB_gpu_shader5) way, you just declare what your geometry shader outputs in your geometry shader source code. For instance, let’s suppose your geom shader is generating POINTS output to 2 streams, writing a vec4 and a float to each for point, in your geom shader you’d have:

# extension GL_ARB_gpu_shader5  : require

  layout( points, max_vertices = 1 ) out;

  layout( stream=0 ) out vec4  apples0;
  layout( stream=1 ) out vec4  apples1;
  layout( stream=0 ) out float oranges0;
  layout( stream=1 ) out float oranges1;

Uao thanks very much guys! that’s a lot of stuff I’ll have my time to get deep into that :slight_smile: unluckily I don’t have parte of the features you mentioned but I have a lot to play with now:)