Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bevy_pbr2: Use the infinite reverse right-handed perspective projection #16

Open
wants to merge 30 commits into
base: pipelined-rendering
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2e99d84
remove .system from pipelined code (#2538)
cart Jul 26, 2021
0973d40
Add RenderWorld to Extract step (#2555)
cart Jul 28, 2021
3ec6b3f
move bevy_core_pipeline to its own plugin (#2552)
cart Jul 28, 2021
6944d38
bevy_render2: Log adapter info on initialization (#2542)
superdump Jul 29, 2021
0b800e5
Fix some nightly clippy lints (#2522)
BoxyUwU Jul 29, 2021
7b336fd
fix nightly clippy lints (#2568)
cart Jul 30, 2021
ae4f809
Port bevy_gltf to pipelined-rendering (#2537)
superdump Jul 30, 2021
115b170
Add sprite atlases into the new renderer. (#2560)
StarArawn Aug 4, 2021
2f32a2a
Added StorageTextureAccess to the exposed wgpu API (#2614)
Dimev Aug 8, 2021
b5b9a95
Add missing bytemuck feature (#2625)
zicklag Aug 10, 2021
c833003
Re-implement Automatic Sprite Sizing (#2613)
zicklag Aug 10, 2021
5fa0b5b
Added ComputePipelineDescriptor (#2628)
Dimev Aug 11, 2021
3faca93
Add ClearColor Resource to Pipelined Renderer (#2631)
zicklag Aug 19, 2021
993ce84
bevy_render2: Make default near plane more sensible at 0.1 (#2703)
superdump Aug 23, 2021
c3d3ae7
bevy_pbr2: Improve lighting units and documentation (#2704)
superdump Aug 23, 2021
e290a7e
Implement Sub-App Labels (#2695)
zicklag Aug 24, 2021
9898469
Sub app label changes (#2717)
cart Aug 24, 2021
f368bf7
bevy_pbr2: Add support for configurable shadow map sizes (#2700)
superdump Aug 25, 2021
f4aa328
bevy_pbr2: Add support for not casting/receiving shadows (#2726)
superdump Aug 25, 2021
dd32cd0
Pipelined separate shadow vertex shader (#2727)
superdump Aug 25, 2021
ec62a80
3d_scene_pipelined: Minor cleanup
superdump Jul 25, 2021
ace8a66
bevy_render2/bevy_pbr2: Use the infinite reverse rh perspective proje…
superdump Jul 25, 2021
b4d4def
Add the orthographic_pipelined example
superdump Jul 25, 2021
a41cc5f
bevy_render2/_pbr2/_sprite2: Add useful matrices to view and mesh uni…
superdump Aug 23, 2021
17a7f99
bevy_pbr2: Fix transformation of normals
superdump Aug 23, 2021
546d7b9
bevy_pbr2: Correct detection of an orthographic projection
superdump Aug 23, 2021
dc9e501
examples/README.md: Add orthographic_pipelined
superdump Aug 23, 2021
0ab73d8
bevy_pbr2: Minor simplification of the point light projection code
superdump Aug 26, 2021
cf8a4ff
bevy_pbr2: Cleanup
superdump Aug 26, 2021
2ee8f32
bevy_*2: Remove unnecessary ViewUniform members
superdump Aug 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ status = [
"build (stable, ubuntu-latest)",
"build (stable, macos-latest)",
"build (nightly, ubuntu-latest)",
"build-wasm (stable, ubuntu-latest)",
"build-wasm (nightly, ubuntu-latest)",
# TODO: re-enable after wasm works on pipelined-rendering
# "build-wasm (stable, ubuntu-latest)",
# "build-wasm (nightly, ubuntu-latest)",
"markdownlint",
"check-markdown-links",
"run-examples",
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ jobs:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"

build-wasm:
strategy:
matrix:
toolchain: [stable, nightly]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
target: wasm32-unknown-unknown
override: true

- name: Check wasm
uses: actions-rs/cargo@v1
with:
command: check
args: --target wasm32-unknown-unknown --no-default-features --features bevy_winit,x11,hdr,bevy_gltf
# NOTE: temporarily disabled while we sort out pipelined-rendering support
# build-wasm:
# strategy:
# matrix:
# toolchain: [stable, nightly]
# os: [ubuntu-latest]
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v2

# - uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ matrix.toolchain }}
# target: wasm32-unknown-unknown
# override: true

# - name: Check wasm
# uses: actions-rs/cargo@v1
# with:
# command: check
# args: --target wasm32-unknown-unknown --no-default-features --features bevy_winit,x11,hdr,bevy_gltf

build-android:
runs-on: ubuntu-latest
Expand Down
39 changes: 34 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ members = ["crates/*", "pipelined/*", "examples/ios", "tools/ci"]
[features]
default = [
"bevy_audio",
"bevy_core_pipeline",
"bevy_dynamic_plugin",
"bevy_gilrs",
"bevy_gltf",
"bevy_gltf2",
"bevy_wgpu",
"bevy_sprite2",
"bevy_render2",
Expand All @@ -41,7 +42,13 @@ default = [
dynamic = ["bevy_dylib"]

# Rendering support (Also needs the bevy_wgpu feature or a third-party rendering backend)
render = ["bevy_internal/bevy_pbr", "bevy_internal/bevy_render", "bevy_internal/bevy_sprite", "bevy_internal/bevy_text", "bevy_internal/bevy_ui"]
render = [
"bevy_internal/bevy_pbr",
"bevy_internal/bevy_render",
"bevy_internal/bevy_sprite",
"bevy_internal/bevy_text",
"bevy_internal/bevy_ui",
]

# Optional bevy crates
bevy_audio = ["bevy_internal/bevy_audio"]
Expand All @@ -51,9 +58,11 @@ bevy_gltf = ["bevy_internal/bevy_gltf"]
bevy_wgpu = ["bevy_internal/bevy_wgpu"]
bevy_winit = ["bevy_internal/bevy_winit"]

bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline"]
bevy_render2 = ["bevy_internal/bevy_render2"]
bevy_sprite2 = ["bevy_internal/bevy_sprite2"]
bevy_pbr2 = ["bevy_internal/bevy_pbr2"]
bevy_gltf2 = ["bevy_internal/bevy_gltf2"]

trace_chrome = ["bevy_internal/trace_chrome"]
trace = ["bevy_internal/trace"]
Expand Down Expand Up @@ -89,14 +98,14 @@ subpixel_glyph_atlas = ["bevy_internal/subpixel_glyph_atlas"]
bevy_ci_testing = ["bevy_internal/bevy_ci_testing"]

[dependencies]
bevy_dylib = {path = "crates/bevy_dylib", version = "0.5.0", default-features = false, optional = true}
bevy_internal = {path = "crates/bevy_internal", version = "0.5.0", default-features = false}
bevy_dylib = { path = "crates/bevy_dylib", version = "0.5.0", default-features = false, optional = true }
bevy_internal = { path = "crates/bevy_internal", version = "0.5.0", default-features = false }

[dev-dependencies]
anyhow = "1.0.4"
rand = "0.8.0"
ron = "0.6.2"
serde = {version = "1", features = ["derive"]}
serde = { version = "1", features = ["derive"] }
# Needed to poll Task examples
futures-lite = "1.11.3"

Expand Down Expand Up @@ -137,6 +146,10 @@ path = "examples/2d/text2d.rs"
name = "texture_atlas"
path = "examples/2d/texture_atlas.rs"

[[example]]
name = "pipelined_texture_atlas"
path = "examples/2d/pipelined_texture_atlas.rs"

# 3D Rendering
[[example]]
name = "3d_scene"
Expand All @@ -154,6 +167,10 @@ path = "examples/3d/cornell_box_pipelined.rs"
name = "load_gltf"
path = "examples/3d/load_gltf.rs"

[[example]]
name = "load_gltf_pipelined"
path = "examples/3d/load_gltf_pipelined.rs"

[[example]]
name = "msaa"
path = "examples/3d/msaa.rs"
Expand All @@ -162,6 +179,10 @@ path = "examples/3d/msaa.rs"
name = "orthographic"
path = "examples/3d/orthographic.rs"

[[example]]
name = "orthographic_pipelined"
path = "examples/3d/orthographic_pipelined.rs"

[[example]]
name = "parenting"
path = "examples/3d/parenting.rs"
Expand All @@ -182,6 +203,10 @@ path = "examples/3d/render_to_texture.rs"
name = "shadow_biases_pipelined"
path = "examples/3d/shadow_biases_pipelined.rs"

[[example]]
name = "shadow_caster_receiver_pipelined"
path = "examples/3d/shadow_caster_receiver_pipelined.rs"

[[example]]
name = "spawner"
path = "examples/3d/spawner.rs"
Expand Down Expand Up @@ -476,6 +501,10 @@ path = "examples/ui/ui.rs"
name = "clear_color"
path = "examples/window/clear_color.rs"

[[example]]
name = "clear_color_pipelined"
path = "examples/window/clear_color_pipelined.rs"

[[example]]
name = "multiple_windows"
path = "examples/window/multiple_windows.rs"
Expand Down
44 changes: 32 additions & 12 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub use bevy_derive::AppLabel;

use crate::{CoreStage, Events, Plugin, PluginGroup, PluginGroupBuilder, StartupStage};
use bevy_ecs::{
component::{Component, ComponentDescriptor},
Expand All @@ -7,12 +9,14 @@ use bevy_ecs::{
},
world::World,
};
use bevy_utils::tracing::debug;
use bevy_utils::{tracing::debug, HashMap};
use std::{fmt::Debug, hash::Hash};

#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;

bevy_utils::define_label!(AppLabel);

#[allow(clippy::needless_doctest_main)]
/// Containers of app logic and data
///
Expand Down Expand Up @@ -40,7 +44,7 @@ pub struct App {
pub world: World,
pub runner: Box<dyn Fn(App)>,
pub schedule: Schedule,
sub_apps: Vec<SubApp>,
sub_apps: HashMap<Box<dyn AppLabel>, SubApp>,
}

struct SubApp {
Expand Down Expand Up @@ -77,7 +81,7 @@ impl App {
world: Default::default(),
schedule: Default::default(),
runner: Box::new(run_once),
sub_apps: Vec::new(),
sub_apps: HashMap::default(),
}
}

Expand All @@ -87,7 +91,7 @@ impl App {
#[cfg(feature = "trace")]
let _bevy_frame_update_guard = bevy_frame_update_span.enter();
self.schedule.run(&mut self.world);
for sub_app in self.sub_apps.iter_mut() {
for sub_app in self.sub_apps.values_mut() {
(sub_app.runner)(&mut self.world, &mut sub_app.app);
}
}
Expand Down Expand Up @@ -544,7 +548,7 @@ impl App {
/// #
/// # struct MyOwnPlugin;
/// # impl Plugin for MyOwnPlugin {
/// # fn build(&self, app: &mut AppBuilder){;}
/// # fn build(&self, app: &mut App) { }
/// # }
/// #
/// App::new()
Expand Down Expand Up @@ -589,19 +593,35 @@ impl App {

pub fn add_sub_app(
&mut self,
label: impl AppLabel,
app: App,
f: impl Fn(&mut World, &mut App) + 'static,
) -> &mut Self {
self.sub_apps.push(SubApp {
app,
runner: Box::new(f),
});
self.sub_apps.insert(
Box::new(label),
SubApp {
app,
runner: Box::new(f),
},
);
self
}

// TODO: use labels instead of indices
pub fn sub_app_mut(&mut self, index: usize) -> &mut App {
&mut self.sub_apps[index].app
/// Retrieves a "sub app" stored inside this [App]. This will panic if the sub app does not exist.
pub fn sub_app(&mut self, label: impl AppLabel) -> &mut App {
match self.get_sub_app(label) {
Ok(app) => app,
Err(label) => panic!("Sub-App with label '{:?}' does not exist", label),
}
}

/// Retrieves a "sub app" inside this [App] with the given label, if it exists. Otherwise returns
/// an [Err] containing the given label.
pub fn get_sub_app(&mut self, label: impl AppLabel) -> Result<&mut App, impl AppLabel> {
self.sub_apps
.get_mut((&label) as &dyn AppLabel)
.map(|sub_app| &mut sub_app.app)
.ok_or(label)
}
}

Expand Down
13 changes: 5 additions & 8 deletions crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct AssetServerInternal {
pub(crate) asset_ref_counter: AssetRefCounter,
pub(crate) asset_sources: Arc<RwLock<HashMap<SourcePathId, SourceInfo>>>,
pub(crate) asset_lifecycles: Arc<RwLock<HashMap<Uuid, Box<dyn AssetLifecycle>>>>,
loaders: RwLock<Vec<Arc<Box<dyn AssetLoader>>>>,
loaders: RwLock<Vec<Arc<dyn AssetLoader>>>,
extension_to_loader_index: RwLock<HashMap<String, usize>>,
handle_to_path: Arc<RwLock<HashMap<HandleId, AssetPath<'static>>>>,
task_pool: TaskPool,
Expand Down Expand Up @@ -112,7 +112,7 @@ impl AssetServer {
.write()
.insert(extension.to_string(), loader_index);
}
loaders.push(Arc::new(Box::new(loader)));
loaders.push(Arc::new(loader));
}

pub fn watch_for_changes(&self) -> Result<(), AssetServerError> {
Expand All @@ -130,10 +130,7 @@ impl AssetServer {
HandleUntyped::strong(id.into(), sender)
}

fn get_asset_loader(
&self,
extension: &str,
) -> Result<Arc<Box<dyn AssetLoader>>, AssetServerError> {
fn get_asset_loader(&self, extension: &str) -> Result<Arc<dyn AssetLoader>, AssetServerError> {
let index = {
// scope map to drop lock as soon as possible
let map = self.server.extension_to_loader_index.read();
Expand All @@ -149,7 +146,7 @@ impl AssetServer {
fn get_path_asset_loader<P: AsRef<Path>>(
&self,
path: P,
) -> Result<Arc<Box<dyn AssetLoader>>, AssetServerError> {
) -> Result<Arc<dyn AssetLoader>, AssetServerError> {
let s = path
.as_ref()
.file_name()
Expand Down Expand Up @@ -478,7 +475,7 @@ impl AssetServer {
.expect("Asset should exist at this point.");
if let Some(asset_lifecycle) = asset_lifecycles.get(&asset_value.type_uuid()) {
let asset_path =
AssetPath::new_ref(&load_context.path, label.as_ref().map(|l| l.as_str()));
AssetPath::new_ref(load_context.path, label.as_ref().map(|l| l.as_str()));
asset_lifecycle.create_asset(asset_path.into(), asset_value, load_context.version);
} else {
panic!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'a> LoadContext<'a> {
}

pub fn path(&self) -> &Path {
&self.path
self.path
}

pub fn has_labeled_asset(&self, label: &str) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where
{
fn play_source(&self, audio_source: &P) {
if let Some(stream_handle) = &self.stream_handle {
let sink = Sink::try_new(&stream_handle).unwrap();
let sink = Sink::try_new(stream_handle).unwrap();
sink.append(audio_source.decoder());
sink.detach();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core/src/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(crate) fn entity_labels_system(
}
}

for added_label in labels.labels.difference(&current_labels) {
for added_label in labels.labels.difference(current_labels) {
entity_labels
.label_entities
.entry(added_label.clone())
Expand Down
10 changes: 10 additions & 0 deletions crates/bevy_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ mod render_resources;
mod resource;
mod shader_defs;

use bevy_macro_utils::{derive_label, BevyManifest};
use proc_macro::TokenStream;
use quote::format_ident;

/// Derives the FromResources trait. Each field must also implement the FromResources trait or this
/// will fail. FromResources is automatically implemented for types that implement Default.
Expand Down Expand Up @@ -60,3 +62,11 @@ pub fn bevy_main(attr: TokenStream, item: TokenStream) -> TokenStream {
pub fn derive_enum_variant_meta(input: TokenStream) -> TokenStream {
enum_variant_meta::derive_enum_variant_meta(input)
}

#[proc_macro_derive(AppLabel)]
pub fn derive_app_label(input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input as syn::DeriveInput);
let mut trait_path = BevyManifest::default().get_path("bevy_app");
trait_path.segments.push(format_ident!("AppLabel").into());
derive_label(input, trait_path)
}
4 changes: 0 additions & 4 deletions crates/bevy_ecs/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
name = "bevy_ecs_macros"
version = "0.5.0"
description = "Bevy ECS Macros"
authors = [
"Bevy Contributors <[email protected]>",
"Carter Anderson <[email protected]>",
]
edition = "2018"
license = "MIT OR Apache-2.0"

Expand Down
Loading