RenderCommand for SetMaterialBindGroup {
type Param = SRes>;
- type ViewWorldQuery = ();
- type ItemWorldQuery = Read>;
+ type ViewQuery = ();
+ type ItemQuery = Read>;
#[inline]
fn render<'w>(
_item: &P,
_view: (),
- material2d_handle: ROQueryItem<'_, Self::ItemWorldQuery>,
+ material2d_handle: Option>,
materials: SystemParamItem<'w, '_, Self::Param>,
pass: &mut TrackedRenderPass<'w>,
) -> RenderCommandResult {
+ let Some(material2d_handle) = material2d_handle else {
+ return RenderCommandResult::Failure;
+ };
let asset_id: AssetId = material2d_handle.clone_weak().into();
let material2d = materials.into_inner().get(&asset_id).unwrap();
pass.set_bind_group(I, &material2d.bind_group, &[]);
@@ -303,7 +309,7 @@ impl RenderCommand for SetMateri
}
pub fn queue_material_ui_quads(
- render_svgs: Res,
+ #[cfg(feature = "svg")] render_svgs: Res,
opacity_layers: Res,
mut commands: Commands,
draw_functions: Res>,
@@ -410,6 +416,7 @@ pub fn queue_material_ui_quads(
&mut image_bind_groups,
&gpu_images,
&quad_pipeline,
+ #[cfg(feature = "svg")]
&render_svgs,
&mut transparent_phase,
&mut opacity_transparent_phase,
diff --git a/src/render/mod.rs b/src/render/mod.rs
index c6d27223..90c0d0d4 100644
--- a/src/render/mod.rs
+++ b/src/render/mod.rs
@@ -3,7 +3,7 @@ use bevy::{
render::{
camera::RenderTarget,
render_asset::RenderAssets,
- render_graph::{RenderGraph, RunGraphOnViewNode},
+ render_graph::{RenderGraph, RenderLabel, RenderSubGraph, RunGraphOnViewNode},
render_phase::DrawFunctions,
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
},
@@ -28,6 +28,7 @@ pub mod material;
pub(crate) mod nine_patch;
mod opacity_layer;
pub(crate) mod quad;
+#[cfg(feature = "svg")]
pub(crate) mod svg;
pub(crate) mod texture_atlas;
mod ui_pass;
@@ -35,12 +36,11 @@ pub mod unified;
pub use opacity_layer::MAX_OPACITY_LAYERS;
-pub mod draw_ui_graph {
- pub const NAME: &str = "kayak_draw_ui";
- pub mod node {
- pub const MAIN_PASS: &str = "kayak_ui_pass";
- }
-}
+#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderSubGraph)]
+pub struct DrawUiGraph;
+
+#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderLabel)]
+pub struct KayakUiPass;
/// The default Kayak UI rendering plugin.
/// Use this to render the UI.
@@ -85,43 +85,39 @@ impl Plugin for BevyKayakUIRenderPlugin {
let ui_graph_3d = get_ui_graph(render_app);
let mut graph = render_app.world.resource_mut::();
- if let Some(graph_2d) = graph.get_sub_graph_mut(bevy::core_pipeline::core_2d::graph::NAME) {
- graph_2d.add_sub_graph(draw_ui_graph::NAME, ui_graph_2d);
- graph_2d.add_node(
- draw_ui_graph::node::MAIN_PASS,
- RunGraphOnViewNode::new(draw_ui_graph::NAME),
- );
+ if let Some(graph_2d) = graph.get_sub_graph_mut(bevy::core_pipeline::core_2d::graph::Core2d)
+ {
+ graph_2d.add_sub_graph(DrawUiGraph, ui_graph_2d);
+ graph_2d.add_node(KayakUiPass, RunGraphOnViewNode::new(DrawUiGraph));
graph_2d.add_node_edge(
- bevy::core_pipeline::core_2d::graph::node::MAIN_PASS,
- draw_ui_graph::node::MAIN_PASS,
+ bevy::core_pipeline::core_2d::graph::Node2d::MainPass,
+ KayakUiPass,
);
graph_2d.add_node_edge(
- bevy::core_pipeline::core_2d::graph::node::TONEMAPPING,
- draw_ui_graph::node::MAIN_PASS,
+ bevy::core_pipeline::core_2d::graph::Node2d::Tonemapping,
+ KayakUiPass,
);
graph_2d.add_node_edge(
- draw_ui_graph::node::MAIN_PASS,
- bevy::core_pipeline::core_2d::graph::node::UPSCALING,
+ KayakUiPass,
+ bevy::core_pipeline::core_2d::graph::Node2d::Upscaling,
);
}
- if let Some(graph_3d) = graph.get_sub_graph_mut(bevy::core_pipeline::core_3d::graph::NAME) {
- graph_3d.add_sub_graph(draw_ui_graph::NAME, ui_graph_3d);
- graph_3d.add_node(
- draw_ui_graph::node::MAIN_PASS,
- RunGraphOnViewNode::new(draw_ui_graph::NAME),
- );
+ if let Some(graph_3d) = graph.get_sub_graph_mut(bevy::core_pipeline::core_3d::graph::Core3d)
+ {
+ graph_3d.add_sub_graph(DrawUiGraph, ui_graph_3d);
+ graph_3d.add_node(KayakUiPass, RunGraphOnViewNode::new(DrawUiGraph));
graph_3d.add_node_edge(
- bevy::core_pipeline::core_3d::graph::node::END_MAIN_PASS,
- draw_ui_graph::node::MAIN_PASS,
+ bevy::core_pipeline::core_3d::graph::Node3d::EndMainPass,
+ KayakUiPass,
);
graph_3d.add_node_edge(
- bevy::core_pipeline::core_3d::graph::node::TONEMAPPING,
- draw_ui_graph::node::MAIN_PASS,
+ bevy::core_pipeline::core_3d::graph::Node3d::Tonemapping,
+ KayakUiPass,
);
graph_3d.add_node_edge(
- draw_ui_graph::node::MAIN_PASS,
- bevy::core_pipeline::core_3d::graph::node::UPSCALING,
+ KayakUiPass,
+ bevy::core_pipeline::core_3d::graph::Node3d::Upscaling,
);
}
}
@@ -130,7 +126,7 @@ impl Plugin for BevyKayakUIRenderPlugin {
fn get_ui_graph(render_app: &mut App) -> RenderGraph {
let ui_pass_node = MainPassUINode::new(&mut render_app.world);
let mut ui_graph = RenderGraph::default();
- ui_graph.add_node(draw_ui_graph::node::MAIN_PASS, ui_pass_node);
+ ui_graph.add_node(KayakUiPass, ui_pass_node);
ui_graph
}
diff --git a/src/render/svg/mod.rs b/src/render/svg/mod.rs
index 97f3c3c9..b0df765f 100644
--- a/src/render/svg/mod.rs
+++ b/src/render/svg/mod.rs
@@ -29,6 +29,7 @@ pub fn extract_svg_asset(
changed_assets.remove(id);
render_assets.remove(id);
}
+ _ => {}
}
}
diff --git a/src/render/ui_pass.rs b/src/render/ui_pass.rs
index 5181e7d1..a75221ca 100644
--- a/src/render/ui_pass.rs
+++ b/src/render/ui_pass.rs
@@ -235,10 +235,11 @@ impl Node for MainPassUINode {
resolve_target: None,
ops: Operations {
load: LoadOp::Clear(Color::rgba(0.0, 0.0, 0.0, 0.0).into()),
- store: true,
+ store: bevy::render::render_resource::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
+ ..Default::default()
};
let mut tracked_pass =
@@ -260,11 +261,9 @@ impl Node for MainPassUINode {
{
let pass_descriptor = RenderPassDescriptor {
label: Some("main_transparent_pass_UI"),
- color_attachments: &[Some(target.get_unsampled_color_attachment(Operations {
- load: LoadOp::Load,
- store: true,
- }))],
+ color_attachments: &[Some(target.get_unsampled_color_attachment())],
depth_stencil_attachment: None,
+ ..Default::default()
};
let mut tracked_pass = render_context.begin_tracked_render_pass(pass_descriptor);
transparent_phase.render(&mut tracked_pass, world, view_entity);
diff --git a/src/render/unified/mod.rs b/src/render/unified/mod.rs
index 72452168..a4939631 100644
--- a/src/render/unified/mod.rs
+++ b/src/render/unified/mod.rs
@@ -1,5 +1,7 @@
+#[cfg(feature = "svg")]
+use bevy::prelude::AssetApp;
use bevy::{
- asset::{load_internal_asset, AssetApp, Handle},
+ asset::{load_internal_asset, Handle},
prelude::{Commands, IntoSystemConfigs, Plugin, Query, Res, ResMut, Resource, With},
render::{
render_phase::AddRenderCommand,
@@ -9,6 +11,7 @@ use bevy::{
},
window::{PrimaryWindow, Window},
};
+#[cfg(feature = "svg")]
use bevy_svg::prelude::Svg;
use crate::{
@@ -24,7 +27,9 @@ use self::pipeline::{
ImageBindGroups, PreviousClip, PreviousIndex, QuadTypeOffsets,
};
-use super::{svg::RenderSvgs, ui_pass::TransparentOpacityUI};
+#[cfg(feature = "svg")]
+use super::svg::RenderSvgs;
+use super::ui_pass::TransparentOpacityUI;
pub mod pipeline;
pub mod text;
@@ -40,8 +45,9 @@ pub const VERTEX_OUTPUT_HANDLE: Handle = Handle::weak_from_u128(88288962
pub struct UnifiedRenderPlugin;
impl Plugin for UnifiedRenderPlugin {
fn build(&self, app: &mut bevy::prelude::App) {
- app.init_asset::