AMD drivers reject system memory surfaces that are larger than the maximum
texture width/height supported by the driver (usually 4096x4096 for AMD).
This can cause issues in games that create larger system memory surfaces.
This workaround crops the driver resource dimensions to the allowed
maximum values and handles blitting outside this region by creating a
temporary resource that maps to the actual affected system memory region.
Fixes crashes with AMD drivers in Rainbow Six games and Desperados,
mentioned in issue #2 and #8.
On recent drivers, double buffered DirectDraw flips no longer wait for the
vertical sync before returning and instead just insert the flip into the
flip queue for later execution. This effectively results in triple buffered
behavior (in the render-ahead sense) and causes up to an extra frame of
latency even if the flip queue size is set to 1.
To restore the legacy double buffered behavior, each flip waits for the
presented frame to leave the flip queue before returning.
To restore the legacy triple buffered behavior, the flip queue size is
forced to 1. This causes the flip to wait if the previous flip is still
pending.