diff --git a/.cargo/config.toml.old b/.cargo/config.toml.old new file mode 100644 index 0000000..1a80232 --- /dev/null +++ b/.cargo/config.toml.old @@ -0,0 +1,9 @@ +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = [ + "-Clink-arg=-fuse-ld=mold", + + # Nightly + "-Zshare-generics=y", + "-Zthreads=0", +] diff --git a/Cargo.toml b/Cargo.toml index b822d89..8b070fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "vidya" version = "0.1.0" edition = "2024" +[patch.crates-io] +bevy = {path = "../bevy"} + [workspace] resolver = "2" @@ -68,22 +71,22 @@ raw-window-handle = "0.6" egui = "0.32" egui_winit_platform = "0.27" -bevy = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_app = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_asset = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_derive = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_ecs = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy", features = ["multi_threaded", "trace"]} -bevy_hierarchy = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_log = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_math = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_platform = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_reflect = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_tasks = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_time = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_transform = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_utils = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_window = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } -bevy_winit = { version = "0.19.0-dev", git = "https://github.com/bevyengine/bevy" } +bevy = { version = "0.20.0-dev" } +bevy_app = { version = "0.20.0-dev" } +bevy_asset = { version = "0.20.0-dev" } +bevy_derive = { version = "0.20.0-dev" } +bevy_ecs = { version = "0.20.0-dev" } +bevy_hierarchy = { version = "0.20.0-dev" } +bevy_log = { version = "0.20.0-dev" } +bevy_math = { version = "0.20.0-dev" } +bevy_platform = { version = "0.20.0-dev" } +bevy_reflect = { version = "0.20.0-dev" } +bevy_tasks = { version = "0.20.0-dev" } +bevy_time = { version = "0.20.0-dev" } +bevy_transform = { version = "0.20.0-dev" } +bevy_utils = { version = "0.20.0-dev" } +bevy_window = { version = "0.20.0-dev" } +bevy_winit = { version = "0.20.0-dev" } [[example]] name = "bevy_integration" diff --git a/crates/renderer/src/render_graph/commands.rs b/crates/renderer/src/render_graph/commands.rs index c0142b8..1f88b15 100644 --- a/crates/renderer/src/render_graph/commands.rs +++ b/crates/renderer/src/render_graph/commands.rs @@ -462,6 +462,7 @@ impl Command for UpdateBuffer { fn apply(self, _recorder: &mut CommandRecorder) {} } +#[derive(Debug, Clone)] pub struct RenderAttachment { pub texture: Texture, pub region: vk::ImageSubresourceRange, @@ -470,6 +471,52 @@ pub struct RenderAttachment { pub store_op: vk::AttachmentStoreOp, } +impl RenderAttachment { + pub fn side_effect(&self, mut map: SideEffectMap, load: bool) { + for attachment in &self.color_attachments { + // The dependencies declared here need to be barrier'd before and + // after the render pass: the spec says pipelineBarrier inside of a + // render pass instance referencing framebuffer-local stages must + // contain only framebuffer-local stages. + + map.with( + vk::PipelineStageFlags2::COLOR_ATTACHMENT_OUTPUT, + if attachment.load_op == vk::AttachmentLoadOp::LOAD { + vk::AccessFlags2::COLOR_ATTACHMENT_READ + } else { + vk::AccessFlags2::empty() + }, + Some(attachment.layout), + ) + .insert_range(attachment.texture.id(), attachment.region); + } + if let Some(depth) = &self.depth_attachment { + map.with( + vk::PipelineStageFlags2::EARLY_FRAGMENT_TESTS, + if depth.load_op == vk::AttachmentLoadOp::LOAD { + vk::AccessFlags2::DEPTH_STENCIL_ATTACHMENT_READ + } else { + vk::AccessFlags2::empty() + }, + Some(depth.layout), + ) + .insert_range(depth.texture.id(), depth.region); + } + if let Some(stencil) = &self.stencil_attachment { + map.with( + vk::PipelineStageFlags2::EARLY_FRAGMENT_TESTS, + if stencil.load_op == vk::AttachmentLoadOp::LOAD { + vk::AccessFlags2::DEPTH_STENCIL_ATTACHMENT_READ + } else { + vk::AccessFlags2::empty() + }, + Some(stencil.layout), + ) + .insert_range(stencil.texture.id(), stencil.region); + } + } +} + pub struct BeginRendering { pub color_attachments: Vec, pub depth_attachment: Option, @@ -478,6 +525,22 @@ pub struct BeginRendering { pub layers: u32, } +pub struct EndRendering { + pub color_attachments: Vec, + pub depth_attachment: Option, + pub stencil_attachment: Option, +} + +impl BeginRendering { + fn end_rendering(&self) -> EndRendering { + EndRendering { + color_attachments: self.color_attachments.clone(), + depth_attachment: self.depth_attachment.clone(), + stencil_attachment: self.stencil_attachment.clone(), + } + } +} + impl Command for BeginRendering { fn side_effects(&self, mut map: SideEffectMap) { for attachment in &self.color_attachments { @@ -526,8 +589,6 @@ impl Command for BeginRendering { fn apply(self, _recorder: &mut CommandRecorder) {} } -pub struct EndRendering; - impl Command for EndRendering { fn side_effects(&self, _map: SideEffectMap) { // TODO: need the beginrendering struct to declare the store-op dependencies. diff --git a/crates/renderer/src/render_graph/recorder.rs b/crates/renderer/src/render_graph/recorder.rs index 801255a..4ad4851 100644 --- a/crates/renderer/src/render_graph/recorder.rs +++ b/crates/renderer/src/render_graph/recorder.rs @@ -12,9 +12,7 @@ use crate::{ images::ImageDesc, render_graph::{ commands::{Command, InsideRenderPass, OutsideRenderPass, RenderAttachment}, - resources::{ - ResourceId, Subresource, SubresourceScope, SubresourceScopeInner, TextureRegion, - }, + resources::{ResourceId, Subresource, SubresourceScope, SubresourceScopeInner}, }, }; diff --git a/crates/renderer/src/render_graph/resources.rs b/crates/renderer/src/render_graph/resources.rs index d723719..24d72ee 100644 --- a/crates/renderer/src/render_graph/resources.rs +++ b/crates/renderer/src/render_graph/resources.rs @@ -416,6 +416,7 @@ impl Buffer { } } +#[derive(Debug, Clone)] pub struct Texture(pub ResourceId); pub struct BufferSlice {