Skip to content

Commit 851e297

Browse files
committed
Isolate raw bindings from generated support code
1 parent c058497 commit 851e297

File tree

99 files changed

+28851
-27456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+28851
-27456
lines changed

ash-examples/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ use std::{
1212
};
1313

1414
use ash::{
15-
vk,
16-
vk::{
17-
ext::debug_utils,
18-
khr::{surface, swapchain},
19-
},
20-
Device, Entry, Instance,
15+
ext::debug_utils,
16+
khr::{surface, swapchain},
17+
vk, Device, Entry, Instance,
2118
};
2219
use winit::{
2320
event::{ElementState, Event, KeyEvent, WindowEvent},
@@ -233,9 +230,9 @@ impl ExampleBase {
233230

234231
#[cfg(any(target_os = "macos", target_os = "ios"))]
235232
{
236-
extension_names.push(vk::khr::portability_enumeration::NAME.as_ptr());
233+
extension_names.push(ash::khr::portability_enumeration::NAME.as_ptr());
237234
// Enabling this extension is a requirement when using `VK_KHR_portability_subset`
238-
extension_names.push(vk::khr::get_physical_device_properties2::NAME.as_ptr());
235+
extension_names.push(ash::khr::get_physical_device_properties2::NAME.as_ptr());
239236
}
240237

241238
let appinfo = vk::ApplicationInfo::default()
@@ -319,7 +316,7 @@ impl ExampleBase {
319316
let device_extension_names_raw = [
320317
swapchain::NAME.as_ptr(),
321318
#[cfg(any(target_os = "macos", target_os = "ios"))]
322-
vk::khr::portability_subset::NAME.as_ptr(),
319+
ash::khr::portability_subset::NAME.as_ptr(),
323320
];
324321
let features = vk::PhysicalDeviceFeatures {
325322
shader_clip_distance: 1,

ash-window/examples/winit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn Error>> {
3535
.build(&event_loop)?;
3636

3737
// Load the surface extensions
38-
let surface_fn = vk::khr::surface::Instance::new(&entry, &instance);
38+
let surface_fn = ash::khr::surface::Instance::new(&entry, &instance);
3939
let mut surface = None;
4040

4141
let _ = event_loop.run(move |event, elwp| match event {

ash-window/src/lib.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
use std::os::raw::c_char;
44

55
use ash::{
6+
ext::metal_surface,
7+
khr::{android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface},
68
prelude::*,
7-
vk,
8-
vk::{
9-
ext::metal_surface,
10-
khr::{
11-
android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface,
12-
},
13-
},
14-
Entry, Instance,
9+
vk, Entry, Instance,
1510
};
1611
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
1712

ash/src/device.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use core::ptr;
1212
pub struct Device {
1313
pub(crate) handle: vk::Device,
1414

15-
pub(crate) device_fn_1_0: vk::DeviceFnV1_0,
16-
pub(crate) device_fn_1_1: vk::DeviceFnV1_1,
17-
pub(crate) device_fn_1_2: vk::DeviceFnV1_2,
18-
pub(crate) device_fn_1_3: vk::DeviceFnV1_3,
15+
pub(crate) device_fn_1_0: crate::DeviceFnV1_0,
16+
pub(crate) device_fn_1_1: crate::DeviceFnV1_1,
17+
pub(crate) device_fn_1_2: crate::DeviceFnV1_2,
18+
pub(crate) device_fn_1_3: crate::DeviceFnV1_3,
1919
}
2020

2121
impl Device {
22-
pub unsafe fn load(instance_fn: &vk::InstanceFnV1_0, device: vk::Device) -> Self {
22+
pub unsafe fn load(instance_fn: &crate::InstanceFnV1_0, device: vk::Device) -> Self {
2323
Self::load_with(
2424
|name| mem::transmute((instance_fn.get_device_proc_addr)(device, name.as_ptr())),
2525
device,
@@ -32,20 +32,20 @@ impl Device {
3232
) -> Self {
3333
Self::from_parts_1_3(
3434
device,
35-
vk::DeviceFnV1_0::load(&mut load_fn),
36-
vk::DeviceFnV1_1::load(&mut load_fn),
37-
vk::DeviceFnV1_2::load(&mut load_fn),
38-
vk::DeviceFnV1_3::load(&mut load_fn),
35+
crate::DeviceFnV1_0::load(&mut load_fn),
36+
crate::DeviceFnV1_1::load(&mut load_fn),
37+
crate::DeviceFnV1_2::load(&mut load_fn),
38+
crate::DeviceFnV1_3::load(&mut load_fn),
3939
)
4040
}
4141

4242
#[inline]
4343
pub fn from_parts_1_3(
4444
handle: vk::Device,
45-
device_fn_1_0: vk::DeviceFnV1_0,
46-
device_fn_1_1: vk::DeviceFnV1_1,
47-
device_fn_1_2: vk::DeviceFnV1_2,
48-
device_fn_1_3: vk::DeviceFnV1_3,
45+
device_fn_1_0: crate::DeviceFnV1_0,
46+
device_fn_1_1: crate::DeviceFnV1_1,
47+
device_fn_1_2: crate::DeviceFnV1_2,
48+
device_fn_1_3: crate::DeviceFnV1_3,
4949
) -> Self {
5050
Self {
5151
handle,
@@ -66,7 +66,7 @@ impl Device {
6666
/// Vulkan core 1.3
6767
impl Device {
6868
#[inline]
69-
pub fn fp_v1_3(&self) -> &vk::DeviceFnV1_3 {
69+
pub fn fp_v1_3(&self) -> &crate::DeviceFnV1_3 {
7070
&self.device_fn_1_3
7171
}
7272

@@ -556,7 +556,7 @@ impl Device {
556556
/// Vulkan core 1.2
557557
impl Device {
558558
#[inline]
559-
pub fn fp_v1_2(&self) -> &vk::DeviceFnV1_2 {
559+
pub fn fp_v1_2(&self) -> &crate::DeviceFnV1_2 {
560560
&self.device_fn_1_2
561561
}
562562

@@ -736,7 +736,7 @@ impl Device {
736736
/// Vulkan core 1.1
737737
impl Device {
738738
#[inline]
739-
pub fn fp_v1_1(&self) -> &vk::DeviceFnV1_1 {
739+
pub fn fp_v1_1(&self) -> &crate::DeviceFnV1_1 {
740740
&self.device_fn_1_1
741741
}
742742

@@ -982,7 +982,7 @@ impl Device {
982982
/// Vulkan core 1.0
983983
impl Device {
984984
#[inline]
985-
pub fn fp_v1_0(&self) -> &vk::DeviceFnV1_0 {
985+
pub fn fp_v1_0(&self) -> &crate::DeviceFnV1_0 {
986986
&self.device_fn_1_0
987987
}
988988

ash/src/entry.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crate::instance::Instance;
2+
#[cfg(doc)]
3+
use crate::khr;
24
use crate::prelude::*;
35
use crate::vk;
46
use crate::RawPtr;
@@ -14,9 +16,9 @@ use libloading::Library;
1416
/// Holds the Vulkan functions independent of a particular instance
1517
#[derive(Clone)]
1618
pub struct Entry {
17-
static_fn: vk::StaticFn,
18-
entry_fn_1_0: vk::EntryFnV1_0,
19-
entry_fn_1_1: vk::EntryFnV1_1,
19+
static_fn: crate::StaticFn,
20+
entry_fn_1_0: crate::EntryFnV1_0,
21+
entry_fn_1_1: crate::EntryFnV1_1,
2022
#[cfg(feature = "loaded")]
2123
_lib_guard: Option<alloc::sync::Arc<Library>>,
2224
}
@@ -111,7 +113,7 @@ impl Entry {
111113
// Sound because we're linking to Vulkan, which provides a vkGetInstanceProcAddr that has
112114
// defined behavior in this use.
113115
unsafe {
114-
Self::from_static_fn(vk::StaticFn {
116+
Self::from_static_fn(crate::StaticFn {
115117
get_instance_proc_addr: vkGetInstanceProcAddr,
116118
})
117119
}
@@ -133,7 +135,7 @@ impl Entry {
133135
.map_err(LoadingError::LibraryLoadFailure)
134136
.map(alloc::sync::Arc::new)?;
135137

136-
let static_fn = vk::StaticFn::load_checked(|name| {
138+
let static_fn = crate::StaticFn::load_checked(|name| {
137139
lib.get(name.to_bytes_with_nul())
138140
.map(|symbol| *symbol)
139141
.unwrap_or(ptr::null_mut())
@@ -145,13 +147,13 @@ impl Entry {
145147
})
146148
}
147149

148-
/// Load entry points based on an already-loaded [`vk::StaticFn`]
150+
/// Load entry points based on an already-loaded [`crate::StaticFn`]
149151
///
150152
/// # Safety
151153
///
152154
/// `static_fn` must contain valid function pointers that comply with the semantics specified
153155
/// by Vulkan 1.0, which must remain valid for at least the lifetime of the returned [`Entry`].
154-
pub unsafe fn from_static_fn(static_fn: vk::StaticFn) -> Self {
156+
pub unsafe fn from_static_fn(static_fn: crate::StaticFn) -> Self {
155157
let load_fn = move |name: &ffi::CStr| {
156158
mem::transmute((static_fn.get_instance_proc_addr)(
157159
vk::Instance::null(),
@@ -161,16 +163,16 @@ impl Entry {
161163

162164
Self::from_parts_1_1(
163165
static_fn,
164-
vk::EntryFnV1_0::load(load_fn),
165-
vk::EntryFnV1_1::load(load_fn),
166+
crate::EntryFnV1_0::load(load_fn),
167+
crate::EntryFnV1_1::load(load_fn),
166168
)
167169
}
168170

169171
#[inline]
170172
pub fn from_parts_1_1(
171-
static_fn: vk::StaticFn,
172-
entry_fn_1_0: vk::EntryFnV1_0,
173-
entry_fn_1_1: vk::EntryFnV1_1,
173+
static_fn: crate::StaticFn,
174+
entry_fn_1_0: crate::EntryFnV1_0,
175+
entry_fn_1_1: crate::EntryFnV1_1,
174176
) -> Self {
175177
Self {
176178
static_fn,
@@ -182,12 +184,12 @@ impl Entry {
182184
}
183185

184186
#[inline]
185-
pub fn fp_v1_0(&self) -> &vk::EntryFnV1_0 {
187+
pub fn fp_v1_0(&self) -> &crate::EntryFnV1_0 {
186188
&self.entry_fn_1_0
187189
}
188190

189191
#[inline]
190-
pub fn static_fn(&self) -> &vk::StaticFn {
192+
pub fn static_fn(&self) -> &crate::StaticFn {
191193
&self.static_fn
192194
}
193195

@@ -235,7 +237,7 @@ impl Entry {
235237
/// # Safety
236238
///
237239
/// The resulting [`Instance`] and any function-pointer objects (e.g. [`Device`][crate::Device]
238-
/// and extensions like [`vk::khr::swapchain::Device`]) loaded from it may not be used after
240+
/// and extensions like [`khr::swapchain::Device`]) loaded from it may not be used after
239241
/// this [`Entry`] object is dropped, unless it was crated using [`Entry::linked()`] or
240242
/// [`Entry::from_parts_1_1()`].
241243
///
@@ -294,7 +296,7 @@ impl Entry {
294296
/// Vulkan core 1.1
295297
impl Entry {
296298
#[inline]
297-
pub fn fp_v1_1(&self) -> &vk::EntryFnV1_1 {
299+
pub fn fp_v1_1(&self) -> &crate::EntryFnV1_1 {
298300
&self.entry_fn_1_1
299301
}
300302

@@ -319,7 +321,7 @@ impl Default for Entry {
319321
}
320322
}
321323

322-
impl vk::StaticFn {
324+
impl crate::StaticFn {
323325
pub fn load_checked<F>(mut _f: F) -> Result<Self, MissingEntryPoint>
324326
where
325327
F: FnMut(&ffi::CStr) -> *const ffi::c_void,

ash/src/extensions/amd/buffer_marker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::vk;
44

5-
impl vk::amd::buffer_marker::Device {
5+
impl crate::amd::buffer_marker::Device {
66
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdWriteBufferMarkerAMD.html>
77
#[inline]
88
pub unsafe fn cmd_write_buffer_marker(

ash/src/extensions/amd/shader_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::vk;
55
use alloc::vec::Vec;
66
use core::mem;
77

8-
impl vk::amd::shader_info::Device {
8+
impl crate::amd::shader_info::Device {
99
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetShaderInfoAMD.html>
1010
#[inline]
1111
pub unsafe fn get_shader_info(

ash/src/extensions/amdx/shader_enqueue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::RawPtr;
66
use alloc::vec::Vec;
77
use core::mem;
88

9-
impl vk::amdx::shader_enqueue::Device {
9+
impl crate::amdx::shader_enqueue::Device {
1010
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateExecutionGraphPipelinesAMDX.html>
1111
#[inline]
1212
pub unsafe fn create_execution_graph_pipelines(

ash/src/extensions/android/external_memory_android_hardware_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::prelude::*;
44
use crate::vk;
55
use core::mem;
66

7-
impl vk::android::external_memory_android_hardware_buffer::Device {
7+
impl crate::android::external_memory_android_hardware_buffer::Device {
88
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetAndroidHardwareBufferPropertiesANDROID.html>
99
#[inline]
1010
pub unsafe fn get_android_hardware_buffer_properties(

ash/src/extensions/ext/acquire_drm_display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::prelude::*;
44
use crate::vk;
55
use core::mem;
66

7-
impl vk::ext::acquire_drm_display::Instance {
7+
impl crate::ext::acquire_drm_display::Instance {
88
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireDrmDisplayEXT.html>
99
#[inline]
1010
pub unsafe fn acquire_drm_display(

0 commit comments

Comments
 (0)