Skip to content

Commit

Permalink
extension: Rename wrapper structs to Device or Instance
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Sep 3, 2023
1 parent caba50a commit 6b07904
Show file tree
Hide file tree
Showing 82 changed files with 170 additions and 248 deletions.
2 changes: 1 addition & 1 deletion ash-window/examples/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() -> Result<(), Box<dyn Error>> {
window.raw_window_handle(),
None,
)?;
let surface_fn = ash::extensions::khr::surface::Surface::new(&entry, &instance);
let surface_fn = ash::extensions::khr::surface::Instance::new(&entry, &instance);
println!("surface: {surface:?}");

event_loop.run(move |event, _, control_flow| match event {
Expand Down
4 changes: 2 additions & 2 deletions ash-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub unsafe fn create_surface(
};

let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
let surface_fn = metal_surface::MetalSurface::new(entry, instance);
let surface_fn = metal_surface::Instance::new(entry, instance);
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
}

Expand All @@ -108,7 +108,7 @@ pub unsafe fn create_surface(
};

let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
let surface_fn = metal_surface::MetalSurface::new(entry, instance);
let surface_fn = metal_surface::Instance::new(entry, instance);
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
}

Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/amd/buffer_marker.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::amd_buffer_marker::NAME;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMD_buffer_marker.html>
#[derive(Clone)]
pub struct BufferMarker {
pub struct Device {
fp: vk::amd_buffer_marker::DeviceFn,
}

impl BufferMarker {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
});
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/amd/shader_info.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::amd_shader_info::NAME;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMD_shader_info.html>
#[derive(Clone)]
pub struct ShaderInfo {
pub struct Device {
handle: vk::Device,
fp: vk::amd_shader_info::DeviceFn,
}

impl ShaderInfo {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/amdx/shader_enqueue.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::amdx_shader_enqueue::NAME;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_AMDX_shader_enqueue.html>
#[derive(Clone)]
pub struct ShaderEnqueue {
pub struct Device {
handle: vk::Device,
fp: vk::amdx_shader_enqueue::DeviceFn,
}

impl ShaderEnqueue {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::android_external_memory_android_hardware_buffer::NAME;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_ANDROID_external_memory_android_hardware_buffer.html>
#[derive(Clone)]
pub struct ExternalMemoryAndroidHardwareBuffer {
pub struct Device {
handle: vk::Device,
fp: vk::android_external_memory_android_hardware_buffer::DeviceFn,
}

impl ExternalMemoryAndroidHardwareBuffer {
pub fn new(instance: &Instance, device: &Device) -> Self {
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 {
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/acquire_drm_display.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use crate::prelude::*;
use crate::vk;
use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_acquire_drm_display::NAME;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_acquire_drm_display.html>
#[derive(Clone)]
pub struct AcquireDrmDisplay {
pub struct Instance {
fp: vk::ext_acquire_drm_display::InstanceFn,
}

impl AcquireDrmDisplay {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
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()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/buffer_device_address.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_buffer_device_address::NAME;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_buffer_device_address.html>
#[derive(Clone)]
pub struct BufferDeviceAddress {
pub struct Device {
handle: vk::Device,
fp: vk::ext_buffer_device_address::DeviceFn,
}

impl BufferDeviceAddress {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
Expand Down
13 changes: 6 additions & 7 deletions ash/src/extensions/ext/calibrated_timestamps.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Entry, Instance};
use std::ffi::CStr;
use std::mem;

Expand All @@ -9,13 +8,13 @@ pub const NAME: &CStr = vk::ext_calibrated_timestamps::NAME;
/// High-level device function wrapper for
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_calibrated_timestamps.html>
#[derive(Clone)]
pub struct CalibratedTimestampsDevice {
pub struct Device {
handle: vk::Device,
fp: vk::ext_calibrated_timestamps::DeviceFn,
}

impl CalibratedTimestampsDevice {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
Expand Down Expand Up @@ -57,12 +56,12 @@ impl CalibratedTimestampsDevice {
/// High-level instance function wrapper for
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_calibrated_timestamps.html>
#[derive(Clone)]
pub struct CalibratedTimestampsInstance {
pub struct Instance {
fp: vk::ext_calibrated_timestamps::InstanceFn,
}

impl CalibratedTimestampsInstance {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
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()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/debug_marker.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_debug_marker::NAME;

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

impl DebugMarker {
pub fn new(instance: &Instance, device: &Device) -> Self {
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()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/debug_report.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_debug_report::NAME;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_report.html>
#[derive(Clone)]
pub struct DebugReport {
pub struct Instance {
handle: vk::Instance,
fp: vk::ext_debug_report::InstanceFn,
}

impl DebugReport {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
impl Instance {
pub fn new(entry: &crate::Entry, instance: &crate::Instance) -> Self {
let handle = instance.handle();
let fp = vk::ext_debug_report::InstanceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
Expand Down
13 changes: 6 additions & 7 deletions ash/src/extensions/ext/debug_utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::prelude::*;
use crate::{vk, RawPtr};
use crate::{Device, Entry, Instance};
use std::ffi::CStr;
use std::mem;

Expand All @@ -9,13 +8,13 @@ pub const NAME: &CStr = vk::ext_debug_utils::NAME;
/// High-level device function wrapper for
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_utils.html>
#[derive(Clone)]
pub struct DebugUtilsDevice {
pub struct Device {
handle: vk::Device,
fp: vk::ext_debug_utils::DeviceFn,
}

impl DebugUtilsDevice {
pub fn new(instance: &Instance, device: &Device) -> Self {
impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::ext_debug_utils::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
Expand Down Expand Up @@ -107,13 +106,13 @@ impl DebugUtilsDevice {
/// High-level instance function wrapper for
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_utils.html>
#[derive(Clone)]
pub struct DebugUtilsInstance {
pub struct Instance {
handle: vk::Instance,
fp: vk::ext_debug_utils::InstanceFn,
}

impl DebugUtilsInstance {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
impl Instance {
pub fn new(entry: &crate::Entry, instance: &crate::Instance) -> Self {
let handle = instance.handle();
let fp = vk::ext_debug_utils::InstanceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/descriptor_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_descriptor_buffer::NAME;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_descriptor_buffer.html>
#[derive(Clone)]
pub struct DescriptorBuffer {
pub struct Device {
handle: vk::Device,
fp: vk::ext_descriptor_buffer::DeviceFn,
}

impl DescriptorBuffer {
pub fn new(instance: &Instance, device: &Device) -> Self {
impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::ext_descriptor_buffer::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/extended_dynamic_state.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;
use std::ptr;

pub const NAME: &CStr = vk::ext_extended_dynamic_state::NAME;

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

impl ExtendedDynamicState {
pub fn new(instance: &Instance, device: &Device) -> Self {
impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let fp = vk::ext_extended_dynamic_state::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/extended_dynamic_state2.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_extended_dynamic_state2::NAME;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_extended_dynamic_state2.html>
#[derive(Clone)]
pub struct ExtendedDynamicState2 {
pub struct Device {
fp: vk::ext_extended_dynamic_state2::DeviceFn,
}

impl ExtendedDynamicState2 {
pub fn new(instance: &Instance, device: &Device) -> Self {
impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let fp = vk::ext_extended_dynamic_state2::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Expand Down
7 changes: 3 additions & 4 deletions ash/src/extensions/ext/extended_dynamic_state3.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

pub const NAME: &CStr = vk::ext_extended_dynamic_state3::NAME;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_extended_dynamic_state3.html>
#[derive(Clone)]
pub struct ExtendedDynamicState3 {
pub struct Device {
fp: vk::ext_extended_dynamic_state3::DeviceFn,
}

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

0 comments on commit 6b07904

Please sign in to comment.