Skip to content

Commit

Permalink
Preliminary ash 0.38 from master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jul 19, 2023
1 parent 9ecb39c commit 1f0aa0e
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 97 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "1.0"
presser = { version = "0.3" }
# Only needed for vulkan. Disable all default features as good practice,
# such as the ability to link/load a Vulkan library.
ash = { version = ">=0.34, <=0.37", optional = true, default-features = false, features = ["debug"] }
ash = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444", optional = true, default-features = false, features = ["debug"] }
# Only needed for visualizer.
imgui = { version = "0.11", features = ["tables-api"], optional = true }

Expand All @@ -47,8 +47,8 @@ optional = true

[dev-dependencies]
# Enable the "loaded" feature to be able to access the Vulkan entrypoint.
ash = { version = "0.37", default-features = false, features = ["debug", "loaded"] }
ash-window = "0.12"
ash = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444", default-features = false, features = ["debug", "loaded"] }
ash-window = { git = "https://github.com/ash-rs/ash.git", rev = "6b56444" }
raw-window-handle = "0.5"
winit = { version = "0.28", features = ["x11", "wayland"] }
env_logger = "0.10"
Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand All @@ -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::*;
Expand All @@ -39,15 +38,14 @@ 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()
let vk_info = vk::BufferCreateInfo::default()
.size(512)
.usage(vk::BufferUsageFlags::STORAGE_BUFFER);

Expand All @@ -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::*;
Expand All @@ -83,7 +81,7 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc {
});
```

### Simple d3d12 allocation example
## Simple d3d12 allocation example

```rust
use gpu_allocator::d3d12::*;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions examples/d3d12-visualization/imgui_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};
Expand All @@ -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,
}
};
Expand Down
14 changes: 7 additions & 7 deletions examples/vulkan-buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() {
let instance = {
let app_name = CString::new("Vulkan gpu-allocator test").unwrap();

let appinfo = vk::ApplicationInfo::builder()
let appinfo = vk::ApplicationInfo::default()
.application_name(&app_name)
.application_version(0)
.engine_name(&app_name)
Expand All @@ -33,7 +33,7 @@ fn main() {

let extensions_names_raw = vec![];

let create_info = vk::InstanceCreateInfo::builder()
let create_info = vk::InstanceCreateInfo::default()
.application_info(&appinfo)
.enabled_layer_names(&layers_names_raw)
.enabled_extension_names(&extensions_names_raw);
Expand Down Expand Up @@ -79,11 +79,11 @@ fn main() {
};
let priorities = [1.0];

let queue_info = vk::DeviceQueueCreateInfo::builder()
let queue_info = vk::DeviceQueueCreateInfo::default()
.queue_family_index(queue_family_index as u32)
.queue_priorities(&priorities);

let create_info = vk::DeviceCreateInfo::builder()
let create_info = vk::DeviceCreateInfo::default()
.queue_create_infos(std::slice::from_ref(&queue_info))
.enabled_extension_names(&device_extension_names_raw)
.enabled_features(&features);
Expand All @@ -104,7 +104,7 @@ fn main() {

// Test allocating Gpu Only memory
{
let test_buffer_info = vk::BufferCreateInfo::builder()
let test_buffer_info = vk::BufferCreateInfo::default()
.size(512)
.usage(vk::BufferUsageFlags::STORAGE_BUFFER)
.sharing_mode(vk::SharingMode::EXCLUSIVE);
Expand Down Expand Up @@ -137,7 +137,7 @@ fn main() {

// Test allocating Cpu to Gpu memory
{
let test_buffer_info = vk::BufferCreateInfo::builder()
let test_buffer_info = vk::BufferCreateInfo::default()
.size(512)
.usage(vk::BufferUsageFlags::STORAGE_BUFFER)
.sharing_mode(vk::SharingMode::EXCLUSIVE);
Expand Down Expand Up @@ -170,7 +170,7 @@ fn main() {

// Test allocating Gpu to Cpu memory
{
let test_buffer_info = vk::BufferCreateInfo::builder()
let test_buffer_info = vk::BufferCreateInfo::default()
.size(512)
.usage(vk::BufferUsageFlags::STORAGE_BUFFER)
.sharing_mode(vk::SharingMode::EXCLUSIVE);
Expand Down
4 changes: 2 additions & 2 deletions examples/vulkan-visualization/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub(crate) fn record_and_submit_command_buffer<F: FnOnce(&ash::Device, vk::Comma
.unwrap();

let command_buffer_begin_info =
vk::CommandBufferBeginInfo::builder().flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT);
vk::CommandBufferBeginInfo::default().flags(vk::CommandBufferUsageFlags::ONE_TIME_SUBMIT);
unsafe { device.begin_command_buffer(command_buffer, &command_buffer_begin_info) }.unwrap();

f(device, command_buffer);

unsafe { device.end_command_buffer(command_buffer) }.unwrap();

let command_buffers = [command_buffer];
let submit_info = vk::SubmitInfo::builder()
let submit_info = vk::SubmitInfo::default()
.wait_semaphores(wait_semaphores)
.wait_dst_stage_mask(wait_mask)
.command_buffers(&command_buffers)
Expand Down
Loading

0 comments on commit 1f0aa0e

Please sign in to comment.