Skip to content

Commit

Permalink
Merge commit 'a0faf9cd01750cb8eea243bdf7bb1dd123d73f2c' into meshlet-…
Browse files Browse the repository at this point in the history
…implicit-tangents
  • Loading branch information
JMS55 committed Sep 8, 2024
2 parents 73dac63 + a0faf9c commit 1a6d28e
Show file tree
Hide file tree
Showing 162 changed files with 4,841 additions and 2,550 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/typos@v1.24.1
uses: crate-ci/typos@v1.24.3
- name: Typos info
if: failure()
run: |
Expand Down
39 changes: 37 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,8 @@ doc-scrape-examples = true
name = "Custom Asset IO"
description = "Implements a custom AssetReader"
category = "Assets"
wasm = true
# Incompatible with the asset path patching of the example-showcase tool
wasm = false

[[example]]
name = "embedded_asset"
Expand All @@ -1429,7 +1430,8 @@ doc-scrape-examples = true
name = "Extra asset source"
description = "Load an asset from a non-standard asset source"
category = "Assets"
wasm = true
# Uses non-standard asset path
wasm = false

[[example]]
name = "hot_asset_reloading"
Expand Down Expand Up @@ -2415,6 +2417,17 @@ description = "A shader that shows how to bind and sample multiple textures as a
category = "Shaders"
wasm = false

[[example]]
name = "storage_buffer"
path = "examples/shader/storage_buffer.rs"
doc-scrape-examples = true

[package.metadata.example.storage_buffer]
name = "Storage Buffer"
description = "A shader that shows how to bind a storage buffer using a custom material."
category = "Shaders"
wasm = true

[[example]]
name = "specialized_mesh_pipeline"
path = "examples/shader/specialized_mesh_pipeline.rs"
Expand Down Expand Up @@ -2904,6 +2917,17 @@ description = "Illustrates how to use 9 Slicing in UI"
category = "UI (User Interface)"
wasm = true

[[example]]
name = "ui_texture_slice_flip_and_tile"
path = "examples/ui/ui_texture_slice_flip_and_tile.rs"
doc-scrape-examples = true

[package.metadata.example.ui_texture_slice_flip_and_tile]
name = "UI Texture Slice Flipping and Tiling"
description = "Illustrates how to flip and tile images with 9 Slicing in UI"
category = "UI (User Interface)"
wasm = true

[[example]]
name = "ui_texture_atlas_slice"
path = "examples/ui/ui_texture_atlas_slice.rs"
Expand Down Expand Up @@ -3395,6 +3419,17 @@ description = "Demonstrates picking sprites and sprite atlases"
category = "Picking"
wasm = true

[[example]]
name = "animation_masks"
path = "examples/animation/animation_masks.rs"
doc-scrape-examples = true

[package.metadata.example.animation_masks]
name = "Animation Masks"
description = "Demonstrates animation masks"
category = "Animation"
wasm = true

[profile.wasm-release]
inherits = "release"
opt-level = "z"
Expand Down
6 changes: 6 additions & 0 deletions assets/animation_graphs/Fox.animgraph.ron
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
nodes: [
(
clip: None,
mask: 0,
weight: 1.0,
),
(
clip: None,
mask: 0,
weight: 0.5,
),
(
clip: Some(AssetPath("models/animated/Fox.glb#Animation0")),
mask: 0,
weight: 1.0,
),
(
clip: Some(AssetPath("models/animated/Fox.glb#Animation1")),
mask: 0,
weight: 1.0,
),
(
clip: Some(AssetPath("models/animated/Fox.glb#Animation2")),
mask: 0,
weight: 1.0,
),
],
Expand All @@ -32,4 +37,5 @@
],
),
root: 0,
mask_groups: {},
)
38 changes: 38 additions & 0 deletions assets/shaders/storage_buffer.wgsl
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.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'w> Benchmark<'w> {

let mut v = vec![];
for _ in 0..10000 {
world.spawn((TableData(0.0), SparseData(0.0))).id();
world.spawn((TableData(0.0), SparseData(0.0)));
v.push(world.spawn(TableData(0.)).id());
}

Expand Down
5 changes: 5 additions & 0 deletions benches/benches/bevy_ecs/iteration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod iter_simple_system;
mod iter_simple_wide;
mod iter_simple_wide_sparse_set;
mod par_iter_simple;
mod par_iter_simple_foreach_hybrid;

use heavy_compute::*;

Expand Down Expand Up @@ -135,4 +136,8 @@ fn par_iter_simple(c: &mut Criterion) {
b.iter(move || bench.run());
});
}
group.bench_function(format!("hybrid"), |b| {
let mut bench = par_iter_simple_foreach_hybrid::Benchmark::new();
b.iter(move || bench.run());
});
}
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)
}
}
2 changes: 2 additions & 0 deletions crates/bevy_animation/src/animatable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Traits and type for interpolating between values.

use crate::util;
use bevy_color::{Laba, LinearRgba, Oklaba, Srgba, Xyza};
use bevy_ecs::world::World;
Expand Down
Loading

0 comments on commit 1a6d28e

Please sign in to comment.