phobos/
lib.rs

1//! Fast, powerful Vulkan abstraction library
2//!
3//! Phobos provides powerful Vulkan abstractions to automatically manage common issues like
4//! synchronization and resource management. It hides away a lot of boilerplate that comes with
5//! Vulkan, while still being highly flexible.
6//!
7//! To get started, the easiest way is to simply
8//! ```
9//! // Import all important traits
10//! use phobos::prelude::traits;
11//! // Import types under a namespace.
12//! use phobos::prelude as ph;
13//!
14//! // Or, if you dont care about using the types under a namespace
15//! use phobos::prelude::*;
16//! ```
17//!
18//! # Example
19//!
20//! For illustrative purposes, we will use winit here. Any windowing library can be supported by implementing a few trait objects
21//! necessary to satisfy the [`WindowInterface`](crate::WindowInterface) trait.
22//! ```
23//! use winit::window::WindowBuilder;
24//! use winit::event_loop::EventLoopBuilder;
25//! let event_loop = EventLoopBuilder::new().build();
26//! let window = WindowBuilder::new()
27//!     .with_title("Phobos test app")
28//!     .build(&event_loop)
29//!     .unwrap();
30//! ```
31//! First, we will define an [`AppSettings`](crate::AppSettings) structure that outlines requirements
32//! and information about our application. Phobos will use this to
33//! pick a suitable GPU to run your program on and initialize Vulkan for it.
34//! ```
35//! use phobos::prelude::*;
36//!
37//! let settings = AppBuilder::new()
38//!         .version((1, 0, 0))
39//!         .name("Phobos demo app")
40//!         .validation(true)
41//!         .window(&window)
42//!         .present_mode(vk::PresentModeKHR::MAILBOX)
43//!         .scratch_size(1 * 1024u64) // 1 KiB scratch memory per buffer type per frame
44//!         .gpu(GPURequirements {
45//!             dedicated: true,
46//!             min_video_memory: 1 * 1024 * 1024 * 1024, // 1 GiB.
47//!             min_dedicated_video_memory: 1 * 1024 * 1024 * 1024,
48//!             queues: vec![
49//!                 QueueRequest { dedicated: false, queue_type: QueueType::Graphics },
50//!                 QueueRequest { dedicated: true, queue_type: QueueType::Transfer },
51//!                 QueueRequest { dedicated: true, queue_type: QueueType::Compute }
52//!             ],
53//!             ..Default::default()
54//!         })
55//!         .build();
56//! ```
57//! Now we are ready to initialize the Phobos library.
58//! ```
59//! use phobos::prelude::*;
60//! let (
61//!     instance,
62//!     physical_device,
63//!     surface,
64//!     device,
65//!     allocator,
66//!     exec,
67//!     frame,
68//!     Some(debug_messenger)
69//! ) = WindowedContext::init(&settings)? else {
70//!     panic!("Asked for debug messenger but didn't get one.")
71//! };
72//!
73//! ```
74//! For more initialization options, see [`initialize()`], [`initialize_with_allocator()`] and
75//! [`WindowedContext::init_with_allocator()`](crate::core::init::WindowedContext::init_with_allocator).
76//!
77//! For further example code, check out the following modules
78//! - [`pipeline`] for pipeline creation and management.
79//! - [`wsi`] for managing your main loop and frame rendering logic.
80//! - [`graph`] for creating a pass graph to record commands.
81//! - [`sync`] for various synchronization primitives, threading utilities, gpu futures and queue synchronization.
82//! - [`descriptor`] for descriptor set management.
83//! - [`command_buffer`] for different Vulkan commands available.
84//! - [`allocator`] For various allocators and related utilities.
85//! - [`image`] for managing [`VkImage`](vk::Image) and [`VkImageView`](vk::ImageView) objects.
86//! - [`buffer`] for managing [`VkBuffer`](vk::Buffer) objects.
87//! - [`util`] for various utilities and common patterns like buffer uploads.
88
89#![cfg_attr(feature = "fsr2", feature(new_uninit))]
90#![warn(missing_docs)]
91
92#[macro_use]
93extern crate derivative;
94#[macro_use]
95extern crate log;
96#[macro_use]
97extern crate static_assertions;
98
99pub use crate::prelude::*;
100
101pub mod prelude;
102
103pub mod allocator;
104pub mod command_buffer;
105pub mod core;
106pub mod descriptor;
107pub mod graph;
108pub mod pipeline;
109pub mod resource;
110pub mod sync;
111pub mod util;
112pub mod wsi;
113
114#[cfg(feature = "fsr2")]
115pub mod fsr2;