The Great Debuggening (#632)

The Great Debuggening
This commit is contained in:
Grayson Burton 2020-10-08 11:43:01 -07:00 committed by GitHub
parent a92790c011
commit 354d71cc1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
79 changed files with 339 additions and 71 deletions

View File

@ -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;

View File

@ -83,7 +83,6 @@ fn map_instance_event<T>(event_instance: &EventInstance<T>) -> &T {
}
/// Reads events of type `T` in order and tracks which events have already been read.
#[derive(Debug)]
pub struct EventReader<T> {
last_event_count: usize,
_marker: PhantomData<T>,

View File

@ -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<T: Resource> {
Created { handle: Handle<T> },
Modified { handle: Handle<T> },
@ -15,6 +16,7 @@ pub enum AssetEvent<T: Resource> {
}
/// Stores Assets of a given type and tracks changes to them.
#[derive(Debug)]
pub struct Assets<T: Resource> {
assets: HashMap<Handle<T>, T>,
events: Events<AssetEvent<T>>,

View File

@ -33,6 +33,7 @@ pub trait AssetLoader<T>: Send + Sync + 'static {
}
/// The result of loading an asset of type `T`
#[derive(Debug)]
pub struct AssetResult<T: 'static> {
pub result: Result<T, AssetLoadError>,
pub handle: Handle<T>,
@ -41,6 +42,7 @@ pub struct AssetResult<T: 'static> {
}
/// A channel to send and receive [AssetResult]s
#[derive(Debug)]
pub struct AssetChannel<T: 'static> {
pub sender: Sender<AssetResult<T>>,
pub receiver: Receiver<AssetResult<T>>,

View File

@ -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<P = AudioSource>
@ -14,6 +14,17 @@ where
queue: RwLock<VecDeque<Handle<P>>>,
}
impl<P> fmt::Debug for AudioOutput<P>
where
P: Decodable,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("AudioOutput")
.field("queue", &self.queue)
.finish()
}
}
impl<P> Default for AudioOutput<P>
where
P: Decodable,

View File

@ -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]>,
}

View File

@ -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<Cow<'static, str>, Vec<Entity>>,
entity_labels: HashMap<Entity, HashSet<Cow<'static, str>>>,

View File

@ -103,7 +103,7 @@ impl Diagnostic {
}
/// A collection of [Diagnostic]s
#[derive(Default)]
#[derive(Debug, Default)]
pub struct Diagnostics {
diagnostics: HashMap<DiagnosticId, Diagnostic>,
}

View File

@ -15,7 +15,7 @@ struct SystemRunInfo {
stop: Instant,
}
#[derive(Default)]
#[derive(Debug, Default)]
struct SystemProfiles {
diagnostic_id: DiagnosticId,
history: Vec<SystemRunInfo>,
@ -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<RwLock<HashMap<Cow<'static, str>, SystemProfiles>>>,
}

View File

@ -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,
}

View File

