bevy_mod_speedup/request_fast_gpu.rs
1use bevy::prelude::*;
2
3#[derive(Resource, Reflect, Debug, Default)]
4#[reflect(Resource)]
5pub enum RequestFastGpuAdjustment {
6 #[default]
7 NotSupportingStatus,
8}
9
10/// Request for usage of high performance gpu in multi gpu setups.
11///
12/// # Platform behavior:
13///
14/// ## Windows:
15/// * Adds the variables `NvOptimusEnablement` and `AmdPowerXpressRequestHighPerformance` with a value of one.
16/// * Required the user to also export those by setting the linker args. This can be done in build.rs via:
17/// ```rust
18/// println!("cargo:rustc-link-arg=/EXPORT:NvOptimusEnablement");
19/// println!("cargo:rustc-link-arg=/EXPORT:AmdPowerXpressRequestHighPerformance");
20/// ```
21///
22/// ## Other platforms:
23///
24/// Currently does nothing on other platforms.
25///
26/// # Validating
27///
28/// Check with dumpbin /exports $APPLICATION.exe
29#[macro_export]
30macro_rules! request_fast_gpu {
31 () => {
32 #[cfg(target_os = "windows")]
33 #[no_mangle]
34 pub static NvOptimusEnablement: i32 = 1;
35
36 #[cfg(target_os = "windows")]
37 #[no_mangle]
38 pub static AmdPowerXpressRequestHighPerformance: i32 = 1;
39 };
40}
41
42#[derive(Debug)]
43pub struct RequestFastGpuPlugin;
44
45impl Plugin for RequestFastGpuPlugin {
46 fn build(
47 &self,
48 _app: &mut App,
49 ) {
50 }
51}