Lightpack icon indicating copy to clipboard operation
Lightpack copied to clipboard

DesktopDuplication call releaseFrame before acquireNextFrame

Open Womifa opened this issue 5 years ago • 5 comments

According to the documentation ( https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgioutputduplication-releaseframe ) the method releaseFrame should be called before the method acquireNextFrame.

Womifa avatar Jul 15 '20 23:07 Womifa

Can one of the admins verify this patch?

psieg-jenkins avatar Jul 15 '20 23:07 psieg-jenkins

Can one of the admins verify this patch?

psieg-jenkins avatar Jul 15 '20 23:07 psieg-jenkins

Thanks for the PR!

The issue with this is that it makes the grabbing block until the next frame has been rendered on the GPU. This means that the effectively captured frame rate is ~half of what the grab timer is configured for. (For example, for a 60 FPS monitor/game with 50ms grab interval the theoretical grab FPS is 20. With this, I get only 10. I don't have a good solution on how to make this work in a way that has a reasonable user experience, I'm open to suggestions.

Do you have any data on how much this reduces GPU load? IIUC the DDupl-capturing is purely GPU, the expensive part of the whole operation is copying the frame buffer back to the system memory, which is unaffected by this. In desktop workloads, the impact of this certainly is near zero (maybe relevant for battery life on laptops, which won't use Prismatik), in gaming >30 FPS there could be some gain.

You should reset m_releaseFrame when the duplication is re-created as well - At the same time, incorrectly calling releaseFrame has no relevant consequences so to me not adding the boolean would be fine as well.

On a side node, please don't reformat half the file for a 4 line patch.

psieg avatar Jul 19 '20 19:07 psieg

The effect of halving the framerate is weird, I reverted the changes for now and will test it some more when I have time.

I don't have any data of the GPU load, but I noticed a significant drop in performance when using DDupl as it is right now when playing Gears 5 which is why I started searching for some relief. For now I am testing Windows 10 Hardware-accelerated GPU scheduling. This seems to result in DDupl having less of a performance impact, but at the cost of DDupl starting to stutter when the GPU is under full load (Game running at 70 fps, DDupl struggles at maybe 5 fps).

As for your side note: I didn't mean to change all of that formatting, however Visual Studio 2019 did...

Womifa avatar Aug 22 '20 00:08 Womifa

see this for your fps

zomfg avatar Aug 22 '20 21:08 zomfg