user6582112
user6582112

Reputation:

Graphics - Multiple Buffering: Queued or last completed?

Assume the GPU has multiple back buffers to render into.

Timeline:

  1. Frame 0 in front buffer
  2. Screen refresh - Frame 0 on screen
  3. Run game loop, submit all render commands for Frame 1 to GPU
  4. Run game loop, submit all render commands for Frame 2 to GPU
  5. GPU processes all commands for Frame 1 and renders Frame 1 into Back Buffer 1
  6. GPU processes all commands for Frame 2 and renders Frame 2 into Back Buffer 2
  7. Screen refresh - Frame ? on screen

Thoughts:

If possible, I'd love to seem see documentation. I just don't know at what level the semantics are defined.

Upvotes: 3

Views: 189

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473212

The semantics are not defined. At least, not in OpenGL, even with wgl/glX_EXT_swap_control. Swap interval will let you decide whether swapping will wait for vsyncs, but if you swap more than once between vsyncs, it's implementation defined which image gets displayed.

wgl/glX_EXT_swap_control_tear allows you to specify that you want tearing behavior if you're late on swapping buffers. But what happens if you're early is not stated.

Vulkan allows implementations to expose different kinds of "swapping" functionality through its present modes. FIFO, the only required presentation mode, means that each image you present will be presented in the order provided. Which means if you try to "swap" (in Vulkan parlance, acquire) the next image and both are waiting to be presented, then the GPU will stall.

There are modes that immediately present the given image, a mode that mirrors "swap_control_tear", and a mode that would be useful in your case, where if you try to render buffers faster than they can be presented, the one waiting is discarded in favor of the next image.

Upvotes: 2

Related Questions