Skip to content

Commit 20a6875

Browse files
committed
Update ash to 0.38
1 parent 48103fe commit 20a6875

17 files changed

+199
-226
lines changed

client/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ license = "Apache-2.0 OR Zlib"
1212
common = { path = "../common" }
1313
server = { path = "../server" }
1414
tracing = "0.1.10"
15-
ash = { version = "0.37.1", features = ["loaded"] }
16-
lahar = { git = "https://github.com/Ralith/lahar", rev = "88abd75e41d04c3a4199d95f581cb135f5962844" }
17-
winit = { version = "0.29.10", features = ["rwh_05"] }
18-
ash-window = "0.12.0"
19-
raw-window-handle = { version = "0.5.0", features = ["std"] }
15+
ash = { version = "0.38.0", default-features = false, features = ["loaded", "debug", "std"] }
16+
lahar = { git = "https://github.com/Ralith/lahar", rev = "7963ae5750ea61fa0a894dbb73d3be0ac77255d2" }
17+
winit = "0.29.10"
18+
ash-window = "0.13"
19+
raw-window-handle = "0.6"
2020
directories = "5.0.1"
2121
vk-shader-macros = "0.2.5"
2222
nalgebra = { workspace = true }

client/benches/surface_extraction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ fn extract(bench: &mut Bencher) {
1919
unsafe {
2020
let cmd_pool = device
2121
.create_command_pool(
22-
&vk::CommandPoolCreateInfo::builder().queue_family_index(gfx.queue_family),
22+
&vk::CommandPoolCreateInfo::default().queue_family_index(gfx.queue_family),
2323
None,
2424
)
2525
.unwrap();
2626

2727
let cmd = device
2828
.allocate_command_buffers(
29-
&vk::CommandBufferAllocateInfo::builder()
29+
&vk::CommandBufferAllocateInfo::default()
3030
.command_pool(cmd_pool)
3131
.command_buffer_count(1),
3232
)
@@ -59,7 +59,7 @@ fn extract(bench: &mut Bencher) {
5959
device
6060
.queue_submit(
6161
gfx.queue,
62-
&[vk::SubmitInfo::builder().command_buffers(&[cmd]).build()],
62+
&[vk::SubmitInfo::default().command_buffers(&[cmd])],
6363
vk::Fence::null(),
6464
)
6565
.unwrap();

client/src/graphics/base.rs

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Common state shared throughout the graphics system
22
3+
use ash::ext::debug_utils;
34
use std::ffi::{c_char, CStr};
45
use std::path::PathBuf;
56
use std::sync::Arc;
6-
use std::{fs, io, ptr};
7+
use std::{fs, io};
78
use tracing::{error, info, trace, warn};
89

910
use ash::{vk, Device};
@@ -34,6 +35,7 @@ pub struct Base {
3435
pub limits: vk::PhysicalDeviceLimits,
3536
pub timestamp_bits: u32,
3637
pipeline_cache_path: Option<PathBuf>,
38+
debug_utils: Option<debug_utils::Device>,
3739
}
3840

3941
unsafe impl Send for Base {}
@@ -133,11 +135,10 @@ impl Base {
133135
instance
134136
.create_device(
135137
physical,
136-
&vk::DeviceCreateInfo::builder()
137-
.queue_create_infos(&[vk::DeviceQueueCreateInfo::builder()
138+
&vk::DeviceCreateInfo::default()
139+
.queue_create_infos(&[vk::DeviceQueueCreateInfo::default()
138140
.queue_family_index(queue_family_index)
139-
.queue_priorities(&[1.0])
140-
.build()])
141+
.queue_priorities(&[1.0])])
141142
.enabled_extension_names(&device_exts),
142143
None,
143144
)
@@ -147,14 +148,14 @@ impl Base {
147148
let memory_properties = instance.get_physical_device_memory_properties(physical);
148149
let pipeline_cache = device
149150
.create_pipeline_cache(
150-
&vk::PipelineCacheCreateInfo::builder().initial_data(&pipeline_cache_data),
151+
&vk::PipelineCacheCreateInfo::default().initial_data(&pipeline_cache_data),
151152
None,
152153
)
153154
.unwrap();
154155

155156
let render_pass = device
156157
.create_render_pass(
157-
&vk::RenderPassCreateInfo::builder()
158+
&vk::RenderPassCreateInfo::default()
158159
.attachments(&[
159160
vk::AttachmentDescription {
160161
format: COLOR_FORMAT,
@@ -176,7 +177,7 @@ impl Base {
176177
},
177178
])
178179
.subpasses(&[
179-
vk::SubpassDescription::builder()
180+
vk::SubpassDescription::default()
180181
.color_attachments(&[vk::AttachmentReference {
181182
attachment: 0,
182183
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
@@ -185,9 +186,8 @@ impl Base {
185186
attachment: 1,
186187
layout: vk::ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
187188
})
188-
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
189-
.build(),
190-
vk::SubpassDescription::builder()
189+
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS),
190+
vk::SubpassDescription::default()
191191
.color_attachments(&[vk::AttachmentReference {
192192
attachment: 0,
193193
layout: vk::ImageLayout::COLOR_ATTACHMENT_OPTIMAL,
@@ -196,8 +196,7 @@ impl Base {
196196
attachment: 1,
197197
layout: vk::ImageLayout::DEPTH_STENCIL_READ_ONLY_OPTIMAL,
198198
}])
199-
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS)
200-
.build(),
199+
.pipeline_bind_point(vk::PipelineBindPoint::GRAPHICS),
201200
])
202201
.dependencies(&[
203202
vk::SubpassDependency {
@@ -225,7 +224,7 @@ impl Base {
225224

226225
let linear_sampler = device
227226
.create_sampler(
228-
&vk::SamplerCreateInfo::builder()
227+
&vk::SamplerCreateInfo::default()
229228
.min_filter(vk::Filter::LINEAR)
230229
.mag_filter(vk::Filter::LINEAR)
231230
.mipmap_mode(vk::SamplerMipmapMode::NEAREST)
@@ -238,28 +237,32 @@ impl Base {
238237

239238
let common_layout = device
240239
.create_descriptor_set_layout(
241-
&vk::DescriptorSetLayoutCreateInfo::builder().bindings(&[
240+
&vk::DescriptorSetLayoutCreateInfo::default().bindings(&[
242241
// Uniforms
243242
vk::DescriptorSetLayoutBinding {
244243
binding: 0,
245244
descriptor_type: vk::DescriptorType::UNIFORM_BUFFER,
246245
descriptor_count: 1,
247246
stage_flags: vk::ShaderStageFlags::VERTEX
248247
| vk::ShaderStageFlags::FRAGMENT,
249-
p_immutable_samplers: ptr::null(),
248+
..Default::default()
250249
},
251250
// Depth buffer
252251
vk::DescriptorSetLayoutBinding {
253252
binding: 1,
254253
descriptor_type: vk::DescriptorType::INPUT_ATTACHMENT,
255254
descriptor_count: 1,
256255
stage_flags: vk::ShaderStageFlags::FRAGMENT,
257-
p_immutable_samplers: ptr::null(),
256+
..Default::default()
258257
},
259258
]),
260259
None,
261260
)
262261
.unwrap();
262+
let debug_utils = core
263+
.debug_utils
264+
.as_ref()
265+
.map(|_| debug_utils::Device::new(&core.instance, &device));
263266

264267
Some(Self {
265268
core,
@@ -275,6 +278,7 @@ impl Base {
275278
pipeline_cache_path,
276279
limits: physical_properties.properties.limits,
277280
timestamp_bits: queue_family_properties.timestamp_valid_bits,
281+
debug_utils,
278282
})
279283
}
280284
}
@@ -301,15 +305,12 @@ impl Base {
301305

302306
/// Set an object's name for use in diagnostics
303307
pub unsafe fn set_name<T: vk::Handle>(&self, object: T, name: &CStr) {
304-
let ex = match self.core.debug_utils.as_ref() {
305-
Some(x) => x,
306-
None => return,
308+
let Some(ref ex) = self.debug_utils else {
309+
return;
307310
};
308311
ex.set_debug_utils_object_name(
309-
self.device.handle(),
310-
&vk::DebugUtilsObjectNameInfoEXT::builder()
311-
.object_type(T::TYPE)
312-
.object_handle(object.as_raw())
312+
&vk::DebugUtilsObjectNameInfoEXT::default()
313+
.object_handle(object)
313314
.object_name(name),
314315
)
315316
.unwrap();

client/src/graphics/core.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::os::raw::c_void;
44
use std::ptr;
55
use std::slice;
66

7-
use ash::extensions::ext::DebugUtils;
7+
use ash::ext::debug_utils;
88
use ash::{vk, Entry, Instance};
99
use tracing::{debug, error, info, trace, warn};
1010

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

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

4848
let mut exts = exts.to_vec();
4949
if has_debug {
50-
exts.push(DebugUtils::name().as_ptr());
50+
exts.push(debug_utils::NAME.as_ptr());
5151
} else {
5252
info!("vulkan debugging unavailable");
5353
}
@@ -63,17 +63,17 @@ impl Core {
6363

6464
let name = cstr!("hypermine");
6565

66-
let app_info = vk::ApplicationInfo::builder()
66+
let app_info = vk::ApplicationInfo::default()
6767
.application_name(name)
6868
.application_version(0)
6969
.engine_name(name)
7070
.engine_version(0)
7171
.api_version(vk::make_api_version(0, 1, 1, 0));
72-
let mut instance_info = vk::InstanceCreateInfo::builder()
72+
let mut instance_info = vk::InstanceCreateInfo::default()
7373
.application_info(&app_info)
7474
.enabled_extension_names(&exts);
7575

76-
let mut debug_utils_messenger_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
76+
let mut debug_utils_messenger_info = vk::DebugUtilsMessengerCreateInfoEXT::default()
7777
.message_severity(
7878
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
7979
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
@@ -98,7 +98,7 @@ impl Core {
9898
let messenger;
9999
if has_debug {
100100
// Configure Vulkan diagnostic message logging
101-
let utils = DebugUtils::new(&entry, &instance);
101+
let utils = debug_utils::Instance::new(&entry, &instance);
102102
messenger = utils
103103
.create_debug_utils_messenger(&debug_utils_messenger_info, None)
104104
.unwrap();

0 commit comments

Comments
 (0)