Replace const fn name() with associated NAME constants (#715)

`CStr::from_bytes_with_nul_unchecked` is `const`-stable since Rust 1.59
which is already required for `ash` so it is high time to finally turn
these inlined `name()` functions into associated constants (which is a
breaking change in itself that cannot be backported).
This commit is contained in:
Marijn Suijten 2023-03-09 23:53:04 +01:00 committed by GitHub
parent 1c9e422577
commit 7a1686014e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 907 additions and 1903 deletions

View file

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Replaced builders with lifetimes/setters directly on Vulkan structs (#602)
- Inlined struct setters (#602)
- Bumped MSRV from 1.59 to 1.60 (#709)
- Replaced `const fn name()` with associated `NAME` constants (#715)
### Removed

View file

@ -206,9 +206,9 @@ use ash::extensions::{Swapchain, XlibSurface, Surface, DebugReport};
#[cfg(all(unix, not(target_os = "android")))]
fn extension_names() -> Vec<*const i8> {
vec![
Surface::name().as_ptr(),
XlibSurface::name().as_ptr(),
DebugReport::name().as_ptr()
Surface::NAME.as_ptr(),
XlibSurface::NAME.as_ptr(),
DebugReport::NAME.as_ptr()
]
}
```

View file

@ -117,48 +117,44 @@ pub fn enumerate_required_extensions(
let extensions = match display_handle {
RawDisplayHandle::Windows(_) => {
const WINDOWS_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
khr::Win32Surface::name().as_ptr(),
khr::Surface::NAME.as_ptr(),
khr::Win32Surface::NAME.as_ptr(),
];
&WINDOWS_EXTS
}
RawDisplayHandle::Wayland(_) => {
const WAYLAND_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
khr::WaylandSurface::name().as_ptr(),
khr::Surface::NAME.as_ptr(),
khr::WaylandSurface::NAME.as_ptr(),
];
&WAYLAND_EXTS
}
RawDisplayHandle::Xlib(_) => {
const XLIB_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
khr::XlibSurface::name().as_ptr(),
];
const XLIB_EXTS: [*const c_char; 2] =
[khr::Surface::NAME.as_ptr(), khr::XlibSurface::NAME.as_ptr()];
&XLIB_EXTS
}
RawDisplayHandle::Xcb(_) => {
const XCB_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
khr::XcbSurface::name().as_ptr(),
];
const XCB_EXTS: [*const c_char; 2] =
[khr::Surface::NAME.as_ptr(), khr::XcbSurface::NAME.as_ptr()];
&XCB_EXTS
}
RawDisplayHandle::Android(_) => {
const ANDROID_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
khr::AndroidSurface::name().as_ptr(),
khr::Surface::NAME.as_ptr(),
khr::AndroidSurface::NAME.as_ptr(),
];
&ANDROID_EXTS
}
RawDisplayHandle::AppKit(_) | RawDisplayHandle::UiKit(_) => {
const METAL_EXTS: [*const c_char; 2] = [
khr::Surface::name().as_ptr(),
ext::MetalSurface::name().as_ptr(),
khr::Surface::NAME.as_ptr(),
ext::MetalSurface::NAME.as_ptr(),
];
&METAL_EXTS
}

View file

@ -32,7 +32,7 @@ pub struct Entry {
impl Entry {
/// Load default Vulkan library for the current platform
///
/// Prefer this over [`linked`](Self::linked) when your application can gracefully handle
/// Prefer this over [`linked()`][Self::linked()] when your application can gracefully handle
/// environments that lack Vulkan support, and when the build environment might not have Vulkan
/// development packages installed (e.g. the Vulkan SDK, or Ubuntu's `libvulkan-dev`).
///
@ -78,7 +78,7 @@ impl Entry {
/// Load entry points from a Vulkan loader linked at compile time
///
/// Compared to [`load`](Self::load), this is infallible, but requires that the build
/// Compared to [`load()`][Self::load()], this is infallible, but requires that the build
/// environment have Vulkan development packages installed (e.g. the Vulkan SDK, or Ubuntu's
/// `libvulkan-dev`), and prevents the resulting binary from starting in environments that do not
/// support Vulkan.
@ -197,9 +197,7 @@ impl Entry {
unsafe {
let mut api_version = 0;
let enumerate_instance_version: Option<vk::PFN_vkEnumerateInstanceVersion> = {
let name = ::std::ffi::CStr::from_bytes_with_nul_unchecked(
b"vkEnumerateInstanceVersion\0",
);
let name = CStr::from_bytes_with_nul_unchecked(b"vkEnumerateInstanceVersion\0");
mem::transmute((self.static_fn.get_instance_proc_addr)(
vk::Instance::null(),
name.as_ptr(),
@ -218,7 +216,7 @@ impl Entry {
///
/// # Safety
/// In order for the created [`Instance`] to be valid for the duration of its
/// usage, the [`Entry`](Self) this was called on must be dropped later than the
/// usage, the [`Entry`][Self] this was called on must be dropped later than the
/// resulting [`Instance`].
#[inline]
pub unsafe fn create_instance(
@ -326,14 +324,11 @@ impl Default for Entry {
impl vk::StaticFn {
pub fn load_checked<F>(mut _f: F) -> Result<Self, MissingEntryPoint>
where
F: FnMut(&::std::ffi::CStr) -> *const c_void,
F: FnMut(&CStr) -> *const c_void,
{
// TODO: Make this a &'static CStr once CStr::from_bytes_with_nul_unchecked is const
static ENTRY_POINT: &[u8] = b"vkGetInstanceProcAddr\0";
Ok(Self {
get_instance_proc_addr: unsafe {
let cname = CStr::from_bytes_with_nul_unchecked(ENTRY_POINT);
let cname = CStr::from_bytes_with_nul_unchecked(b"vkGetInstanceProcAddr\0");
let val = _f(cname);
if val.is_null() {
return Err(MissingEntryPoint);

View file

@ -43,10 +43,7 @@ impl AcquireDrmDisplay {
.assume_init_on_success(display)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtAcquireDrmDisplayFn::name()
}
pub const NAME: &'static CStr = vk::ExtAcquireDrmDisplayFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtAcquireDrmDisplayFn {

View file

@ -27,10 +27,7 @@ impl BufferDeviceAddress {
(self.fp.get_buffer_device_address_ext)(self.handle, info)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtBufferDeviceAddressFn::name()
}
pub const NAME: &'static CStr = vk::ExtBufferDeviceAddressFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn {

View file

@ -55,10 +55,7 @@ impl CalibratedTimestamps {
.result_with_success((timestamps, max_deviation))
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtCalibratedTimestampsFn::name()
}
pub const NAME: &'static CStr = vk::ExtCalibratedTimestampsFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtCalibratedTimestampsFn {

View file

@ -54,10 +54,7 @@ impl DebugMarker {
(self.fp.cmd_debug_marker_insert_ext)(command_buffer, marker_info);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtDebugMarkerFn::name()
}
pub const NAME: &'static CStr = vk::ExtDebugMarkerFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtDebugMarkerFn {

View file

@ -51,10 +51,7 @@ impl DebugReport {
.result_with_success(debug_cb)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtDebugReportFn::name()
}
pub const NAME: &'static CStr = vk::ExtDebugReportFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtDebugReportFn {

View file

@ -134,10 +134,7 @@ impl DebugUtils {
);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtDebugUtilsFn::name()
}
pub const NAME: &'static CStr = vk::ExtDebugUtilsFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtDebugUtilsFn {

View file

@ -194,10 +194,7 @@ impl DescriptorBuffer {
.result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtDescriptorBufferFn::name()
}
pub const NAME: &'static CStr = vk::ExtDescriptorBufferFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtDescriptorBufferFn {

View file

@ -184,10 +184,7 @@ impl ExtendedDynamicState {
)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtExtendedDynamicStateFn::name()
}
pub const NAME: &'static CStr = vk::ExtExtendedDynamicStateFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn {

View file

@ -73,10 +73,7 @@ impl ExtendedDynamicState2 {
)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtExtendedDynamicState2Fn::name()
}
pub const NAME: &'static CStr = vk::ExtExtendedDynamicState2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtExtendedDynamicState2Fn {

View file

@ -397,10 +397,7 @@ impl ExtendedDynamicState3 {
(self.fp.cmd_set_coverage_reduction_mode_nv)(command_buffer, coverage_reduction_mode)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtExtendedDynamicState3Fn::name()
}
pub const NAME: &'static CStr = vk::ExtExtendedDynamicState3Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtExtendedDynamicState3Fn {

View file

@ -69,10 +69,7 @@ impl FullScreenExclusive {
.result_with_success(present_modes)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtFullScreenExclusiveFn::name()
}
pub const NAME: &'static CStr = vk::ExtFullScreenExclusiveFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn {

View file

@ -38,10 +38,7 @@ impl HeadlessSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtHeadlessSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::ExtHeadlessSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtHeadlessSurfaceFn {

View file

@ -30,10 +30,7 @@ impl ImageCompressionControl {
(self.fp.get_image_subresource_layout2_ext)(self.handle, image, subresource, layout)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtImageCompressionControlFn::name()
}
pub const NAME: &'static CStr = vk::ExtImageCompressionControlFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtImageCompressionControlFn {

View file

@ -31,10 +31,7 @@ impl ImageDrmFormatModifier {
.result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtImageDrmFormatModifierFn::name()
}
pub const NAME: &'static CStr = vk::ExtImageDrmFormatModifierFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtImageDrmFormatModifierFn {

View file

@ -82,10 +82,7 @@ impl MeshShader {
);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtMeshShaderFn::name()
}
pub const NAME: &'static CStr = vk::ExtMeshShaderFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtMeshShaderFn {

View file

@ -37,10 +37,7 @@ impl MetalSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtMetalSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::ExtMetalSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtMetalSurfaceFn {

View file

@ -19,8 +19,5 @@ impl PhysicalDeviceDrm {
props_drm
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtPhysicalDeviceDrmFn::name()
}
pub const NAME: &'static CStr = vk::ExtPhysicalDeviceDrmFn::NAME;
}

View file

@ -88,10 +88,7 @@ impl PrivateData {
data
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtPrivateDataFn::name()
}
pub const NAME: &'static CStr = vk::ExtPrivateDataFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtPrivateDataFn {

View file

@ -42,10 +42,7 @@ impl SampleLocations {
(self.fp.cmd_set_sample_locations_ext)(command_buffer, sample_locations_info)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtSampleLocationsFn::name()
}
pub const NAME: &'static CStr = vk::ExtSampleLocationsFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtSampleLocationsFn {

View file

@ -28,10 +28,7 @@ impl ToolingInfo {
})
}
#[inline]
pub const fn name() -> &'static CStr {
vk::ExtToolingInfoFn::name()
}
pub const NAME: &'static CStr = vk::ExtToolingInfoFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::ExtToolingInfoFn {

View file

@ -305,10 +305,7 @@ impl AccelerationStructure {
size_info
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrAccelerationStructureFn::name()
}
pub const NAME: &'static CStr = vk::KhrAccelerationStructureFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrAccelerationStructureFn {

View file

@ -37,10 +37,7 @@ impl AndroidSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrAndroidSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrAndroidSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn {

View file

@ -45,10 +45,7 @@ impl BufferDeviceAddress {
(self.fp.get_device_memory_opaque_capture_address_khr)(self.handle, info)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrBufferDeviceAddressFn::name()
}
pub const NAME: &'static CStr = vk::KhrBufferDeviceAddressFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn {

View file

@ -72,10 +72,7 @@ impl CopyCommands2 {
(self.fp.cmd_resolve_image2_khr)(command_buffer, resolve_image_info)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrCopyCommands2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrCopyCommands2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrCopyCommands2Fn {

View file

@ -73,10 +73,7 @@ impl CreateRenderPass2 {
(self.fp.cmd_end_render_pass2_khr)(command_buffer, subpass_end_info);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrCreateRenderpass2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrCreateRenderpass2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn {

View file

@ -76,10 +76,7 @@ impl DeferredHostOperations {
(self.fp.get_deferred_operation_result_khr)(self.handle, operation).result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDeferredHostOperationsFn::name()
}
pub const NAME: &'static CStr = vk::KhrDeferredHostOperationsFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn {

View file

@ -152,10 +152,7 @@ impl DeviceGroup {
}
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDeviceGroupFn::name()
}
pub const NAME: &'static CStr = vk::KhrDeviceGroupFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDeviceGroupFn {

View file

@ -49,10 +49,7 @@ impl DeviceGroupCreation {
Ok(())
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDeviceGroupCreationFn::name()
}
pub const NAME: &'static CStr = vk::KhrDeviceGroupCreationFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDeviceGroupCreationFn {

View file

@ -126,10 +126,7 @@ impl Display {
.assume_init_on_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDisplayFn::name()
}
pub const NAME: &'static CStr = vk::KhrDisplayFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDisplayFn {

View file

@ -40,10 +40,7 @@ impl DisplaySwapchain {
Ok(swapchains)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDisplaySwapchainFn::name()
}
pub const NAME: &'static CStr = vk::KhrDisplaySwapchainFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn {

View file

@ -62,10 +62,7 @@ impl DrawIndirectCount {
);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDrawIndirectCountFn::name()
}
pub const NAME: &'static CStr = vk::KhrDrawIndirectCountFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDrawIndirectCountFn {

View file

@ -32,10 +32,7 @@ impl DynamicRendering {
(self.fp.cmd_end_rendering_khr)(command_buffer)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrDynamicRenderingFn::name()
}
pub const NAME: &'static CStr = vk::KhrDynamicRenderingFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrDynamicRenderingFn {

View file

@ -32,10 +32,7 @@ impl ExternalFenceFd {
(self.fp.get_fence_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalFenceFdFn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalFenceFdFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalFenceFdFn {

View file

@ -41,10 +41,7 @@ impl ExternalFenceWin32 {
.result_with_success(handle)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalFenceWin32Fn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalFenceWin32Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalFenceWin32Fn {

View file

@ -43,10 +43,7 @@ impl ExternalMemoryFd {
.result_with_success(memory_fd_properties)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalMemoryFdFn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalMemoryFdFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn {

View file

@ -49,10 +49,7 @@ impl ExternalMemoryWin32 {
.result_with_success(memory_win32_handle_properties)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalMemoryWin32Fn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalMemoryWin32Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalMemoryWin32Fn {

View file

@ -35,10 +35,7 @@ impl ExternalSemaphoreFd {
(self.fp.get_semaphore_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalSemaphoreFdFn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalSemaphoreFdFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn {

View file

@ -41,10 +41,7 @@ impl ExternalSemaphoreWin32 {
.result_with_success(handle)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrExternalSemaphoreWin32Fn::name()
}
pub const NAME: &'static CStr = vk::KhrExternalSemaphoreWin32Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrExternalSemaphoreWin32Fn {

View file

@ -75,10 +75,7 @@ impl GetMemoryRequirements2 {
assert_eq!(count as usize, out.len());
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrGetMemoryRequirements2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrGetMemoryRequirements2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn {

View file

@ -155,10 +155,7 @@ impl GetPhysicalDeviceProperties2 {
assert_eq!(count as usize, out.len());
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrGetPhysicalDeviceProperties2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrGetPhysicalDeviceProperties2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn {

View file

@ -72,10 +72,7 @@ impl GetSurfaceCapabilities2 {
err_code.result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrGetSurfaceCapabilities2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrGetSurfaceCapabilities2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrGetSurfaceCapabilities2Fn {

View file

@ -28,10 +28,7 @@ impl Maintenance1 {
(self.fp.trim_command_pool_khr)(self.handle, command_pool, flags);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrMaintenance1Fn::name()
}
pub const NAME: &'static CStr = vk::KhrMaintenance1Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrMaintenance1Fn {

View file

@ -28,10 +28,7 @@ impl Maintenance3 {
(self.fp.get_descriptor_set_layout_support_khr)(self.handle, create_info, out);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrMaintenance3Fn::name()
}
pub const NAME: &'static CStr = vk::KhrMaintenance3Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrMaintenance3Fn {

View file

@ -74,10 +74,7 @@ impl Maintenance4 {
assert_eq!(count as usize, out.len());
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrMaintenance4Fn::name()
}
pub const NAME: &'static CStr = vk::KhrMaintenance4Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrMaintenance4Fn {

View file

@ -67,10 +67,7 @@ impl PipelineExecutableProperties {
})
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrPipelineExecutablePropertiesFn::name()
}
pub const NAME: &'static CStr = vk::KhrPipelineExecutablePropertiesFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {

View file

@ -30,10 +30,7 @@ impl PresentWait {
(self.fp.wait_for_present_khr)(self.handle, swapchain, present_id, timeout).result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrPresentWaitFn::name()
}
pub const NAME: &'static CStr = vk::KhrPresentWaitFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrPresentWaitFn {

View file

@ -56,10 +56,7 @@ impl PushDescriptor {
);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrPushDescriptorFn::name()
}
pub const NAME: &'static CStr = vk::KhrPushDescriptorFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrPushDescriptorFn {

View file

@ -30,10 +30,7 @@ impl RayTracingMaintenance1 {
(self.fp.cmd_trace_rays_indirect2_khr)(command_buffer, indirect_device_address);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrRayTracingMaintenance1Fn::name()
}
pub const NAME: &'static CStr = vk::KhrRayTracingMaintenance1Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrRayTracingMaintenance1Fn {

View file

@ -177,10 +177,7 @@ impl RayTracingPipeline {
(self.fp.cmd_set_ray_tracing_pipeline_stack_size_khr)(command_buffer, pipeline_stack_size);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrRayTracingPipelineFn::name()
}
pub const NAME: &'static CStr = vk::KhrRayTracingPipelineFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn {

View file

@ -93,10 +93,7 @@ impl Surface {
(self.fp.destroy_surface_khr)(self.handle, surface, allocation_callbacks.as_raw_ptr());
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrSurfaceFn {

View file

@ -194,10 +194,7 @@ impl Swapchain {
}
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrSwapchainFn::name()
}
pub const NAME: &'static CStr = vk::KhrSwapchainFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrSwapchainFn {

View file

@ -89,10 +89,7 @@ impl Synchronization2 {
(self.fp.queue_submit2_khr)(queue, submits.len() as u32, submits.as_ptr(), fence).result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrSynchronization2Fn::name()
}
pub const NAME: &'static CStr = vk::KhrSynchronization2Fn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrSynchronization2Fn {

View file

@ -43,10 +43,7 @@ impl TimelineSemaphore {
(self.fp.signal_semaphore_khr)(self.handle, signal_info).result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrTimelineSemaphoreFn::name()
}
pub const NAME: &'static CStr = vk::KhrTimelineSemaphoreFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {

View file

@ -54,10 +54,7 @@ impl WaylandSurface {
b > 0
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrWaylandSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrWaylandSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn {

View file

@ -52,10 +52,7 @@ impl Win32Surface {
b > 0
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrWin32SurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrWin32SurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrWin32SurfaceFn {

View file

@ -56,10 +56,7 @@ impl XcbSurface {
b > 0
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrXcbSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrXcbSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrXcbSurfaceFn {

View file

@ -56,10 +56,7 @@ impl XlibSurface {
b > 0
}
#[inline]
pub const fn name() -> &'static CStr {
vk::KhrXlibSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::KhrXlibSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::KhrXlibSurfaceFn {

View file

@ -37,10 +37,7 @@ impl IOSSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::MvkIosSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::MvkIosSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::MvkIosSurfaceFn {

View file

@ -37,10 +37,7 @@ impl MacOSSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::MvkMacosSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::MvkMacosSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::MvkMacosSurfaceFn {

View file

@ -37,10 +37,7 @@ impl ViSurface {
.result_with_success(surface)
}
#[inline]
pub const fn name() -> &'static CStr {
vk::NnViSurfaceFn::name()
}
pub const NAME: &'static CStr = vk::NnViSurfaceFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NnViSurfaceFn {

View file

@ -58,10 +58,7 @@ impl CoverageReductionMode {
Ok(())
}
#[inline]
pub const fn name() -> &'static CStr {
vk::NvCoverageReductionModeFn::name()
}
pub const NAME: &'static CStr = vk::NvCoverageReductionModeFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NvCoverageReductionModeFn {

View file

@ -51,10 +51,7 @@ impl DeviceDiagnosticCheckpoints {
assert_eq!(count as usize, out.len());
}
#[inline]
pub const fn name() -> &'static CStr {
vk::NvDeviceDiagnosticCheckpointsFn::name()
}
pub const NAME: &'static CStr = vk::NvDeviceDiagnosticCheckpointsFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn {

View file

@ -69,10 +69,7 @@ impl MeshShader {
);
}
#[inline]
pub const fn name() -> &'static CStr {
vk::NvMeshShaderFn::name()
}
pub const NAME: &'static CStr = vk::NvMeshShaderFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NvMeshShaderFn {

View file

@ -254,10 +254,7 @@ impl RayTracing {
(self.fp.compile_deferred_nv)(self.handle, pipeline, shader).result()
}
#[inline]
pub const fn name() -> &'static CStr {
vk::NvRayTracingFn::name()
}
pub const NAME: &'static CStr = vk::NvRayTracingFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NvRayTracingFn {

File diff suppressed because it is too large Load diff

View file

@ -228,13 +228,13 @@ impl ExampleBase {
ash_window::enumerate_required_extensions(window.raw_display_handle())
.unwrap()
.to_vec();
extension_names.push(DebugUtils::name().as_ptr());
extension_names.push(DebugUtils::NAME.as_ptr());
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
extension_names.push(KhrPortabilityEnumerationFn::name().as_ptr());
extension_names.push(KhrPortabilityEnumerationFn::NAME.as_ptr());
// Enabling this extension is a requirement when using `VK_KHR_portability_subset`
extension_names.push(KhrGetPhysicalDeviceProperties2Fn::name().as_ptr());
extension_names.push(KhrGetPhysicalDeviceProperties2Fn::NAME.as_ptr());
}
let appinfo = vk::ApplicationInfo::default()
@ -316,9 +316,9 @@ impl ExampleBase {
.expect("Couldn't find suitable device.");
let queue_family_index = queue_family_index as u32;
let device_extension_names_raw = [
Swapchain::name().as_ptr(),
Swapchain::NAME.as_ptr(),
#[cfg(any(target_os = "macos", target_os = "ios"))]
KhrPortabilitySubsetFn::name().as_ptr(),
KhrPortabilitySubsetFn::NAME.as_ptr(),
];
let features = vk::PhysicalDeviceFeatures {
shader_clip_distance: 1,

View file

@ -1078,10 +1078,9 @@ pub fn generate_extension_commands<'a>(
let byte_name_ident = Literal::byte_string(format!("{extension_name}\0").as_bytes());
let extension_cstr = quote! {
impl #ident {
#[inline]
pub const fn name() -> &'static ::std::ffi::CStr {
unsafe { ::std::ffi::CStr::from_bytes_with_nul_unchecked(#byte_name_ident) }
}
pub const NAME: &'static ::std::ffi::CStr = unsafe {
::std::ffi::CStr::from_bytes_with_nul_unchecked(#byte_name_ident)
};
#spec_version
}
};