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