glDeleteBuffers slower than glBufferData

前端 未结 1 911
情书的邮戳
情书的邮戳 2021-01-01 06:27

I\'m having a bit of performance issue in my iOS/Android game where several VBO\'s have to be updated every once in a while. After profiling my game it turns out that glDele

相关标签:
1条回答
  • 2021-01-01 07:05

    glGenBuffers and glDeleteBuffers are designed to only be run on initialization and cleanup, respectively. Calling them during runtime is bad.

    glBufferData replaces the current buffer data with a new set of data, which automatically changes the size of the buffer. You can safely remove the whole glGenBuffers/glDeleteBuffers thing and move it into initialization and cleanup.

    Additionally, you are creating the buffer as a static buffer. This is telling OpenGL that you will almost never change it so it stores it in a way that's quicker to access on the GPU but slower to access from the rest of the system. Try changing GL_STATIC_DRAW to GL_DYNAMIC_DRAW or GL_STREAM_DRAW. More on this here: http://www.opengl.org/wiki/Buffer_Objects#Buffer_Object_Usage

    0 讨论(0)
提交回复
热议问题