-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'a0faf9cd01750cb8eea243bdf7bb1dd123d73f2c' into meshlet-…
…implicit-tangents
- Loading branch information
Showing
162 changed files
with
4,841 additions
and
2,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#import bevy_pbr::{ | ||
mesh_functions, | ||
view_transformations::position_world_to_clip | ||
} | ||
|
||
@group(2) @binding(0) var<storage, read> colors: array<vec4<f32>, 5>; | ||
|
||
struct Vertex { | ||
@builtin(instance_index) instance_index: u32, | ||
@location(0) position: vec3<f32>, | ||
}; | ||
|
||
struct VertexOutput { | ||
@builtin(position) clip_position: vec4<f32>, | ||
@location(0) world_position: vec4<f32>, | ||
@location(1) color: vec4<f32>, | ||
}; | ||
|
||
@vertex | ||
fn vertex(vertex: Vertex) -> VertexOutput { | ||
var out: VertexOutput; | ||
var world_from_local = mesh_functions::get_world_from_local(vertex.instance_index); | ||
out.world_position = mesh_functions::mesh_position_local_to_world(world_from_local, vec4(vertex.position, 1.0)); | ||
out.clip_position = position_world_to_clip(out.world_position.xyz); | ||
|
||
// We have 5 colors in the storage buffer, but potentially many instances of the mesh, so | ||
// we use the instance index to select a color from the storage buffer. | ||
out.color = colors[vertex.instance_index % 5]; | ||
|
||
return out; | ||
} | ||
|
||
@fragment | ||
fn fragment( | ||
mesh: VertexOutput, | ||
) -> @location(0) vec4<f32> { | ||
return mesh.color; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
benches/benches/bevy_ecs/iteration/par_iter_simple_foreach_hybrid.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use bevy_ecs::prelude::*; | ||
use bevy_tasks::{ComputeTaskPool, TaskPool}; | ||
use rand::{prelude::SliceRandom, SeedableRng}; | ||
use rand_chacha::ChaCha8Rng; | ||
|
||
#[derive(Component, Copy, Clone)] | ||
struct TableData(f32); | ||
|
||
#[derive(Component, Copy, Clone)] | ||
#[component(storage = "SparseSet")] | ||
struct SparseData(f32); | ||
|
||
fn deterministic_rand() -> ChaCha8Rng { | ||
ChaCha8Rng::seed_from_u64(42) | ||
} | ||
pub struct Benchmark<'w>(World, QueryState<(&'w mut TableData, &'w SparseData)>); | ||
|
||
impl<'w> Benchmark<'w> { | ||
pub fn new() -> Self { | ||
let mut world = World::new(); | ||
ComputeTaskPool::get_or_init(TaskPool::default); | ||
|
||
let mut v = vec![]; | ||
for _ in 0..100000 { | ||
world.spawn((TableData(0.0), SparseData(0.0))); | ||
v.push(world.spawn(TableData(0.)).id()); | ||
} | ||
|
||
// by shuffling ,randomize the archetype iteration order to significantly deviate from the table order. This maximizes the loss of cache locality during archetype-based iteration. | ||
v.shuffle(&mut deterministic_rand()); | ||
for e in v.into_iter() { | ||
world.entity_mut(e).despawn(); | ||
} | ||
|
||
let query = world.query::<(&mut TableData, &SparseData)>(); | ||
Self(world, query) | ||
} | ||
|
||
#[inline(never)] | ||
pub fn run(&mut self) { | ||
self.1 | ||
.par_iter_mut(&mut self.0) | ||
.for_each(|(mut v1, v2)| v1.0 += v2.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.