mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
fix missed examples in WebGPU update (#8553)
# Objective - I missed a few examples in #8336 - fixes #8556 - fixes #8620 ## Solution - Update them
This commit is contained in:
parent
56686a8962
commit
e0b18091b5
4 changed files with 57 additions and 22 deletions
|
@ -60,7 +60,6 @@ impl Plugin for TemporalAntiAliasPlugin {
|
|||
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
|
||||
|
||||
render_app
|
||||
.init_resource::<TAAPipeline>()
|
||||
.init_resource::<SpecializedRenderPipelines<TAAPipeline>>()
|
||||
.add_systems(ExtractSchedule, extract_taa_settings)
|
||||
.add_systems(
|
||||
|
@ -84,6 +83,12 @@ impl Plugin for TemporalAntiAliasPlugin {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else { return };
|
||||
|
||||
render_app.init_resource::<TAAPipeline>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Bundle to apply temporal anti-aliasing.
|
||||
|
|
|
@ -277,15 +277,21 @@ impl Plugin for ColoredMesh2dPlugin {
|
|||
Shader::from_wgsl(COLORED_MESH2D_SHADER),
|
||||
);
|
||||
|
||||
// Register our custom draw function and pipeline, and add our render systems
|
||||
// Register our custom draw function, and add our render systems
|
||||
app.get_sub_app_mut(RenderApp)
|
||||
.unwrap()
|
||||
.add_render_command::<Transparent2d, DrawColoredMesh2d>()
|
||||
.init_resource::<ColoredMesh2dPipeline>()
|
||||
.init_resource::<SpecializedRenderPipelines<ColoredMesh2dPipeline>>()
|
||||
.add_systems(ExtractSchedule, extract_colored_mesh2d)
|
||||
.add_systems(Render, queue_colored_mesh2d.in_set(RenderSet::Queue));
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
// Register our custom pipeline
|
||||
app.get_sub_app_mut(RenderApp)
|
||||
.unwrap()
|
||||
.init_resource::<ColoredMesh2dPipeline>();
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract the [`ColoredMesh2d`] marker component into the render app
|
||||
|
|
|
@ -70,8 +70,6 @@ impl Plugin for PostProcessPlugin {
|
|||
};
|
||||
|
||||
render_app
|
||||
// Initialize the pipeline
|
||||
.init_resource::<PostProcessPipeline>()
|
||||
// Bevy's renderer uses a render graph which is a collection of nodes in a directed acyclic graph.
|
||||
// It currently runs on each view/camera and executes each node in the specified order.
|
||||
// It will make sure that any node that needs a dependency from another node
|
||||
|
@ -99,6 +97,17 @@ impl Plugin for PostProcessPlugin {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
// We need to get the render app from the main app
|
||||
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||
return;
|
||||
};
|
||||
|
||||
render_app
|
||||
// Initialize the pipeline
|
||||
.init_resource::<PostProcessPipeline>();
|
||||
}
|
||||
}
|
||||
|
||||
/// The post process node used for the render graph
|
||||
|
|
|
@ -9,30 +9,17 @@ use bevy::{
|
|||
render_resource::{AsBindGroupError, PreparedBindGroup, *},
|
||||
renderer::RenderDevice,
|
||||
texture::FallbackImage,
|
||||
RenderApp,
|
||||
},
|
||||
};
|
||||
use std::num::NonZeroU32;
|
||||
use std::{num::NonZeroU32, process::exit};
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
app.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()));
|
||||
|
||||
let render_device = app.world.resource::<RenderDevice>();
|
||||
|
||||
// check if the device support the required feature
|
||||
if !render_device
|
||||
.features()
|
||||
.contains(WgpuFeatures::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING)
|
||||
{
|
||||
error!(
|
||||
"Render device doesn't support feature \
|
||||
SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, \
|
||||
which is required for texture binding arrays"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
app.add_plugin(MaterialPlugin::<BindlessMaterial>::default())
|
||||
app.add_plugin(GpuFeatureSupportChecker)
|
||||
.add_plugin(MaterialPlugin::<BindlessMaterial>::default())
|
||||
.add_systems(Startup, setup)
|
||||
.run();
|
||||
}
|
||||
|
@ -42,6 +29,34 @@ const TILE_ID: [usize; 16] = [
|
|||
19, 23, 4, 33, 12, 69, 30, 48, 10, 65, 40, 47, 57, 41, 44, 46,
|
||||
];
|
||||
|
||||
struct GpuFeatureSupportChecker;
|
||||
|
||||
impl Plugin for GpuFeatureSupportChecker {
|
||||
fn build(&self, _app: &mut App) {}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
|
||||
return
|
||||
};
|
||||
|
||||
let render_device = render_app.world.resource::<RenderDevice>();
|
||||
|
||||
// Check if the device support the required feature. If not, exit the example.
|
||||
// In a real application, you should setup a fallback for the missing feature
|
||||
if !render_device
|
||||
.features()
|
||||
.contains(WgpuFeatures::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING)
|
||||
{
|
||||
error!(
|
||||
"Render device doesn't support feature \
|
||||
SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, \
|
||||
which is required for texture binding arrays"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
|
|
Loading…
Reference in a new issue