1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-21 01:24:21 +00:00
JUCE/modules
reuk 9ae52f3d7a Direct2D: Update backbuffer implementation
Problem description
===================

Firstly, the linked-list of pending presentations acted as a stack
(FILO).  If the swap chain thread and main thread processed frames at
varying rates, then the following sequence of events was possible:

Main thread           Swap chain thread       Queue state
---------------------------------------------------------
Push frame (1)                                [1]
Push frame (2)                                [2, 1]
                      Pop frame (2)           [1]
Push frame (3)                                [3, 1]
                      Pop frame (3)           [1]
                      Pop frame (1)           [] <--  Out of sequence!

Secondly, the swap chain's sequential flip model can only maintain a
valid back-buffer state as long as the list of dirty rects is correct,
and every pixel within the dirty rects is painted incrementally.

In the example above, if the main thread were to produce two frames
before the swap chain thread could present any frame, then presenting
*only* the frame 2 (skipping frame 1) may produce incorrect results when
combined with the existing back buffer. This is because regions updated
in frame 1 may not be updated in frame 2, so regions *only* updated in
frame 1 will be omitted from the back buffer.

Mitigation
==========

This patch removes the old stack of presentations and replaces it with a
slightly more complex mechanism that tracks two different Presentation
objects. At any time, up to one Presentation may be in use by the swap
chain thread (i.e. actively presenting), up to one Presentation may be
accumulating updated/dirty regions (i.e. painting), and up to one region
may be ready, awaiting display.

This scheme resolves the first issue described above by ensuring that
old frame data is not kept around. There is never more than one frame
awaiting display, which means that if the swap chain thread attempts to
display twice in a row (before the main thread produces a new frame),
the second attempt will be a no-op.

The second issue is resolved by accumulating changes into a single
Presentation whenever the main thread produces two or more frames in a
row. If there is already a 'ready' Presentation when the main thread
finishes painting, then all updated regions from the newest Presentation
will be added to the 'ready' Presentation, rather than replacing it.
When the swap chain thread is ready to present, it will therefore see
the result of all the accumulated Presentations produced by the main
thread, instead of just the newest Presentation.
2024-06-26 14:33:25 +01:00
..
juce_analytics Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_animation Fix some Doxygen docstrings 2024-06-12 09:35:32 +01:00
juce_audio_basics AudioChannelSet: Fix typos in comments 2024-06-11 11:34:05 +01:00
juce_audio_devices CoreAudio: Prevent racing between calls to start and stop a device 2024-06-12 09:35:32 +01:00
juce_audio_formats ComSmartPtr: Make ownership more explicit 2024-04-16 21:07:45 +01:00
juce_audio_plugin_client AU Client: Avoid creating ModalComponentManager during shutdown 2024-06-20 17:52:23 +01:00
juce_audio_processors AudioUnit (host): Prevent a warning from using bitwise operations with different enum types 2024-06-13 16:09:38 +00:00
juce_audio_utils MPEKeyboardComponent: Avoid asserting when clicking on highest visible key 2024-05-08 17:53:52 +01:00
juce_box2d Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_core URLConnectionState: Use a shared NSURLSession to improve performance 2024-06-24 12:50:02 +01:00
juce_cryptography Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_data_structures ValueTree: Optimise when listeners don't remove themselves 2024-06-07 20:25:39 +01:00
juce_dsp Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_events ListenerList: Add a thread safe ListenerList type 2024-06-07 20:25:39 +01:00
juce_graphics Direct2D: Update backbuffer implementation 2024-06-26 14:33:25 +01:00
juce_gui_basics Windowing: Avoid recursively calling WM_NCHITTEST in contains() 2024-06-26 14:33:25 +01:00
juce_gui_extra Fix some Doxygen docstrings 2024-06-12 09:35:32 +01:00
juce_midi_ci Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_opengl Direct2D: Add initial support 2024-04-18 14:16:02 +01:00
juce_osc Bump version number to 8.0.0 2024-04-16 17:43:20 +01:00
juce_product_unlocking InAppPurchases: Update Android implementation to support GPB 7.0.0 2024-06-12 19:16:32 +01:00
juce_video CameraDevice: Simplify data shared across threads, to reduce potential for data races 2024-05-20 12:49:54 +01:00
CMakeLists.txt Animation: Add juce_animation module 2024-04-16 17:43:21 +01:00