diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 2f495f52e8..7854eb207c 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -80,5 +80,5 @@ impl App { } /// An event that indicates the app should exit. This will fully exit the app process. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct AppExit; diff --git a/crates/bevy_app/src/event.rs b/crates/bevy_app/src/event.rs index 1daf7f0456..4ee13f51b4 100644 --- a/crates/bevy_app/src/event.rs +++ b/crates/bevy_app/src/event.rs @@ -83,7 +83,6 @@ fn map_instance_event(event_instance: &EventInstance) -> &T { } /// Reads events of type `T` in order and tracks which events have already been read. -#[derive(Debug)] pub struct EventReader { last_event_count: usize, _marker: PhantomData, diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index cd7ad98f07..9ed0ef6ad1 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -8,6 +8,7 @@ use bevy_type_registry::RegisterType; use bevy_utils::HashMap; /// Events that happen on assets of type `T` +#[derive(Debug)] pub enum AssetEvent { Created { handle: Handle }, Modified { handle: Handle }, @@ -15,6 +16,7 @@ pub enum AssetEvent { } /// Stores Assets of a given type and tracks changes to them. +#[derive(Debug)] pub struct Assets { assets: HashMap, T>, events: Events>, diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index db398a17d3..945b5a5ba9 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -33,6 +33,7 @@ pub trait AssetLoader: Send + Sync + 'static { } /// The result of loading an asset of type `T` +#[derive(Debug)] pub struct AssetResult { pub result: Result, pub handle: Handle, @@ -41,6 +42,7 @@ pub struct AssetResult { } /// A channel to send and receive [AssetResult]s +#[derive(Debug)] pub struct AssetChannel { pub sender: Sender>, pub receiver: Receiver>, diff --git a/crates/bevy_audio/src/audio_output.rs b/crates/bevy_audio/src/audio_output.rs index d484e46b03..a3a5f91bd1 100644 --- a/crates/bevy_audio/src/audio_output.rs +++ b/crates/bevy_audio/src/audio_output.rs @@ -3,7 +3,7 @@ use bevy_asset::{Assets, Handle}; use bevy_ecs::Res; use parking_lot::RwLock; use rodio::{Device, Sink}; -use std::collections::VecDeque; +use std::{collections::VecDeque, fmt}; /// Used to play audio on the current "audio device" pub struct AudioOutput

@@ -14,6 +14,17 @@ where queue: RwLock>>, } +impl

fmt::Debug for AudioOutput

+where + P: Decodable, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("AudioOutput") + .field("queue", &self.queue) + .finish() + } +} + impl

Default for AudioOutput

