Skip to content

Commit

Permalink
Add basic VMA example
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMayes committed Sep 5, 2024
1 parent 6c190d2 commit f17d6d0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ext/vma/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
// SPDX-License-Identifier: Apache-2.0

//! An integration of [Vulkan Memory Allocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) with [`vulkanalia`](https://github.com/KyleMayes/vulkanalia).
//!
//! ### Example
//!
//! ```
//! use vulkanalia::prelude::v1_0::*;
//! use vulkanalia_vma::{self as vma, Alloc};
//!
//! fn example(instance: &Instance, device: &Device, physical_device: vk::PhysicalDevice) {
//! // Create an allocator.
//! let allocator_options = vma::AllocatorOptions::new(instance, device, physical_device);
//! let allocator = unsafe { vma::Allocator::new(&allocator_options) }.unwrap();
//!
//! // Allocate a buffer using the allocator.
//! let buffer_create_info = vk::BufferCreateInfo::builder()
//! .size(65_536)
//! .usage(vk::BufferUsageFlags::VERTEX_BUFFER)
//! .sharing_mode(vk::SharingMode::CONCURRENT);
//! let allocation_options = vma::AllocationOptions::default();
//! let (buffer, allocation) = unsafe { allocator.create_buffer(buffer_create_info, &allocation_options) }.unwrap();
//!
//! // Deallocate the buffer using the allocator.
//! unsafe { allocator.destroy_buffer(buffer, allocation) };
//! }
//! ```

#![no_std]
#![allow(clippy::missing_safety_doc)]
Expand Down

0 comments on commit f17d6d0

Please sign in to comment.