diff options
Diffstat (limited to 'src/graphics/permanent.rs')
| -rw-r--r-- | src/graphics/permanent.rs | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/graphics/permanent.rs b/src/graphics/permanent.rs index f359dbd..df86284 100644 --- a/src/graphics/permanent.rs +++ b/src/graphics/permanent.rs @@ -19,10 +19,10 @@ use winit::window::{ Window, WindowAttributes }; const VULKAN_FIRST_PORTABILITY_VERSION: Version = Version::new(1, 3, 216); -// The PermanentGraphicsState collects the various windowing-system and -// Vulkan objects which never need to be regenerated once they're created. The -// ones which do need that are collected below, in WindowDressing. -pub struct PermanentGraphicsState { +// Permanent is a state object which collects the various windowing-system +// and Vulkan objects which never need to be regenerated once they're created. +// The ones which do need that are collected below, in WindowDressing. +pub struct Permanent { // The "window" is the usual operating-system concept of a window; it's // provided by winit, and may be X11, Wayland, or some more curious thing. // The way we initialize Vulkan requires us to have at least one of these; @@ -100,11 +100,10 @@ pub struct EnableAnisotropy(pub bool); pub struct EnableSwapchain(pub bool); -impl PermanentGraphicsState { +impl Permanent { #[allow(unsafe_code)] pub fn new(event_loop: &ActiveEventLoop) - -> Result<(Self, GraphicsStateForReinit, EnableAnisotropy, - EnableSwapchain)> + -> Result<(Self, ForReinit, EnableAnisotropy, EnableSwapchain)> { let window = init_window(event_loop)?; @@ -141,11 +140,11 @@ impl PermanentGraphicsState { let (primary_command_pool, transient_command_pool) = init_command_pools(&device, &indices)?; - Ok((PermanentGraphicsState { + Ok((Permanent { window, entry, instance, debug_messager, surface, device, graphics_queue, presentation_queue, primary_command_pool, transient_command_pool, - }, GraphicsStateForReinit { + }, ForReinit { indices, sample_count, descriptor_set_layout, }, enable_anisotropy, enable_swapchain)) } @@ -230,18 +229,18 @@ impl PermanentGraphicsState { } -// The GraphicsStateForReinit connects Vulkan objects which are only needed -// during the creation of the window-dressing objects. They are used during -// initial startup, and again any time the window-dressing needs to be -// reinitialized. Most notably, they are not needed when rendering. -pub struct GraphicsStateForReinit { +// ForReinit is a state object that collects Vulkan objects which are only +// needed during the creation of the window-dressing objects. They are used +// during initial startup, and again any time the window-dressing needs to be +// reinitialized. Most notably, they are not needed when rendering. +pub struct ForReinit { pub indices: QueueFamilyIndices, pub sample_count: vk::SampleCountFlags, pub descriptor_set_layout: vk::DescriptorSetLayout, } -impl GraphicsStateForReinit { +impl ForReinit { #[allow(unsafe_code)] pub fn destroy(self, device: &Device) -> () { unsafe { @@ -494,7 +493,7 @@ fn init_vulkan_device(instance: &Instance, surface: &vk::SurfaceKHR, // we are discarding its results a second time. We'll do it for the // third and last time in swapchain creation. if let Acceptable::Accepted(_) - = PermanentGraphicsState::find_device_swapchain_features( + = Permanent::find_device_swapchain_features( &instance, &surface, &physical_device)? { extensions.push(swapchain_extension_name.as_ptr()); @@ -752,7 +751,7 @@ fn score_vulkan_device(instance: &Instance, surface: &vk::SurfaceKHR, // With that said, however, it only counts if we're able to actually // use it on the surface we have. Let's find out... if let Acceptable::Accepted(_) - = PermanentGraphicsState::find_device_swapchain_features( + = Permanent::find_device_swapchain_features( instance, surface, physical_device)? { // We don't count it for enough points to override a device type |