@ -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<T>(NonNull<T>);
impl<'a, T: Resource> FetchResource<'a> for FetchResourceRead<T> {
@ -229,6 +231,7 @@ impl<'a, T: Resource> ResourceQuery for ChangedRes<'a, T> {
}
/// Fetches a shared resource reference
#[derive(Debug)]
pub struct FetchResourceChanged<T>(NonNull<T>);
impl<'a, T: Resource> FetchResource<'a> for FetchResourceChanged<T> {
@ -263,6 +266,7 @@ impl<'a, T: Resource> ResourceQuery for ResMut<'a, T> {
}
/// Fetches a unique resource reference
#[derive(Debug)]
pub struct FetchResourceWrite<T>(NonNull<T>);
impl<'a, T: Resource> FetchResource<'a> for FetchResourceWrite<T> {
@ -300,6 +304,7 @@ impl<'a, T: Resource + FromResources> ResourceQuery for Local<'a, T> {
}
/// Fetches a `Local<T>` resource reference
#[derive(Debug)]
pub struct FetchResourceLocalMut<T>(NonNull<T>);
impl<'a, T: Resource + FromResources> FetchResource<'a> for FetchResourceLocalMut<T> {
@ -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>(T);
#[derive(Debug)]
pub struct FetchResourceOr<T>(NonNull<T>);
macro_rules! tuple_impl_or {

View File

@ -9,19 +9,21 @@ use std::ptr::NonNull;
pub trait Resource: Send + Sync + 'static {}
impl<T: Send + Sync + 'static> Resource for T {}
#[derive(Debug)]
pub(crate) struct ResourceData {
archetype: Archetype,
default_index: Option<usize>,
system_id_to_archetype_index: HashMap<usize, usize>,
}
#[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<TypeId, ResourceData>,
}

View File

@ -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<Cow<'static, str>>) {
let stage: Cow<str> = stage.into();

View File

@ -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<dyn ResourcesWriter>),
}
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<Self>, world: &mut World);
}
#[derive(Debug)]
pub(crate) struct Spawn<T>
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<T>
where
T: Component,
@ -93,6 +111,7 @@ where
}
}
#[derive(Debug)]
pub(crate) struct RemoveOne<T>
where
T: Component,
@ -112,6 +131,7 @@ where
}
}
#[derive(Debug)]
pub(crate) struct Remove<T>
where
T: Bundle + Send + Sync + 'static,
@ -143,6 +163,7 @@ impl<T: Resource> ResourcesWriter for InsertResource<T> {
}
}
#[derive(Debug)]
pub(crate) struct InsertLocalResource<T: Resource> {
resource: T,
system_id: SystemId,
@ -154,7 +175,7 @@ impl<T: Resource> ResourcesWriter for InsertLocalResource<T> {
}
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct CommandsInternal {
pub commands: Vec<Command>,
pub current_entity: Option<Entity>,
@ -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<Mutex<CommandsInternal>>,
}

View File

@ -7,6 +7,7 @@ use crate::{
use bevy_hecs::{Fetch, Query as HecsQuery, World};
use std::borrow::Cow;
#[derive(Debug)]
pub(crate) struct SystemFn<State, F, ThreadLocalF, Init, SetArchetypeAccess>
where
F: FnMut(&World, &Resources, &ArchetypeAccess, &mut State) + Send + Sync,

View File

@ -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<Q>,
}
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<ChunkIter<Q>>,
}
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<Q: HecsQuery> {
len: usize,
}
impl<Q: HecsQuery> fmt::Debug for ChunkIter<Q>
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<Q: HecsQuery> ChunkIter<Q> {
#[inline]
unsafe fn next<'a>(&mut self) -> Option<<Q::Fetch as Fetch<'a>>::Item> {
@ -363,6 +399,18 @@ pub struct Batch<'q, Q: HecsQuery> {
state: ChunkIter<Q>,
}
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 = <Q::Fetch as Fetch<'q>>::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,

View File

@ -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<Entity>,

View File

@ -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<Mutex<GilrsSendWrapper>>);
impl GilrsArcMutexWrapper {

View File

@ -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<Mesh> for GltfLoader {

View File

@ -1,5 +1,6 @@
use std::{collections::HashMap, hash::Hash};
#[derive(Debug)]
pub struct Axis<T> {
axis_data: HashMap<T, f32>,
}

View File

@ -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,

View File

@ -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],

View File

@ -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,

View File

@ -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<BufferId>,
staging_buffer: Option<BufferId>,

View File

@ -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::<Vec<_>>();
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 {

View File

@ -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,
}

View File

@ -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<String, PropertyTypeRegistration>,
short_names: HashMap<String, String>,
@ -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<Box<dyn Property>, erased_serde::Error>),
)
.field("short_name", &self.short_name)
.field("name", &self.name)
.finish()
}
}
impl PropertyTypeRegistration {
pub fn of<T: Property + DeserializeProperty>() -> Self {
let ty = TypeId::of::<T>();

View File

@ -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<TKey: Key> BatchKey<TKey> {
}
}
#[derive(Debug)]
pub struct BatcherKeyState<TKey: Key> {
batch_key: Option<BatchKey<TKey>>,
keys: SmallVec<[Option<TKey>; 2]>,
@ -77,6 +78,28 @@ where
pub key_count: usize,
}
impl<TKey: Key, TValue, TData> fmt::Debug for Batcher<TKey, TValue, TData>
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::<Vec<_>>();
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<TKey, TValue, TData> Batcher<TKey, TValue, TData>
where
TKey: Key,

View File

@ -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<String, Option<Entity>>,
}

View File

@ -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<PipelineDescriptor>>,
pub shaders: ResMut<'a, Assets<Shader>>,
@ -151,6 +152,7 @@ impl<'a> ResourceQuery for DrawContext<'a> {
type Fetch = FetchDrawContext;
}
#[derive(Debug)]
pub struct FetchDrawContext;
// TODO: derive this impl

View File

@ -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,

View File

@ -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],

View File