where P: Decodable, diff --git a/crates/bevy_audio/src/audio_source.rs b/crates/bevy_audio/src/audio_source.rs index bd3356dc92..335c080032 100644 --- a/crates/bevy_audio/src/audio_source.rs +++ b/crates/bevy_audio/src/audio_source.rs @@ -3,7 +3,7 @@ use bevy_asset::AssetLoader; use std::{io::Cursor, path::Path, sync::Arc}; /// A source of audio data -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct AudioSource { pub bytes: Arc<[u8]>, } diff --git a/crates/bevy_core/src/label.rs b/crates/bevy_core/src/label.rs index b6f3c0d2d8..16de6edd39 100644 --- a/crates/bevy_core/src/label.rs +++ b/crates/bevy_core/src/label.rs @@ -52,7 +52,7 @@ impl Labels { } /// Maintains a mapping from [Entity](bevy_ecs::prelude::Entity) ids to entity labels and entity labels to [Entities](bevy_ecs::prelude::Entity). -#[derive(Default)] +#[derive(Debug, Default)] pub struct EntityLabels { label_entities: HashMap, Vec>, entity_labels: HashMap>>, diff --git a/crates/bevy_diagnostic/src/diagnostic.rs b/crates/bevy_diagnostic/src/diagnostic.rs index bab53f5113..75356801e7 100644 --- a/crates/bevy_diagnostic/src/diagnostic.rs +++ b/crates/bevy_diagnostic/src/diagnostic.rs @@ -103,7 +103,7 @@ impl Diagnostic { } /// A collection of [Diagnostic]s -#[derive(Default)] +#[derive(Debug, Default)] pub struct Diagnostics { diagnostics: HashMap, } diff --git a/crates/bevy_diagnostic/src/system_profiler.rs b/crates/bevy_diagnostic/src/system_profiler.rs index b3c0cf974b..c87d5adbe1 100644 --- a/crates/bevy_diagnostic/src/system_profiler.rs +++ b/crates/bevy_diagnostic/src/system_profiler.rs @@ -15,7 +15,7 @@ struct SystemRunInfo { stop: Instant, } -#[derive(Default)] +#[derive(Debug, Default)] struct SystemProfiles { diagnostic_id: DiagnosticId, history: Vec, @@ -23,7 +23,7 @@ struct SystemProfiles { } /// Profiles systems by recording their run duration as diagnostics. -#[derive(Default)] +#[derive(Debug, Default)] pub struct SystemProfiler { system_profiles: Arc, SystemProfiles>>>, } diff --git a/crates/bevy_ecs/hecs/src/entities.rs b/crates/bevy_ecs/hecs/src/entities.rs index 66ce1ac1db..929a2c8c60 100644 --- a/crates/bevy_ecs/hecs/src/entities.rs +++ b/crates/bevy_ecs/hecs/src/entities.rs @@ -322,6 +322,7 @@ impl Entities { } /// Reserves entities in a way that is usable in multi-threaded contexts. +#[derive(Debug)] pub struct EntityReserver { entities: &'static Entities, } diff --git a/crates/bevy_ecs/src/resource/resource_query.rs b/crates/bevy_ecs/src/resource/resource_query.rs index 012116f965..267f45a8a0 100644 --- a/crates/bevy_ecs/src/resource/resource_query.rs +++ b/crates/bevy_ecs/src/resource/resource_query.rs @@ -13,6 +13,7 @@ use std::marker::PhantomData; /// A shared borrow of a Resource /// that will only return in a query if the Resource has been changed +#[derive(Debug)] pub struct ChangedRes<'a, T: Resource> { value: &'a T, } @@ -200,6 +201,7 @@ impl<'a, T: Resource> ResourceQuery for Res<'a, T> { } /// Fetches a shared resource reference +#[derive(Debug)] pub struct FetchResourceRead(NonNull); impl<'a, T: Resource> FetchResource<'a> for FetchResourceRead { @@ -229,6 +231,7 @@ impl<'a, T: Resource> ResourceQuery for ChangedRes<'a, T> { } /// Fetches a shared resource reference +#[derive(Debug)] pub struct FetchResourceChanged(NonNull); impl<'a, T: Resource> FetchResource<'a> for FetchResourceChanged { @@ -263,6 +266,7 @@ impl<'a, T: Resource> ResourceQuery for ResMut<'a, T> { } /// Fetches a unique resource reference +#[derive(Debug)] pub struct FetchResourceWrite(NonNull); impl<'a, T: Resource> FetchResource<'a> for FetchResourceWrite { @@ -300,6 +304,7 @@ impl<'a, T: Resource + FromResources> ResourceQuery for Local<'a, T> { } /// Fetches a `Local` resource reference +#[derive(Debug)] pub struct FetchResourceLocalMut(NonNull); impl<'a, T: Resource + FromResources> FetchResource<'a> for FetchResourceLocalMut { @@ -385,8 +390,10 @@ macro_rules! tuple_impl { smaller_tuples_too!(tuple_impl, O, N, M, L, K, J, I, H, G, F, E, D, C, B, A); +#[derive(Debug)] pub struct OrRes(T); +#[derive(Debug)] pub struct FetchResourceOr(NonNull); macro_rules! tuple_impl_or { diff --git a/crates/bevy_ecs/src/resource/resources.rs b/crates/bevy_ecs/src/resource/resources.rs index 4b2992bc18..e09273c089 100644 --- a/crates/bevy_ecs/src/resource/resources.rs +++ b/crates/bevy_ecs/src/resource/resources.rs @@ -9,19 +9,21 @@ use std::ptr::NonNull; pub trait Resource: Send + Sync + 'static {} impl Resource for T {} +#[derive(Debug)] pub(crate) struct ResourceData { archetype: Archetype, default_index: Option, system_id_to_archetype_index: HashMap, } +#[derive(Debug)] pub enum ResourceIndex { Global, System(SystemId), } /// A collection of resource instances identified by their type. -#[derive(Default)] +#[derive(Debug, Default)] pub struct Resources { pub(crate) resource_data: HashMap, } diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 0fca964395..88a2b21e64 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -4,7 +4,7 @@ use crate::{ }; use bevy_hecs::World; use bevy_utils::{HashMap, HashSet}; -use std::borrow::Cow; +use std::{borrow::Cow, fmt}; /// An ordered collection of stages, which each contain an ordered list of [System]s. /// Schedules are essentially the "execution plan" for an App's systems. @@ -18,6 +18,27 @@ pub struct Schedule { last_initialize_generation: usize, } +impl fmt::Debug for Schedule { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + writeln!(f, "Schedule {{")?; + + let stages = self + .stage_order + .iter() + .map(|s| (s, self.stages[s].iter().map(|s| (s.name(), s.id())))); + + for (stage, syss) in stages { + writeln!(f, " Stage \"{}\"", stage)?; + + for (name, id) in syss { + writeln!(f, " System {{ name: \"{}\", id: {:?} }}", name, id)?; + } + } + + writeln!(f, "}}") + } +} + impl Schedule { pub fn add_stage(&mut self, stage: impl Into>) { let stage: Cow = stage.into(); diff --git a/crates/bevy_ecs/src/system/commands.rs b/crates/bevy_ecs/src/system/commands.rs index 48e9f6cd34..c562c36042 100644 --- a/crates/bevy_ecs/src/system/commands.rs +++ b/crates/bevy_ecs/src/system/commands.rs @@ -2,7 +2,7 @@ use super::SystemId; use crate::resource::{Resource, Resources}; use bevy_hecs::{Bundle, Component, DynamicBundle, Entity, EntityReserver, World}; use parking_lot::Mutex; -use std::{marker::PhantomData, sync::Arc}; +use std::{fmt, marker::PhantomData, sync::Arc}; /// A queued command to mutate the current [World] or [Resources] pub enum Command { @@ -10,11 +10,27 @@ pub enum Command { WriteResources(Box), } +impl fmt::Debug for Command { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Command::WriteWorld(x) => f + .debug_tuple("WriteWorld") + .field(&(x.as_ref() as *const dyn WorldWriter)) + .finish(), + Command::WriteResources(x) => f + .debug_tuple("WriteResources") + .field(&(x.as_ref() as *const dyn ResourcesWriter)) + .finish(), + } + } +} + /// A [World] mutation pub trait WorldWriter: Send + Sync { fn write(self: Box, world: &mut World); } +#[derive(Debug)] pub(crate) struct Spawn where T: DynamicBundle + Send + Sync + 'static, @@ -49,6 +65,7 @@ where } } +#[derive(Debug)] pub(crate) struct Despawn { entity: Entity, } @@ -76,6 +93,7 @@ where } } +#[derive(Debug)] pub(crate) struct InsertOne where T: Component, @@ -93,6 +111,7 @@ where } } +#[derive(Debug)] pub(crate) struct RemoveOne where T: Component, @@ -112,6 +131,7 @@ where } } +#[derive(Debug)] pub(crate) struct Remove where T: Bundle + Send + Sync + 'static, @@ -143,6 +163,7 @@ impl ResourcesWriter for InsertResource { } } +#[derive(Debug)] pub(crate) struct InsertLocalResource { resource: T, system_id: SystemId, @@ -154,7 +175,7 @@ impl ResourcesWriter for InsertLocalResource { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct CommandsInternal { pub commands: Vec, pub current_entity: Option, @@ -212,7 +233,7 @@ impl CommandsInternal { } /// A queue of [Command]s to run on the current [World] and [Resources] -#[derive(Default, Clone)] +#[derive(Debug, Default, Clone)] pub struct Commands { pub commands: Arc>, } diff --git a/crates/bevy_ecs/src/system/into_system.rs b/crates/bevy_ecs/src/system/into_system.rs index 3da8449cac..cfad1b9ca2 100644 --- a/crates/bevy_ecs/src/system/into_system.rs +++ b/crates/bevy_ecs/src/system/into_system.rs @@ -7,6 +7,7 @@ use crate::{ use bevy_hecs::{Fetch, Query as HecsQuery, World}; use std::borrow::Cow; +#[derive(Debug)] pub(crate) struct SystemFn where F: FnMut(&World, &Resources, &ArchetypeAccess, &mut State) + Send + Sync, diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index e184780c86..0bf409699f 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -4,7 +4,7 @@ use bevy_hecs::{ Without, World, }; use bevy_tasks::ParallelIterator; -use std::marker::PhantomData; +use std::{fmt, marker::PhantomData}; /// Provides scoped access to a World according to a given [HecsQuery] #[derive(Debug)] @@ -140,6 +140,17 @@ pub struct QueryBorrowChecked<'w, Q: HecsQuery> { _marker: PhantomData, } +impl<'w, Q: HecsQuery> fmt::Debug for QueryBorrowChecked<'w, Q> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("QueryBorrowChecked") + .field("archetypes", &self.archetypes) + .field("archetype_access", self.archetype_access) + .field("borrowed", &self.borrowed) + .field("_marker", &self._marker) + .finish() + } +} + impl<'w, Q: HecsQuery> QueryBorrowChecked<'w, Q> { pub(crate) fn new(archetypes: &'w [Archetype], archetype_access: &'w ArchetypeAccess) -> Self { Self { @@ -241,6 +252,19 @@ pub struct QueryIter<'q, 'w, Q: HecsQuery> { iter: Option>, } +impl<'q, 'w, Q: HecsQuery> fmt::Debug for QueryIter<'q, 'w, Q> +where + Q::Fetch: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("QueryIter") + .field("borrow", self.borrow) + .field("archetype_index", &self.archetype_index) + .field("iter", &self.iter) + .finish() + } +} + unsafe impl<'q, 'w, Q: HecsQuery> Send for QueryIter<'q, 'w, Q> {} unsafe impl<'q, 'w, Q: HecsQuery> Sync for QueryIter<'q, 'w, Q> {} @@ -296,6 +320,18 @@ struct ChunkIter { len: usize, } +impl fmt::Debug for ChunkIter +where + Q::Fetch: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ChunkIter") + .field("fetch", &self.fetch) + .field("len", &self.len) + .finish() + } +} + impl ChunkIter { #[inline] unsafe fn next<'a>(&mut self) -> Option<>::Item> { @@ -363,6 +399,18 @@ pub struct Batch<'q, Q: HecsQuery> { state: ChunkIter, } +impl<'q, Q: HecsQuery> fmt::Debug for Batch<'q, Q> +where + Q::Fetch: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Batch") + .field("_marker", &self._marker) + .field("state", &self.state) + .finish() + } +} + impl<'q, 'w, Q: HecsQuery> Iterator for Batch<'q, Q> { type Item = >::Item; @@ -375,6 +423,7 @@ impl<'q, 'w, Q: HecsQuery> Iterator for Batch<'q, Q> { unsafe impl<'q, Q: HecsQuery> Send for Batch<'q, Q> {} /// A borrow of a `World` sufficient to execute the query `Q` on a single entity +#[derive(Debug)] pub struct QueryOneChecked<'a, Q: HecsQuery> { archetype: &'a Archetype, index: usize, diff --git a/crates/bevy_ecs/src/world/world_builder.rs b/crates/bevy_ecs/src/world/world_builder.rs index 6430f3f3dd..3fbb42184b 100644 --- a/crates/bevy_ecs/src/world/world_builder.rs +++ b/crates/bevy_ecs/src/world/world_builder.rs @@ -15,6 +15,7 @@ impl WorldBuilderSource for World { } /// Modify a [World] using the builder pattern +#[derive(Debug)] pub struct WorldBuilder<'a> { pub world: &'a mut World, pub current_entity: Option, diff --git a/crates/bevy_gilrs/src/gilrs_system.rs b/crates/bevy_gilrs/src/gilrs_system.rs index 0ee880d894..f1486c1308 100644 --- a/crates/bevy_gilrs/src/gilrs_system.rs +++ b/crates/bevy_gilrs/src/gilrs_system.rs @@ -6,10 +6,12 @@ use gilrs::{Button, EventType, Gilrs}; use std::sync::{Arc, Mutex}; // TODO: remove this if/when bevy_ecs supports thread local resources +#[derive(Debug)] struct GilrsSendWrapper(Gilrs); unsafe impl Send for GilrsSendWrapper {} +#[derive(Debug)] pub struct GilrsArcMutexWrapper(Arc>); impl GilrsArcMutexWrapper { diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 7fb690ce39..c926139dda 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -12,7 +12,7 @@ use thiserror::Error; /// Loads meshes from GLTF files into Mesh assets /// /// NOTE: eventually this will loading into Scenes instead of Meshes -#[derive(Default)] +#[derive(Debug, Default)] pub struct GltfLoader; impl AssetLoader for GltfLoader { diff --git a/crates/bevy_input/src/axis.rs b/crates/bevy_input/src/axis.rs index 6d8937cf7b..df1ff289d6 100644 --- a/crates/bevy_input/src/axis.rs +++ b/crates/bevy_input/src/axis.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, hash::Hash}; +#[derive(Debug)] pub struct Axis { axis_data: HashMap, } diff --git a/crates/bevy_pbr/src/entity.rs b/crates/bevy_pbr/src/entity.rs index 935e7fa0cd..4a4b61df09 100644 --- a/crates/bevy_pbr/src/entity.rs +++ b/crates/bevy_pbr/src/entity.rs @@ -53,7 +53,7 @@ impl Default for PbrComponents { } /// A component bundle for "light" entities -#[derive(Bundle, Default)] +#[derive(Debug, Bundle, Default)] pub struct LightComponents { pub light: Light, pub transform: Transform, diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index d291e722e5..153a2b1930 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -8,7 +8,7 @@ use bevy_transform::components::GlobalTransform; use std::ops::Range; /// A point light -#[derive(Properties)] +#[derive(Debug, Properties)] pub struct Light { pub color: Color, pub fov: f32, @@ -26,7 +26,7 @@ impl Default for Light { } #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub(crate) struct LightRaw { pub proj: [[f32; 4]; 4], pub pos: [f32; 4], diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index c5329b9450..7c6b3fcf23 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -2,7 +2,7 @@ use bevy_asset::{self, Handle}; use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, texture::Texture}; /// A material with "standard" properties used in PBR lighting -#[derive(RenderResources, ShaderDefs)] +#[derive(Debug, RenderResources, ShaderDefs)] #[allow(clippy::manual_non_exhaustive)] pub struct StandardMaterial { pub albedo: Color, diff --git a/crates/bevy_pbr/src/render_graph/lights_node.rs b/crates/bevy_pbr/src/render_graph/lights_node.rs index fb1ac16253..c9381ffcba 100644 --- a/crates/bevy_pbr/src/render_graph/lights_node.rs +++ b/crates/bevy_pbr/src/render_graph/lights_node.rs @@ -14,7 +14,7 @@ use bevy_render::{ use bevy_transform::prelude::*; /// A Render Graph [Node] that write light data from the ECS to GPU buffers -#[derive(Default)] +#[derive(Debug, Default)] pub struct LightsNode { command_queue: CommandQueue, max_lights: usize, @@ -43,7 +43,7 @@ impl Node for LightsNode { } #[repr(C)] -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] struct LightCount { pub num_lights: [u32; 4], } @@ -67,7 +67,7 @@ impl SystemNode for LightsNode { } /// Local "lights node system" state -#[derive(Default)] +#[derive(Debug, Default)] pub struct LightsNodeSystemState { light_buffer: Option, staging_buffer: Option, diff --git a/crates/bevy_property/src/dynamic_properties.rs b/crates/bevy_property/src/dynamic_properties.rs index 4e864fc0fe..6312c8ebdb 100644 --- a/crates/bevy_property/src/dynamic_properties.rs +++ b/crates/bevy_property/src/dynamic_properties.rs @@ -4,7 +4,7 @@ use crate::{ }; use bevy_utils::HashMap; use serde::de::DeserializeSeed; -use std::{any::Any, borrow::Cow}; +use std::{any::Any, borrow::Cow, fmt}; pub struct DynamicProperties { pub type_name: String, @@ -14,6 +14,24 @@ pub struct DynamicProperties { pub property_type: PropertyType, } +impl fmt::Debug for DynamicProperties { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let props = self + .props + .iter() + .map(|p| p.as_ref() as *const dyn Property) + .collect::>(); + + f.debug_struct("DynamicProperties") + .field("type_name", &self.type_name) + .field("props", &props) + .field("prop_names", &self.prop_names) + .field("prop_indices", &self.prop_indices) + .field("property_type", &self.property_type) + .finish() + } +} + impl DynamicProperties { pub fn map() -> Self { DynamicProperties { diff --git a/crates/bevy_property/src/property_serde.rs b/crates/bevy_property/src/property_serde.rs index e84b9b099b..b6a9d04a87 100644 --- a/crates/bevy_property/src/property_serde.rs +++ b/crates/bevy_property/src/property_serde.rs @@ -25,6 +25,7 @@ impl<'a> Serializable<'a> { } } } + pub struct PropertyValueSerializer<'a, T> where T: Property + Serialize, @@ -277,6 +278,7 @@ impl<'a, 'de> DeserializeSeed<'de> for PropertyDeserializer<'a> { } } } + pub struct SeqPropertyDeserializer<'a> { registry: &'a PropertyTypeRegistry, } diff --git a/crates/bevy_property/src/type_registry.rs b/crates/bevy_property/src/type_registry.rs index adc665f6e2..224dc96e35 100644 --- a/crates/bevy_property/src/type_registry.rs +++ b/crates/bevy_property/src/type_registry.rs @@ -1,8 +1,8 @@ use crate::{DeserializeProperty, Property}; use bevy_utils::{HashMap, HashSet}; -use std::any::TypeId; +use std::{any::TypeId, fmt}; -#[derive(Default)] +#[derive(Debug, Default)] pub struct PropertyTypeRegistry { registrations: HashMap, short_names: HashMap, @@ -72,6 +72,24 @@ pub struct PropertyTypeRegistration { pub name: &'static str, } +impl fmt::Debug for PropertyTypeRegistration { + fn fmt<'a>(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("PropertyTypeRegistration") + .field("ty", &self.ty) + .field( + "deserialize_fn", + &(self.deserialize_fn + as fn( + deserializer: &'a mut dyn erased_serde::Deserializer<'a>, + property_type_registry: &'a PropertyTypeRegistry, + ) -> Result, erased_serde::Error>), + ) + .field("short_name", &self.short_name) + .field("name", &self.name) + .finish() + } +} + impl PropertyTypeRegistration { pub fn of() -> Self { let ty = TypeId::of::(); diff --git a/crates/bevy_render/src/batch/batcher.rs b/crates/bevy_render/src/batch/batcher.rs index 7f95247468..7eeb639aef 100644 --- a/crates/bevy_render/src/batch/batcher.rs +++ b/crates/bevy_render/src/batch/batcher.rs @@ -1,7 +1,7 @@ use super::Batch; use bevy_utils::HashMap; use smallvec::{smallvec, SmallVec}; -use std::{borrow::Cow, hash::Hash}; +use std::{borrow::Cow, fmt, hash::Hash}; // TODO: add sorting by primary / secondary handle to reduce rebinds of data @@ -28,6 +28,7 @@ impl BatchKey { } } +#[derive(Debug)] pub struct BatcherKeyState { batch_key: Option>, keys: SmallVec<[Option; 2]>, @@ -77,6 +78,28 @@ where pub key_count: usize, } +impl fmt::Debug for Batcher +where + TKey: Key + fmt::Debug, + TValue: fmt::Debug, + TData: fmt::Debug, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let is_index = self + .is_index + .iter() + .map(|f| f as *const for<'r> fn(&'r TKey) -> bool) + .collect::>(); + + f.debug_struct("Batcher") + .field("batches", &self.batches) + .field("is_index", &is_index) + .field("key_states", &self.key_states) + .field("key_count", &self.key_count) + .finish() + } +} + impl Batcher where TKey: Key, diff --git a/crates/bevy_render/src/camera/active_cameras.rs b/crates/bevy_render/src/camera/active_cameras.rs index fef17d3d8e..5c41049710 100644 --- a/crates/bevy_render/src/camera/active_cameras.rs +++ b/crates/bevy_render/src/camera/active_cameras.rs @@ -2,7 +2,7 @@ use super::Camera; use bevy_ecs::{Entity, Query, ResMut}; use bevy_utils::HashMap; -#[derive(Default)] +#[derive(Debug, Default)] pub struct ActiveCameras { pub cameras: HashMap>, } diff --git a/crates/bevy_render/src/draw.rs b/crates/bevy_render/src/draw.rs index a54db24fce..e64ee9c493 100644 --- a/crates/bevy_render/src/draw.rs +++ b/crates/bevy_render/src/draw.rs @@ -50,7 +50,7 @@ pub enum RenderCommand { } /// A component that indicates how to draw an entity. -#[derive(Properties, Clone)] +#[derive(Debug, Properties, Clone)] pub struct Draw { pub is_visible: bool, pub is_transparent: bool, @@ -123,6 +123,7 @@ pub enum DrawError { BufferAllocationFailure, } +//#[derive(Debug)] pub struct DrawContext<'a> { pub pipelines: ResMut<'a, Assets>, pub shaders: ResMut<'a, Assets>, @@ -151,6 +152,7 @@ impl<'a> ResourceQuery for DrawContext<'a> { type Fetch = FetchDrawContext; } +#[derive(Debug)] pub struct FetchDrawContext; // TODO: derive this impl diff --git a/crates/bevy_render/src/mesh/mesh.rs b/crates/bevy_render/src/mesh/mesh.rs index 5f631f202f..f08eae7edb 100644 --- a/crates/bevy_render/src/mesh/mesh.rs +++ b/crates/bevy_render/src/mesh/mesh.rs @@ -181,6 +181,7 @@ pub mod shape { use hexasphere::Hexasphere; /// A cube. + #[derive(Debug)] pub struct Cube { /// Half the side length of the cube. pub size: f32, @@ -259,6 +260,7 @@ pub mod shape { } /// A rectangle on the XY plane. + #[derive(Debug)] pub struct Quad { /// Full width and height of the rectangle. pub size: Vec2, @@ -357,6 +359,7 @@ pub mod shape { } /// A square on the XZ plane. + #[derive(Debug)] pub struct Plane { /// The total side length of the square. pub size: f32, @@ -397,6 +400,7 @@ pub mod shape { } /// A sphere made from a subdivided Icosahedron. + #[derive(Debug)] pub struct Icosphere { /// The radius of the sphere. pub radius: f32, diff --git a/crates/bevy_render/src/mesh/vertex.rs b/crates/bevy_render/src/mesh/vertex.rs index b711d39fb4..f8e4530c56 100644 --- a/crates/bevy_render/src/mesh/vertex.rs +++ b/crates/bevy_render/src/mesh/vertex.rs @@ -2,7 +2,7 @@ use crate::pipeline::AsVertexBufferDescriptor; use bevy_core::Byteable; #[repr(C)] -#[derive(Clone, Copy, AsVertexBufferDescriptor)] +#[derive(Debug, Clone, Copy, AsVertexBufferDescriptor)] #[as_crate(bevy_render)] pub struct Vertex { pub position: [f32; 3], diff --git a/crates/bevy_render/src/pipeline/pipeline_compiler.rs b/crates/bevy_render/src/pipeline/pipeline_compiler.rs index b696aa3182..276f9e94a6 100644 --- a/crates/bevy_render/src/pipeline/pipeline_compiler.rs +++ b/crates/bevy_render/src/pipeline/pipeline_compiler.rs @@ -44,11 +44,13 @@ pub struct ShaderSpecialization { pub shader_defs: HashSet, } +#[derive(Debug)] struct SpecializedShader { shader: Handle, specialization: ShaderSpecialization, } +#[derive(Debug)] struct SpecializedPipeline { pipeline: Handle, specialization: PipelineSpecialization, @@ -60,7 +62,7 @@ pub struct DynamicBinding { pub binding: u32, } -#[derive(Default)] +#[derive(Debug, Default)] pub struct PipelineCompiler { specialized_shaders: HashMap, Vec>, specialized_pipelines: HashMap, Vec>, diff --git a/crates/bevy_render/src/pipeline/render_pipelines.rs b/crates/bevy_render/src/pipeline/render_pipelines.rs index bc477a7bf6..b941412230 100644 --- a/crates/bevy_render/src/pipeline/render_pipelines.rs +++ b/crates/bevy_render/src/pipeline/render_pipelines.rs @@ -9,7 +9,7 @@ use bevy_asset::{Assets, Handle}; use bevy_ecs::{Query, Res, ResMut}; use bevy_property::Properties; -#[derive(Properties, Default, Clone)] +#[derive(Debug, Properties, Default, Clone)] #[non_exhaustive] pub struct RenderPipeline { pub pipeline: Handle, @@ -35,7 +35,7 @@ impl RenderPipeline { } } -#[derive(Properties, Clone)] +#[derive(Debug, Properties, Clone)] pub struct RenderPipelines { pub pipelines: Vec, #[property(ignore)] diff --git a/crates/bevy_render/src/pipeline/vertex_buffer_descriptor.rs b/crates/bevy_render/src/pipeline/vertex_buffer_descriptor.rs index 1f30bcac0b..ad4875e54d 100644 --- a/crates/bevy_render/src/pipeline/vertex_buffer_descriptor.rs +++ b/crates/bevy_render/src/pipeline/vertex_buffer_descriptor.rs @@ -46,7 +46,7 @@ pub struct VertexAttributeDescriptor { pub shader_location: u32, } -#[derive(Default)] +#[derive(Debug, Default)] pub struct VertexBufferDescriptors { pub descriptors: HashMap, } diff --git a/crates/bevy_render/src/render_graph/base.rs b/crates/bevy_render/src/render_graph/base.rs index 62536fcebd..bc3d68a8d9 100644 --- a/crates/bevy_render/src/render_graph/base.rs +++ b/crates/bevy_render/src/render_graph/base.rs @@ -17,6 +17,7 @@ use bevy_window::WindowId; #[derive(Default, Properties)] pub struct MainPass; +#[derive(Debug)] pub struct Msaa { pub samples: u32, } @@ -50,6 +51,7 @@ impl Msaa { } } +#[derive(Debug)] pub struct BaseRenderGraphConfig { pub add_2d_camera: bool, pub add_3d_camera: bool, diff --git a/crates/bevy_render/src/render_graph/command.rs b/crates/bevy_render/src/render_graph/command.rs index c301d30058..466b4897f5 100644 --- a/crates/bevy_render/src/render_graph/command.rs +++ b/crates/bevy_render/src/render_graph/command.rs @@ -27,7 +27,7 @@ pub enum Command { FreeBuffer(BufferId), } -#[derive(Default, Clone)] +#[derive(Debug, Default, Clone)] pub struct CommandQueue { // TODO: this shouldn't really need a mutex. it just needs to be shared on whatever thread it's scheduled on queue: Arc>>, diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index 06f4dffdc7..678c4be2cd 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -40,6 +40,7 @@ pub trait SystemNode: Node { fn get_system(&self, commands: &mut Commands) -> Box; } +#[derive(Debug)] pub struct Edges { pub id: NodeId, pub input_edges: Vec, diff --git a/crates/bevy_render/src/render_graph/nodes/camera_node.rs b/crates/bevy_render/src/render_graph/nodes/camera_node.rs index d057311a0f..f1a37e58c5 100644 --- a/crates/bevy_render/src/render_graph/nodes/camera_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/camera_node.rs @@ -12,6 +12,7 @@ use bevy_ecs::{Commands, IntoQuerySystem, Local, Query, Res, ResMut, Resources, use bevy_transform::prelude::*; use std::borrow::Cow; +#[derive(Debug)] pub struct CameraNode { command_queue: CommandQueue, camera_name: Cow<'static, str>, @@ -58,7 +59,7 @@ impl SystemNode for CameraNode { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct CameraNodeState { command_queue: CommandQueue, camera_name: Cow<'static, str>, diff --git a/crates/bevy_render/src/render_graph/nodes/pass_node.rs b/crates/bevy_render/src/render_graph/nodes/pass_node.rs index 954a997a04..979edd1a2a 100644 --- a/crates/bevy_render/src/render_graph/nodes/pass_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/pass_node.rs @@ -13,8 +13,9 @@ use crate::{ }; use bevy_asset::{Assets, Handle}; use bevy_ecs::{HecsQuery, ReadOnlyFetch, Resources, World}; -use std::{marker::PhantomData, ops::Deref}; +use std::{fmt, marker::PhantomData, ops::Deref}; +#[derive(Debug)] struct CameraInfo { name: String, bind_group_id: Option, @@ -32,6 +33,36 @@ pub struct PassNode { _marker: PhantomData, } +impl fmt::Debug for PassNode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("PassNose") + .field("descriptor", &self.descriptor) + .field("inputs", &self.inputs) + .field("cameras", &self.cameras) + .field( + "color_attachment_input_indices", + &self.color_attachment_input_indices, + ) + .field( + "color_resolve_target_indices", + &self.color_resolve_target_indices, + ) + .field( + "depth_stencil_attachment_input_index", + &self.depth_stencil_attachment_input_index, + ) + .field( + "default_clear_color_inputs", + &self.default_clear_color_inputs, + ) + .field( + "camera_bind_group_descriptor", + &self.camera_bind_group_descriptor, + ) + .finish() + } +} + impl PassNode { pub fn new(descriptor: PassDescriptor) -> Self { let mut inputs = Vec::new(); @@ -295,7 +326,7 @@ where } /// Tracks the current pipeline state to ensure draw calls are valid. -#[derive(Default)] +#[derive(Debug, Default)] struct DrawState { pipeline: Option>, bind_groups: Vec>, diff --git a/crates/bevy_render/src/render_graph/nodes/shared_buffers_node.rs b/crates/bevy_render/src/render_graph/nodes/shared_buffers_node.rs index 62f754d1f8..676df16fc5 100644 --- a/crates/bevy_render/src/render_graph/nodes/shared_buffers_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/shared_buffers_node.rs @@ -4,7 +4,7 @@ use crate::{ }; use bevy_ecs::{Resources, World}; -#[derive(Default)] +#[derive(Debug, Default)] pub struct SharedBuffersNode; impl Node for SharedBuffersNode { diff --git a/crates/bevy_render/src/render_graph/schedule.rs b/crates/bevy_render/src/render_graph/schedule.rs index d92d6be2e7..e250de45de 100644 --- a/crates/bevy_render/src/render_graph/schedule.rs +++ b/crates/bevy_render/src/render_graph/schedule.rs @@ -107,7 +107,7 @@ pub trait RenderGraphStager { // TODO: remove this /// This scheduler ignores dependencies and puts everything in one stage. It shouldn't be used for anything :) -#[derive(Default)] +#[derive(Debug, Default)] pub struct LinearStager; impl RenderGraphStager for LinearStager { @@ -124,7 +124,7 @@ impl RenderGraphStager for LinearStager { } } -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] /// Determines the grouping strategy used when constructing graph stages pub enum JobGrouping { /// Default to adding the current node to a new job in its assigned stage. This results @@ -135,6 +135,7 @@ pub enum JobGrouping { Tight, } +#[derive(Debug)] /// Produces Render Graph stages and jobs in a way that ensures node dependencies are respected. pub struct DependentNodeStager { job_grouping: JobGrouping, diff --git a/crates/bevy_render/src/renderer/headless_render_resource_context.rs b/crates/bevy_render/src/renderer/headless_render_resource_context.rs index 0a467d0718..7e478ce758 100644 --- a/crates/bevy_render/src/renderer/headless_render_resource_context.rs +++ b/crates/bevy_render/src/renderer/headless_render_resource_context.rs @@ -11,7 +11,7 @@ use bevy_window::Window; use parking_lot::RwLock; use std::{ops::Range, sync::Arc}; -#[derive(Default)] +#[derive(Debug, Default)] pub struct HeadlessRenderResourceContext { buffer_info: Arc>>, texture_descriptors: Arc>>, diff --git a/crates/bevy_render/src/renderer/render_resource/bind_group.rs b/crates/bevy_render/src/renderer/render_resource/bind_group.rs index 2e4f264e58..97c4f1edab 100644 --- a/crates/bevy_render/src/renderer/render_resource/bind_group.rs +++ b/crates/bevy_render/src/renderer/render_resource/bind_group.rs @@ -28,7 +28,7 @@ impl BindGroup { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct BindGroupBuilder { pub indexed_bindings: Vec, pub dynamic_uniform_indices: Vec, diff --git a/crates/bevy_render/src/renderer/render_resource/render_resource_bindings.rs b/crates/bevy_render/src/renderer/render_resource/render_resource_bindings.rs index b9e95f580f..7cded917f0 100644 --- a/crates/bevy_render/src/renderer/render_resource/render_resource_bindings.rs +++ b/crates/bevy_render/src/renderer/render_resource/render_resource_bindings.rs @@ -253,7 +253,7 @@ impl RenderResourceBindings { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct AssetRenderResourceBindings { pub bindings: HashMap, } diff --git a/crates/bevy_render/src/texture/texture.rs b/crates/bevy_render/src/texture/texture.rs index 714c892171..46884ccea8 100644 --- a/crates/bevy_render/src/texture/texture.rs +++ b/crates/bevy_render/src/texture/texture.rs @@ -11,7 +11,7 @@ use bevy_utils::HashSet; pub const TEXTURE_ASSET_INDEX: usize = 0; pub const SAMPLER_ASSET_INDEX: usize = 1; -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Texture { pub data: Vec, pub size: Vec2, diff --git a/crates/bevy_scene/src/loaded_scenes.rs b/crates/bevy_scene/src/loaded_scenes.rs index 51979b4853..dcc80027d4 100644 --- a/crates/bevy_scene/src/loaded_scenes.rs +++ b/crates/bevy_scene/src/loaded_scenes.rs @@ -8,6 +8,7 @@ use parking_lot::RwLock; use serde::de::DeserializeSeed; use std::{path::Path, sync::Arc}; +#[derive(Debug)] pub struct SceneLoader { property_type_registry: Arc>, } diff --git a/crates/bevy_scene/src/scene.rs b/crates/bevy_scene/src/scene.rs index 1db5561e3b..61692ca299 100644 --- a/crates/bevy_scene/src/scene.rs +++ b/crates/bevy_scene/src/scene.rs @@ -5,11 +5,12 @@ use bevy_property::{DynamicProperties, PropertyTypeRegistry}; use bevy_type_registry::ComponentRegistry; use serde::Serialize; -#[derive(Default)] +#[derive(Debug, Default)] pub struct Scene { pub entities: Vec, } +#[derive(Debug)] pub struct Entity { pub entity: u32, pub components: Vec, diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 4c581d9156..1810e9f88d 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -7,6 +7,7 @@ use bevy_utils::HashMap; use thiserror::Error; use uuid::Uuid; +#[derive(Debug)] struct InstanceInfo { entity_map: HashMap, } diff --git a/crates/bevy_scene/src/serde.rs b/crates/bevy_scene/src/serde.rs index 9d9e4b7c9b..4191a0b0fd 100644 --- a/crates/bevy_scene/src/serde.rs +++ b/crates/bevy_scene/src/serde.rs @@ -159,6 +159,7 @@ pub const ENTITY_STRUCT: &str = "Entity"; pub const ENTITY_FIELD_ENTITY: &str = "entity"; pub const ENTITY_FIELD_COMPONENTS: &str = "components"; +#[derive(Debug)] struct SceneEntityVisiter<'a> { pub registry: &'a PropertyTypeRegistry, } diff --git a/crates/bevy_sprite/src/color_material.rs b/crates/bevy_sprite/src/color_material.rs index ee2dea40ed..9755159666 100644 --- a/crates/bevy_sprite/src/color_material.rs +++ b/crates/bevy_sprite/src/color_material.rs @@ -1,7 +1,7 @@ use bevy_asset::{self, Handle}; use bevy_render::{color::Color, renderer::RenderResources, shader::ShaderDefs, texture::Texture}; -#[derive(RenderResources, ShaderDefs)] +#[derive(Debug, RenderResources, ShaderDefs)] pub struct ColorMaterial { pub color: Color, #[shader_def] diff --git a/crates/bevy_sprite/src/sprite.rs b/crates/bevy_sprite/src/sprite.rs index 03c9935859..49b4043268 100644 --- a/crates/bevy_sprite/src/sprite.rs +++ b/crates/bevy_sprite/src/sprite.rs @@ -4,7 +4,7 @@ use bevy_ecs::{Query, Res}; use bevy_math::Vec2; use bevy_render::{renderer::RenderResources, texture::Texture}; -#[derive(Default, RenderResources)] +#[derive(Debug, Default, RenderResources)] pub struct Sprite { pub size: Vec2, #[render_resources(ignore)] diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index 65d8c51aae..e41e516887 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -10,7 +10,7 @@ use bevy_render::{ use bevy_utils::HashMap; /// An atlas containing multiple textures (like a spritesheet or a tilemap) -#[derive(RenderResources)] +#[derive(Debug, RenderResources)] pub struct TextureAtlas { /// The handle to the texture in which the sprites are stored pub texture: Handle, @@ -25,7 +25,7 @@ pub struct TextureAtlas { // NOTE: cannot do `unsafe impl Byteable` here because Vec3 takes up the space of a Vec4. If/when glam changes this we can swap out // Bytes for Byteable as a micro-optimization. https://github.com/bitshifter/glam-rs/issues/36 -#[derive(Bytes, RenderResources, RenderResource)] +#[derive(Bytes, Debug, RenderResources, RenderResource)] #[render_resources(from_self)] pub struct TextureAtlasSprite { pub color: Color, diff --git a/crates/bevy_sprite/src/texture_atlas_builder.rs b/crates/bevy_sprite/src/texture_atlas_builder.rs index e508c447f7..e8ee29ae55 100644 --- a/crates/bevy_sprite/src/texture_atlas_builder.rs +++ b/crates/bevy_sprite/src/texture_atlas_builder.rs @@ -9,6 +9,7 @@ use rectangle_pack::{ }; use thiserror::Error; +#[derive(Debug)] pub struct TextureAtlasBuilder { pub textures: Vec>, pub rects_to_place: GroupedRectsToPlace>, diff --git a/crates/bevy_tasks/src/iter/adapters.rs b/crates/bevy_tasks/src/iter/adapters.rs index 1d6740406a..047f6fb8ad 100644 --- a/crates/bevy_tasks/src/iter/adapters.rs +++ b/crates/bevy_tasks/src/iter/adapters.rs @@ -1,5 +1,6 @@ use crate::iter::ParallelIterator; +#[derive(Debug)] pub struct Chain { pub(crate) left: T, pub(crate) right: U, @@ -25,6 +26,7 @@ where } } +#[derive(Debug)] pub struct Map { pub(crate) iter: P, pub(crate) f: F, @@ -43,6 +45,7 @@ where } } +#[derive(Debug)] pub struct Filter { pub(crate) iter: P, pub(crate) predicate: F, @@ -63,6 +66,7 @@ where } } +#[derive(Debug)] pub struct FilterMap { pub(crate) iter: P, pub(crate) f: F, @@ -81,6 +85,7 @@ where } } +#[derive(Debug)] pub struct FlatMap { pub(crate) iter: P, pub(crate) f: F, @@ -103,6 +108,7 @@ where } } +#[derive(Debug)] pub struct Flatten

