Skip to content

Commit

Permalink
🥳 Upgrade to ash 0.38
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jun 12, 2024
1 parent 52b88cd commit 8ba4132
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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 = { version = "0.38", optional = true, default-features = false, features = ["debug"] }
# Only needed for visualizer.
egui = { version = ">=0.24, <=0.27", optional = true, default-features = false }
egui_extras = { version = ">=0.24, <=0.27", optional = true, default-features = false }
Expand All @@ -54,7 +54,7 @@ optional = true

[dev-dependencies]
# Enable the "loaded" feature to be able to access the Vulkan entrypoint.
ash = { version = ">=0.34,<=0.37", default-features = false, features = ["debug", "loaded"] }
ash = { version = "0.38", default-features = false, features = ["debug", "loaded"] }
env_logger = "0.10"

[target.'cfg(windows)'.dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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 Down
21 changes: 9 additions & 12 deletions examples/vulkan-buffer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::default::Default;
use std::ffi::CStr;

use ash::vk;
use log::info;
Expand All @@ -16,20 +15,18 @@ fn main() {

// Create Vulkan instance
let instance = {
let app_name = CStr::from_bytes_with_nul(b"Vulkan gpu-allocator test\0").unwrap();
let app_name = c"Vulkan gpu-allocator test";

let appinfo = vk::ApplicationInfo::builder()
let appinfo = vk::ApplicationInfo::default()
.application_name(app_name)
.application_version(0)
.engine_name(app_name)
.engine_version(0)
.api_version(vk::make_api_version(0, 1, 0, 0));

let layer_names_raw = [CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0")
.unwrap()
.as_ptr()];
let layer_names_raw = [c"VK_LAYER_KHRONOS_validation".as_ptr()];

let create_info = vk::InstanceCreateInfo::builder()
let create_info = vk::InstanceCreateInfo::default()
.application_info(&appinfo)
.enabled_layer_names(&layer_names_raw);

Expand Down Expand Up @@ -74,11 +71,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 @@ -99,7 +96,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 @@ -132,7 +129,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 @@ -165,7 +162,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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
//! # }).unwrap();
//!
//! // Setup vulkan info
//! let vk_info = vk::BufferCreateInfo::builder()
//! let vk_info = vk::BufferCreateInfo::default()
//! .size(512)
//! .usage(vk::BufferUsageFlags::STORAGE_BUFFER);
//!
Expand Down
10 changes: 5 additions & 5 deletions src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,12 @@ impl MemoryBlock {
requires_personal_block: bool,
) -> Result<Self> {
let device_memory = {
let alloc_info = vk::MemoryAllocateInfo::builder()
let alloc_info = vk::MemoryAllocateInfo::default()
.allocation_size(size)
.memory_type_index(mem_type_index as u32);

let allocation_flags = vk::MemoryAllocateFlags::DEVICE_ADDRESS;
let mut flags_info = vk::MemoryAllocateFlagsInfo::builder().flags(allocation_flags);
let mut flags_info = vk::MemoryAllocateFlagsInfo::default().flags(allocation_flags);
// TODO(manon): Test this based on if the device has this feature enabled or not
let alloc_info = if buffer_device_address {
alloc_info.push_next(&mut flags_info)
Expand All @@ -366,7 +366,7 @@ impl MemoryBlock {
};

// Flag the memory as dedicated if required.
let mut dedicated_memory_info = vk::MemoryDedicatedAllocateInfo::builder();
let mut dedicated_memory_info = vk::MemoryDedicatedAllocateInfo::default();
let alloc_info = match allocation_scheme {
AllocationScheme::DedicatedBuffer(buffer) => {
dedicated_memory_info = dedicated_memory_info.buffer(buffer);
Expand Down Expand Up @@ -748,8 +748,8 @@ impl Allocator {
.get_physical_device_memory_properties(desc.physical_device)
};

let memory_types = &mem_props.memory_types[..mem_props.memory_type_count as _];
let memory_heaps = mem_props.memory_heaps[..mem_props.memory_heap_count as _].to_vec();
let memory_types = &mem_props.memory_types_as_slice();
let memory_heaps = mem_props.memory_heaps_as_slice().to_vec();

if desc.debug_settings.log_memory_information {
debug!("memory type count: {}", mem_props.memory_type_count);
Expand Down

0 comments on commit 8ba4132

Please sign in to comment.