Skip to content

Commit

Permalink
Unify extension module hierarchies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Mar 26, 2024
1 parent 71387e9 commit a526d8d
Show file tree
Hide file tree
Showing 96 changed files with 4,625 additions and 2,984 deletions.
2 changes: 1 addition & 1 deletion ash-examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
borrow::Cow, cell::RefCell, default::Default, error::Error, ffi, ops::Drop, os::raw::c_char,
};

use ash::extensions::{
use ash::vk::{
ext::debug_utils,
khr::{surface, swapchain},
};
Expand Down
2 changes: 1 addition & 1 deletion ash-window/examples/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.build(&event_loop)?;

// Load the surface extensions
let surface_fn = ash::extensions::khr::surface::Instance::new(&entry, &instance);
let surface_fn = vk::khr::surface::Instance::new(&entry, &instance);
let mut surface = None;

let _ = event_loop.run(move |event, elwp| match event {
Expand Down
7 changes: 4 additions & 3 deletions ash-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
use std::os::raw::c_char;

use ash::{
extensions::{
prelude::*,
vk,
vk::{
ext::metal_surface,
khr::{
android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface,
},
},
prelude::*,
vk, Entry, Instance,
Entry, Instance,
};
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};

Expand Down
4 changes: 2 additions & 2 deletions ash/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ impl Entry {
/// # Safety
///
/// The resulting [`Instance`] and any function-pointer objects (e.g. [`Device`][crate::Device]
/// and [extensions][crate::extensions]) loaded from it may not be used after this [`Entry`]
/// object is dropped, unless it was crated using [`Entry::linked()`] or
/// and extensions like [`vk::khr::swapchain::Device`]) loaded from it may not be used after
/// this [`Entry`] object is dropped, unless it was crated using [`Entry::linked()`] or
/// [`Entry::from_parts_1_1()`].
///
/// [`Instance`] does _not_ implement [drop][drop()] semantics and can only be destroyed via
Expand Down
21 changes: 1 addition & 20 deletions ash/src/extensions/amd/buffer_marker.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMD_buffer_marker.html>

use crate::vk;
use core::mem;
pub use vk::amd::buffer_marker::NAME;

#[derive(Clone)]
pub struct Device {
fp: vk::amd::buffer_marker::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let fp = vk::amd::buffer_marker::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Self { fp }
}

impl vk::amd::buffer_marker::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdWriteBufferMarkerAMD.html>
#[inline]
pub unsafe fn cmd_write_buffer_marker(
Expand All @@ -35,9 +21,4 @@ impl Device {
marker,
)
}

#[inline]
pub fn fp(&self) -> &vk::amd::buffer_marker::DeviceFn {
&self.fp
}
}
27 changes: 1 addition & 26 deletions ash/src/extensions/amd/shader_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@ use crate::prelude::*;
use crate::vk;
use alloc::vec::Vec;
use core::mem;
pub use vk::amd::shader_info::NAME;

#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::amd::shader_info::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::amd::shader_info::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::amd::shader_info::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetShaderInfoAMD.html>
#[inline]
pub unsafe fn get_shader_info(
Expand Down Expand Up @@ -64,16 +49,6 @@ impl Device {
x => unimplemented!("ShaderInfoTypeAMD {}", x.0),
}
}

#[inline]
pub fn fp(&self) -> &vk::amd::shader_info::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}

#[derive(Clone)]
Expand Down
27 changes: 1 addition & 26 deletions ash/src/extensions/amdx/shader_enqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,8 @@ use crate::vk;
use crate::RawPtr;
use alloc::vec::Vec;
use core::mem;
pub use vk::amdx::shader_enqueue::NAME;

#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::amdx::shader_enqueue::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::amdx::shader_enqueue::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::amdx::shader_enqueue::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateExecutionGraphPipelinesAMDX.html>
#[inline]
pub unsafe fn create_execution_graph_pipelines(
Expand Down Expand Up @@ -116,14 +101,4 @@ impl Device {
) {
(self.fp.cmd_dispatch_graph_indirect_count_amdx)(command_buffer, scratch, count_info)
}

#[inline]
pub fn fp(&self) -> &vk::amdx::shader_enqueue::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,8 @@
use crate::prelude::*;
use crate::vk;
use core::mem;
pub use vk::android::external_memory_android_hardware_buffer::NAME;

#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::android::external_memory_android_hardware_buffer::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp =
vk::android::external_memory_android_hardware_buffer::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::android::external_memory_android_hardware_buffer::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetAndroidHardwareBufferPropertiesANDROID.html>
#[inline]
pub unsafe fn get_android_hardware_buffer_properties(
Expand All @@ -42,14 +26,4 @@ impl Device {
(self.fp.get_memory_android_hardware_buffer_android)(self.handle, info, buffer.as_mut_ptr())
.assume_init_on_success(buffer)
}

#[inline]
pub fn fp(&self) -> &vk::android::external_memory_android_hardware_buffer::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
21 changes: 1 addition & 20 deletions ash/src/extensions/ext/acquire_drm_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,8 @@
use crate::prelude::*;
use crate::vk;
use core::mem;
pub use vk::ext::acquire_drm_display::NAME;

#[derive(Clone)]
pub struct Instance {
fp: vk::ext::acquire_drm_display::InstanceFn,
}

impl Instance {
pub fn new(entry: &crate::Entry, instance: &crate::Instance) -> Self {
let handle = instance.handle();
let fp = vk::ext::acquire_drm_display::InstanceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
});
Self { fp }
}

impl vk::ext::acquire_drm_display::Instance {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireDrmDisplayEXT.html>
#[inline]
pub unsafe fn acquire_drm_display(
Expand All @@ -42,9 +28,4 @@ impl Instance {
(self.fp.get_drm_display_ext)(physical_device, drm_fd, connector_id, display.as_mut_ptr())
.assume_init_on_success(display)
}

#[inline]
pub fn fp(&self) -> &vk::ext::acquire_drm_display::InstanceFn {
&self.fp
}
}
28 changes: 1 addition & 27 deletions ash/src/extensions/ext/buffer_device_address.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_buffer_device_address.html>

use crate::vk;
use core::mem;
pub use vk::ext::buffer_device_address::NAME;

#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::ext::buffer_device_address::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::ext::buffer_device_address::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::ext::buffer_device_address::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetBufferDeviceAddressEXT.html>
#[inline]
pub unsafe fn get_buffer_device_address(
Expand All @@ -27,14 +11,4 @@ impl Device {
) -> vk::DeviceAddress {
(self.fp.get_buffer_device_address_ext)(self.handle, info)
}

#[inline]
pub fn fp(&self) -> &vk::ext::buffer_device_address::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
49 changes: 2 additions & 47 deletions ash/src/extensions/ext/calibrated_timestamps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,8 @@ use crate::prelude::*;
use crate::vk;
use alloc::vec::Vec;
use core::mem;
pub use vk::ext::calibrated_timestamps::NAME;

/// High-level device function wrapper
#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::ext::calibrated_timestamps::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::ext::calibrated_timestamps::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::ext::calibrated_timestamps::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetCalibratedTimestampsEXT.html>
///
/// Returns a tuple containing `(timestamps, max_deviation)`
Expand All @@ -43,33 +27,9 @@ impl Device {
timestamps.set_len(info.len());
Ok((timestamps, max_deviation))
}

#[inline]
pub fn fp(&self) -> &vk::ext::calibrated_timestamps::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}

/// High-level instance function wrapper
#[derive(Clone)]
pub struct Instance {
fp: vk::ext::calibrated_timestamps::InstanceFn,
}

impl Instance {
pub fn new(entry: &crate::Entry, instance: &crate::Instance) -> Self {
let handle = instance.handle();
let fp = vk::ext::calibrated_timestamps::InstanceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
});
Self { fp }
}

impl vk::ext::calibrated_timestamps::Instance {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceCalibrateableTimeDomainsEXT.html>
#[inline]
pub unsafe fn get_physical_device_calibrateable_time_domains(
Expand All @@ -84,9 +44,4 @@ impl Instance {
)
})
}

#[inline]
pub fn fp(&self) -> &vk::ext::calibrated_timestamps::InstanceFn {
&self.fp
}
}
28 changes: 1 addition & 27 deletions ash/src/extensions/ext/debug_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,8 @@

use crate::prelude::*;
use crate::vk;
use core::mem;
pub use vk::ext::debug_marker::NAME;

#[derive(Clone)]
pub struct Device {
handle: vk::Device,
fp: vk::ext::debug_marker::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::ext::debug_marker::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}

impl vk::ext::debug_marker::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>
#[inline]
pub unsafe fn debug_marker_set_object_name(
Expand Down Expand Up @@ -54,14 +38,4 @@ impl Device {
) {
(self.fp.cmd_debug_marker_insert_ext)(command_buffer, marker_info);
}

#[inline]
pub fn fp(&self) -> &vk::ext::debug_marker::DeviceFn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
Loading

0 comments on commit a526d8d

Please sign in to comment.