Hi all!
I have been trying Shader Storage Buffer Objects for a sprite rendering engine I’m making. At some point, there was a Vertex Buffer Object which stored the quads’ untransformed position and texture coordinates. There was a also an (immutable) Index buffer - I only draw quads so the index sequence is always the same. The SSBO contained the texture ID (using bindless), and stuff like rotation, scale etc. Since attributes like sprite rotation applies to the entire quad, it made sense to use a SSBO instead of storing extra floats per vertex in the VBO. I’m using glDrawElements() by the way.
Then, it kind of dawned on me that the VBO may be wholly redundant. Consider this: A sprite is a quad. It’s the same thing over and over again. Why not put everything in the SSBO and use gl_VertexID for all quad attributes?
So I went and deleted the VBO altogether. No shader inputs, no vertex attribute pointers, nothing. The shader just reads stuff from the SSBO and draws the quads. It does work! I tested it on a new Nvidia GPU, an older AMD GPU and a new integrated Intel GPU. But I have 2 main questions regarding this approach:
- Is this…dangerous? I mean, is the usage of a VBO mandatory for a draw call to succeed? I have created a VAO, bound an index buffer to it, no attributes whatsoever enabled.
- Performance - wise, I haven’t been able to verify any speed increase compared to also using a VBO. This does seem a bit weird to be honest. Does the absence of a VBO somehow slows down the rendering pipeline to such a degree that it offsets any potential speed gains? Should I stick to having a dummy VBO for compatibility reasons?