use crate::{
binding_model::{BindGroup, BindGroupLayout, PipelineLayout},
command::{CommandBuffer, RenderBundle},
device::{queue::Queue, Device},
instance::Adapter,
pipeline::{ComputePipeline, PipelineCache, RenderPipeline, ShaderModule},
registry::{Registry, RegistryReport},
resource::{
Blas, Buffer, Fallible, QuerySet, Sampler, StagingBuffer, Texture, TextureView, Tlas,
},
};
use std::{fmt::Debug, sync::Arc};
#[derive(Debug, PartialEq, Eq)]
pub struct HubReport {
pub adapters: RegistryReport,
pub devices: RegistryReport,
pub queues: RegistryReport,
pub pipeline_layouts: RegistryReport,
pub shader_modules: RegistryReport,
pub bind_group_layouts: RegistryReport,
pub bind_groups: RegistryReport,
pub command_buffers: RegistryReport,
pub render_bundles: RegistryReport,
pub render_pipelines: RegistryReport,
pub compute_pipelines: RegistryReport,
pub pipeline_caches: RegistryReport,
pub query_sets: RegistryReport,
pub buffers: RegistryReport,
pub textures: RegistryReport,
pub texture_views: RegistryReport,
pub samplers: RegistryReport,
}
impl HubReport {
pub fn is_empty(&self) -> bool {
self.adapters.is_empty()
}
}
#[allow(rustdoc::private_intra_doc_links)]
pub struct Hub {
pub(crate) adapters: Registry<Arc<Adapter>>,
pub(crate) devices: Registry<Arc<Device>>,
pub(crate) queues: Registry<Arc<Queue>>,
pub(crate) pipeline_layouts: Registry<Fallible<PipelineLayout>>,
pub(crate) shader_modules: Registry<Fallible<ShaderModule>>,
pub(crate) bind_group_layouts: Registry<Fallible<BindGroupLayout>>,
pub(crate) bind_groups: Registry<Fallible<BindGroup>>,
pub(crate) command_buffers: Registry<Arc<CommandBuffer>>,
pub(crate) render_bundles: Registry<Fallible<RenderBundle>>,
pub(crate) render_pipelines: Registry<Fallible<RenderPipeline>>,
pub(crate) compute_pipelines: Registry<Fallible<ComputePipeline>>,
pub(crate) pipeline_caches: Registry<Fallible<PipelineCache>>,
pub(crate) query_sets: Registry<Fallible<QuerySet>>,
pub(crate) buffers: Registry<Fallible<Buffer>>,
pub(crate) staging_buffers: Registry<StagingBuffer>,
pub(crate) textures: Registry<Fallible<Texture>>,
pub(crate) texture_views: Registry<Fallible<TextureView>>,
pub(crate) samplers: Registry<Fallible<Sampler>>,
pub(crate) blas_s: Registry<Fallible<Blas>>,
pub(crate) tlas_s: Registry<Fallible<Tlas>>,
}
impl Hub {
pub(crate) fn new() -> Self {
Self {
adapters: Registry::new(),
devices: Registry::new(),
queues: Registry::new(),
pipeline_layouts: Registry::new(),
shader_modules: Registry::new(),
bind_group_layouts: Registry::new(),
bind_groups: Registry::new(),
command_buffers: Registry::new(),
render_bundles: Registry::new(),
render_pipelines: Registry::new(),
compute_pipelines: Registry::new(),
pipeline_caches: Registry::new(),
query_sets: Registry::new(),
buffers: Registry::new(),
staging_buffers: Registry::new(),
textures: Registry::new(),
texture_views: Registry::new(),
samplers: Registry::new(),
blas_s: Registry::new(),
tlas_s: Registry::new(),
}
}
pub fn generate_report(&self) -> HubReport {
HubReport {
adapters: self.adapters.generate_report(),
devices: self.devices.generate_report(),
queues: self.queues.generate_report(),
pipeline_layouts: self.pipeline_layouts.generate_report(),
shader_modules: self.shader_modules.generate_report(),
bind_group_layouts: self.bind_group_layouts.generate_report(),
bind_groups: self.bind_groups.generate_report(),
command_buffers: self.command_buffers.generate_report(),
render_bundles: self.render_bundles.generate_report(),
render_pipelines: self.render_pipelines.generate_report(),
compute_pipelines: self.compute_pipelines.generate_report(),
pipeline_caches: self.pipeline_caches.generate_report(),
query_sets: self.query_sets.generate_report(),
buffers: self.buffers.generate_report(),
textures: self.textures.generate_report(),
texture_views: self.texture_views.generate_report(),
samplers: self.samplers.generate_report(),
}
}
}