Fix feature gating in texture_binding_array example (#7425)
# Objective Fixes #7374 ## Solution Move the feature gate into `main`, before `MaterialPlugin::<BindlessMaterial>` is added, as described in https://github.com/bevyengine/bevy/issues/7374#issuecomment-1405890519
This commit is contained in:
parent
8f81be9845
commit
5b930c8486
@ -14,9 +14,25 @@ use bevy::{
|
|||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
let mut app = App::new();
|
||||||
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
|
app.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()));
|
||||||
.add_plugin(MaterialPlugin::<BindlessMaterial>::default())
|
|
||||||
|
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())
|
||||||
.add_startup_system(setup)
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@ -31,21 +47,7 @@ fn setup(
|
|||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<BindlessMaterial>>,
|
mut materials: ResMut<Assets<BindlessMaterial>>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
render_device: Res<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;
|
|
||||||
}
|
|
||||||
|
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn(Camera3dBundle {
|
||||||
transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
|
transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
Loading…
Reference in New Issue
Block a user