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

Add padded static size and recursive padding to crevice and use it #18

Open
wants to merge 29 commits into
base: pipelined-rendering
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c074777
pipelined rendering proof of concept
cart Apr 11, 2021
6600dde
Added compute to the new pipelined renderer.
StarArawn May 30, 2021
13d613b
Share code between passes for setting bind groups.
StarArawn May 31, 2021
4b26031
Reverted combining of set_bind_group between different passes.
StarArawn May 31, 2021
18a4fcf
SubGraphs, Views, Shadows, and more
cart Jun 2, 2021
53a442f
Fix ExclusiveSystemCoerced so it updates system with new archetypes
cart Jun 17, 2021
334a857
StandardMaterial flat values (#3)
superdump Jun 18, 2021
fbe8456
bevy_render now uses wgpu directly
cart Jun 21, 2021
2cc0c56
fix tracing and add graph spans
cart Jun 25, 2021
64f99b2
RenderAssetPlugin
cart Jun 25, 2021
eef62d3
Port Mesh to RenderAsset, add Slab and FrameSlabMap garbage collectio…
cart Jun 26, 2021
b3e2fab
bevy_pbr2: Add support for most of the StandardMaterial textures (#4)
superdump Jun 27, 2021
cf7e24c
Add `log` crate compatibility to bevy_log
cart Jun 28, 2021
b6d9277
Begin WGSL port (sprites work, pbr lights are broken)
cart Jun 28, 2021
1635de4
Force main thread for prepare_windows system (#11)
TheRawMeatball Jun 29, 2021
03cf087
wgsl PBR fixes (#12)
superdump Jun 29, 2021
ff33307
crevice: Add std{140,430}_padded_size_static
superdump Jul 1, 2021
0530368
bevy_render2/bevy_pbr2: Use std140_padded_size_static
superdump Jul 1, 2021
f454e39
bevy_render2/bevy_pbr2: Update to wgpu 0.9 / naga 0.5 (#19)
superdump Jul 1, 2021
5de75a5
Fixed issue where transform buffer wasn't creating new bindings on re…
StarArawn Jul 1, 2021
bbb69ea
Allows resizing of windows (#8)
bilsen Jul 1, 2021
c0b6d05
bevy_pbr2: pbr.wgsl: Fix the orthographic projection check (#17)
superdump Jul 1, 2021
c16a030
Do not queue sprites/meshes if there are no views (#13)
superdump Jul 1, 2021
30e4b8d
Omnilight shadow map wgsl (#15)
mtsr Jul 1, 2021
d0c3185
omni light -> point light
cart Jul 1, 2021
9a79b79
fix clippy
cart Jul 2, 2021
b9757fa
Merge branch 'pipelined-rendering' into crevice-padded-size
superdump Jul 4, 2021
345b618
crevice: Simplify *_padded_size_static
superdump Jul 4, 2021
8aea360
crevice: Add recursive padding support
superdump Jul 4, 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
Prev Previous commit
Next Next commit
Added compute to the new pipelined renderer.
  • Loading branch information
StarArawn authored and cart committed Jun 4, 2021
commit 6600dde42080d9363f38179094ab7fce8660391c
6 changes: 5 additions & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,11 @@ impl App {
self
}

pub fn add_sub_app(&mut self, app: App, f: impl Fn(&mut World, &mut App) + 'static) -> &mut Self {
pub fn add_sub_app(
&mut self,
app: App,
f: impl Fn(&mut World, &mut App) + 'static,
) -> &mut Self {
self.sub_apps.push(SubApp {
app,
runner: Box::new(f),
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ pub use schedule_runner::*;

pub mod prelude {
#[doc(hidden)]
pub use crate::{
app::App, CoreStage, DynamicPlugin, Plugin, PluginGroup,
StartupStage,
};
pub use crate::{app::App, CoreStage, DynamicPlugin, Plugin, PluginGroup, StartupStage};
}

use bevy_ecs::schedule::StageLabel;
Expand Down
28 changes: 23 additions & 5 deletions crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,9 @@ mod tests {

fn clear_entities() {
let mut world = World::default();
world.register_component(ComponentDescriptor::new::<f32>(StorageType::SparseSet)).unwrap();
world
.register_component(ComponentDescriptor::new::<f32>(StorageType::SparseSet))
.unwrap();
world.insert_resource::<i32>(0);
world.spawn().insert(1u32);
world.spawn().insert(1.0f32);
Expand All @@ -1243,9 +1245,25 @@ mod tests {

world.clear_entities();

assert_eq!(q1.iter(&world).len(), 0, "world should not contain table components");
assert_eq!(q2.iter(&world).len(), 0, "world should not contain sparse set components");
assert_eq!(world.entities().len(), 0, "world should not have any entities");
assert_eq!(*world.get_resource::<i32>().unwrap(), 0, "world should still contain resources");
assert_eq!(
q1.iter(&world).len(),
0,
"world should not contain table components"
);
assert_eq!(
q2.iter(&world).len(),
0,
"world should not contain sparse set components"
);
assert_eq!(
world.entities().len(),
0,
"world should not have any entities"
);
assert_eq!(
*world.get_resource::<i32>().unwrap(),
0,
"world should still contain resources"
);
}
}
2 changes: 1 addition & 1 deletion crates/crevice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ pub mod internal;
#[cfg(feature = "mint")]
mod mint;

mod glam;
mod glam;
5 changes: 4 additions & 1 deletion pipelined/bevy_render2/src/camera/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::camera::{CAMERA_2D, CAMERA_3D, Camera, DepthCalculation, OrthographicProjection, PerspectiveProjection, ScalingMode};
use crate::camera::{
Camera, DepthCalculation, OrthographicProjection, PerspectiveProjection, ScalingMode,
CAMERA_2D, CAMERA_3D,
};
use bevy_ecs::bundle::Bundle;
use bevy_transform::components::{GlobalTransform, Transform};

Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/color/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mod color;
mod colorspace;

pub use color::*;
pub use colorspace::*;
pub use colorspace::*;
38 changes: 19 additions & 19 deletions pipelined/bevy_render2/src/main_pass/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
mod draw_state;
mod draw;
mod draw_state;

pub use draw_state::*;
pub use draw::*;
pub use draw_state::*;

use crate::{RenderStage, pass::RenderPassColorAttachment, renderer::RenderContext};
use crate::{
camera::CameraPlugin,
color::Color,
pass::{
LoadOp, Operations, PassDescriptor, RenderPass,
TextureAttachment,
},
pass::{LoadOp, Operations, PassDescriptor, RenderPass, TextureAttachment},
render_graph::{Node, RenderGraph, ResourceSlotInfo, ResourceSlots, WindowSwapChainNode},
render_resource::RenderResourceType,
};
use crate::{pass::RenderPassColorAttachment, renderer::RenderContext, RenderStage};
use bevy_app::{App, Plugin};
use bevy_ecs::prelude::*;
use bevy_window::WindowId;
Expand Down Expand Up @@ -120,17 +117,20 @@ impl Node for MainPassNode {
let transparent_phase = world.get_resource::<RenderPhase>().unwrap();
let draw_functions = world.get_resource::<DrawFunctions>().unwrap();

render_context.begin_pass(&pass_descriptor, &mut |render_pass: &mut dyn RenderPass| {
let mut draw_functions = draw_functions.draw_function.lock();
let mut tracked_pass = TrackedRenderPass::new(render_pass);
for drawable in transparent_phase.drawn_things.iter() {
draw_functions[drawable.draw_function].draw(
world,
&mut tracked_pass,
drawable.draw_key,
drawable.sort_key,
);
}
})
render_context.begin_render_pass(
&pass_descriptor,
&mut |render_pass: &mut dyn RenderPass| {
let mut draw_functions = draw_functions.draw_function.lock();
let mut tracked_pass = TrackedRenderPass::new(render_pass);
for drawable in transparent_phase.drawn_things.iter() {
draw_functions[drawable.draw_function].draw(
world,
&mut tracked_pass,
drawable.draw_key,
drawable.sort_key,
);
}
},
)
}
}
5 changes: 4 additions & 1 deletion pipelined/bevy_render2/src/mesh/mesh.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
mod conversions;

use crate::pipeline::{IndexFormat, InputStepMode, PrimitiveTopology, VertexAttribute, VertexBufferLayout, VertexFormat};
use crate::pipeline::{
IndexFormat, InputStepMode, PrimitiveTopology, VertexAttribute, VertexBufferLayout,
VertexFormat,
};
use bevy_core::cast_slice;
use bevy_math::*;
use bevy_reflect::TypeUuid;
Expand Down
18 changes: 18 additions & 0 deletions pipelined/bevy_render2/src/pass/compute_pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::{
pipeline::{BindGroupDescriptorId, PipelineId},
render_resource::BindGroupId,
renderer::RenderContext,
};

pub trait ComputePass {
fn get_render_context(&self) -> &dyn RenderContext;
fn set_pipeline(&mut self, pipeline: PipelineId);
fn dispatch(&mut self, x: u32, y: u32, z: u32);
fn set_bind_group(
&mut self,
index: u32,
bind_group_descriptor_id: BindGroupDescriptorId,
bind_group: BindGroupId,
dynamic_uniform_indices: Option<&[u32]>,
);
}
2 changes: 2 additions & 0 deletions pipelined/bevy_render2/src/pass/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
mod compute_pass;
mod ops;
#[allow(clippy::module_inception)]
mod pass;
mod render_pass;

pub use compute_pass::*;
pub use ops::*;
pub use pass::*;
pub use render_pass::*;
1 change: 0 additions & 1 deletion pipelined/bevy_render2/src/pass/pass.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{color::Color, pass::Operations, render_resource::TextureId};


#[derive(Debug, Clone)]
pub enum TextureAttachment {
Id(TextureId),
Expand Down
29 changes: 29 additions & 0 deletions pipelined/bevy_render2/src/pipeline/compute_pipeline.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use super::PipelineLayout;
use crate::shader::ComputeShaderStages;
use bevy_reflect::TypeUuid;

#[derive(Clone, Debug, TypeUuid)]
#[uuid = "359c1fff-0c86-4fbb-8b66-4e2af422a2f1"]
pub struct ComputePipelineDescriptor {
pub name: Option<String>,
pub layout: PipelineLayout,
pub shader_stages: ComputeShaderStages,
}

impl ComputePipelineDescriptor {
pub fn new(shader_stages: ComputeShaderStages, layout: PipelineLayout) -> Self {
ComputePipelineDescriptor {
name: None,
layout,
shader_stages,
}
}

pub fn default_config(shader_stages: ComputeShaderStages, layout: PipelineLayout) -> Self {
ComputePipelineDescriptor {
name: None,
layout,
shader_stages,
}
}
}
2 changes: 2 additions & 0 deletions pipelined/bevy_render2/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod bind_group;
mod binding;
mod compute_pipeline;
#[allow(clippy::module_inception)]
mod pipeline;
mod pipeline_layout;
Expand All @@ -9,6 +10,7 @@ mod vertex_format;

pub use bind_group::*;
pub use binding::*;
pub use compute_pipeline::*;
pub use pipeline::*;
pub use pipeline_layout::*;
pub use state_descriptors::*;
Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/pipeline/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
BlendComponent, BlendState, ColorTargetState, DepthBiasState, DepthStencilState,
MultisampleState, PolygonMode, PrimitiveState, StencilFaceState, StencilState,
},
shader::{ShaderStages},
shader::ShaderStages,
texture::TextureFormat,
};
use bevy_reflect::{TypeUuid, Uuid};
Expand Down
4 changes: 2 additions & 2 deletions pipelined/bevy_render2/src/render_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ mod edge;
mod graph;
mod node;
mod node_slot;
mod schedule;
mod nodes;
mod schedule;

pub use edge::*;
pub use graph::*;
pub use node::*;
pub use node_slot::*;
pub use schedule::*;
pub use nodes::*;
pub use schedule::*;

use thiserror::Error;

Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/render_graph/nodes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod window_swap_chain_node;

pub use window_swap_chain_node::*;
pub use window_swap_chain_node::*;
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/render_resource/bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ impl BindGroupBuilder {
}
}
}
}
}
2 changes: 1 addition & 1 deletion pipelined/bevy_render2/src/render_resource/buffer_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
render_resource::{BufferId, BufferInfo, BufferMapMode, BufferUsage},
renderer::{RenderContext, RenderResources},
};
use bevy_core::{Pod, cast_slice};
use bevy_core::{cast_slice, Pod};

pub struct BufferVec<T: Pod> {
values: Vec<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ impl RenderResourceId {
None
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::RenderResourceContext;
use crate::{
pipeline::{BindGroupDescriptorId, PipelineDescriptor, PipelineId},
pipeline::{BindGroupDescriptorId, ComputePipelineDescriptor, PipelineDescriptor, PipelineId},
render_resource::{
BindGroup, BufferId, BufferInfo, BufferMapMode, SamplerId, SwapChainDescriptor, TextureId,
},
Expand Down Expand Up @@ -101,6 +101,13 @@ impl RenderResourceContext for HeadlessRenderResourceContext {
PipelineId::new()
}

fn create_compute_pipeline(
&self,
_pipeline_descriptor: &ComputePipelineDescriptor,
) -> PipelineId {
PipelineId::new()
}

fn create_bind_group(
&self,
_bind_group_descriptor_id: BindGroupDescriptorId,
Expand Down
6 changes: 4 additions & 2 deletions pipelined/bevy_render2/src/renderer/render_context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::RenderResourceContext;
use crate::{
pass::{PassDescriptor, RenderPass},
pass::{ComputePass, PassDescriptor, RenderPass},
render_resource::{BufferId, TextureId},
texture::Extent3d,
};
Expand Down Expand Up @@ -49,9 +49,11 @@ pub trait RenderContext {
destination_mip_level: u32,
size: Extent3d,
);
fn begin_pass(
fn begin_render_pass(
&mut self,
pass_descriptor: &PassDescriptor,
run_pass: &mut dyn FnMut(&mut dyn RenderPass),
);

fn begin_compute_pass(&mut self, run_pass: &mut dyn FnMut(&mut dyn ComputePass));
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
pipeline::{BindGroupDescriptorId, PipelineDescriptor, PipelineId},
pipeline::{BindGroupDescriptorId, ComputePipelineDescriptor, PipelineDescriptor, PipelineId},
render_resource::{
BindGroup, BufferId, BufferInfo, BufferMapMode, SamplerId, SwapChainDescriptor, TextureId,
},
Expand Down Expand Up @@ -65,6 +65,10 @@ pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
fn get_aligned_uniform_size(&self, size: usize, dynamic: bool) -> usize;
fn get_aligned_texture_size(&self, data_size: usize) -> usize;
fn create_render_pipeline(&self, pipeline_descriptor: &PipelineDescriptor) -> PipelineId;
fn create_compute_pipeline(
&self,
_pipeline_descriptor: &ComputePipelineDescriptor,
) -> PipelineId;
fn bind_group_descriptor_exists(&self, bind_group_descriptor_id: BindGroupDescriptorId)
-> bool;
fn create_bind_group(
Expand Down
6 changes: 6 additions & 0 deletions pipelined/bevy_render2/src/shader/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ pub struct ShaderStages {
pub fragment: Option<ShaderId>,
}

/// All stages in a compute shader program
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct ComputeShaderStages {
pub compute: ShaderId,
}

#[derive(Default)]
pub struct ShaderLoader;

Expand Down
4 changes: 2 additions & 2 deletions pipelined/bevy_sprite2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod bundle;
mod render;
mod rect;
mod render;
mod sprite;

pub use bundle::*;
pub use rect::*;
pub use render::*;
pub use sprite::*;
pub use bundle::*;

use bevy_app::prelude::*;
use bevy_ecs::prelude::IntoSystem;
Expand Down
2 changes: 1 addition & 1 deletion pipelined/bevy_sprite2/src/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ impl Sprite {
flip_y: false,
}
}
}
}
Loading