NEW FEATURE: SegmentCopyHeight and SegmentCopyVerticalOffset properties to aid in eliminating display tearing [17175]

DetailIt appears that for some (and most likely all) DirectX display adapters, a Blt (bit block transfer; i.e. Canvas.Copy) operation actually fills the memory from bottom to top. This results in display operations having tearing problems.

Tearing occurs when display contents are sent to the display adapter while it is drawing. When this happens, the CRT paints a portion of the old contents at the top and the new contents tear into the bottom. During quick animations that bounce between screens, what appears as a gray line will appear to tear across the display.

Typically this is due to not synchronizing the transfer to the top of the screen. However, many DirectX display adapters fill the memory for display from the bottom to the top versus from the top to the bottom. Although these Blt (bit block transfer; i.e. Canvas.Copy) operations are very quick, it is possible that the CRT can be a quarter of the way down the screen by the time the contents are in memory.

To combat this issue, two properties have been implemented to cut up a Blt (bit block transfer; i.e. Canvas.Copy) operation so that the top portions of the screen get into video memory first. This provides a means to help keep the display memory contents ahead of the CRT painting. The memory is still filled from bottom to top, but is sectioned so that it can be in memory before the CRT displays the content.

Display.SegmentCopyHeight- Value specified in pixels. - If zero, then essentially turned off (this is the default) - If non-zero, then any Blt (bit block transfer; i.e. Canvas.Copy) operation with a height greater than this value will be cut up in chunks of this value until satisfied. The special case is that any "top" value that falls past the Display.SegmentCopyVerticalOffset will use the remainder of the height, no matter what that is (see more below).

Display.SegmentCopyVerticalOffset- Value specified in pixels - If zero, then essentially turned off (this is the default) - If non-zero, then any Blt (bit block transfer; i.e. Canvas.Copy) operation with a "top" coordinate from this value down will be done in one operation. Setting this value allows for the bottom portion of the screen to be copied in one operation. Without setting this value, Blt (bit block transfer; i.e. Canvas.Copy) operations would be split up into chunks of DisplayDevice.SegmentCopyMaxHeight for the entire screen, which is not necessary and can add additional overhead and decrease performance.

The values would then need to be tweaked if tearing still exists (or there is double tearing).

These values should be as large as possible. Although DisplayDevice.SegmentCopyHeight = 1 and Display.SegmentCopyVerticalOffset = Display.YRes would work, there would be too many Canvas.Copy operations and could deter system performance dramatically.

To illustrate, a full screen 640x480 copy with the following properties...

...will result internally into four separate Blt (bit block transfer; i.e. Canvas.Copy) operations instead of one 640x480 operation. Since the transfer is cut up into pieces, it has a better chance of staying ahead of the CRT and reducing the chances for tearing to occur.

All of these operations are done internally and require no further user intervention.

The following is a summary for how these properties work:

- Any Y pixel before DisplayDevice.SegmentCopyVerticalOffsetwill be Blt(bit block transfer; i.e. Canvas.Copy) in chunks of DisplayDevice.SegmentCopyHeightuntil completed.- Any Y pixel afterDisplayDevice.SegmentCopyVerticalOffsetwill be Blt(bit block transfer; i.e. Canvas.Copy) in one operation even if that height is larger than DisplayDevice.SegmentCopyHeight

If either value is zero, it essentially turns "segment copy" off and one Blt(bit block transfer; i.e. Canvas.Copy) operation will occur.

This topic applies to:E-Prime 1.0E-Prime 1.1

This feature breaks syntax compatibility with E-Prime 1.0.Using either SegmentCopyHeightor SegmentCopyVerticalOffsetproperties on a 1.0 runtime system will result in a compiler error.