diff --git a/README.md b/README.md index cc67d1f6..102bc78c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # 📒 gpu-allocator - [![Actions Status](https://img.shields.io/github/actions/workflow/status/Traverse-Research/gpu-allocator/ci.yml?branch=main&logo=github)](https://github.com/Traverse-Research/gpu-allocator/actions) [![Latest version](https://img.shields.io/crates/v/gpu-allocator.svg?logo=rust)](https://crates.io/crates/gpu-allocator) [![Docs](https://img.shields.io/docsrs/gpu-allocator?logo=docs.rs)](https://docs.rs/gpu-allocator/) @@ -17,14 +16,14 @@ gpu-allocator = "0.22.0" This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12. -### [Windows-rs] and [winapi] +## [Windows-rs] and [winapi] `gpu-allocator` recently migrated from [winapi] to [windows-rs] but still provides convenient helpers to convert to and from [winapi] types, enabled when compiling with the `public-winapi` crate feature. [Windows-rs]: https://github.com/microsoft/windows-rs [winapi]: https://github.com/retep998/winapi-rs -### Setting up the Vulkan memory allocator +## Setting up the Vulkan memory allocator ```rust use gpu_allocator::vulkan::*; @@ -39,13 +38,12 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc { }); ``` -### Simple Vulkan allocation example +## Simple Vulkan allocation example ```rust use gpu_allocator::vulkan::*; use gpu_allocator::MemoryLocation; - // Setup vulkan info let vk_info = vk::BufferCreateInfo::builder() .size(512) @@ -71,7 +69,7 @@ allocator.free(allocation).unwrap(); unsafe { device.destroy_buffer(buffer, None) }; ``` -### Setting up the D3D12 memory allocator +## Setting up the D3D12 memory allocator ```rust use gpu_allocator::d3d12::*; @@ -83,7 +81,7 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc { }); ``` -### Simple d3d12 allocation example +## Simple d3d12 allocation example ```rust use gpu_allocator::d3d12::*; @@ -129,19 +127,20 @@ drop(resource); allocator.free(allocation).unwrap(); ``` -### License +## License Licensed under either of -* Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) +- Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. -### Alternative libraries -* [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) +## Alternative libraries + +- [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 diff --git a/README.tpl b/README.tpl index a0252b64..0ec6e4a3 100644 --- a/README.tpl +++ b/README.tpl @@ -1,6 +1,5 @@ # 📒 gpu-allocator - [![Actions Status](https://img.shields.io/github/actions/workflow/status/Traverse-Research/gpu-allocator/ci.yml?branch=main&logo=github)](https://github.com/Traverse-Research/gpu-allocator/actions) [![Latest version](https://img.shields.io/crates/v/gpu-allocator.svg?logo=rust)](https://crates.io/crates/gpu-allocator) [![Docs](https://img.shields.io/docsrs/gpu-allocator?logo=docs.rs)](https://docs.rs/gpu-allocator/) @@ -17,19 +16,20 @@ gpu-allocator = "0.22.0" {{readme}} -### License +## License Licensed under either of -* Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) +- Apache License, Version 2.0, ([LICENSE-APACHE](../master/LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](../master/LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. -### Alternative libraries -* [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) +## Alternative libraries + +- [vk-mem-rs](https://github.com/gwihlidal/vk-mem-rs) -### Contribution +## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 diff --git a/examples/d3d12-visualization/imgui_renderer.rs b/examples/d3d12-visualization/imgui_renderer.rs index ba9835c1..4643f0cc 100644 --- a/examples/d3d12-visualization/imgui_renderer.rs +++ b/examples/d3d12-visualization/imgui_renderer.rs @@ -790,7 +790,7 @@ impl ImGuiRenderer { D3D12_VERTEX_BUFFER_VIEW { BufferLocation: address, - SizeInBytes: (vertices.len() * stride) as u32, + SizeInBytes: std::mem::size_of_val(vertices) as u32, StrideInBytes: stride as u32, } }; @@ -802,7 +802,7 @@ impl ImGuiRenderer { D3D12_INDEX_BUFFER_VIEW { BufferLocation: address, - SizeInBytes: (indices.len() * stride) as u32, + SizeInBytes: std::mem::size_of_val(indices) as u32, Format: all_dxgi::DXGI_FORMAT_R16_UINT, } }; diff --git a/src/lib.rs b/src/lib.rs index 64ca125e..636e239f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,13 @@ //! This crate provides a fully written in Rust memory allocator for Vulkan and DirectX 12. //! -//! ## [Windows-rs] and [winapi] +//! # [Windows-rs] and [winapi] //! //! `gpu-allocator` recently migrated from [winapi] to [windows-rs] but still provides convenient helpers to convert to and from [winapi] types, enabled when compiling with the `public-winapi` crate feature. //! //! [Windows-rs]: https://github.com/microsoft/windows-rs //! [winapi]: https://github.com/retep998/winapi-rs //! -//! ## Setting up the Vulkan memory allocator +//! # Setting up the Vulkan memory allocator //! //! ```no_run //! # #[cfg(feature = "vulkan")] @@ -31,7 +31,7 @@ //! # fn main() {} //! ``` //! -//! ## Simple Vulkan allocation example +//! # Simple Vulkan allocation example //! //! ```no_run //! # #[cfg(feature = "vulkan")] @@ -42,7 +42,6 @@ //! # let device = todo!(); //! # let instance = todo!(); //! # let physical_device = todo!(); -//! //! # let mut allocator = Allocator::new(&AllocatorCreateDesc { //! # instance, //! # device, @@ -80,7 +79,7 @@ //! # fn main() {} //! ``` //! -//! ## Setting up the D3D12 memory allocator +//! # Setting up the D3D12 memory allocator //! //! ```no_run //! # #[cfg(feature = "d3d12")] @@ -98,7 +97,7 @@ //! # fn main() {} //! ``` //! -//! ## Simple d3d12 allocation example +//! # Simple d3d12 allocation example //! //! ```no_run //! # #[cfg(feature = "d3d12")]