Skip to content

Commit

Permalink
Merge branch 'main' into update-winit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Nov 22, 2023
2 parents c5de847 + 208ecb5 commit 1318e23
Show file tree
Hide file tree
Showing 208 changed files with 4,190 additions and 984 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/action-on-PR-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
if: github.event.label.name == 'C-Breaking-Change' && !contains(github.event.pull_request.body, '## Migration Guide')
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci-comment-failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- name: 'Download artifact'
id: find-artifact
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand All @@ -50,7 +50,7 @@ jobs:
if: ${{ steps.find-artifact.outputs.result == 'true' }}
- name: 'Comment on PR'
if: ${{ steps.find-artifact.outputs.result == 'true' }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
steps:
- name: 'Download artifact'
id: find-artifact
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand All @@ -108,7 +108,7 @@ jobs:
if: ${{ steps.find-artifact.outputs.result == 'true' }}
- name: 'Comment on PR'
if: ${{ steps.find-artifact.outputs.result == 'true' }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
steps:
- name: 'Download artifact'
id: find-artifact
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand All @@ -166,7 +166,7 @@ jobs:
if: ${{ steps.find-artifact.outputs.result == 'true' }}
- name: 'Comment on PR'
if: ${{ steps.find-artifact.outputs.result == 'true' }}
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ jobs:
VALIDATE_MARKDOWN: true
DEFAULT_BRANCH: main

toml:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install taplo
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz \
| gzip -d - \
| install -m 755 /dev/stdin /usr/local/bin/taplo
- name: Run Taplo
id: taplo
run: taplo fmt --check --diff
- name: Taplo info
if: failure()
run: |
echo 'To fix toml fmt, please run `taplo fmt`'
echo 'Or if you use VSCode, use the Even Better Toml extension'
run-examples-on-windows-dx12:
runs-on: windows-latest
timeout-minutes: 60
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
welcome:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
script: |
// Get a list of all issues created by the PR opener
Expand Down
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,14 @@ If you're new to Bevy, here's the workflow we use:
To locally lint your files using the same workflow as our CI:
1. Install [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli).
2. Run `markdownlint -f -c .github/linters/.markdown-lint.yml .` in the root directory of the Bevy project.
5. Push your changes to your fork on Github and open a Pull Request.
6. Respond to any CI failures or review feedback. While CI failures must be fixed before we can merge your PR, you do not need to *agree* with all feedback from your reviews, merely acknowledge that it was given. If you cannot come to an agreement, leave the thread open and defer to a Maintainer or Project Lead's final judgement.
7. When your PR is ready to merge, a Maintainer or Project Lead will review it and suggest final changes. If those changes are minimal they may even apply them directly to speed up merging.

5. When working with Toml (`.toml`) files, Bevy's CI will check toml files using [taplo](https://taplo.tamasfe.dev/): `taplo fmt --check --diff`
1. If you use VSCode, install [Even better toml](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) and format your files.
2. If you want to use the cli tool, install [taplo-cli](https://taplo.tamasfe.dev/cli/installation/cargo.html) and run `taplo fmt --check --diff` to check for the formatting. Fix any issues by running `taplo fmt` in the root directory of the Bevy project.

6. Push your changes to your fork on Github and open a Pull Request.
7. Respond to any CI failures or review feedback. While CI failures must be fixed before we can merge your PR, you do not need to *agree* with all feedback from your reviews, merely acknowledge that it was given. If you cannot come to an agreement, leave the thread open and defer to a Maintainer or Project Lead's final judgement.
8. When your PR is ready to merge, a Maintainer or Project Lead will review it and suggest final changes. If those changes are minimal they may even apply them directly to speed up merging.

If you end up adding a new official Bevy crate to the `bevy` repo:

Expand Down
35 changes: 33 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/bevyengine/bevy"
rust-version = "1.70.0"
rust-version = "1.74.0"

[workspace]
exclude = [
Expand All @@ -29,6 +29,14 @@ members = [
"errors",
]

[workspace.lints.clippy]
type_complexity = "allow"
doc_markdown = "warn"
undocumented_unsafe_blocks = "warn"

[lints]
workspace = true

[features]
default = [
"animation",
Expand Down Expand Up @@ -282,6 +290,7 @@ bevy_internal = { path = "crates/bevy_internal", version = "0.12.0", default-fea
[dev-dependencies]
rand = "0.8.0"
ron = "0.8.0"
flate2 = "1.0"
serde = { version = "1", features = ["derive"] }
bytemuck = "1.7"
# Needed to poll Task examples
Expand Down Expand Up @@ -1077,6 +1086,17 @@ description = "Demonstrates various methods to load assets"
category = "Assets"
wasm = false

[[example]]
name = "asset_decompression"
path = "examples/asset/asset_decompression.rs"
doc-scrape-examples = true

[package.metadata.example.asset_decompression]
name = "Asset Decompression"
description = "Demonstrates loading a compressed asset"
category = "Assets"
wasm = false

[[example]]
name = "custom_asset"
path = "examples/asset/custom_asset.rs"
Expand Down Expand Up @@ -1109,7 +1129,7 @@ required-features = ["file_watcher"]
name = "Hot Reloading of Assets"
description = "Demonstrates automatic reloading of assets when modified on disk"
category = "Assets"
wasm = true
wasm = false

[[example]]
name = "asset_processing"
Expand Down Expand Up @@ -1767,6 +1787,17 @@ description = "A shader and a material that uses it"
category = "Shaders"
wasm = true

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

[package.metadata.example.shader_material_2d]
name = "Material"
description = "A shader and a material that uses it on a 2d mesh"
category = "Shaders"
wasm = true

[[example]]
name = "extended_material"
path = "examples/shader/extended_material.rs"
Expand Down
Binary file added assets/data/compressed_image.png.gz
Binary file not shown.
7 changes: 6 additions & 1 deletion assets/scenes/load_scene_example.scn.ron
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
y: 0.0,
z: 0.0
),
rotation: (0.0, 0.0, 0.0, 1.0),
rotation: (
x: 0.0,
y: 0.0,
z: 0.0,
w: 1.0,
),
scale: (
x: 1.0,
y: 1.0,
Expand Down
6 changes: 2 additions & 4 deletions assets/shaders/custom_material.frag
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ layout(location = 0) in vec2 v_Uv;

layout(location = 0) out vec4 o_Target;

layout(set = 1, binding = 0) uniform CustomMaterial {
vec4 Color;
};
layout(set = 1, binding = 0) uniform vec4 CustomMaterial_color;

layout(set = 1, binding = 1) uniform texture2D CustomMaterial_texture;
layout(set = 1, binding = 2) uniform sampler CustomMaterial_sampler;
Expand All @@ -16,5 +14,5 @@ layout(set = 1, binding = 2) uniform sampler CustomMaterial_sampler;

void main() {
// o_Target = PbrFuncs::tone_mapping(Color * texture(sampler2D(CustomMaterial_texture,CustomMaterial_sampler), v_Uv));
o_Target = Color * texture(sampler2D(CustomMaterial_texture,CustomMaterial_sampler), v_Uv);
o_Target = CustomMaterial_color * texture(sampler2D(CustomMaterial_texture,CustomMaterial_sampler), v_Uv);
}
12 changes: 4 additions & 8 deletions assets/shaders/custom_material.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
// we can import items from shader modules in the assets folder with a quoted path
#import "shaders/custom_material_import.wgsl"::COLOR_MULTIPLIER

struct CustomMaterial {
color: vec4<f32>,
};

@group(1) @binding(0) var<uniform> material: CustomMaterial;
@group(1) @binding(1) var base_color_texture: texture_2d<f32>;
@group(1) @binding(2) var base_color_sampler: sampler;
@group(1) @binding(0) var<uniform> material_color: vec4<f32>;
@group(1) @binding(1) var material_color_texture: texture_2d<f32>;
@group(1) @binding(2) var material_color_sampler: sampler;

@fragment
fn fragment(
mesh: VertexOutput,
) -> @location(0) vec4<f32> {
return material.color * textureSample(base_color_texture, base_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
return material_color * textureSample(material_color_texture, material_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
}
12 changes: 12 additions & 0 deletions assets/shaders/custom_material_2d.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import bevy_sprite::mesh2d_vertex_output::VertexOutput
// we can import items from shader modules in the assets folder with a quoted path
#import "shaders/custom_material_import.wgsl"::COLOR_MULTIPLIER

@group(1) @binding(0) var<uniform> material_color: vec4<f32>;
@group(1) @binding(1) var base_color_texture: texture_2d<f32>;
@group(1) @binding(2) var base_color_sampler: sampler;

@fragment
fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
return material_color * textureSample(base_color_texture, base_color_sampler, mesh.uv) * COLOR_MULTIPLIER;
}
5 changes: 5 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ harness = false
name = "bezier"
path = "benches/bevy_math/bezier.rs"
harness = false

[[bench]]
name = "utils"
path = "benches/bevy_utils/entity_hash.rs"
harness = false
75 changes: 75 additions & 0 deletions benches/benches/bevy_utils/entity_hash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
use bevy_ecs::entity::Entity;
use bevy_utils::EntityHashSet;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;

criterion_group!(benches, entity_set_build_and_lookup,);
criterion_main!(benches);

const SIZES: [usize; 5] = [100, 316, 1000, 3162, 10000];

fn make_entity(rng: &mut impl Rng, size: usize) -> Entity {
// -log₂(1-x) gives an exponential distribution with median 1.0
// That lets us get values that are mostly small, but some are quite large
// * For ids, half are in [0, size), half are unboundedly larger.
// * For generations, half are in [0, 2), half are unboundedly larger.

let x: f64 = rng.gen();
let id = -(1.0 - x).log2() * (size as f64);
let x: f64 = rng.gen();
let gen = -(1.0 - x).log2() * 2.0;

// this is not reliable, but we're internal so a hack is ok
let bits = ((gen as u64) << 32) | (id as u64);
let e = Entity::from_bits(bits);
assert_eq!(e.index(), id as u32);
assert_eq!(e.generation(), gen as u32);
e
}

fn entity_set_build_and_lookup(c: &mut Criterion) {
let mut group = c.benchmark_group("entity_hash");
for size in SIZES {
// Get some random-but-consistent entities to use for all the benches below.
let mut rng = ChaCha8Rng::seed_from_u64(size as u64);
let entities = Vec::from_iter(
std::iter::repeat_with(|| make_entity(&mut rng, size)).take(size),
);

group.throughput(Throughput::Elements(size as u64));
group.bench_function(
BenchmarkId::new("entity_set_build", size),
|bencher| {
bencher.iter_with_large_drop(|| EntityHashSet::from_iter(entities.iter().copied()));
},
);
group.bench_function(
BenchmarkId::new("entity_set_lookup_hit", size),
|bencher| {
let set = EntityHashSet::from_iter(entities.iter().copied());
bencher.iter(|| entities.iter().copied().filter(|e| set.contains(e)).count());
},
);
group.bench_function(
BenchmarkId::new("entity_set_lookup_miss_id", size),
|bencher| {
let set = EntityHashSet::from_iter(entities.iter().copied());
bencher.iter(|| entities.iter()
.copied()
.map(|e| Entity::from_bits(e.to_bits() + 1))
.filter(|e| set.contains(e)).count());
},
);
group.bench_function(
BenchmarkId::new("entity_set_lookup_miss_gen", size),
|bencher| {
let set = EntityHashSet::from_iter(entities.iter().copied());
bencher.iter(|| entities.iter()
.copied()
.map(|e| Entity::from_bits(e.to_bits() + (1 << 32)))
.filter(|e| set.contains(e)).count());
},
);
}
}
3 changes: 3 additions & 0 deletions crates/bevy_a11y/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ bevy_derive = { path = "../bevy_derive", version = "0.12.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0" }

accesskit = "0.12"

[lints]
workspace = true
1 change: 0 additions & 1 deletion crates/bevy_a11y/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Accessibility for Bevy

#![warn(missing_docs)]
#![allow(clippy::type_complexity)]
#![forbid(unsafe_code)]

use std::sync::{
Expand Down
7 changes: 6 additions & 1 deletion crates/bevy_animation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ bevy_app = { path = "../bevy_app", version = "0.12.0" }
bevy_asset = { path = "../bevy_asset", version = "0.12.0" }
bevy_core = { path = "../bevy_core", version = "0.12.0" }
bevy_math = { path = "../bevy_math", version = "0.12.0" }
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = ["bevy"] }
bevy_reflect = { path = "../bevy_reflect", version = "0.12.0", features = [
"bevy",
] }
bevy_render = { path = "../bevy_render", version = "0.12.0" }
bevy_time = { path = "../bevy_time", version = "0.12.0" }
bevy_utils = { path = "../bevy_utils", version = "0.12.0" }
bevy_ecs = { path = "../bevy_ecs", version = "0.12.0" }
bevy_transform = { path = "../bevy_transform", version = "0.12.0" }
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.12.0" }

[lints]
workspace = true
Loading

0 comments on commit 1318e23

Please sign in to comment.