godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Integrating Frame Pacing Library to Vulkan Renderer for Android #2351

Closed buefox closed 1 week ago

buefox commented 3 years ago

Describe the project you are working on

Godot Vulkan renderer

Describe the problem or limitation you are having in your project

Currently there is no frame pacing mechanism that is built-in for Android in Godot.

Without proper frame pacing applications will have janky display and jumpy screen refresh rate.

This project will focus on Vulkan renderer (Godot 4.x) as for GLES renderer it would require the rewrite of GLSurfaceView

Describe the feature / enhancement and how it helps to overcome the problem or limitation

With Swappy, which is a frame pacing library built by Android, applications will have smooth screen refresh rate, enhancing the gaming experiences. The developers have choices to pick the desired refresh rate or let Swappy to choose the optimal one. Swappy also supports higher refresh rate displays of 90Hz and 120Hz

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The implementation is based on what is described in Android Developer's Guide which can be summarized as follows:

  1. Adding Swappy source code to godot/thirdparty
  2. Inserting Swappy functions and modify necessary sections such as vkQueuePresentKHR() in godot/drivers/vulkan/vulkan_context.cpp
  3. Adding radio button or check boxes in project settings panel to allow developers to select desired refresh rate
  4. Create a test app which can demonstrate the difference between with and with out frame pacing is enabled.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

This project requires renderer changes that happens within Vulkan driver.

Calinou commented 3 years ago

cc @m4gr3d

  1. Adding Swappy source code to godot/thirdparty

One of my concerns with the Android Frame Pacing library is that last time I checked, it was under a proprietary license. Did this change, or are there plans to address this? If not, the dependency needs to be made optional so that Godot games can still be uploaded to F-Droid. The source code will also need to be stored externally as the Godot repository should only contain open source code.

Also, what's the relation between Swappy and the Android Frame Pacing library?

buefox commented 3 years ago

Thanks for the feedback!

One of my concerns with the Android Frame Pacing library is that last time I checked, it was under a proprietary license. Did this change, or are there plans to address this?

As this is a part of Android GameSDK I think it should be open-sourced. I would need to check that with GameSDK team maintaining this.

If not, the dependency needs to be made optional so that Godot games can still be uploaded to F-Droid. The source code will also need to be stored externally as the Godot repository should only contain open source code.

Also, what's the relation between Swappy and the Android Frame Pacing library?

Sorry for not making this clear. Swappy is the name of the Android Frame Pacing Library.

jordo commented 3 years ago

Honestly, we should almost have a proposal to abstract away the presentation engine details in core... It's going to get very messy very quickly with 3 different backends, and each API (GLES2, GLES3, Vulkan, + future) having different apis & mechanisms for acquire/submit/present. And, also pacing information really comes from the presentation engine. Whether under the hood it's Choreographer, DisplayLink, or whatever.

buefox commented 3 years ago

@Calinou Just checked with the team on the licensing on Android Frame Pacing Library, a.k.a. Swappy, that Swappy is in the Game SDK on AOSP which is under the Apache 2.0 license. You can also find Apache 2.0 license header in each Swappy file. So I think it's good to use.

Let me know if you have any concerns :) Thanks!

oncetap commented 1 month ago

Any updates on this?

Calinou commented 1 month ago

Any updates on this?

https://github.com/godotengine/godot/pull/96439 implements this proposal :slightly_smiling_face:

oncetap commented 1 month ago

Any updates on this?

godotengine/godot#96439 implements this proposal 🙂

Nice!