Created
April 13, 2016 21:29
-
-
Save andykorth/bc7cbdecf356b6a19f80280b08585be2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title: | |
Poor performance due to synchronous buffer access | |
--- | |
Replication project and gl traces are included. | |
We've been debugging performance issues that occur specifically on both the OpenGLCore and OpenGL2 renderers. On machines with fast enough GPUs, this issue does occur but the GPU might be fast enough to complete work without huge frame drops. | |
We have not run into it on Windows. | |
It occurs particularly on MacBooks, Macbook Pros, and Macbook Airs. | |
A helpful explanation can be found here: | |
https://www.opengl.org/wiki/Buffer_Object_Streaming | |
0.04 µs glPushGroupMarkerEXT(0, "Camera.ImageEffects"); | |
0.03 µs glPopGroupMarkerEXT(); returns: "Camera.ImageEffects" | |
0.03 µs glPushGroupMarkerEXT(0, "Camera.GUILayer"); | |
0.02 µs glPopGroupMarkerEXT(); returns: "Camera.GUILayer" | |
0.02 µs glPopGroupMarkerEXT(); returns: "Camera.Render" | |
0.03 µs glPushGroupMarkerEXT(0, "GUI.Repaint"); | |
0.03 µs glPopGroupMarkerEXT(); returns: "GUI.Repaint" | |
0.38 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
****************************************************************************************** | |
* Buffers 2 and 3 are used in the next few lines: | |
****************************************************************************************** | |
0.26 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00001548, 0x00000060, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT); returns: 0x16a83548 | |
0.08 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
0.05 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00000750, 0x0000000c, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT); returns: 0x16b82750 | |
0.05 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
0.96 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x00000060); | |
0.10 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
0.06 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
0.24 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x0000000c); | |
0.02 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
5.91 µs glUseProgram(87); | |
0.21 µs glBindTexture(GL_TEXTURE_2D, 22); | |
0.40 µs glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
0.17 µs glDepthFunc(GL_ALWAYS); | |
0.76 µs glUniformMatrix4fv(2, 1, 0, {0.00195312, 0, 0, 0, 0, 0.00260417, 0, 0, 0, 0, -0.019802, 0, -1, -1, -0.980198, 1}); | |
15.23 µs glDrawElementsBaseVertex(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0x00000750, 227); | |
0.04 µs glPushGroupMarkerEXT(0, "PlayerEndOfFrame"); | |
0.04 µs glPopGroupMarkerEXT(); returns: "PlayerEndOfFrame" | |
****************************************************************************************** | |
* This frame ends.... | |
****************************************************************************************** | |
169.34 µs CGLFlushDrawable(); | |
0.05 µs glPushGroupMarkerEXT(0, "ReflectionProbes.Update"); | |
0.04 µs glPopGroupMarkerEXT(); returns: "ReflectionProbes.Update" | |
0.06 µs glPushGroupMarkerEXT(0, "Camera.Render"); | |
0.04 µs glPushGroupMarkerEXT(0, "Drawing"); | |
0.03 µs glPushGroupMarkerEXT(0, "Render.OpaqueGeometry"); | |
0.03 µs glPushGroupMarkerEXT(0, "RenderForwardOpaque.Render"); | |
0.03 µs glPushGroupMarkerEXT(0, "Clear"); | |
1.54 µs glEnable(GL_SCISSOR_TEST); | |
0.23 µs glDepthMask(GL_TRUE); | |
0.33 µs glClearColor(0.192157, 0.301961, 0.47451, 0.0196078); | |
0.32 µs glClearDepthf(1); | |
0.15 µs glClearStencil(0); | |
13.07 µs glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | |
0.30 µs glDisable(GL_SCISSOR_TEST); | |
0.04 µs glPopGroupMarkerEXT(); returns: "Clear" | |
0.03 µs glPopGroupMarkerEXT(); returns: "RenderForwardOpaque.Render" | |
0.02 µs glPopGroupMarkerEXT(); returns: "Render.OpaqueGeometry" | |
0.03 µs glPushGroupMarkerEXT(0, "Camera.ImageEffects"); | |
0.01 µs glPopGroupMarkerEXT(); returns: "Camera.ImageEffects" | |
0.02 µs glPushGroupMarkerEXT(0, "Render.TransparentGeometry"); | |
0.02 µs glPushGroupMarkerEXT(0, "RenderForwardAlpha.Render"); | |
3.01 µs glUseProgram(6); | |
0.70 µs glBindTexture(GL_TEXTURE_2D, 2); | |
0.20 µs glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | |
0.08 µs glDepthFunc(GL_LEQUAL); | |
0.06 µs glDepthMask(GL_FALSE); | |
****************************************************************************************** | |
* The same buffers, (2 and 3) are remapped synchronously- without being discarded or ensuring exclusive access by the CPU. | |
* The first one takes a REALLY long time. This is definitely a worst case situation | |
* for the single sprite replication project we sent, but similarly high (or higher) | |
* times can be found on real projects in the same manner. | |
****************************************************************************************** | |
0.41 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
29731.12 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x00001548, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); returns: 0x16a82000 | |
2.28 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
4.18 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x0000073e, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); returns: 0x16b82000 | |
0.24 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
6.26 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x00001548); | |
0.45 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
0.11 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
1.49 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x0000073e); | |
0.05 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
1.00 µs glBindTexture(GL_TEXTURE_2D, 18); | |
2.66 µs glUniformMatrix4fv(2, 1, 0, {0.15, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.0020006, 0, -0.358024, -0.2, -0.980594, 1}); | |
89.01 µs glDrawElements(GL_TRIANGLES, 927, GL_UNSIGNED_SHORT, 0x00000000); | |
0.22 µs glPopGroupMarkerEXT(); returns: "RenderForwardAlpha.Render" | |
0.03 µs glPopGroupMarkerEXT(); returns: "Render.TransparentGeometry" | |
0.03 µs glPopGroupMarkerEXT(); returns: "Drawing" | |
0.05 µs glPushGroupMarkerEXT(0, "Camera.ImageEffects"); | |
0.03 µs glPopGroupMarkerEXT(); returns: "Camera.ImageEffects" | |
0.03 µs glPushGroupMarkerEXT(0, "Camera.GUILayer"); | |
0.03 µs glPopGroupMarkerEXT(); returns: "Camera.GUILayer" | |
0.03 µs glPopGroupMarkerEXT(); returns: "Camera.Render" | |
0.04 µs glPushGroupMarkerEXT(0, "GUI.Repaint"); | |
0.03 µs glPopGroupMarkerEXT(); returns: "GUI.Repaint" | |
0.52 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
0.42 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00001548, 0x00000060, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT); returns: 0x16a83548 | |
0.10 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
0.09 µs glMapBufferRange(GL_COPY_WRITE_BUFFER, 0x00000750, 0x0000000c, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT | GL_MAP_UNSYNCHRONIZED_BIT); returns: 0x16b82750 | |
0.07 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 2); | |
1.54 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x00000060); | |
0.14 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
0.09 µs glBindBuffer(GL_COPY_WRITE_BUFFER, 3); | |
0.28 µs glFlushMappedBufferRange(GL_COPY_WRITE_BUFFER, 0x00000000, 0x0000000c); | |
0.05 µs glUnmapBuffer(GL_COPY_WRITE_BUFFER); returns: GL_TRUE | |
6.17 µs glUseProgram(87); | |
0.28 µs glBindTexture(GL_TEXTURE_2D, 22); | |
0.49 µs glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
0.45 µs glDepthFunc(GL_ALWAYS); | |
0.84 µs glUniformMatrix4fv(2, 1, 0, {0.00195312, 0, 0, 0, 0, 0.00260417, 0, 0, 0, 0, -0.019802, 0, -1, -1, -0.980198, 1}); | |
19.34 µs glDrawElementsBaseVertex(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0x00000750, 227); | |
****************************************************************************************** | |
* End of second frame. | |
****************************************************************************************** | |
0.06 µs glPushGroupMarkerEXT(0, "PlayerEndOfFrame"); | |
0.05 µs glPopGroupMarkerEXT(); returns: "PlayerEndOfFrame" | |
222.50 µs CGLFlushDrawable(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment