Add VK_KHR/EXT_buffer_device_address extension (#405)

This commit is contained in:
Rua 2021-03-20 13:55:46 +01:00 committed by GitHub
parent a2a26fd1e7
commit 98d66c6b7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,43 @@
#![allow(dead_code)]
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct BufferDeviceAddress {
handle: vk::Device,
fns: vk::ExtBufferDeviceAddressFn,
}
impl BufferDeviceAddress {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> BufferDeviceAddress {
let fns = vk::ExtBufferDeviceAddressFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
BufferDeviceAddress {
handle: device.handle(),
fns,
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressEXT.html>"]
unsafe fn get_buffer_device_address(
&self,
info: &vk::BufferDeviceAddressInfoEXT,
) -> vk::DeviceAddress {
self.fns.get_buffer_device_address_ext(self.handle, info)
}
pub fn name() -> &'static CStr {
vk::ExtBufferDeviceAddressFn::name()
}
pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn {
&self.fns
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

View file

@ -1,3 +1,4 @@
pub use self::buffer_device_address::BufferDeviceAddress;
#[allow(deprecated)]
pub use self::debug_marker::DebugMarker;
#[allow(deprecated)]
@ -6,6 +7,7 @@ pub use self::debug_utils::DebugUtils;
pub use self::metal_surface::MetalSurface;
pub use self::tooling_info::ToolingInfo;
mod buffer_device_address;
#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]
mod debug_marker;
#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]

View file

@ -0,0 +1,61 @@
#![allow(dead_code)]
use crate::version::{DeviceV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct BufferDeviceAddress {
handle: vk::Device,
fns: vk::KhrBufferDeviceAddressFn,
}
impl BufferDeviceAddress {
pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> BufferDeviceAddress {
let fns = vk::KhrBufferDeviceAddressFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
BufferDeviceAddress {
handle: device.handle(),
fns,
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddressKHR.html>"]
unsafe fn get_buffer_device_address(
&self,
info: &vk::BufferDeviceAddressInfoKHR,
) -> vk::DeviceAddress {
self.fns.get_buffer_device_address_khr(self.handle, info)
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html>"]
unsafe fn get_buffer_opaque_capture_address(
&self,
info: &vk::BufferDeviceAddressInfoKHR,
) -> u64 {
self.fns
.get_buffer_opaque_capture_address_khr(self.handle, info)
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceMemoryOpaqueCaptureAddressKHR.html>"]
unsafe fn get_device_memory_opaque_capture_address(
&self,
info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR,
) -> u64 {
self.fns
.get_device_memory_opaque_capture_address_khr(self.handle, info)
}
pub fn name() -> &'static CStr {
vk::KhrBufferDeviceAddressFn::name()
}
pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn {
&self.fns
}
pub fn device(&self) -> vk::Device {
self.handle
}
}

View file

@ -1,5 +1,6 @@
pub use self::acceleration_structure::AccelerationStructure;
pub use self::android_surface::AndroidSurface;
pub use self::buffer_device_address::BufferDeviceAddress;
pub use self::deferred_host_operations::DeferredHostOperations;
pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain;
@ -20,6 +21,7 @@ pub use self::xlib_surface::XlibSurface;
mod acceleration_structure;
mod android_surface;
mod buffer_device_address;
mod deferred_host_operations;
mod display;
mod display_swapchain;