Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framerate cap not working correctly, and getting worse as FPS go higher #5

Open
EnriqueWood opened this issue Dec 4, 2019 · 7 comments

Comments

@EnriqueWood
Copy link

EnriqueWood commented Dec 4, 2019

I'm testing this library in Age of Empires 2: Definitive Edition.

When not using the library, the game runs at approx 170~250FPS.

I'm using linux steam client, setting as Launch Options for the game and for these tests I'm only modifiying the FPS number

These are screenshot of the in-game Vulkan's full HUD info in the same condition (game as idle as possible).

1.--- Not setting any FPS value ---
Launch Options:
DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_VkGHL" %command%
not_using

2.----- 25FPS cap ---
Launch Options:
VSYNC=0 FPS=25.00 DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_VkGHL" %command%
cap_25

3.--- 40FPS cap ---
Launch Options:
VSYNC=0 FPS=40.00 DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_VkGHL" %command%
cap_40

4.--- 60FPS cap ---
Launch Options:
VSYNC=0 FPS=60.00 DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_VkGHL" %command%
cap_60

5.--- 60FPS cap ---
Launch Options:
VSYNC=0 FPS=100.00 DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_LUNARG_VkGHL" %command%
cap_100

So, as you can see, as the FPS number raises, the difference between the expected cap and the actual cap does raise too.

Another thing to consider is the shown min and max values in every test (and what makes me think it may be a miscalculation in some of the variables, like the sleep time for the limiter).

What I understand (I may be wrong) is that the job of the limiter is to make the framerate not to get lower than 1000/fps (in ms) and, for example, in the first test, the min value for 25 fps should be not lower than 1000/25=40 and the test shows that the min framerate was actually 3.9 which I think should not happen. The same thing occurs in the other tests as well.

@EnriqueWood EnriqueWood changed the title Framerate cap not working correctly, and gets worse as FPS go higher Framerate cap not working correctly, and getting worse as FPS go higher Dec 4, 2019
@pchome
Copy link
Owner

pchome commented Dec 5, 2019

Here is the build I use now: VkGHL.tar.gz
I rewrote it as "pure" layer a few months ago, and used it a lot with Proton. Same logic, but maybe I accidentally fixed something, it works fine (+/-) for me so far with both versions.
Please note changed name : VK_LAYER_CUSTOM_VkGHL.

I'll check limiter logic later.

@EnriqueWood
Copy link
Author

EnriqueWood commented Dec 5, 2019

Here is the build I use now: VkGHL.tar.gz
I rewrote it as "pure" layer a few months ago, and used it a lot with Proton. Same logic, but maybe I accidentally fixed something, it works fine (+/-) for me so far with both versions.
Please note changed name : VK_LAYER_CUSTOM_VkGHL.

I'll check limiter logic later.

Thanks for the quick response, I really appreciate it!

I tried that one trying to cap frame rate at 20fps using this command:
VSYNC=0 FPS=20.00 DXVK_HUD=full VK_INSTANCE_LAYERS="VK_LAYER_CUSTOM_VkGHL" %command%

new_cap_50

It looks like it's not capping at all this time.
Edit: It is working again but I had to set the full path to libVkLayer_VkGHL.so in the VkLayer_VkGHL.json file.

I did all the testing again and the results are pretty much the same as in the first post though :/

If there's something that I could help you with just let me know, I've spend a lot of hours to get this to work in this game that I wouldn't mind repeating some more tests or helping out with some other information.

@EnriqueWood
Copy link
Author

EnriqueWood commented Dec 6, 2019

Not that I know how this actually works, but maybe it is a problem of the layer being executed ahead of time? I'd say that it should be the last layer to be executed before presenting the completely processed image... Does it make any sense to you? If that were the problem, is there a way to make this layer execute always after every operations are completed?

@pchome
Copy link
Owner

pchome commented Dec 7, 2019

I rewrote it almost from scratch (again), trying to follow Vulkan guide recommendations and adding more code guards (except threading): VkGHL.tar.gz.

Don't expect too much, it still not so accurate in Wine than in native Vulkan applications, so the problem can be somewhere in Wine or with the game itself. You could check WINEDEBUG=+loaddll and DXVK_LOG_LEVEL=info for anomalies.

@EnriqueWood
Copy link
Author

Wow! Thank you very much for working so hard to fix this problem, I really appreciate what you're doing for the community here!

I'll give it a try and comment you as soon as I do the proper testing

@DadSchoorse
Copy link

@pchome Can you opensource your new code? I would like to take a look at it.

@pchome
Copy link
Owner

pchome commented Jan 28, 2020

@DadSchoorse
Sure, I'll do this, eventually.

The only reason this wasn't done yet -- no functional changes, except new code is a standalone layer. So I need to do boring part, e.g. decide how to properly deprecate old repository, create new readme, license, release versioning, etc. This is not what I want to do right now. Maybe later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants