Is there an existing issue for this?
Is your issue described in the documentation?
Is your issue present in the nightly release?
Describe the Bug
Sleeping before AcquireNextFrame can cause frametime jerkiness under a "heavier" games:

Expected Behavior
Expected to have stable frames:

Additional Context
This is an issue created based on the PR #1168. Where the sleep is eliminated when using the DWMFlush.
Without DWMFlush, however more work is needed to synchronize everything, therefore a proper solution is needed.
Host Operating System
Windows
Operating System Version
Windows 11 Pro 22H2 22621.1413
Architecture
64 bit
Sunshine commit or version
0.19.1
Package
Windows - installer
GPU Type
Nvidia
GPU Model
RTX 3080 Ti
GPU Driver/Mesa Version
531.41
Capture Method (Linux Only)
No response
Config
sw_preset = veryslow
resolutions = [
352x240,
480x360,
858x480,
1280x720,
1920x1080,
2560x1080,
3440x1440,
1920x1200,
3860x2160,
3840x1600
]
min_log_level = 2
hevc_mode = 0
virtual_sink = {0.0.0.00000000}.{139ca0ae-8910-4be6-91dc-52e29e2b6e1b}
sw_tune = film
gamepad = ds4
nv_preset = p1
Apps
No response
Relevant log output
[2023:04:12:17:26:22]: Info: Sunshine version: 0.19.1
[2023:04:12:17:26:22]: Info: Compiling shaders...
[2023:04:12:17:26:22]: Info: System tray created
[2023:04:12:17:26:22]: Info: Compiled shaders
[2023:04:12:17:26:22]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2023:04:12:17:26:22]: Info: Trying encoder [nvenc]
[2023:04:12:17:26:22]: Info: ddprobe.exe [1] [] returned: 0x00000000
[2023:04:12:17:26:22]: Info: Set GPU preference: 1
[2023:04:12:17:26:23]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:23]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:23]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:23]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:23]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:23]: Info: Color range: [JPEG]
[2023:04:12:17:26:24]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:24]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:24]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:24]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:24]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:24]: Info: Color range: [JPEG]
[2023:04:12:17:26:24]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:24]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:24]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:24]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:24]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:24]: Info: Color range: [JPEG]
[2023:04:12:17:26:25]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:25]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:25]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:25]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:25]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:25]: Info: Color range: [JPEG]
[2023:04:12:17:26:25]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:25]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:25]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:25]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:25]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:25]: Info: Color range: [JPEG]
[2023:04:12:17:26:26]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:26]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:26]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:26]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:26]: Info: SDR color coding [Rec. 709]
[2023:04:12:17:26:26]: Info: Color range: [JPEG]
[2023:04:12:17:26:26]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:26]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:26]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:26]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:26]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:26]: Info: Color range: [JPEG]
[2023:04:12:17:26:27]: Info:
Device Description : NVIDIA GeForce RTX 3080 Ti
Device Vendor ID : 0x000010DE
Device Device ID : 0x00002208
Device Video Mem : 12100 MiB
Device Sys Mem : 0 MiB
Share Sys Mem : 16254 MiB
Feature Level : 0x0000B100
Capture size : 2560x1440
Offset : 0x0
Virtual Desktop : 2560x1440
[2023:04:12:17:26:27]: Info: Desktop resolution [2560x1440]
[2023:04:12:17:26:27]: Info: Desktop format [DXGI_FORMAT_B8G8R8A8_UNORM]
[2023:04:12:17:26:27]: Info:
Colorspace : DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Bits Per Color : 8
Red Primary : [0.639648,0.330078]
Green Primary : [0.299805,0.599609]
Blue Primary : [0.149414,0.0595703]
White Point : [0.3125,0.329102]
Min Luminance : 0.5 nits
Max Luminance : 270 nits
Max Full Luminance : 270 nits
[2023:04:12:17:26:27]: Info: SDR color coding [Rec. 601]
[2023:04:12:17:26:27]: Info: Color range: [JPEG]
[2023:04:12:17:26:27]: Warning: nvenc: hevc: replacing nalu prefix data
[2023:04:12:17:26:27]: Info:
[2023:04:12:17:26:27]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2023:04:12:17:26:27]: Info:
[2023:04:12:17:26:27]: Info: Found encoder nvenc: [h264_nvenc, hevc_nvenc]
[2023:04:12:17:26:27]: Info: Configuration UI available at [https://localhost:47990]
[2023:04:12:17:26:28]: Info: Registered Sunshine mDNS service
Is there an existing issue for this?
Is your issue described in the documentation?
Is your issue present in the nightly release?
Describe the Bug
Sleeping before AcquireNextFrame can cause frametime jerkiness under a "heavier" games:

Expected Behavior
Expected to have stable frames:

Additional Context
This is an issue created based on the PR #1168. Where the sleep is eliminated when using the DWMFlush.
Without DWMFlush, however more work is needed to synchronize everything, therefore a proper solution is needed.
Host Operating System
Windows
Operating System Version
Windows 11 Pro 22H2 22621.1413
Architecture
64 bit
Sunshine commit or version
0.19.1
Package
Windows - installer
GPU Type
Nvidia
GPU Model
RTX 3080 Ti
GPU Driver/Mesa Version
531.41
Capture Method (Linux Only)
No response
Config
sw_preset = veryslow resolutions = [ 352x240, 480x360, 858x480, 1280x720, 1920x1080, 2560x1080, 3440x1440, 1920x1200, 3860x2160, 3840x1600 ] min_log_level = 2 hevc_mode = 0 virtual_sink = {0.0.0.00000000}.{139ca0ae-8910-4be6-91dc-52e29e2b6e1b} sw_tune = film gamepad = ds4 nv_preset = p1Apps
No response
Relevant log output