diff options
| author | Micha White <botahamec@outlook.com> | 2023-01-29 15:43:58 -0500 |
|---|---|---|
| committer | Micha White <botahamec@outlook.com> | 2023-01-29 15:43:58 -0500 |
| commit | 483b1a2238edf41537681f797c4fce1212b992b4 (patch) | |
| tree | 8a77a6b6e05b7b6b7e0c38ae9b29ac3907a73440 | |
| parent | 4b97a5e10d2c11b0603b31f45e56004eca0c98c2 (diff) | |
Optimize bunnymark
| -rw-r--r-- | alligator_render/Cargo.toml | 2 | ||||
| -rw-r--r-- | alligator_render/examples/black.rs | 1 | ||||
| -rw-r--r-- | alligator_render/examples/bunnymark.rs | 22 | ||||
| -rw-r--r-- | alligator_render/src/config.rs | 2 |
4 files changed, 22 insertions, 5 deletions
diff --git a/alligator_render/Cargo.toml b/alligator_render/Cargo.toml index cefb924..6de7b42 100644 --- a/alligator_render/Cargo.toml +++ b/alligator_render/Cargo.toml @@ -17,7 +17,7 @@ cgmath = "0.18" image = "0.24" texture_packer = "0.24" profiling = "1" -tracy-client = { version = "0.14", optional = true } +tracy-client = { version = "0.15", optional = true } dhat = { version = "0.3", optional = true } [lib] diff --git a/alligator_render/examples/black.rs b/alligator_render/examples/black.rs index b8846ca..106e0f0 100644 --- a/alligator_render/examples/black.rs +++ b/alligator_render/examples/black.rs @@ -6,6 +6,7 @@ fn update(_renderer: &mut Renderer) {} fn main() { let start = std::time::Instant::now(); + // configure the render window let config = RenderWindowConfig { //vsync: false, diff --git a/alligator_render/examples/bunnymark.rs b/alligator_render/examples/bunnymark.rs index 62371c9..4fe37d3 100644 --- a/alligator_render/examples/bunnymark.rs +++ b/alligator_render/examples/bunnymark.rs @@ -4,11 +4,26 @@ use alligator_render::{ ImageFormat, Instance, InstanceId, RenderWindowConfig, Renderer, TextureId, }; +fn xorshift_plus(seed: &mut [u64; 2]) -> u64 { + let mut t = seed[0]; + let s = seed[1]; + + t ^= t << 23; + t ^= t >> 18; + t ^= s ^ (s >> 5); + + seed[0] = s; + seed[1] = t; + + t + s +} + #[derive(Debug)] struct State { texture_id: TextureId, bunnies: Vec<Bunny>, previous_timestamp: Option<Instant>, + seed: [u64; 2], stopped: bool, } @@ -18,6 +33,7 @@ impl State { texture_id, bunnies: Vec::with_capacity(10_000_000), previous_timestamp: None, + seed: [0x0D15EA5E8BADF00D, 0xDECAFBADDEADBEAF], stopped: false, } } @@ -78,13 +94,13 @@ impl State { let instance_id = renderer.instances_mut().push_instance(Instance { texture_coordinates: [texture_x, texture_y], texture_size: [texture_width, texture_height], - size: [0.1, 0.1], + size: [0.08, 0.08], position: [-1.5, 0.70], ..Default::default() }); - let velocity_x = fps.fract() / 24.0; - let velocity_y = 0.0; + let velocity_x = (xorshift_plus(&mut self.seed) % 1_000_000) as f32 / 25_000_000.0; + let velocity_y = (xorshift_plus(&mut self.seed) % 1_000_000) as f32 / 25_000_000.0; self.bunnies.push(Bunny { instance_id, velocity_x, diff --git a/alligator_render/src/config.rs b/alligator_render/src/config.rs index c73c357..34b5856 100644 --- a/alligator_render/src/config.rs +++ b/alligator_render/src/config.rs @@ -80,7 +80,7 @@ impl<'a> Default for RenderWindowConfig<'a> { title: "Alligator Game", low_power: true, vsync: true, - instance_capacity: 0, // TODO this should probably be bigger + instance_capacity: 500, } } } |
