bevy_mod_speedup

Crates.iobevy_mod_speedup
lib.rsbevy_mod_speedup
version
sourcesrc
created_at2024-04-21 13:50:24.643313
updated_at2024-11-30 14:12:52.51304
descriptionbevy_mod_speedup is a collection of ways to increase the performance of your application.
homepagehttps://github.com/FrTerstappen/bevy_mod_speedup
repositoryhttps://github.com/FrTerstappen/bevy_mod_speedup
max_upload_size
id1215405
Cargo.toml error:TOML parse error at line 20, column 1 | 20 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Frederik Terstappen (FrTerstappen)

documentation

https://docs.rs/bevy_mod_speedup

README

bevy_mod_speedup

License Crates.io Version Following released Bevy versions

bevy_mod_speedup is a collection of ways to increase the performance of your application.

[!WARNING]
This plugin is in a very early stage of development.
Expect major changes to the contained features and to the api of existing features.

Description

[!NOTE]
This repository is open for additional features and the expansion of existing features to other platforms.
It is currently limited to the features I use in my personal project and the platforms I have available.

bevy_mod_speedup contains a collection of techniques to make your game (or application) more performant. This is mostly achieved by interacting with the system the game runs on. One example is adjusting the energy saving state of the system. The availability of the provided techniques is dependent on the used platform.

This plugin also offers some Resources to check the status of the "speedup". This allows the application to react to the applied changes or a failure to adjust something. See this chapter for more information.

[!WARNING]
The techniques implemented here are not guaranteed to always improve performance.
As such it is recommended to check all used features on their supported platforms.
It is also recommended to ensure the application is not dependent on the improvements provided here as this does not replace optimized code.

This repository also includes other tips to improve the performance of your application. For the other tips look here. These tips can not be implemented in a library and need to be done directly in your project.

Status resources

The resource SpeedupAdjustments can be used to check the status of the adjustments. The features each add a field to the resource that matches the feature name. These fields are enums with variants describing the current status.

Features

To be as modular as possible this library has most of its functionality gated behind separate features.
Most of those features are enable by default via the on-by-default feature full_speed.
You can see the availability of features and their inclusion in full_speed in this table.

Platform independent features

The features described here are independent of the used platform.

Feature: egui

Adds a convenience method to display the SpeedupAdjustments with egui. See the egui example for usage.

Run the example with cargo run --example egui --features="egui".

Platform dependent features

Feature support on different platform:

in full_speed Linux Windows
exclusive_fullscreen no :grey_question: :white_check_mark:
power yes :grey_question: :white_check_mark:
priority yes :white_check_mark: :white_check_mark:
request_fast_gpu yes :grey_question: :white_check_mark:
unattended no :grey_question: :white_check_mark:

Legend:
:grey_question: = To be evaluated
:white_square_button: = Not yet implemented
:white_check_mark: = Implemented
:negative_squared_cross_mark: = Feature not supported on this platform

[!NOTE]
Features enabled on a platform they do not support do nothing1.

Feature: exclusive_fullscreen

This features tries to fulfill all the conditions for fullscreen exclusivity. A application that is fullscreen exclusive can bypass the compositor and render slightly faster.

This feature is not enough for fullscreen exclusivity by itself. It requires further platform dependent adjustments to the application.

TODO: Add information about what is needed to achieve fullscreen exclusivity and how to check that it works.

  • Windows: Adjusts the DPI awareness2

Feature: power

Adjusts system settings to disable power saving and/or use high performance mode.

  • Windows: Sets the power scheme to GUID_MIN_POWER_SAVINGS, restores the original plan on AppExit.

Feature: priority

This tries to adjust the priority of the application.

  • Linux: Adjust the priority to -5. Only works with privileges
  • Windows: Adjust the priority class to ABOVE_NORMAL_PRIORITY_CLASS

Feature: request_fast_gpu

In hardware setups with integrated and dedicated GPUs it can be necessary to declare that the application wants to use the dedicated GPU.

Windows

This is on windows achieved by declaring special exports in the application. As this can not be done from a library you have to add additional code to your application to make use of this feature. The following two steps are needed:

  • Call the macro request_fast_gpu!() in your application

  • Add the following code in your build.rs to export the added variables.

    println!("cargo:rustc-link-arg=/EXPORT:NvOptimusEnablement");
    println!("cargo:rustc-link-arg=/EXPORT:AmdPowerXpressRequestHighPerformance");
    

You can check for the exports with dumpbin /exports $APPLICATION.exe.

Feature: unattended

This feature allows the application to run unattended without limitations. This means disabling screen-saver, hibernation and similar features.

  • Windows: Uses SetThreadExecutionState, with ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED.

Installation

Include the library in your project by adding it to your Cargo.toml.

[dependencies]
bevy = "0.14.0"
bevy_mod_speedup = "0.3.0"

Then add the SpeedupPlugin to your app like shown below.

use bevy::prelude::*;
use bevy_mod_speedup::SpeedupPlugin;

fn main(){
  App::new()
    .add_plugins(SpeedupPlugin)
    .run();
}

Other performance tips

TODO

Further reading / references

Contributing

Contributions are welcome. For larger changes please open a issue first.

Your contributions

Unless explicitly stated otherwise, any contribution submitted to this project shall be dual licensed under the MIT License and Apache License, Version 2.0, without any additional terms or conditions.

License

All code in this repository is dual-licensed under either:

Bevy compatibility

bevy bevy_mod_speedup
0.15.0 0.5.0
0.14.1 0.4.0
0.14.0 0.3.0
0.13.1 0.1.0 - 0.2.0

Footnotes

  1. Beside a log entry in some cases.

  2. Can alternatively be set via "Application Manifests".

Commit count: 29

cargo fmt