mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
don't crash without features bevy_pbr
, ktx2
, zstd
(#14020)
# Objective - Fixes #13728 ## Solution - add a new feature `smaa_luts`. if enables, it also enables `ktx2` and `zstd`. if not, it doesn't load the files but use placeholders instead - adds all the resources needed in the same places that system that uses them are added.
This commit is contained in:
parent
8308ad08a2
commit
19d078c609
10 changed files with 50 additions and 16 deletions
|
@ -77,6 +77,7 @@ default = [
|
|||
"bevy_gizmos",
|
||||
"android_shared_stdcxx",
|
||||
"tonemapping_luts",
|
||||
"smaa_luts",
|
||||
"default_font",
|
||||
"webgl2",
|
||||
"sysinfo_plugin",
|
||||
|
@ -286,6 +287,9 @@ detailed_trace = ["bevy_internal/detailed_trace"]
|
|||
# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.
|
||||
tonemapping_luts = ["bevy_internal/tonemapping_luts", "ktx2", "zstd"]
|
||||
|
||||
# Include SMAA Look Up Tables KTX2 Files
|
||||
smaa_luts = ["bevy_internal/smaa_luts"]
|
||||
|
||||
# Enable AccessKit on Unix backends (currently only works with experimental screen readers and forks.)
|
||||
accesskit_unix = ["bevy_internal/accesskit_unix"]
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ trace = []
|
|||
webgl = []
|
||||
webgpu = []
|
||||
tonemapping_luts = ["bevy_render/ktx2", "bevy_render/zstd"]
|
||||
smaa_luts = ["bevy_render/ktx2", "bevy_render/zstd"]
|
||||
|
||||
[dependencies]
|
||||
# bevy
|
||||
|
|
|
@ -136,6 +136,14 @@ impl Plugin for Core3dPlugin {
|
|||
.init_resource::<DrawFunctions<AlphaMask3dPrepass>>()
|
||||
.init_resource::<DrawFunctions<Opaque3dDeferred>>()
|
||||
.init_resource::<DrawFunctions<AlphaMask3dDeferred>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<Opaque3d>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<AlphaMask3d>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<Opaque3dPrepass>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<AlphaMask3dPrepass>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<Opaque3dDeferred>>()
|
||||
.init_resource::<ViewBinnedRenderPhases<AlphaMask3dDeferred>>()
|
||||
.init_resource::<ViewSortedRenderPhases<Transmissive3d>>()
|
||||
.init_resource::<ViewSortedRenderPhases<Transparent3d>>()
|
||||
.add_systems(ExtractSchedule, extract_core_3d_camera_phases)
|
||||
.add_systems(ExtractSchedule, extract_camera_prepass_phase)
|
||||
.add_systems(
|
||||
|
|
|
@ -24,7 +24,7 @@ use bevy_render::{
|
|||
};
|
||||
use prepass::{SkyboxPrepassPipeline, SKYBOX_PREPASS_SHADER_HANDLE};
|
||||
|
||||
use crate::core_3d::CORE_3D_DEPTH_FORMAT;
|
||||
use crate::{core_3d::CORE_3D_DEPTH_FORMAT, prepass::PreviousViewUniforms};
|
||||
|
||||
const SKYBOX_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(55594763423201);
|
||||
|
||||
|
@ -53,6 +53,7 @@ impl Plugin for SkyboxPlugin {
|
|||
render_app
|
||||
.init_resource::<SpecializedRenderPipelines<SkyboxPipeline>>()
|
||||
.init_resource::<SpecializedRenderPipelines<SkyboxPrepassPipeline>>()
|
||||
.init_resource::<PreviousViewUniforms>()
|
||||
.add_systems(
|
||||
Render,
|
||||
(
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
//! [SMAA]: https://www.iryoku.com/smaa/
|
||||
|
||||
use bevy_app::{App, Plugin};
|
||||
use bevy_asset::{load_internal_asset, load_internal_binary_asset, Handle};
|
||||
#[cfg(feature = "smaa_luts")]
|
||||
use bevy_asset::load_internal_binary_asset;
|
||||
use bevy_asset::{load_internal_asset, Handle};
|
||||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::{
|
||||
component::Component,
|
||||
|
@ -47,7 +49,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
|||
use bevy_render::{
|
||||
camera::ExtractedCamera,
|
||||
extract_component::{ExtractComponent, ExtractComponentPlugin},
|
||||
render_asset::{RenderAssetUsages, RenderAssets},
|
||||
render_asset::RenderAssets,
|
||||
render_graph::{
|
||||
NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner,
|
||||
},
|
||||
|
@ -65,15 +67,19 @@ use bevy_render::{
|
|||
VertexState,
|
||||
},
|
||||
renderer::{RenderContext, RenderDevice, RenderQueue},
|
||||
texture::{
|
||||
BevyDefault, CachedTexture, CompressedImageFormats, GpuImage, Image, ImageFormat,
|
||||
ImageSampler, ImageType, TextureCache,
|
||||
},
|
||||
texture::{BevyDefault, CachedTexture, GpuImage, Image, TextureCache},
|
||||
view::{ExtractedView, ViewTarget},
|
||||
Render, RenderApp, RenderSet,
|
||||
};
|
||||
#[cfg(feature = "smaa_luts")]
|
||||
use bevy_render::{
|
||||
render_asset::RenderAssetUsages,
|
||||
texture::{CompressedImageFormats, ImageFormat, ImageSampler, ImageType},
|
||||
};
|
||||
use bevy_utils::prelude::default;
|
||||
|
||||
#[cfg(not(feature = "smaa_luts"))]
|
||||
use crate::tonemapping::lut_placeholder;
|
||||
use crate::{
|
||||
core_2d::graph::{Core2d, Node2d},
|
||||
core_3d::graph::{Core3d, Node3d},
|
||||
|
@ -287,6 +293,7 @@ impl Plugin for SmaaPlugin {
|
|||
|
||||
// Load the two lookup textures. These are compressed textures in KTX2
|
||||
// format.
|
||||
#[cfg(feature = "smaa_luts")]
|
||||
load_internal_binary_asset!(
|
||||
app,
|
||||
SMAA_AREA_LUT_TEXTURE_HANDLE,
|
||||
|
@ -304,6 +311,7 @@ impl Plugin for SmaaPlugin {
|
|||
.expect("Failed to load SMAA area LUT")
|
||||
);
|
||||
|
||||
#[cfg(feature = "smaa_luts")]
|
||||
load_internal_binary_asset!(
|
||||
app,
|
||||
SMAA_SEARCH_LUT_TEXTURE_HANDLE,
|
||||
|
@ -321,6 +329,16 @@ impl Plugin for SmaaPlugin {
|
|||
.expect("Failed to load SMAA search LUT")
|
||||
);
|
||||
|
||||
#[cfg(not(feature = "smaa_luts"))]
|
||||
app.world_mut()
|
||||
.resource_mut::<bevy_asset::Assets<Image>>()
|
||||
.insert(SMAA_AREA_LUT_TEXTURE_HANDLE.id(), lut_placeholder());
|
||||
|
||||
#[cfg(not(feature = "smaa_luts"))]
|
||||
app.world_mut()
|
||||
.resource_mut::<bevy_asset::Assets<Image>>()
|
||||
.insert(SMAA_SEARCH_LUT_TEXTURE_HANDLE.id(), lut_placeholder());
|
||||
|
||||
app.add_plugins(ExtractComponentPlugin::<SmaaSettings>::default())
|
||||
.register_type::<SmaaSettings>();
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ zstd = ["bevy_render/zstd"]
|
|||
# Include tonemapping LUT KTX2 files.
|
||||
tonemapping_luts = ["bevy_core_pipeline/tonemapping_luts"]
|
||||
|
||||
# Include SMAA LUT KTX2 Files
|
||||
smaa_luts = ["bevy_core_pipeline/smaa_luts"]
|
||||
|
||||
# Audio format support (vorbis is enabled by default)
|
||||
flac = ["bevy_audio/flac"]
|
||||
mp3 = ["bevy_audio/mp3"]
|
||||
|
|
|
@ -102,8 +102,7 @@ where
|
|||
)
|
||||
.init_resource::<PrepassViewBindGroup>()
|
||||
.init_resource::<SpecializedMeshPipelines<PrepassPipeline<M>>>()
|
||||
.allow_ambiguous_resource::<SpecializedMeshPipelines<PrepassPipeline<M>>>()
|
||||
.init_resource::<PreviousViewUniforms>();
|
||||
.allow_ambiguous_resource::<SpecializedMeshPipelines<PrepassPipeline<M>>>();
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
|
|
|
@ -218,8 +218,6 @@ impl Plugin for MeshRenderPlugin {
|
|||
);
|
||||
};
|
||||
|
||||
let indirect_parameters_buffer = IndirectParametersBuffer::new();
|
||||
|
||||
let render_device = render_app.world().resource::<RenderDevice>();
|
||||
if let Some(per_object_buffer_batch_size) =
|
||||
GpuArrayBuffer::<MeshUniform>::batch_size(render_device)
|
||||
|
@ -231,7 +229,6 @@ impl Plugin for MeshRenderPlugin {
|
|||
}
|
||||
|
||||
render_app
|
||||
.insert_resource(indirect_parameters_buffer)
|
||||
.init_resource::<MeshPipelineViewLayouts>()
|
||||
.init_resource::<MeshPipeline>();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,9 @@ impl Plugin for BatchingPlugin {
|
|||
return;
|
||||
};
|
||||
|
||||
render_app.add_systems(
|
||||
render_app
|
||||
.insert_resource(IndirectParametersBuffer::new())
|
||||
.add_systems(
|
||||
Render,
|
||||
write_indirect_parameters_buffer.in_set(RenderSet::PrepareResourcesFlush),
|
||||
);
|
||||
|
|
|
@ -35,6 +35,7 @@ The default feature set enables most of the expected features of a game engine,
|
|||
|ktx2|KTX2 compressed texture support|
|
||||
|multi_threaded|Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread.|
|
||||
|png|PNG image format support|
|
||||
|smaa_luts|Include SMAA Look Up Tables KTX2 Files|
|
||||
|sysinfo_plugin|Enables system information diagnostic plugin|
|
||||
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.|
|
||||
|vorbis|OGG/VORBIS audio format support|
|
||||
|
|
Loading…
Reference in a new issue