Do not crash if RenderDevice doesn't exist (#4427)
# Objective Avoid crashing if `RenderDevice` doesn't exist (required for headless mode). Fixes #4392. ## Solution Use `CompressedImageFormats::all()` if there is no `RenderDevice`.
This commit is contained in:
parent
dbb2fcb677
commit
ea6e6f7db2
@ -88,10 +88,13 @@ impl AssetLoader for GltfLoader {
|
|||||||
|
|
||||||
impl FromWorld for GltfLoader {
|
impl FromWorld for GltfLoader {
|
||||||
fn from_world(world: &mut World) -> Self {
|
fn from_world(world: &mut World) -> Self {
|
||||||
|
let supported_compressed_formats = match world.get_resource::<RenderDevice>() {
|
||||||
|
Some(render_device) => CompressedImageFormats::from_features(render_device.features()),
|
||||||
|
|
||||||
|
None => CompressedImageFormats::all(),
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
supported_compressed_formats: CompressedImageFormats::from_features(
|
supported_compressed_formats,
|
||||||
world.resource::<RenderDevice>().features(),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,10 +69,13 @@ impl AssetLoader for ImageTextureLoader {
|
|||||||
|
|
||||||
impl FromWorld for ImageTextureLoader {
|
impl FromWorld for ImageTextureLoader {
|
||||||
fn from_world(world: &mut World) -> Self {
|
fn from_world(world: &mut World) -> Self {
|
||||||
|
let supported_compressed_formats = match world.get_resource::<RenderDevice>() {
|
||||||
|
Some(render_device) => CompressedImageFormats::from_features(render_device.features()),
|
||||||
|
|
||||||
|
None => CompressedImageFormats::all(),
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
supported_compressed_formats: CompressedImageFormats::from_features(
|
supported_compressed_formats,
|
||||||
world.resource::<RenderDevice>().features(),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user