Ephenation is a MMORPG in an adventure setting that supports player defined additions.
This is a blog where I show the progress from making the game. Main focus is on the application of OpenGL. I hope this will help others to benefit from my mistakes and experiences.
Any bitcoin donations are welcome to 18JGunpjKBiJ4gVbwP2d9UHaX8z2RPBrL7.
15 januari 2012
Measuring graphics performance
If you want to measure the render time, it doesn't work very well with a standard OS timer function. The reason for this is that OpenGL will do some of the work in the background, which means your timer function can return a value close to zero. There is support in OpenGL 3.3 to request the actual render time, using queries. This is done in a couple of steps:
Request OpenGL to begin the query.
Do the Draw operation
Request OpenGL to stop the query.
Read out the result of the query.
The problem is that you obviously can't read the result until the drawing is done. And as already mentioned, the actual drawing may be done in the background and still not be complete when you ask for the result. That means that OpenGL will have to wait until the drawing is actually done, and then return the result. This can severely degrade the performance. It could be okay if you only do this during development, but it will screw up the timing of other functions, and be less helpful.
The result of a query is available until you start the next query on the same query ID. As long as the result isn't requested too early, the pipeline will not be disturbed. The trick I am using is to read out the result the frame after, instead of in the current frame. The draw back is that the result will be one frame old, which is not a problem for doing statistics. That is why, in the pseudo code below, I read out the result first, and then request a new query to be set up.
GLuint queries; // The unique query id
GLuint queryResults; // Save the time, in nanoseconds