I’ve been trying to optimize various parts of an application for a couple of weeks now. One of the things I’ve been focusing on was picking. The way this was done was by rendering all geometry in a second pass, only drawing an ID for each primitive. Both this pass and the color pass was using the fixed function pipeline.
I was hoping that by using shaders, I could draw both color and ID in one pass. Said and done, things got slower. Right now, I only have one shader which I only bind once, and this shader has one uniform (a vec3 for the ID) which I only look up the location for once. I set this uniform to a different value for every primitive (sphere, cone, cylinder etc). To me, it seems like this is where the overhead would come from. Is it possible that the pipeline is being flushed in order to not overwrite the uniform while being used by the previous render call?
The shaders doesn’t do anything particularly fancy, so it shouldn’t be that either. Since everything was set up to use the fixed function pipeline, I’m using those attributes (such as gl_Color) as much as possible in the shaders as well. Which btw seems to cause an entirely different problem, namely that several primitives seem to get rendered without gl_Color etc being changed in between them… Less concerning for now, but perhaps you can explain this behaviour as well?
Thank you for your time!