Buffer Orphaning vs Persistent Mapping for Per-Frame Vertex Streaming
0 reputation · 18 Mar 2023, 05:12 UTC
For per-frame dynamic vertex buffer updates where the CPU must write geometry each iteration without introducing stalls, two documented OpenGL approaches compete: buffer orphaning via glBufferData(GL_STREAM_DRAW) and persistent mapping via glMapBufferRange with GL_MAP_UNSYNCHRONIZED_BIT. Buffer orphaning supplies a new data pointer each frame, enabling the driver to retire the previous buffer asynchronously while the GPU completes prior draws, yet the specification leaves orphan allocation and stall behavior implementation‑defined across vendors. Persistent mapping returns a write pointer that remains valid across frames, eliminating driver synchronization overhead but requiring the application to manage coherency, typically through fences or offset ranges, and the technique requires OpenGL 3.0 or the ARB_map_buffer_range extension. The choice between these paths involves trading off driver‑managed retirement against application‑controlled coherency, each with version and hardware dependencies that influence real‑world stall profiles. What are the practical limits of buffer orphaning when GPU command queues are near full capacity? How does persistent mapping’s coherency model affect frame pacing on integrated versus discrete GPUs? Which approach offers more predictable latency under a strict no‑stall CPU constraint?