{ pub(crate) iter: P, } @@ -123,6 +129,7 @@ where } } +#[derive(Debug)] pub struct Fuse

{ pub(crate) iter: Option

, } @@ -148,6 +155,7 @@ where } } +#[derive(Debug)] pub struct Inspect { pub(crate) iter: P, pub(crate) f: F, @@ -166,6 +174,7 @@ where } } +#[derive(Debug)] pub struct Copied

{ pub(crate) iter: P, } @@ -183,6 +192,7 @@ where } } +#[derive(Debug)] pub struct Cloned

{ pub(crate) iter: P, } @@ -200,6 +210,7 @@ where } } +#[derive(Debug)] pub struct Cycle

{ pub(crate) iter: P, pub(crate) curr: Option

, diff --git a/crates/bevy_tasks/src/single_threaded_task_pool.rs b/crates/bevy_tasks/src/single_threaded_task_pool.rs index 69048c9140..6b515b1326 100644 --- a/crates/bevy_tasks/src/single_threaded_task_pool.rs +++ b/crates/bevy_tasks/src/single_threaded_task_pool.rs @@ -104,12 +104,14 @@ impl TaskPool { } } +#[derive(Debug)] pub struct FakeTask; impl FakeTask { pub fn detach(self) {} } +#[derive(Debug)] pub struct Scope<'scope, T> { executor: &'scope async_executor::LocalExecutor<'scope>, // Vector to gather results of all futures spawned during scope run diff --git a/crates/bevy_tasks/src/task.rs b/crates/bevy_tasks/src/task.rs index 2456be140f..2704682735 100644 --- a/crates/bevy_tasks/src/task.rs +++ b/crates/bevy_tasks/src/task.rs @@ -13,6 +13,7 @@ use std::{ /// /// Tasks that panic get immediately canceled. Awaiting a canceled task also causes a panic. /// Wraps async_executor::Task +#[derive(Debug)] pub struct Task(async_executor::Task); impl Task { diff --git a/crates/bevy_tasks/src/task_pool.rs b/crates/bevy_tasks/src/task_pool.rs index ce49292ee7..7185dfb861 100644 --- a/crates/bevy_tasks/src/task_pool.rs +++ b/crates/bevy_tasks/src/task_pool.rs @@ -59,6 +59,7 @@ impl TaskPoolBuilder { } } +#[derive(Debug)] struct TaskPoolInner { threads: Vec>, shutdown_tx: async_channel::Sender<()>, @@ -78,7 +79,7 @@ impl Drop for TaskPoolInner { /// A thread pool for executing tasks. Tasks are futures that are being automatically driven by /// the pool on threads owned by the pool. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct TaskPool { /// The executor for the pool /// @@ -213,6 +214,7 @@ impl Default for TaskPool { } } +#[derive(Debug)] pub struct Scope<'scope, T> { executor: &'scope async_executor::Executor<'scope>, spawned: Vec>, diff --git a/crates/bevy_tasks/src/usages.rs b/crates/bevy_tasks/src/usages.rs index c7c73c3b51..7adf60639b 100644 --- a/crates/bevy_tasks/src/usages.rs +++ b/crates/bevy_tasks/src/usages.rs @@ -15,7 +15,7 @@ use std::ops::Deref; /// A newtype for a task pool for CPU-intensive work that must be completed to deliver the next /// frame -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct ComputeTaskPool(pub TaskPool); impl Deref for ComputeTaskPool { @@ -27,7 +27,7 @@ impl Deref for ComputeTaskPool { } /// A newtype for a task pool for CPU-intensive work that may span across multiple frames -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct AsyncComputeTaskPool(pub TaskPool); impl Deref for AsyncComputeTaskPool { @@ -40,7 +40,7 @@ impl Deref for AsyncComputeTaskPool { /// A newtype for a task pool for IO-intensive work (i.e. tasks that spend very little time in a /// "woken" state) -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct IoTaskPool(pub TaskPool); impl Deref for IoTaskPool { diff --git a/crates/bevy_text/src/draw.rs b/crates/bevy_text/src/draw.rs index 18696e41a0..dc8071923c 100644 --- a/crates/bevy_text/src/draw.rs +++ b/crates/bevy_text/src/draw.rs @@ -15,7 +15,7 @@ use bevy_render::{ }; use bevy_sprite::{TextureAtlas, TextureAtlasSprite}; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct TextStyle { pub font_size: f32, pub color: Color, diff --git a/crates/bevy_text/src/font.rs b/crates/bevy_text/src/font.rs index a98acd0076..d7afae8f6b 100644 --- a/crates/bevy_text/src/font.rs +++ b/crates/bevy_text/src/font.rs @@ -5,6 +5,7 @@ use bevy_render::{ texture::{Texture, TextureFormat}, }; +#[derive(Debug)] pub struct Font { pub font: FontVec, } diff --git a/crates/bevy_transform/src/hierarchy/child_builder.rs b/crates/bevy_transform/src/hierarchy/child_builder.rs index 158e09b8d2..5fdd0410b9 100644 --- a/crates/bevy_transform/src/hierarchy/child_builder.rs +++ b/crates/bevy_transform/src/hierarchy/child_builder.rs @@ -2,6 +2,7 @@ use crate::prelude::{Children, Parent, PreviousParent}; use bevy_ecs::{Commands, CommandsInternal, Component, DynamicBundle, Entity, WorldWriter}; use smallvec::SmallVec; +#[derive(Debug)] pub struct InsertChildren { parent: Entity, children: SmallVec<[Entity; 8]>, @@ -35,11 +36,13 @@ impl WorldWriter for InsertChildren { } } +#[derive(Debug)] pub struct PushChildren { parent: Entity, children: SmallVec<[Entity; 8]>, } +#[derive(Debug)] pub struct ChildBuilder<'a> { commands: &'a mut CommandsInternal, push_children: PushChildren, diff --git a/crates/bevy_transform/src/hierarchy/hierarchy.rs b/crates/bevy_transform/src/hierarchy/hierarchy.rs index 5e340c93b0..f123474c59 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy.rs @@ -39,6 +39,7 @@ where previous_result } +#[derive(Debug)] pub struct DespawnRecursive { entity: Entity, } diff --git a/crates/bevy_transform/src/hierarchy/world_child_builder.rs b/crates/bevy_transform/src/hierarchy/world_child_builder.rs index ce12192afd..119deb7113 100644 --- a/crates/bevy_transform/src/hierarchy/world_child_builder.rs +++ b/crates/bevy_transform/src/hierarchy/world_child_builder.rs @@ -1,6 +1,7 @@ use crate::prelude::{Children, Parent, PreviousParent}; use bevy_ecs::{Component, DynamicBundle, Entity, WorldBuilder}; +#[derive(Debug)] pub struct WorldChildBuilder<'a, 'b> { world_builder: &'b mut WorldBuilder<'a>, parent_entities: Vec, diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index a4de6dc9c1..d31e31b19a 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -16,7 +16,7 @@ use bevy_render::{ use bevy_sprite::{ColorMaterial, QUAD_HANDLE}; use bevy_transform::prelude::{GlobalTransform, Transform}; -#[derive(Bundle, Clone)] +#[derive(Bundle, Clone, Debug)] pub struct NodeComponents { pub node: Node, pub style: Style, @@ -60,7 +60,7 @@ impl Default for NodeComponents { } } -#[derive(Bundle, Clone)] +#[derive(Bundle, Clone, Debug)] pub struct ImageComponents { pub node: Node, pub style: Style, @@ -108,7 +108,7 @@ impl Default for ImageComponents { } } -#[derive(Bundle, Clone)] +#[derive(Bundle, Clone, Debug)] pub struct TextComponents { pub node: Node, pub style: Style, @@ -138,7 +138,7 @@ impl Default for TextComponents { } } -#[derive(Bundle, Clone)] +#[derive(Bundle, Clone, Debug)] pub struct ButtonComponents { pub node: Node, pub button: Button, @@ -188,7 +188,7 @@ impl Default for ButtonComponents { } } -#[derive(Bundle)] +#[derive(Bundle, Debug)] pub struct UiCameraComponents { pub camera: Camera, pub orthographic_projection: OrthographicProjection, diff --git a/crates/bevy_ui/src/flex/mod.rs b/crates/bevy_ui/src/flex/mod.rs index 9efe3a43c1..ee7967929e 100644 --- a/crates/bevy_ui/src/flex/mod.rs +++ b/crates/bevy_ui/src/flex/mod.rs @@ -6,6 +6,7 @@ use bevy_math::Vec2; use bevy_transform::prelude::{Children, Parent, Transform}; use bevy_utils::HashMap; use bevy_window::{Window, WindowId, Windows}; +use std::fmt; use stretch::{number::Number, Stretch}; pub struct FlexSurface { @@ -14,6 +15,15 @@ pub struct FlexSurface { stretch: Stretch, } +impl fmt::Debug for FlexSurface { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("FlexSurface") + .field("entity_to_stretch", &self.entity_to_stretch) + .field("window_nodes", &self.window_nodes) + .finish() + } +} + impl Default for FlexSurface { fn default() -> Self { Self { diff --git a/crates/bevy_ui/src/node.rs b/crates/bevy_ui/src/node.rs index 2948558451..6d2a3a3053 100644 --- a/crates/bevy_ui/src/node.rs +++ b/crates/bevy_ui/src/node.rs @@ -44,7 +44,7 @@ impl AddAssign for Val { } } -#[derive(Default, Copy, Clone)] +#[derive(Default, Copy, Clone, Debug)] pub struct CalculatedSize { pub size: Size, } diff --git a/crates/bevy_ui/src/widget/button.rs b/crates/bevy_ui/src/widget/button.rs index 8201482dc3..47baf3b6fa 100644 --- a/crates/bevy_ui/src/widget/button.rs +++ b/crates/bevy_ui/src/widget/button.rs @@ -1,2 +1,2 @@ -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Button; diff --git a/crates/bevy_ui/src/widget/image.rs b/crates/bevy_ui/src/widget/image.rs index 51e800657d..2010cf2fb0 100644 --- a/crates/bevy_ui/src/widget/image.rs +++ b/crates/bevy_ui/src/widget/image.rs @@ -5,7 +5,7 @@ use bevy_math::Size; use bevy_render::texture::Texture; use bevy_sprite::ColorMaterial; -#[derive(Clone)] +#[derive(Debug, Clone)] pub enum Image { KeepAspect, } diff --git a/crates/bevy_ui/src/widget/text.rs b/crates/bevy_ui/src/widget/text.rs index cb6d558c94..4646ddf702 100644 --- a/crates/bevy_ui/src/widget/text.rs +++ b/crates/bevy_ui/src/widget/text.rs @@ -12,12 +12,12 @@ use bevy_sprite::TextureAtlas; use bevy_text::{DrawableText, Font, FontAtlasSet, TextStyle}; use bevy_transform::prelude::GlobalTransform; -#[derive(Default)] +#[derive(Debug, Default)] pub struct QueuedText { entities: Vec, } -#[derive(Default, Clone)] +#[derive(Debug, Default, Clone)] pub struct Text { pub value: String, pub font: Handle, diff --git a/crates/bevy_wgpu/src/renderer/wgpu_render_context.rs b/crates/bevy_wgpu/src/renderer/wgpu_render_context.rs index 309804d3e4..b42f9722b3 100644 --- a/crates/bevy_wgpu/src/renderer/wgpu_render_context.rs +++ b/crates/bevy_wgpu/src/renderer/wgpu_render_context.rs @@ -15,7 +15,7 @@ use bevy_render::{ use std::sync::Arc; -#[derive(Default)] +#[derive(Debug, Default)] pub struct LazyCommandEncoder { command_encoder: Option, } @@ -50,6 +50,7 @@ impl LazyCommandEncoder { } } +#[derive(Debug)] pub struct WgpuRenderContext { pub device: Arc, pub command_encoder: LazyCommandEncoder, diff --git a/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs b/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs index 3821aa1c71..e8b864d9e3 100644 --- a/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs +++ b/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs @@ -8,6 +8,7 @@ use bevy_utils::HashMap; use parking_lot::RwLock; use std::sync::Arc; +#[derive(Debug)] pub struct WgpuRenderGraphExecutor { pub max_thread_count: usize, } diff --git a/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs b/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs index 2f2e630c82..0f89affbe8 100644 --- a/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs +++ b/crates/bevy_wgpu/src/renderer/wgpu_render_resource_context.rs @@ -20,7 +20,7 @@ use futures_lite::future; use std::{borrow::Cow, ops::Range, sync::Arc}; use wgpu::util::DeviceExt; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct WgpuRenderResourceContext { pub device: Arc, pub resources: WgpuResources, diff --git a/crates/bevy_wgpu/src/wgpu_render_pass.rs b/crates/bevy_wgpu/src/wgpu_render_pass.rs index ef1ea961f1..66f1c15518 100644 --- a/crates/bevy_wgpu/src/wgpu_render_pass.rs +++ b/crates/bevy_wgpu/src/wgpu_render_pass.rs @@ -7,6 +7,7 @@ use bevy_render::{ }; use std::ops::Range; +#[derive(Debug)] pub struct WgpuRenderPass<'a> { pub render_pass: wgpu::RenderPass<'a>, pub render_context: &'a WgpuRenderContext, diff --git a/crates/bevy_wgpu/src/wgpu_renderer.rs b/crates/bevy_wgpu/src/wgpu_renderer.rs index 11da00a263..49e6663d33 100644 --- a/crates/bevy_wgpu/src/wgpu_renderer.rs +++ b/crates/bevy_wgpu/src/wgpu_renderer.rs @@ -7,6 +7,7 @@ use bevy_render::{ }; use bevy_window::{WindowCreated, WindowResized, Windows}; use std::{ops::Deref, sync::Arc}; + pub struct WgpuRenderer { pub instance: wgpu::Instance, pub device: Arc, diff --git a/crates/bevy_wgpu/src/wgpu_resources.rs b/crates/bevy_wgpu/src/wgpu_resources.rs index 5409534337..5e2bedb275 100644 --- a/crates/bevy_wgpu/src/wgpu_resources.rs +++ b/crates/bevy_wgpu/src/wgpu_resources.rs @@ -10,7 +10,7 @@ use bevy_window::WindowId; use parking_lot::{RwLock, RwLockReadGuard}; use std::sync::Arc; -#[derive(Default)] +#[derive(Debug, Default)] pub struct WgpuBindGroupInfo { pub bind_groups: HashMap, } @@ -37,6 +37,7 @@ pub struct WgpuBindGroupInfo { /// /// Single threaded implementations don't need to worry about these lifetimes constraints at all. RenderPasses can use a RenderContext's /// WgpuResources directly. RenderContext already has a lifetime greater than the RenderPass. +#[derive(Debug)] pub struct WgpuResourcesReadLock<'a> { pub buffers: RwLockReadGuard<'a, HashMap>>, pub textures: RwLockReadGuard<'a, HashMap>, @@ -59,6 +60,7 @@ impl<'a> WgpuResourcesReadLock<'a> { } /// Stores read only references to WgpuResource collections. See WgpuResourcesReadLock docs for context on why this exists +#[derive(Debug)] pub struct WgpuResourceRefs<'a> { pub buffers: &'a HashMap>, pub textures: &'a HashMap, @@ -67,7 +69,7 @@ pub struct WgpuResourceRefs<'a> { pub bind_groups: &'a HashMap, } -#[derive(Default, Clone)] +#[derive(Default, Clone, Debug)] pub struct WgpuResources { pub buffer_infos: Arc>>, pub texture_descriptors: Arc>>, diff --git a/crates/bevy_window/src/windows.rs b/crates/bevy_window/src/windows.rs index 2166956924..8345a14362 100644 --- a/crates/bevy_window/src/windows.rs +++ b/crates/bevy_window/src/windows.rs @@ -1,7 +1,7 @@ use super::{Window, WindowId}; use bevy_utils::HashMap; -#[derive(Default)] +#[derive(Debug, Default)] pub struct Windows { windows: HashMap, } diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index 5257ae4a0f..584d0b7027 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -1,5 +1,5 @@ /// A resource for configuring usage of the `rust_winit` library. -#[derive(Default)] +#[derive(Debug, Default)] pub struct WinitConfig { /// Configures the winit library to return control to the main thread after /// the [run](bevy_app::App::run) loop is exited. Winit strongly recommends diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 2cc5390421..e73a98aa79 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -1,7 +1,7 @@ use bevy_utils::HashMap; use bevy_window::{Window, WindowId, WindowMode}; -#[derive(Default)] +#[derive(Debug, Default)] pub struct WinitWindows { pub windows: HashMap, pub window_id_to_winit: HashMap,