Skip to content

Commit

Permalink
Inline predule module contents into their parent modules (#972)
Browse files Browse the repository at this point in the history
We've never used `prelude` in a sensible way, both modules inside
the crate root and `vk` namespace have always abused these modules to
store a random combination of private utilities next to a few extra
hand-written type/trait definitions and implementations.

Neither of these need to glob-imported by users to make easy use of
`ash` functionality besides perhaps ensuring traits like `Handle` and
`TaggedStructure` are in scope.  Their glob imports were only useful
to `ash` itself, and even then the `vk::prelude` was already fully
glob-reexported in `vk`.

Besides inlining its contents, I've shuffled some private helpers like
`debug_flags()` closer to where they are being used.
  • Loading branch information
MarijnS95 authored Dec 8, 2024
1 parent 92a0ee6 commit 8b0d4c5
Show file tree
Hide file tree
Showing 78 changed files with 393 additions and 380 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- Removed unused lifetime from `vk::AllocationCallbacks` structure (#968)
- Removed `ash::prelude` and `ash::vk::prelude` in favour of capturing all contents directly in their parent module. (#972)

## [0.38.0] - 2024-04-01

Expand Down
3 changes: 1 addition & 2 deletions ash-window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::os::raw::c_char;
use ash::{
ext::metal_surface,
khr::{android_surface, surface, wayland_surface, win32_surface, xcb_surface, xlib_surface},
prelude::*,
vk, Entry, Instance,
vk, Entry, Instance, VkResult,
};
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};

Expand Down
3 changes: 2 additions & 1 deletion ash/src/device.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(clippy::trivially_copy_pass_by_ref)]
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::ffi;
use core::mem;
Expand Down
5 changes: 3 additions & 2 deletions ash/src/entry.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::instance::Instance;
use super::Instance;
#[cfg(doc)]
use crate::khr;
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::ffi;
use core::fmt;
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/amd/shader_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMD_shader_info.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;
use core::mem::size_of_val; // TODO: Remove when bumping MSRV to 1.80
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/amdx/shader_enqueue.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMDX_shader_enqueue.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_ANDROID_external_memory_android_hardware_buffer.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::android::external_memory_android_hardware_buffer::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/acquire_drm_display.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_acquire_drm_display.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::ext::acquire_drm_display::Instance {
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/ext/calibrated_timestamps.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_calibrated_timestamps.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/debug_marker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_marker.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;

impl crate::ext::debug_marker::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/debug_report.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_report.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::ext::debug_report::Instance {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/debug_utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_debug_utils.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::ext::debug_utils::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/descriptor_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_descriptor_buffer.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::ext::descriptor_buffer::Device {
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/ext/full_screen_exclusive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_full_screen_exclusive.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/headless_surface.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_headless_surface.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::ext::headless_surface::Instance {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/host_image_copy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
#[cfg(doc)]
use crate::{ext, khr};

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/image_drm_format_modifier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_drm_format_modifier.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;

impl crate::ext::image_drm_format_modifier::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageDrmFormatModifierPropertiesEXT.html>
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/metal_surface.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_metal_surface.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::ext::metal_surface::Instance {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/pipeline_properties.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_pipeline_properties.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;

impl crate::ext::pipeline_properties::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPipelinePropertiesEXT.html>
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/private_data.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_private_data.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::ext::private_data::Device {
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/ext/shader_object.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_shader_object.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::ptr;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/swapchain_maintenance1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_swapchain_maintenance1.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;

impl crate::ext::swapchain_maintenance1::Device {
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkReleaseSwapchainImagesEXT.html>
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/ext/tooling_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_tooling_info.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;
use core::ptr;

Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/google/display_timing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_GOOGLE_display_timing.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/acceleration_structure.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_acceleration_structure.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/android_surface.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_android_surface.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::khr::android_surface::Instance {
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/khr/calibrated_timestamps.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! <https://registry.khronos.org//vulkan/specs/1.3-extensions/man/html/VK_KHR_calibrated_timestamps.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/cooperative_matrix.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_cooperative_matrix.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;
use core::ptr;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/create_renderpass2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_create_renderpass2.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::khr::create_renderpass2::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/deferred_host_operations.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_deferred_host_operations.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use core::mem;

impl crate::khr::deferred_host_operations::Device {
Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/khr/device_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#[cfg(doc)]
use crate::khr;
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/device_group_creation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group_creation.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;
use core::ptr;

Expand Down
3 changes: 2 additions & 1 deletion ash/src/extensions/khr/display.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_display.html>
use crate::prelude::*;
use crate::read_into_uninitialized_vector;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;
use core::mem;

Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/display_swapchain.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_display_swapchain.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::VkResult;
use alloc::vec::Vec;

impl crate::khr::display_swapchain::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_fence_fd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_fence_fd.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_fence_fd::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_fence_win32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_fence_win32.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_fence_win32::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_memory_fd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_memory_fd.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_memory_fd::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_memory_win32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_memory_win32.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_memory_win32::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_semaphore_fd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_semaphore_fd.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_semaphore_fd::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/external_semaphore_win32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_semaphore_win32.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;

impl crate::khr::external_semaphore_win32::Device {
Expand Down
2 changes: 1 addition & 1 deletion ash/src/extensions/khr/get_display_properties2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_get_display_properties2.html>
use crate::prelude::*;
use crate::vk;
use crate::VkResult;
use core::mem;
use core::ptr;

Expand Down
Loading

0 comments on commit 8b0d4c5

Please sign in to comment.