@ -44,11 +44,13 @@ pub struct ShaderSpecialization {
pub shader_defs: HashSet<String>,
}
#[derive(Debug)]
struct SpecializedShader {
shader: Handle<Shader>,
specialization: ShaderSpecialization,
}
#[derive(Debug)]
struct SpecializedPipeline {
pipeline: Handle<PipelineDescriptor>,
specialization: PipelineSpecialization,
@ -60,7 +62,7 @@ pub struct DynamicBinding {
pub binding: u32,
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct PipelineCompiler {
specialized_shaders: HashMap<Handle<Shader>, Vec<SpecializedShader>>,
specialized_pipelines: HashMap<Handle<PipelineDescriptor>, Vec<SpecializedPipeline>>,

View File

@ -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<PipelineDescriptor>,
@ -35,7 +35,7 @@ impl RenderPipeline {
}
}
#[derive(Properties, Clone)]
#[derive(Debug, Properties, Clone)]
pub struct RenderPipelines {
pub pipelines: Vec<RenderPipeline>,
#[property(ignore)]

View File

@ -46,7 +46,7 @@ pub struct VertexAttributeDescriptor {
pub shader_location: u32,
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct VertexBufferDescriptors {
pub descriptors: HashMap<String, VertexBufferDescriptor>,
}

View File

@ -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,

View File

@ -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<Mutex<Vec<Command>>>,

View File

@ -40,6 +40,7 @@ pub trait SystemNode: Node {
fn get_system(&self, commands: &mut Commands) -> Box<dyn System>;
}
#[derive(Debug)]
pub struct Edges {
pub id: NodeId,
pub input_edges: Vec<Edge>,

View File

@ -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>,

View File

@ -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<BindGroupId>,
@ -32,6 +33,36 @@ pub struct PassNode<Q: HecsQuery> {
_marker: PhantomData<Q>,
}
impl<Q: HecsQuery> fmt::Debug for PassNode<Q> {
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<Q: HecsQuery> PassNode<Q> {
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<Handle<PipelineDescriptor>>,
bind_groups: Vec<Option<BindGroupId>>,

View File

@ -4,7 +4,7 @@ use crate::{
};
use bevy_ecs::{Resources, World};
#[derive(Default)]
#[derive(Debug, Default)]
pub struct SharedBuffersNode;
impl Node for SharedBuffersNode {

View File

@ -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,

View File

@ -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<RwLock<HashMap<BufferId, BufferInfo>>>,
texture_descriptors: Arc<RwLock<HashMap<TextureId, TextureDescriptor>>>,

View File

@ -28,7 +28,7 @@ impl BindGroup {
}
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct BindGroupBuilder {
pub indexed_bindings: Vec<IndexedBindGroupEntry>,
pub dynamic_uniform_indices: Vec<u32>,

View File

@ -253,7 +253,7 @@ impl RenderResourceBindings {
}
}
#[derive(Default)]
#[derive(Debug, Default)]
pub struct AssetRenderResourceBindings {
pub bindings: HashMap<HandleUntyped, RenderResourceBindings>,
}

View File

@ -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<u8>,
pub size: Vec2,

View File

@ -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<RwLock<PropertyTypeRegistry>>,
}

View File

@ -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<Entity>,
}
#[derive(Debug)]
pub struct Entity {
pub entity: u32,
pub components: Vec<DynamicProperties>,

View File

@ -7,6 +7,7 @@ use bevy_utils::HashMap;
use thiserror::Error;
use uuid::Uuid;
#[derive(Debug)]
struct InstanceInfo {
entity_map: HashMap<u32, bevy_ecs::Entity>,
}

View File

@ -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,
}

View File

@ -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]

View File

@ -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)]

View File

@ -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<Texture>,
@ -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,

View File

@ -9,6 +9,7 @@ use rectangle_pack::{
};
use thiserror::Error;
#[derive(Debug)]
pub struct TextureAtlasBuilder {
pub textures: Vec<Handle<Texture>>,
pub rects_to_place: GroupedRectsToPlace<Handle<Texture>>,

View File

@ -1,5 +1,6 @@
use crate::iter::ParallelIterator;
#[derive(Debug)]
pub struct Chain<T, U> {
pub(crate) left: T,
pub(crate) right: U,
@ -25,6 +26,7 @@ where
}
}
#[derive(Debug)]
pub struct Map<P, F> {
pub(crate) iter: P,
pub(crate) f: F,
@ -43,6 +45,7 @@ where
}
}
#[derive(Debug)]
pub struct Filter<P, F> {
pub(crate) iter: P,
pub(crate) predicate: F,
@ -63,6 +66,7 @@ where
}
}
#[derive(Debug)]
pub struct FilterMap<P, F> {
pub(crate) iter: P,
pub(crate) f: F,
@ -81,6 +85,7 @@ where
}
}
#[derive(Debug)]
pub struct FlatMap<P, F> {
pub(crate) iter: P,
pub(crate) f: F,
@ -103,6 +108,7 @@ where
}
}
#[derive(Debug)]
pub struct Flatten<P> {
pub(crate) iter: P,
}
@ -123,6 +129,7 @@ where
}
}
#[derive(Debug)]
pub struct Fuse<P> {
pub(crate) iter: Option<P>,
}
@ -148,6 +155,7 @@ where
}
}
#[derive(Debug)]
pub struct Inspect<P, F> {
pub(crate) iter: P,
pub(crate) f: F,
@ -166,6 +174,7 @@ where
}
}
#[derive(Debug)]
pub struct Copied<P> {
pub(crate) iter: P,
}
@ -183,6 +192,7 @@ where
}
}
#[derive(Debug)]
pub struct Cloned<P> {
pub(crate) iter: P,
}
@ -200,6 +210,7 @@ where
}
}
#[derive(Debug)]
pub struct Cycle<P> {
pub(crate) iter: P,
pub(crate) curr: Option<P>,

View File

@ -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

View File

@ -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<T>(async_executor::Task<T>);
impl<T> Task<T> {

View File

@ -59,6 +59,7 @@ impl TaskPoolBuilder {
}
}
#[derive(Debug)]
struct TaskPoolInner {
threads: Vec<JoinHandle<()>>,
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<async_executor::Task<T>>,

View File

@ -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 {

View File

@ -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,

View File

@ -5,6 +5,7 @@ use bevy_render::{
texture::{Texture, TextureFormat},
};
#[derive(Debug)]
pub struct Font {
pub font: FontVec,
}

View File

@ -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,

View File

@ -39,6 +39,7 @@ where
previous_result
}
#[derive(Debug)]
pub struct DespawnRecursive {
entity: Entity,
}

View File

@ -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<Entity>,

View File

@ -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,

View File

@ -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 {

View File

@ -44,7 +44,7 @@ impl AddAssign<f32> for Val {
}
}
#[derive(Default, Copy, Clone)]
#[derive(Default, Copy, Clone, Debug)]
pub struct CalculatedSize {
pub size: Size,
}

View File

@ -1,2 +1,2 @@
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Button;

View File

@ -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,
}

View File

@ -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<Entity>,
}
#[derive(Default, Clone)]
#[derive(Debug, Default, Clone)]
pub struct Text {
pub value: String,
pub font: Handle<Font>,

View File

@ -15,7 +15,7 @@ use bevy_render::{
use std::sync::Arc;
#[derive(Default)]
#[derive(Debug, Default)]
pub struct LazyCommandEncoder {
command_encoder: Option<wgpu::CommandEncoder>,
}
@ -50,6 +50,7 @@ impl LazyCommandEncoder {
}
}
#[derive(Debug)]
pub struct WgpuRenderContext {
pub device: Arc<wgpu::Device>,
pub command_encoder: LazyCommandEncoder,

View File

@ -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,
}

View File

@ -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<wgpu::Device>,
pub resources: WgpuResources,

View File

@ -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,

View File

@ -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<wgpu::Device>,

View File

@ -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<BindGroupId, wgpu::BindGroup>,
}
@ -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<BufferId, Arc<wgpu::Buffer>>>,
pub textures: RwLockReadGuard<'a, HashMap<TextureId, wgpu::TextureView>>,
@ -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<BufferId, Arc<wgpu::Buffer>>,
pub textures: &'a HashMap<TextureId, wgpu::TextureView>,
@ -67,7 +69,7 @@ pub struct WgpuResourceRefs<'a> {
pub bind_groups: &'a HashMap<BindGroupDescriptorId, WgpuBindGroupInfo>,
}
#[derive(Default, Clone)]
#[derive(Default, Clone, Debug)]
pub struct WgpuResources {
pub buffer_infos: Arc<RwLock<HashMap<BufferId, BufferInfo>>>,
pub texture_descriptors: Arc<RwLock<HashMap<TextureId, TextureDescriptor>>>,

View File

@ -1,7 +1,7 @@
use super::{Window, WindowId};
use bevy_utils::HashMap;
#[derive(Default)]
#[derive(Debug, Default)]
pub struct Windows {
windows: HashMap<WindowId, Window>,
}

View File

@ -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

View File

@ -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<winit::window::WindowId, winit::window::Window>,
pub window_id_to_winit: HashMap<WindowId, winit::window::WindowId>,