push_dc_driver() places drivers based on their priorities, so the newly created driver is not
necessarily on top. Thus in windrv_CreateDC(), find_dc_driver() should be used to find the DIB
driver instead of assuming the DIB driver is the top driver, which could be the path driver because
it has a higher priority.
The exact wrong code path was:
1. A path driver with priority 400 is created for a DC.
2. windrv_CreateDC() is called to create a window driver for the DC.
3. Then in dibdrv_CreateDC(), push_dc_driver() is called with 'dev' pointing to the top driver, which is the path driver.
4. push_dc_driver() updates 'dev' to point to the address of the next driver because DIB driver has a lower 300 priority.
5. The DIB driver is assigned to 'dev', which is not the original parameter passed into push_dc_driver().
6. In windrv_CreateDC(), get_dibdrv_pdev(*dev) is called, assuming the top driver is the DIB driver. But actually the top
driver that '*dev' points to is still the path driver.
The added tests can demonstrate the memory corruption before this fix is applied.
Normally, a new window_surface has no damage so its draw_start_ticks
value is reset at the time of the first lock_surface.
However, if contents from the old window_surface are copied to the new
one when the window_surface for a window is updated, the new
window_surface will be initially damaged. We want to reset the
draw_start_ticks value in this case too, to avoid flushes occuring soon
after such updates, during the initial redraw of the window_surface.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Track ticks since draw start per window_surface, instead of per DC as is
currently the case. This change helps reduce visual glitches caused by
badly timed flushes when drawing to the same window_surface from
multiple DCs (e.g., for child windows).
This approach is a better fit for the current heuristic for forcing
flushing, which consults the shared window_surface bounds to decide
whether this is the start of a draw in order to reset the (currently per
DC) draw start time.
The problem in the current implementation occurs when a drawing to a DC
begins with an already damaged window_surface, e.g., due to draws from
other DCs targeting that window_surface. In such a case, the DC draw
start time is not reset and refers to the start of some previous draw
sequence using this DC, thus increasing the chances that the 50ms time
flush limit will be eventually exceeded in the middle of the current
draw sequence. In other words, the state of the (shared) window_surface
damage is not a reliable indicator of the beginning (or not) of a draw
to a DC.
An example, assuming DC1 and DC2 target the same window_surface:
DC1.start_ticks = 0
DC2.start_ticks = 0
FLUSH_PERIOD = 50
0 flush
1 draw to DC1 -> DC1.start_ticks = 1
... [no flush] ...
2 draw to DC2 -> DC2.start_ticks remains 0 since surface is damaged
...
50 flush
51 draw to DC1 -> DC1.start_ticks = 51
... [no flush] ...
52 draw to DC2 -> DC2.start_ticks remains 0 since surface is damaged,
current - DC2.start_ticks > FLUSH_PERIOD so we are
forced to flush in the middle of the drawing
sequence => potential glitch
Tracking the draw start per window_surface ameliorates the problem
because the beginning of a draw on a DC targeting an undamaged
window_surface resets the start time for all DCs targeting that
window_surface:
...
50 flush
51 draw to DC1 -> surface.draw_ticks = 51
... [no flush] ...
52 draw to DC2 -> surface.draw_ticks remains 51 since surface is damaged,
but current - surface.draw_ticks < FLUSH_PERIOD, so we
do not flush
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
The Vulkan device is used for querying video memory information for implementing
D3DKMTQueryVideoMemoryInfo().
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
To get rid of get_dc_ptr() and thus not to fail
concurrent __wine_get_wgl_driver().
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>