summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/main.rs b/src/main.rs
index 44e92bd..eb9c5d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -202,19 +202,17 @@ impl Surreality {
 
   fn init(&mut self, event_loop: &ActiveEventLoop) -> Result<()> {
     let window = Self::init_window(event_loop)?;
-    let entry = Self::init_vulkan_entry()?;
 
-    let (instance,
-         debug_messager,
-
-         //   There are a few Vulkan features (in the informal sense of
-         // "feature") that we want to be able to run both with and without.
-         // Here, we have booleans describing which we're doing.
-         //
-         //   These are only used to communicate between initialization
-         // phases; we don't keep them around after that.
+    //   There are a few Vulkan features (in the informal sense of
+    // "feature") that we want to be able to run both with and without.
+    // The enable_* values, here and below, are wrapped booleans that describe
+    // those choices.
+    //
+    //   These are only used to communicate between initialization
+    // phases; we don't keep them around after that.
+    let (entry, instance, debug_messager,
          enable_portability, enable_validation)
-        = Self::init_vulkan_instance(&window, &entry)?;
+        = Self::init_vulkan(&window)?;
 
     let surface = Self::init_surface(&window, &instance)?;
 
@@ -273,7 +271,7 @@ impl Surreality {
   fn init_window(event_loop: &ActiveEventLoop) -> Result<Window> {
     //   Notice that we do this before having a Vulkan instance. The window is
     // actually a parameter needed to create the instance; see
-    // init_vulkan_instance(), below.
+    // init_vulkan(), below.
     let window_attributes = WindowAttributes::default()
             .with_title("Love, Curiosity, Justice")
             .with_inner_size(LogicalSize::new(1024, 768));
@@ -281,10 +279,14 @@ impl Surreality {
     Ok(event_loop.create_window(window_attributes)?)
   }
 
-  // TODO this is another candidate for rolling into its parent
-  // (in addition to init_surface, which is below. what is time)
   #[allow(unsafe_code)]
-  fn init_vulkan_entry() -> Result<Entry> {
+  fn init_vulkan(window: &Window)
+      -> Result<(Entry, Instance, Option<vk::DebugUtilsMessengerEXT>,
+                 EnablePortability, EnableValidation)>
+  {
+    let enable_validation = cfg!(feature = "vulkan-validation")
+                            || cfg!(debug_assertions);
+
     //   Okay, so, a Vulkan "entry" is a small set of functions which are used
     // to dynamically load all the rest of Vulkan. It's our responsibility to
     // know how to load the entry, then it will take care of the rest. At
@@ -297,17 +299,6 @@ impl Surreality {
     let loader = unsafe { LibloadingLoader::new(LIBRARY) }?;
     let entry = unsafe { Entry::new(loader) }?;
 
-    Ok(entry)
-  }
-
-  #[allow(unsafe_code)]
-  fn init_vulkan_instance(window: &Window, entry: &Entry)
-      -> Result<(Instance, Option<vk::DebugUtilsMessengerEXT>,
-                 EnablePortability, EnableValidation)>
-  {
-    let enable_validation = cfg!(feature = "vulkan-validation")
-                            || cfg!(debug_assertions);
-
     //   Since there's a lot of factors going into our instance creation
     // request, we'll build up the parameters mutably.
     let mut flags = vk::InstanceCreateFlags::empty();
@@ -451,7 +442,8 @@ impl Surreality {
       None
     };
 
-    Ok((instance, debug_messager, enable_portability, enable_validation))
+    Ok((entry, instance, debug_messager,
+        enable_portability, enable_validation))
   }
 
   // TODO this is so short that it can likely be eliminated