Skip to content

Commit

Permalink
fixup! generator: Separate Fn struct
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Sep 3, 2023
1 parent bf94149 commit caba50a
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 207 deletions.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bumped MSRV from 1.59 to 1.60 (#709)
- Replaced `const fn name()` with associated `NAME` constants (#715)
- Generic builders now automatically set `objecttype` to `<T as Handle>::ObjectType` (#724)
- Separated low-level `*Fn` structs an high-level extension wrappers between instance and device functions, for the following extensions: (#734)
- Separated low-level `*Fn` structs and high-level extension wrappers between instance and device functions, for the following extensions: (#734)
- `VK_KHR_swapchain`
- `VK_KHR_video_queue`
- `VK_KHR_device_group`
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 @@ -41,7 +41,7 @@ fn main() -> Result<(), Box<dyn Error>> {
window.raw_window_handle(),
None,
)?;
let surface_fn = ash::extensions::khr::Surface::new(&entry, &instance);
let surface_fn = ash::extensions::khr::surface::Surface::new(&entry, &instance);
println!("surface: {surface:?}");

event_loop.run(move |event, _, control_flow| match event {
Expand Down
49 changes: 23 additions & 26 deletions ash-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
use std::os::raw::c_char;

use ash::{
extensions::{ext, khr},
extensions::{
ext::metal_surface,
khr::{
android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface,
},
},
prelude::*,
vk, Entry, Instance,
};
Expand Down Expand Up @@ -44,38 +49,38 @@ pub unsafe fn create_surface(
let surface_desc = vk::Win32SurfaceCreateInfoKHR::default()
.hinstance(window.hinstance)
.hwnd(window.hwnd);
let surface_fn = khr::Win32Surface::new(entry, instance);
let surface_fn = win32_surface::Win32Surface::new(entry, instance);
surface_fn.create_win32_surface(&surface_desc, allocation_callbacks)
}

(RawDisplayHandle::Wayland(display), RawWindowHandle::Wayland(window)) => {
let surface_desc = vk::WaylandSurfaceCreateInfoKHR::default()
.display(display.display)
.surface(window.surface);
let surface_fn = khr::WaylandSurface::new(entry, instance);
let surface_fn = wayland_surface::WaylandSurface::new(entry, instance);
surface_fn.create_wayland_surface(&surface_desc, allocation_callbacks)
}

(RawDisplayHandle::Xlib(display), RawWindowHandle::Xlib(window)) => {
let surface_desc = vk::XlibSurfaceCreateInfoKHR::default()
.dpy(display.display.cast())
.window(window.window);
let surface_fn = khr::XlibSurface::new(entry, instance);
let surface_fn = xlib_surface::XlibSurface::new(entry, instance);
surface_fn.create_xlib_surface(&surface_desc, allocation_callbacks)
}

(RawDisplayHandle::Xcb(display), RawWindowHandle::Xcb(window)) => {
let surface_desc = vk::XcbSurfaceCreateInfoKHR::default()
.connection(display.connection)
.window(window.window);
let surface_fn = khr::XcbSurface::new(entry, instance);
let surface_fn = xcb_surface::XcbSurface::new(entry, instance);
surface_fn.create_xcb_surface(&surface_desc, allocation_callbacks)
}

(RawDisplayHandle::Android(_), RawWindowHandle::AndroidNdk(window)) => {
let surface_desc =
vk::AndroidSurfaceCreateInfoKHR::default().window(window.a_native_window);
let surface_fn = khr::AndroidSurface::new(entry, instance);
let surface_fn = android_surface::AndroidSurface::new(entry, instance);
surface_fn.create_android_surface(&surface_desc, allocation_callbacks)
}

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

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

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

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

Expand All @@ -123,46 +128,38 @@ pub fn enumerate_required_extensions(
) -> VkResult<&'static [*const c_char]> {
let extensions = match display_handle {
RawDisplayHandle::Windows(_) => {
const WINDOWS_EXTS: [*const c_char; 2] = [
khr::Surface::NAME.as_ptr(),
khr::Win32Surface::NAME.as_ptr(),
];
const WINDOWS_EXTS: [*const c_char; 2] =
[surface::NAME.as_ptr(), win32_surface::NAME.as_ptr()];
&WINDOWS_EXTS
}

RawDisplayHandle::Wayland(_) => {
const WAYLAND_EXTS: [*const c_char; 2] = [
khr::Surface::NAME.as_ptr(),
khr::WaylandSurface::NAME.as_ptr(),
];
const WAYLAND_EXTS: [*const c_char; 2] =
[surface::NAME.as_ptr(), wayland_surface::NAME.as_ptr()];
&WAYLAND_EXTS
}

RawDisplayHandle::Xlib(_) => {
const XLIB_EXTS: [*const c_char; 2] =
[khr::Surface::NAME.as_ptr(), khr::XlibSurface::NAME.as_ptr()];
[surface::NAME.as_ptr(), xlib_surface::NAME.as_ptr()];
&XLIB_EXTS
}

RawDisplayHandle::Xcb(_) => {
const XCB_EXTS: [*const c_char; 2] =
[khr::Surface::NAME.as_ptr(), khr::XcbSurface::NAME.as_ptr()];
[surface::NAME.as_ptr(), xcb_surface::NAME.as_ptr()];
&XCB_EXTS
}

RawDisplayHandle::Android(_) => {
const ANDROID_EXTS: [*const c_char; 2] = [
khr::Surface::NAME.as_ptr(),
khr::AndroidSurface::NAME.as_ptr(),
];
const ANDROID_EXTS: [*const c_char; 2] =
[surface::NAME.as_ptr(), android_surface::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(),
];
const METAL_EXTS: [*const c_char; 2] =
[surface::NAME.as_ptr(), metal_surface::NAME.as_ptr()];
&METAL_EXTS
}

Expand Down
7 changes: 2 additions & 5 deletions ash/src/extensions/amd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
pub use self::buffer_marker::BufferMarker;
pub use self::shader_info::{ShaderInfo, ShaderInfoResult};

mod buffer_marker;
mod shader_info;
pub mod buffer_marker;
pub mod shader_info;
4 changes: 1 addition & 3 deletions ash/src/extensions/amdx/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub use self::shader_enqueue::ShaderEnqueue;

mod shader_enqueue;
pub mod shader_enqueue;
4 changes: 1 addition & 3 deletions ash/src/extensions/android/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub use self::external_memory_android_hardware_buffer::ExternalMemoryAndroidHardwareBuffer;

mod external_memory_android_hardware_buffer;
pub mod external_memory_android_hardware_buffer;
75 changes: 24 additions & 51 deletions ash/src/extensions/ext/mod.rs
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
pub use self::acquire_drm_display::AcquireDrmDisplay;
pub use self::buffer_device_address::BufferDeviceAddress;
pub use self::calibrated_timestamps::{CalibratedTimestampsDevice, CalibratedTimestampsInstance};
#[allow(deprecated)]
pub use self::debug_marker::DebugMarker;
#[allow(deprecated)]
pub use self::debug_report::DebugReport;
pub use self::debug_utils::{DebugUtilsDevice, DebugUtilsInstance};
pub use self::descriptor_buffer::DescriptorBuffer;
pub use self::extended_dynamic_state::ExtendedDynamicState;
pub use self::extended_dynamic_state2::ExtendedDynamicState2;
pub use self::extended_dynamic_state3::ExtendedDynamicState3;
pub use self::full_screen_exclusive::{FullScreenExclusiveDevice, FullScreenExclusiveInstance};
pub use self::headless_surface::HeadlessSurface;
pub use self::host_image_copy::HostImageCopy;
pub use self::image_compression_control::ImageCompressionControl;
pub use self::image_drm_format_modifier::ImageDrmFormatModifier;
pub use self::mesh_shader::MeshShader;
pub use self::metal_surface::MetalSurface;
pub use self::pipeline_properties::PipelineProperties;
pub use self::private_data::PrivateData;
pub use self::sample_locations::{SampleLocationsDevice, SampleLocationsInstance};
pub use self::shader_object::ShaderObject;
pub use self::swapchain_maintenance1::SwapchainMaintenance1;
pub use self::tooling_info::ToolingInfo;
pub use self::vertex_input_dynamic_state::VertexInputDynamicState;

mod acquire_drm_display;
mod buffer_device_address;
mod calibrated_timestamps;
pub mod acquire_drm_display;
pub mod buffer_device_address;
pub mod calibrated_timestamps;
#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]
mod debug_marker;
pub mod debug_marker;
#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")]
mod debug_report;
mod debug_utils;
mod descriptor_buffer;
mod extended_dynamic_state;
mod extended_dynamic_state2;
mod extended_dynamic_state3;
mod full_screen_exclusive;
mod headless_surface;
mod host_image_copy;
mod image_compression_control;
mod image_drm_format_modifier;
mod mesh_shader;
mod metal_surface;
mod pipeline_properties;
mod private_data;
mod sample_locations;
mod shader_object;
mod swapchain_maintenance1;
mod tooling_info;
mod vertex_input_dynamic_state;
pub mod debug_report;
pub mod debug_utils;
pub mod descriptor_buffer;
pub mod extended_dynamic_state;
pub mod extended_dynamic_state2;
pub mod extended_dynamic_state3;
pub mod full_screen_exclusive;
pub mod headless_surface;
pub mod host_image_copy;
pub mod image_compression_control;
pub mod image_drm_format_modifier;
pub mod mesh_shader;
pub mod metal_surface;
pub mod pipeline_properties;
pub mod private_data;
pub mod sample_locations;
pub mod shader_object;
pub mod swapchain_maintenance1;
pub mod tooling_info;
pub mod vertex_input_dynamic_state;
4 changes: 1 addition & 3 deletions ash/src/extensions/google/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub use self::display_timing::DisplayTiming;

mod display_timing;
pub mod display_timing;
124 changes: 41 additions & 83 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,41 @@
pub use self::acceleration_structure::AccelerationStructure;
pub use self::android_surface::AndroidSurface;
pub use self::buffer_device_address::BufferDeviceAddress;
pub use self::cooperative_matrix::CooperativeMatrix;
pub use self::copy_commands2::CopyCommands2;
pub use self::create_render_pass2::CreateRenderPass2;
pub use self::deferred_host_operations::DeferredHostOperations;
pub use self::device_group::{DeviceGroupDevice, DeviceGroupInstance};
pub use self::device_group_creation::DeviceGroupCreation;
pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain;
pub use self::draw_indirect_count::DrawIndirectCount;
pub use self::dynamic_rendering::DynamicRendering;
pub use self::external_fence_fd::ExternalFenceFd;
pub use self::external_fence_win32::ExternalFenceWin32;
pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::external_memory_win32::ExternalMemoryWin32;
pub use self::external_semaphore_fd::ExternalSemaphoreFd;
pub use self::external_semaphore_win32::ExternalSemaphoreWin32;
pub use self::get_memory_requirements2::GetMemoryRequirements2;
pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2;
pub use self::get_surface_capabilities2::GetSurfaceCapabilities2;
pub use self::maintenance1::Maintenance1;
pub use self::maintenance3::Maintenance3;
pub use self::maintenance4::Maintenance4;
pub use self::maintenance5::Maintenance5;
pub use self::performance_query::{PerformanceQueryDevice, PerformanceQueryInstance};
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
pub use self::present_wait::PresentWait;
pub use self::push_descriptor::PushDescriptor;
pub use self::ray_tracing_maintenance1::RayTracingMaintenance1;
pub use self::ray_tracing_pipeline::RayTracingPipeline;
pub use self::sampler_ycbcr_conversion::SamplerYcbcrConversion;
pub use self::surface::Surface;
pub use self::swapchain::{SwapchainDevice, SwapchainInstance};
pub use self::synchronization2::Synchronization2;
pub use self::timeline_semaphore::TimelineSemaphore;
pub use self::wayland_surface::WaylandSurface;
pub use self::win32_surface::Win32Surface;
pub use self::xcb_surface::XcbSurface;
pub use self::xlib_surface::XlibSurface;

mod acceleration_structure;
mod android_surface;
mod buffer_device_address;
mod cooperative_matrix;
mod copy_commands2;
mod create_render_pass2;
mod deferred_host_operations;
mod device_group;
mod device_group_creation;
mod display;
mod display_swapchain;
mod draw_indirect_count;
mod dynamic_rendering;
mod external_fence_fd;
mod external_fence_win32;
mod external_memory_fd;
mod external_memory_win32;
mod external_semaphore_fd;
mod external_semaphore_win32;
mod get_memory_requirements2;
mod get_physical_device_properties2;
mod get_surface_capabilities2;
mod maintenance1;
mod maintenance3;
mod maintenance4;
mod maintenance5;
mod performance_query;
mod pipeline_executable_properties;
mod present_wait;
mod push_descriptor;
mod ray_tracing_maintenance1;
mod ray_tracing_pipeline;
mod sampler_ycbcr_conversion;
mod surface;
mod swapchain;
mod synchronization2;
mod timeline_semaphore;
mod wayland_surface;
mod win32_surface;
mod xcb_surface;
mod xlib_surface;
pub mod acceleration_structure;
pub mod android_surface;
pub mod buffer_device_address;
pub mod cooperative_matrix;
pub mod copy_commands2;
pub mod create_render_pass2;
pub mod deferred_host_operations;
pub mod device_group;
pub mod device_group_creation;
pub mod display;
pub mod display_swapchain;
pub mod draw_indirect_count;
pub mod dynamic_rendering;
pub mod external_fence_fd;
pub mod external_fence_win32;
pub mod external_memory_fd;
pub mod external_memory_win32;
pub mod external_semaphore_fd;
pub mod external_semaphore_win32;
pub mod get_memory_requirements2;
pub mod get_physical_device_properties2;
pub mod get_surface_capabilities2;
pub mod maintenance1;
pub mod maintenance3;
pub mod maintenance4;
pub mod maintenance5;
pub mod performance_query;
pub mod pipeline_executable_properties;
pub mod present_wait;
pub mod push_descriptor;
pub mod ray_tracing_maintenance1;
pub mod ray_tracing_pipeline;
pub mod sampler_ycbcr_conversion;
pub mod surface;
pub mod swapchain;
pub mod synchronization2;
pub mod timeline_semaphore;
pub mod wayland_surface;
pub mod win32_surface;
pub mod xcb_surface;
pub mod xlib_surface;
7 changes: 2 additions & 5 deletions ash/src/extensions/mvk/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
pub use self::ios_surface::IOSSurface;
pub use self::macos_surface::MacOSSurface;

mod ios_surface;
mod macos_surface;
pub mod ios_surface;
pub mod macos_surface;
4 changes: 1 addition & 3 deletions ash/src/extensions/nn/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub use self::vi_surface::ViSurface;

mod vi_surface;
pub mod vi_surface;
Loading

0 comments on commit caba50a

Please sign in to comment.