add missing image switch
This commit is contained in:
54
Cargo.lock
generated
54
Cargo.lock
generated
@@ -163,6 +163,12 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
|
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android-tzdata"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "android_log-sys"
|
name = "android_log-sys"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
@@ -1582,6 +1588,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy-inspector-egui",
|
"bevy-inspector-egui",
|
||||||
|
"iyes_perf_ui",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1749,6 +1756,18 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chrono"
|
||||||
|
version = "0.4.41"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
|
||||||
|
dependencies = [
|
||||||
|
"android-tzdata",
|
||||||
|
"iana-time-zone",
|
||||||
|
"num-traits",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clang-sys"
|
name = "clang-sys"
|
||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
@@ -2794,6 +2813,30 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone"
|
||||||
|
version = "0.1.63"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
|
||||||
|
dependencies = [
|
||||||
|
"android_system_properties",
|
||||||
|
"core-foundation-sys",
|
||||||
|
"iana-time-zone-haiku",
|
||||||
|
"js-sys",
|
||||||
|
"log",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-core 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iana-time-zone-haiku"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.25.6"
|
version = "0.25.6"
|
||||||
@@ -2933,6 +2976,17 @@ version = "1.0.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iyes_perf_ui"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3e4468c51a47d2422a3a3e01b45cb47ed0fbce520495dd7de495bcfe8ce0f856"
|
||||||
|
dependencies = [
|
||||||
|
"bevy",
|
||||||
|
"chrono",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni"
|
name = "jni"
|
||||||
version = "0.21.1"
|
version = "0.21.1"
|
||||||
|
|||||||
12
Cargo.toml
12
Cargo.toml
@@ -6,3 +6,15 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = {version = "0.16.1", features = ["bevy_image", "file_watcher"]}
|
bevy = {version = "0.16.1", features = ["bevy_image", "file_watcher"]}
|
||||||
bevy-inspector-egui = "0.31.0"
|
bevy-inspector-egui = "0.31.0"
|
||||||
|
iyes_perf_ui = "0.5.0"
|
||||||
|
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
# Bevy supplies arguments to systems via dependency injection, so it's natural for systems to
|
||||||
|
# request more than 7 arguments, which would undesirably trigger this lint.
|
||||||
|
too_many_arguments = "allow"
|
||||||
|
# Queries may access many components, which would undesirably trigger this lint.
|
||||||
|
type_complexity = "allow"
|
||||||
|
# Make sure macros use their standard braces, such as `[]` for `bevy_ecs::children!`.
|
||||||
|
nonstandard_macro_braces = "warn"
|
||||||
|
needless_return = "allow"
|
||||||
|
|||||||
16
src/app.rs
16
src/app.rs
@@ -4,6 +4,7 @@ use bevy::{
|
|||||||
render::render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages},
|
render::render_resource::{Extent3d, TextureDimension, TextureFormat, TextureUsages},
|
||||||
window::PrimaryWindow,
|
window::PrimaryWindow,
|
||||||
};
|
};
|
||||||
|
use iyes_perf_ui::prelude::*;
|
||||||
|
|
||||||
use crate::render::pipeline::{TracerPipelinePlugin, TracerRenderTextures, TracerUniforms};
|
use crate::render::pipeline::{TracerPipelinePlugin, TracerRenderTextures, TracerUniforms};
|
||||||
|
|
||||||
@@ -14,15 +15,28 @@ impl Plugin for Blackhole {
|
|||||||
app.register_type::<TracerRenderTextures>();
|
app.register_type::<TracerRenderTextures>();
|
||||||
|
|
||||||
app.add_systems(Startup, setup);
|
app.add_systems(Startup, setup);
|
||||||
|
|
||||||
app.add_plugins(TracerPipelinePlugin);
|
app.add_plugins(TracerPipelinePlugin);
|
||||||
app.insert_resource(TracerUniforms {
|
app.insert_resource(TracerUniforms {
|
||||||
sky_color: LinearRgba::BLUE,
|
sky_color: LinearRgba::BLUE,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Perf UI
|
||||||
|
app.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin::default())
|
||||||
|
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
|
||||||
|
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
|
||||||
|
.add_plugins(PerfUiPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>, window: Single<&Window, With<PrimaryWindow>>) {
|
fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>, window: Single<&Window, With<PrimaryWindow>>) {
|
||||||
|
commands.spawn((
|
||||||
|
PerfUiRoot::default(),
|
||||||
|
PerfUiEntryFPS::default(),
|
||||||
|
PerfUiEntryFPSWorst::default(),
|
||||||
|
PerfUiEntryFrameTime::default(),
|
||||||
|
PerfUiEntryFrameTimeWorst::default(),
|
||||||
|
));
|
||||||
|
|
||||||
let size = window.physical_size();
|
let size = window.physical_size();
|
||||||
|
|
||||||
let extent = Extent3d {
|
let extent = Extent3d {
|
||||||
|
|||||||
@@ -27,13 +27,6 @@ pub struct TracerLabel;
|
|||||||
#[reflect(Resource)]
|
#[reflect(Resource)]
|
||||||
pub struct TracerRenderTextures(pub Handle<Image>, pub Handle<Image>);
|
pub struct TracerRenderTextures(pub Handle<Image>, pub Handle<Image>);
|
||||||
|
|
||||||
#[derive(Resource)]
|
|
||||||
pub struct TracerPipeline {
|
|
||||||
pub texture_bind_group_layout: BindGroupLayout,
|
|
||||||
pub init_pipeline: CachedComputePipelineId,
|
|
||||||
pub update_pipeline: CachedComputePipelineId,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Resource, Clone, ExtractResource, ShaderType, Default)]
|
#[derive(Resource, Clone, ExtractResource, ShaderType, Default)]
|
||||||
pub struct TracerUniforms {
|
pub struct TracerUniforms {
|
||||||
pub sky_color: LinearRgba,
|
pub sky_color: LinearRgba,
|
||||||
@@ -47,7 +40,8 @@ impl Plugin for TracerPipelinePlugin {
|
|||||||
ExtractResourcePlugin::<TracerRenderTextures>::default(),
|
ExtractResourcePlugin::<TracerRenderTextures>::default(),
|
||||||
ExtractResourcePlugin::<TracerUniforms>::default(),
|
ExtractResourcePlugin::<TracerUniforms>::default(),
|
||||||
));
|
));
|
||||||
app.init_resource::<TracerUniforms>();
|
app.init_resource::<TracerUniforms>()
|
||||||
|
.add_systems(Update, switch_textures);
|
||||||
let render_app = app.sub_app_mut(RenderApp);
|
let render_app = app.sub_app_mut(RenderApp);
|
||||||
|
|
||||||
// render_app.add_systems(Startup, init_pipeline);
|
// render_app.add_systems(Startup, init_pipeline);
|
||||||
@@ -64,6 +58,21 @@ impl Plugin for TracerPipelinePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn switch_textures(images: Res<TracerRenderTextures>, mut sprite: Single<&mut Sprite>) {
|
||||||
|
if sprite.image == images.0 {
|
||||||
|
sprite.image = images.1.clone();
|
||||||
|
} else {
|
||||||
|
sprite.image = images.0.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct TracerPipeline {
|
||||||
|
pub texture_bind_group_layout: BindGroupLayout,
|
||||||
|
pub init_pipeline: CachedComputePipelineId,
|
||||||
|
pub update_pipeline: CachedComputePipelineId,
|
||||||
|
}
|
||||||
|
|
||||||
impl FromWorld for TracerPipeline {
|
impl FromWorld for TracerPipeline {
|
||||||
fn from_world(world: &mut World) -> Self {
|
fn from_world(world: &mut World) -> Self {
|
||||||
let render_device = world.resource::<RenderDevice>();
|
let render_device = world.resource::<RenderDevice>();
|
||||||
@@ -109,6 +118,7 @@ impl FromWorld for TracerPipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)] //Pending bevy update for RenderStartup schedule
|
||||||
fn init_pipeline(
|
fn init_pipeline(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
render_device: Res<RenderDevice>,
|
render_device: Res<RenderDevice>,
|
||||||
|
|||||||
Reference in New Issue
Block a user