Merge pull request #103409 from darksylinc/matias-swappy-2025-01

Update to latest version of Swappy
This commit is contained in:
Rémi Verschelde 2025-03-04 01:02:14 +01:00
commit e8c555b002
No known key found for this signature in database
GPG key ID: C3336907360768E1
6 changed files with 187 additions and 129 deletions

View file

@ -62,8 +62,8 @@ jobs:
- name: Download pre-built Android Swappy Frame Pacing Library
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
repo: darksylinc/godot-swappy
version: tags/v2023.3.0.0
repo: godotengine/godot-swappy
version: tags/from-source-2025-01-31
file: godot-swappy.7z
target: swappy/godot-swappy.7z

5
.gitignore vendored
View file

@ -263,6 +263,11 @@ bld/
!thirdparty/**/arm/
!thirdparty/**/arm64/
thirdparty/swappy-frame-pacing/arm64-v8a/abi.json
thirdparty/swappy-frame-pacing/armeabi-v7a/abi.json
thirdparty/swappy-frame-pacing/x86/abi.json
thirdparty/swappy-frame-pacing/x86_64/abi.json
# Visual Studio 2015/2017 cache/options directory
.vs/

View file

@ -187,7 +187,7 @@ def configure(env: "SConsEnvironment"):
has_swappy = detect_swappy()
if not has_swappy:
print_warning(
"Swappy Frame Pacing not detected! It is strongly recommended you download it from https://github.com/darksylinc/godot-swappy/releases and extract it so that the following files can be found:\n"
"Swappy Frame Pacing not detected! It is strongly recommended you download it from https://github.com/godotengine/godot-swappy/releases and extract it so that the following files can be found:\n"
+ " thirdparty/swappy-frame-pacing/arm64-v8a/libswappy_static.a\n"
+ " thirdparty/swappy-frame-pacing/armeabi-v7a/libswappy_static.a\n"
+ " thirdparty/swappy-frame-pacing/x86/libswappy_static.a\n"

View file

@ -37,5 +37,6 @@
#define ANDROID_GAMESDK_MINOR_VERSION(PACKED) (((PACKED) >> 8) & 0xff)
#define ANDROID_GAMESDK_BUGFIX_VERSION(PACKED) ((PACKED) & 0xff)
#define AGDK_STRING_VERSION(MAJOR, MINOR, BUGFIX, GIT) \
#MAJOR "." #MINOR "." #BUGFIX "." #GIT
#define AGDK_STRINGIFY(NUMBER) #NUMBER
#define AGDK_STRING_VERSION(MAJOR, MINOR, BUGFIX) \
AGDK_STRINGIFY(MAJOR) "." AGDK_STRINGIFY(MINOR) "." AGDK_STRINGIFY(BUGFIX)

View file

@ -384,7 +384,8 @@ void SwappyVk_enableStats(VkSwapchainKHR swapchain, bool enabled);
* @see SwappyVk_enableStats.
*/
void SwappyVk_recordFrameStart(VkQueue queue, VkSwapchainKHR swapchain, uint32_t image);
void SwappyVk_recordFrameStart(VkQueue queue, VkSwapchainKHR swapchain,
uint32_t image);
/**
* @brief Returns the stats collected, if statistics collection was toggled on.
@ -396,8 +397,8 @@ void SwappyVk_recordFrameStart(VkQueue queue, VkSwapchainKHR swapchain, uint32_t
* conditions.
*
* @param[in] swapchain - The swapchain for which stats are being queried.
* @param swappyStats - Pointer to a SwappyStats that will be populated with
* the collected stats. Cannot be NULL.
* @param swappyStats - Pointer to a SwappyStats that will be populated
* with the collected stats. Cannot be NULL.
* @see SwappyStats
*/
void SwappyVk_getStats(VkSwapchainKHR swapchain, SwappyStats* swappyStats);
@ -413,6 +414,58 @@ void SwappyVk_getStats(VkSwapchainKHR swapchain, SwappyStats *swappyStats);
*/
void SwappyVk_clearStats(VkSwapchainKHR swapchain);
/**
* @brief Reset the swappy pacing mechanism
*
* In cases where the frame timing history is irrelevant (for example during
* scene/level transitions or after loading screens), calling this would
* remove all the history for frame pacing. Calling this entry point
* would reset the frame rate to the initial state at the end of the current
* frame. Then swappy would just pace as normal with fresh state from next
* frame. There are no error conditions associated with this call.
*
* @param[in] swapchain - The swapchain for which frame pacing is reset.
*/
void SwappyVk_resetFramePacing(VkSwapchainKHR swapchain);
/**
* @brief Enable/Disable the swappy pacing mechanism
*
* By default frame pacing is enabled when swappy is used, however it can be
* disabled at runtime by calling `SwappyVk_enableFramePacing(swapchain,
* false)`. When the frame pacing is disabled, ::SwappyVk_enableBlockingWait
* will control whether
* ::SwappyVk_queuePresent will return immediately, or will block until the
* previous frame's GPU work is completed. All enabling/disabling effects take
* place from next frame. Once disabled, `SwappyVk_enableFramePacing(swapchain,
* true)` will enable frame pacing again with a fresh frame time state -
* equivalent of calling ::SwappyVk_resetFramePacing().
*
* @param[in] swapchain - The swapchain for which stats are being queried.
* @param enable - If true, enables frame pacing otherwise disables it
*/
void SwappyVk_enableFramePacing(VkSwapchainKHR swapchain, bool enable);
/**
* @brief Enable/Disable blocking wait when frame-pacing is disabled
*
* By default ::SwappyVk_queuePresent will do a blocking wait until previous
* frame's GPU work is completed. However when frame pacing is disabled, calling
* `SwappyVk_enableBlockingWait(swapchain, false)` will ensure that
* ::SwappyVk_queuePresent returns without waiting for previous frame's GPU
* work. This behaviour impacts the GPU time returned in the
* ::SwappyPostWaitCallback callback. If the last frame's GPU work is done by
* the time ::SwappyVk_queuePresent for this frame is called, then the previous
* frame's GPU time will be returned otherwise `-1` will be delivered in the
* callback for the frame. This setting has no impact when frame pacing is
* enabled.
*
* @param[in] swapchain - The swapchain for which stats are being queried.
* @param enable - If true, ::SwappyVk_queuePresent will block until
* the previous frame's GPU work is complete.
*/
void SwappyVk_enableBlockingWait(VkSwapchainKHR swapchain, bool enable);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -48,7 +48,7 @@
// Internal macros to track Swappy version, do not use directly.
#define SWAPPY_MAJOR_VERSION 2
#define SWAPPY_MINOR_VERSION 0
#define SWAPPY_MINOR_VERSION 2
#define SWAPPY_BUGFIX_VERSION 0
#define SWAPPY_PACKED_VERSION \
ANDROID_GAMESDK_PACKED_VERSION(SWAPPY_MAJOR_VERSION, SWAPPY_MINOR_VERSION, \
@ -178,7 +178,6 @@ typedef struct SwappyStats {
uint64_t latencyFrames[MAX_FRAME_BUCKETS];
} SwappyStats;
#ifdef __cplusplus
} // extern "C"
#endif