开发者

Small delays in buffering VBO data

I'm working on a minecraft-inspired graphics engine to be implemented in an actual game soon. I've got the engine up to 60+ FPS under geometry stress testing. I am using only LWJGL for graphics assistance. At one point I had large delays while updating the VBO data on local memory, but I solved that by multi-threading, streamlining, and synchronizing the generic block culler/constructer.

During the time in which I buffer the VBO data to video memory AFTER culling, I occassionally experience a small hitch (20-30milliseconds), which can cause the screen to freeze for that amount of time. I think the reason the delay occurs is because I send an enormous amount of geometry data to the VBO(3-5mb) via glBufferData (in static draw mode) every couple frames. I have already implemented chunk frustum culling, block frustum culling, air-block culling, and a directional surroundings culler.

This leaves me with two questions:

  1. Is there another data buffering method I can use which is fast than glBufferData? (Maybe a way to multithread a second buffer as a preparatory, which will move the hitch to the second thread)?

  2. If not, how would I go about implementing direct occlusion culling from local-memory (possibly video memory), using a matrix of floating points indicating the corners of cubes (easily manipulated)? Note that antiportals are incompatible with my framework.

Or, in 'plain' english: How can I speed up buffering data to vram using glBufferData without further reduction of data size?

Update: Going to run the custom occlusion culling route. I'm fairly certain my data buffering time is vastly increased by the time taken to add occluded blocks, and po开发者_运维百科ssibly even delayed by synchronization as the culling updater takes the locks. If anyone has suggestions regarding occlusion culling from a buffer that would be great.

Update 2: Problem was coincidentally solved once I added hidden-face culling (two touching faces=neither renders). I won't be needing additional performance increase now, as that alone has brought my buffer size down by 90% and framerate up 400%. Thanks for the answers RTS.


Yes, there is a couple of ways.

  1. Use glBufferSubData
  2. Set Buffer usage to either dynamic or stream
  3. Use glMapBuffers
  4. Use smaller vertex primitives (float instead of double, or short instead of int)
  5. Make sure your data is aligned
  6. Interleave your VBO's so that you only have to do one buffer update
  7. Use a VAO(Vertex Array Object)
  8. Use double buffering so that you upload data to the VBO a frame in advanced to when you need to render using it, to avoid resource conflicts.
  9. Use connected primitives to avoid duplicated vertices (GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, etc.)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