What I don’t understand is this: why does OpenGL make the devs go through hoops to get optimal rendering performance? I mean, obviously the driver is the best place to figure out if texture buffers, per-instance vertex attributes, uniform value array, etc. should be used on any given piece of hardware so why can’t we have one API call to set per-instance stuff and let the driver figure out the most optimal way to send the data?
Conversion between a uniform array and a 1D texture buffer should be handled automatically by the driver. Why should we bang our heads trying to figure out when to use each method? Even worse, this almost always has to be done through reverse engineering of the drivers and extensive benchmarks. This is pretty easy to screw up by forgetting to take into account one of the numerous states or not replicating exactly the application’s usage pattern. Also, this is obviously not “future-proof” as the driver behavior can change.
Note to be rude, but:
Textures for using like textures, i.e. typical use pattern of, well, textures.
Buffer objects for using like data, i.e. localized, quasi-random access.
As for a new comer seeing which to use, actually GL makes strong hints:
texturing –> sampler1D/2D/3D –> textures!
data–> vertex buffer objects–> buffers!
it is when you get to more advanced stuff like texture buffer object, uniform buffer object that it gets murkier, but by then you are no longer a new comer.
The specifying of dynamic buffer data is a harder call, i.e. glMapBuffer vs glSubBufferData… but again those different API’s exists for different usage patterns… so, perhaps what you would like is some kind of companion doc for the GL spec that is for developers and implementers, a “hint specification” where it states the usage and performance expectations of different API calls?
edit:
It’s the other way around, at least on G80 and later NVIDIA hardware: Textures are generally best suited for random access.
Wow that I did not know at all! I always figured that textures we for very, very sequential access; I can make sense of the uniform buffer part on caching… my knowledge of the speed state is basically just:
slowest to fasted:
1.texel fetch
2. uniform texture buffer object fetch
3. uniform buffer value (i.e. the bindless graphics deal) fetch
But the part where texel fetches are well suited for random access totall blew me out of the water!