Background
At work, we develop two products which both have OpenGL 3.x+ and GLES 2.0/3.0+ backends. Teams are independent, but do have some overlap, and we were recently discussing performance of glGetError
.
In both products, the design is such that no GL calls should generate an error code recorded by glGetError
. To detect such errors, in debug we have a macro that adds a glGetError
after each GL call, and it asserts if any errors are detected, as this means there is a bug. On my product, this is enabled by default, in the other, it must be explicitly enabled.
These have been present in the codebase of the product I work on for many years, and we see that they cause performance hits, generally it in the neighbourhood of 25% across many platforms. We have decided this is a reasonable price to pay for early detection of errors. The other team claimed under some circumstances, that adding these checks can slow down execution of their product running at 60FPS to < 1FPS, making the product unusable, which is why they are not enabled by default. Both products run on many OpenGL/GLES platforms (PC, OSX, Linux, iOS and Android).
Questions
I understand the reasoning behind glGetError
reducing performance; you (may) require a CPU/GPU synchronization for the status of the previous operation to be correct. From my understanding this should change the expected frame time from "MAX(CPU time, GPU time)
" (assuming no other sync points, and no queued frames) to "CPU time + GPU time + synchronization overheap
" (assuming every glGetError call results in a sync point). Is this not correct reasoning, or, is there is additional reason for performance reduction using glGetError
?
I was always under the impression that per-call glGetError
in debug was a reasonable thing to do (at least after GL calls where no errors should be possible). Is this not the case or not considered a 'best practice'?
Is there some circumstance(s) that can cause extreme performance issues such as the other team described (eg. with a particular set of GL calls and/or platform)?