When are VBOs faster than “simple” OpenGL primitives (glBegin())?

后端 未结 5 1386
深忆病人
深忆病人 2020-12-12 22:16

After many years of hearing about Vertex Buffer Objects (VBOs), I finally decided to experiment with them (my stuff isn\'t normally performance critical, obviously...)

5条回答
  •  余生分开走
    2020-12-12 23:09

    There are a lot of factors to optimizing 3D rendering. usually there are 4 bottlenecks:

    • CPU (creating vertices, APU calls, everything else)
    • Bus (CPU<->GPU transfer)
    • Vertex (vertex shader over fixed function pipeline execution)
    • Pixel (fill, fragment shader execution and rops)

    Your test is giving skewed results because you have a lot of CPU (and bus) while maxing out vertex or pixel throughput. VBOs are used to lower CPU (fewer api calls, parallel to CPU DMA transfers). Since you are not CPU bound, they don't give you any gain. This is optimization 101. In a game for example CPU becomes precious as it is needed for other things like AI and physics, not just for issuing tons of api calls. It is easy to see that writing vertex data (3 floats for example) directly to a memory pointer is much faster than calling a function that writes 3 floats to memory - at the very least you save the cycles for the call.

提交回复
热议问题