Equalizer logo
Collage logo
GPU-SD logo

Swap Barriers

Author: [email protected]
State:

Overview

The purpose of a swap barrier is to synchronize buffer swaps of multiple windows, potentially residing on different nodes. More information is to in the user documentation.

Software Swap Synchronization

The software swapbarrier uses a co::Barrier together with a Window::finish to synchronize the buffer swaps without special hardware support. The finish ensures that all GL commands for the window have been executed prior to entering the barrier. When leaving the barrier, the buffer swap is the next command and will be executed immediately, which is ensured using a second finish.

Software swap synchronization does not perform frame synchronization, but can work with frame synchronization provided by the driver, e.g., using an NVidia G-Syn board. Furthermore a swap command may very occasionally be executed on video too late, because it just missed its turn due to timing issues.

The server creates one co::Barrier with the appropriate height for all swap barriers with the same name.

Multiple windows on the same pipe can join the same software swap barrier. All windows will execute a finish, but the barrier will only be executed by the first window of each pipe. Since all windows have finished before swapBuffers, the first window will block in the barrier, and all subsequent windows will swap immediately afterwards since all commands have been finished already. Each window will flush at the end of a frame to ensure timely execution of the swap command.

Hardware Swap Synchronization (NV_swap_group)

The WGL and GLX swap group extensions use a two-tiered strategy to provide hardware-based swap synchronization. On a single system, all windows join a swap group, which ensures that the buffer swaps happen synchronously. Between systems, swap groups join the same swap barrier for synchronization.

If a swap barrier defines a NV_group or NV_barrier, the appropriate NV_swap_group extension (GLX or WGL) is used. Setting a barrier number implies a valid group number.

If the extension is not supported by the driver of window system (AGL), a warning is printed and no barrier is joined.

Configuration

Up to Equalizer 1.0, swap barriers are configured per compound. The swap barrier description is really a display-related feature, to be configured in the canvas or segment.

The canvas may have a swap barriers, which is the default swap barrier for each segment. Existing segments are not modified. A segment may have a swap barrier, which becomes the compound's swap barrier when the destination channel is set on the compount. The compound keeps the swapbarrier configuration and logics as in Equalizer 1.0.

Stereo-Selective Configuration

In Equalizer 1.0, one can use different swap barrier settings for different stereo-mode compounds. The same can be achieved with per-segment barriers, in have different segments per eye using the same output channel.

File Format

  canvas
  {
      swapbarrier // default for all segments
      { 
          name "barrier-name" // sync's compound's window swap buffers
          NV_group    OFF | ON (1) | unsigned // use HW group n (NV_swap_group)
          NV_barrier  OFF | ON (1) | unsigned // use HW barrier n
      }
      segment
      {
          swapbarrier { ..as above.. }
      }
  }
  compound
  {
      swapbarrier { ..as above.. }
  }

API

  class SystemWindow
  {
      virtual bool joinNVSwapBarrier( const uint32_t group, 
          const uint32_t barrier ) { return false; }
  };

Implementation

NV_swap_group synchronization

Implement GLXWindow, WGLWindow joinNVSwapBarrier. Check if extension is available, if not warn and return false. Do check for max barriers and groups. Barrier and group can be 0 to un-join.

Server sends swap group and barrier as part of the window's config init packet, which are saved on the eq::Window. The SystemWindow implementation queries the values in configInit and configExit and calls joinNVSwapBarrier.

Compound::init sets eq::server::Window swap group and barrier. Check that there is only one per window, otherwise warn and overwrite values.

Ignore swap barriers with NV settings in software swapbarrier implementation.

Issues

Only one window per swap group, and therefore system, is supported for current nVidia hardware.