Phobos

build

Phobos is a Vulkan abstraction library aiming to create Vulkan applications more easily. It provides abstractions to automatically manage common Vulkan problems like synchronization and resource management. At the same time, it aims to expose the full Vulkan API without major limitations.

At the moment, the project is highly WIP, and not all these goals have been fully achieved yet. It is developed together with a rendering engine using it, so features are currently added as needed.

What does Phobos do?

What does Phobos not do?

Example

For more elaborate examples, please check the examples folder.

```rust use phobos::prelude::*;

fn main() { // Fill out app settings for initialization let settings = AppBuilder::new() .version((1, 0, 0)) .name("Phobos example app") .validation(true) .window(&window) // Your winit window, or some other interface. .presentmode(vk::PresentModeKHR::MAILBOX) .scratchsize(1024u64) .gpu(ph::GPURequirements { dedicated: true, queues: vec![ QueueRequest { dedicated: false, queuetype: QueueType::Graphics }, QueueRequest { dedicated: true, queuetype: QueueType::Transfer }, QueueRequest { dedicated: true, queue_type: QueueType::Compute } ], ..Default::default() }) .build();

// Initialize Vulkan. There are other ways to initialize, for example // with a custom allocator, or without a window context. See the core::init module for this // functionality. use phobos::prelude::*; let ( instance, physicaldevice, surface, device allocator, exec, frame, Some(debugmessenger) ) = WindowedContext::init(&settings)? else { panic!("Asked for debug messenger but didn't get one.") };

// Create a new pass graph for rendering. Note how we only do this once, as // we are using virtual resources that do not depend on the frame. let swapchain = VirtualResource::image("swapchain"); let clearpass = PassBuilder::render("clear") .colorattachment(&swapchain, vk::AttachmentLoadOp::CLEAR, // Clear the swapchain to red. Some(vk::ClearColorValue { float32: [1.0, 0.0, 0.0, 1.0] }))? .build(); let presentpass = PassBuilder::present("present", clearpass.output(&swapchain).unwrap()); let graph = PassGraph::new() .addpass(clearpass)? .addpass(presentpass)? .build()?; // Your event loop goes here while eventloop { // Wait for a new frame to be available. Once there is one, the provided // callback will be called. futures::executor::blockon(frame.newframe(exec.clone(), window, &surface, |mut ifc| { // Bind some physical resources to the render graph. let mut bindings = PhysicalResourceBindings::new(); bindings.bindimage("swapchain", &ifc.swapchainimage.asref().unwrap()); let cmd = exec.on_domain::(None, None)?; // Record render graph to our command buffer graph.record(cmd, &bindings, &mut ifc, None, &mut ()).finish() }))?; } } ```

Support

Visit the docs.rs page, or open an issue.

Planned features