nowrep / obs-vkcapture

OBS Linux Vulkan/OpenGL game capture
GNU General Public License v2.0
508 stars 25 forks source link

Fix old frames sometimes being captured. (Visual Jitter in OBS capture window) #124

Closed sekhat closed 1 year ago

sekhat commented 1 year ago

The code for copying the back buffer data wasn't syncrhonized with previous draw commands, which meant every now and then, it'd copy a back buffer that hadn't been altered.

I noticed this when using obs-vkcapture and was getting what appeared as jitter in the output. Recording this output and playing it back I noticed I was getting old frames, (animations looked like they went backwards for a frame).

The general idea for the fix, is to force the QueueSubmit operation for the copy to wait on the semaphores that are passed to vkQueuePresent, and then having a semaphore to signal the end of the QueueSubmit and use that instead in vkQueuePresent.

This would mean everything that needed to occur for present to be okay with proceeding, has to have occurred for the copy to proceed, and presenting won't proceed until the copy is done.

Now this patch is a quick and dirty fix, and probably needs some work to better fit it in with the surrounding code but I've submitted here to at least show the general idea of what I've done.

I can also confirm, this has fixed my "jitter" in my output.

nowrep commented 1 year ago

With this I think e03cbba8859 can be reverted. Also the copy could now always be done on transfer queue?

nowrep commented 1 year ago

Thanks!