Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ash to 0.38 #377

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ license = "Apache-2.0 OR Zlib"
common = { path = "../common" }
server = { path = "../server" }
tracing = "0.1.10"
ash = { version = "0.37.1", features = ["loaded"] }
lahar = { git = "https://github.com/Ralith/lahar", rev = "88abd75e41d04c3a4199d95f581cb135f5962844" }
winit = { version = "0.29.10", features = ["rwh_05"] }
ash-window = "0.12.0"
raw-window-handle = { version = "0.5.0", features = ["std"] }
ash = { version = "0.38.0", default-features = false, features = ["loaded", "debug", "std"] }
lahar = { git = "https://github.com/Ralith/lahar", rev = "7963ae5750ea61fa0a894dbb73d3be0ac77255d2" }
winit = "0.29.10"
ash-window = "0.13"
raw-window-handle = "0.6"
directories = "5.0.1"
vk-shader-macros = "0.2.5"
nalgebra = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions client/benches/surface_extraction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ fn extract(bench: &mut Bencher) {
unsafe {
let cmd_pool = device
.create_command_pool(
&vk::CommandPoolCreateInfo::builder().queue_family_index(gfx.queue_family),
&vk::CommandPoolCreateInfo::default().queue_family_index(gfx.queue_family),
None,
)
.unwrap();

let cmd = device
.allocate_command_buffers(
&vk::CommandBufferAllocateInfo::builder()
&vk::CommandBufferAllocateInfo::default()
.command_pool(cmd_pool)
.command_buffer_count(1),
)
Expand Down Expand Up @@ -59,7 +59,7 @@ fn extract(bench: &mut Bencher) {
device
.queue_submit(
gfx.queue,
&[vk::SubmitInfo::builder().command_buffers(&[cmd]).build()],
&[vk::SubmitInfo::default().command_buffers(&[cmd])],
vk::Fence::null(),
)
.unwrap();
Expand Down
49 changes: 25 additions & 24 deletions client/src/graphics/base.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//! Common state shared throughout the graphics system

use ash::ext::debug_utils;
use std::ffi::{c_char, CStr};
use std::path::PathBuf;
use std::sync::Arc;
use std::{fs, io, ptr};
use std::{fs, io};
use tracing::{error, info, trace, warn};

use ash::{vk, Device};
Expand Down Expand Up @@ -34,6 +35,7 @@ pub struct Base {
pub limits: vk::PhysicalDeviceLimits,
pub timestamp_bits: u32,
pipeline_cache_path: Option<PathBuf>,
debug_utils: Option<debug_utils::Device>,
}

unsafe impl Send for Base {}
Expand Down Expand Up @@ -133,11 +135,10 @@ impl Base {
instance
.create_device(
physical,
&vk::DeviceCreateInfo::builder()
.queue_create_infos(&[vk::DeviceQueueCreateInfo::builder()
&vk::DeviceCreateInfo::default()
.queue_create_infos(&[vk::DeviceQueueCreateInfo::default()
.queue_family_index(queue_family_index)
.queue_priorities(&[1.0])
.build()])
.queue_priorities(&[1.0])])
.enabled_extension_names(&device_exts),
None,
)
Expand All @@ -147,14 +148,14 @@ impl Base {
let memory_properties = instance.get_physical_device_memory_properties(physical);
let pipeline_cache = device
.create_pipeline_cache(
&vk::PipelineCacheCreateInfo::builder().initial_data(&pipeline_cache_data),
&vk::PipelineCacheCreateInfo::default().initial_data(&pipeline_cache_data),
None,
)
.unwrap();

let render_pass = device
.create_render_pass(
&vk::RenderPassCreateInfo::builder()
&vk::RenderPassCreateInfo::default()
.attachments(&[
vk::AttachmentDescription {
format: COLOR_FORMAT,
Expand All @@ -176,7 +177,7 @@ impl Base {
},
])
.subpasses(&[
vk::SubpassDescription::builder()
vk::SubpassDescription::default()
.color_attachments(&[vk::AttachmentReference {
attachment: 0,
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
Expand All @@ -185,9 +186,8 @@ impl Base {
attachment: 1,
layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
})
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
.build(),
vk::SubpassDescription::builder()
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS),
vk::SubpassDescription::default()
.color_attachments(&[vk::AttachmentReference {
attachment: 0,
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
Expand All @@ -196,8 +196,7 @@ impl Base {
attachment: 1,
layout: vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL,
}])
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
.build(),
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS),
])
.dependencies(&[
vk::SubpassDependency {
Expand Down Expand Up @@ -225,7 +224,7 @@ impl Base {

let linear_sampler = device
.create_sampler(
&vk::SamplerCreateInfo::builder()
&vk::SamplerCreateInfo::default()
.min_filter(vk::Filter::LINEAR)
.mag_filter(vk::Filter::LINEAR)
.mipmap_mode(vk::SamplerMipmapMode::NEAREST)
Expand All @@ -238,28 +237,32 @@ impl Base {

let common_layout = device
.create_descriptor_set_layout(
&vk::DescriptorSetLayoutCreateInfo::builder().bindings(&[
&vk::DescriptorSetLayoutCreateInfo::default().bindings(&[
// Uniforms
vk::DescriptorSetLayoutBinding {
binding: 0,
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
descriptor_count: 1,
stage_flags: vk::ShaderStageFlags::VERTEX
| vk::ShaderStageFlags::FRAGMENT,
p_immutable_samplers: ptr::null(),
..Default::default()
},
// Depth buffer
vk::DescriptorSetLayoutBinding {
binding: 1,
descriptor_type: vk::DescriptorType::INPUT_ATTACHMENT,
descriptor_count: 1,
stage_flags: vk::ShaderStageFlags::FRAGMENT,
p_immutable_samplers: ptr::null(),
..Default::default()
},
]),
None,
)
.unwrap();
let debug_utils = core
.debug_utils
.as_ref()
.map(|_| debug_utils::Device::new(&core.instance, &device));

Some(Self {
core,
Expand All @@ -275,6 +278,7 @@ impl Base {
pipeline_cache_path,
limits: physical_properties.properties.limits,
timestamp_bits: queue_family_properties.timestamp_valid_bits,
debug_utils,
})
}
}
Expand All @@ -301,15 +305,12 @@ impl Base {

/// Set an object's name for use in diagnostics
pub unsafe fn set_name<T: vk::Handle>(&self, object: T, name: &CStr) {
let ex = match self.core.debug_utils.as_ref() {
Some(x) => x,
None => return,
let Some(ref ex) = self.debug_utils else {
return;
};
ex.set_debug_utils_object_name(
self.device.handle(),
&vk::DebugUtilsObjectNameInfoEXT::builder()
.object_type(T::TYPE)
.object_handle(object.as_raw())
&vk::DebugUtilsObjectNameInfoEXT::default()
.object_handle(object)
.object_name(name),
)
.unwrap();
Expand Down
16 changes: 8 additions & 8 deletions client/src/graphics/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::os::raw::c_void;
use std::ptr;
use std::slice;

use ash::extensions::ext::DebugUtils;
use ash::ext::debug_utils;
use ash::{vk, Entry, Instance};
use tracing::{debug, error, info, trace, warn};

Expand All @@ -20,7 +20,7 @@ pub struct Core {
/// Diagnostic infrastructure, configured if the environment supports them. Typically present
/// when the Vulkan validation layers are enabled or a graphics debugger is in use and absent
/// otherwise.
pub debug_utils: Option<DebugUtils>,
pub debug_utils: Option<debug_utils::Instance>,
messenger: vk::DebugUtilsMessengerEXT,
}

Expand All @@ -43,11 +43,11 @@ impl Core {
let supported_exts = entry.enumerate_instance_extension_properties(None).unwrap();
let has_debug = supported_exts
.iter()
.any(|x| CStr::from_ptr(x.extension_name.as_ptr()) == DebugUtils::name());
.any(|x| CStr::from_ptr(x.extension_name.as_ptr()) == debug_utils::NAME);

let mut exts = exts.to_vec();
if has_debug {
exts.push(DebugUtils::name().as_ptr());
exts.push(debug_utils::NAME.as_ptr());
} else {
info!("vulkan debugging unavailable");
}
Expand All @@ -63,17 +63,17 @@ impl Core {

let name = cstr!("hypermine");

let app_info = vk::ApplicationInfo::builder()
let app_info = vk::ApplicationInfo::default()
.application_name(name)
.application_version(0)
.engine_name(name)
.engine_version(0)
.api_version(vk::make_api_version(0, 1, 1, 0));
let mut instance_info = vk::InstanceCreateInfo::builder()
let mut instance_info = vk::InstanceCreateInfo::default()
.application_info(&app_info)
.enabled_extension_names(&exts);

let mut debug_utils_messenger_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
let mut debug_utils_messenger_info = vk::DebugUtilsMessengerCreateInfoEXT::default()
.message_severity(
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
Expand All @@ -98,7 +98,7 @@ impl Core {
let messenger;
if has_debug {
// Configure Vulkan diagnostic message logging
let utils = DebugUtils::new(&entry, &instance);
let utils = debug_utils::Instance::new(&entry, &instance);
messenger = utils
.create_debug_utils_messenger(&debug_utils_messenger_info, None)
.unwrap();
Expand Down
Loading
Loading