summary refs log tree commit diff
path: root/src/graphics_permanent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics_permanent.rs')
-rw-r--r--src/graphics_permanent.rs49
1 files changed, 6 insertions, 43 deletions
diff --git a/src/graphics_permanent.rs b/src/graphics_permanent.rs
index 63e8994..c19bacd 100644
--- a/src/graphics_permanent.rs
+++ b/src/graphics_permanent.rs
@@ -62,8 +62,6 @@ pub struct PermanentGraphicsState {
   // follow Vulkan's lead and let it have a short variable name.
   pub device: Device,
 
-  pub sampler: vk::Sampler,
-
   //   Vulkan has a first-class concept of command queues. We have two of
   // them, one for graphics drawing commands and one for presentation.
   //
@@ -90,14 +88,15 @@ pub struct QueueFamilyIndices {
 // for accidentally passing or returning one boolean as if it's another.
 struct EnablePortability(bool);
 struct EnableValidation(bool);
-struct EnableAnisotropy(bool);
+pub struct EnableAnisotropy(pub bool);
 pub struct EnableSwapchain(pub bool);
 
 
 impl PermanentGraphicsState {
   #[allow(unsafe_code)]
   pub fn new(event_loop: &ActiveEventLoop)
-      -> Result<(Self, GraphicsStateForReinit, EnableSwapchain)>
+      -> Result<(Self, GraphicsStateForReinit, EnableAnisotropy,
+                 EnableSwapchain)>
   {
     let window = init_window(event_loop)?;
 
@@ -130,22 +129,18 @@ impl PermanentGraphicsState {
         = init_vulkan_device(&instance, &surface,
                              enable_validation, enable_portability)?;
 
-    let sampler = init_sampler(&device, &enable_anisotropy)?;
-
     let descriptor_set_layout = init_descriptor_set_layout(&device)?;
 
     Ok((PermanentGraphicsState {
-      window, entry, instance, debug_messager, surface, device, sampler,
+      window, entry, instance, debug_messager, surface, device,
       graphics_queue, presentation_queue
     }, GraphicsStateForReinit {
-      physical_device, indices, descriptor_set_layout
-    }, enable_swapchain))
+      physical_device, indices, descriptor_set_layout,
+    }, enable_anisotropy, enable_swapchain))
   }
 
   #[allow(unsafe_code)]
   pub fn destroy(self) -> () {
-    unsafe { self.device.destroy_sampler(self.sampler, None) };
-
     unsafe { self.device.destroy_device(None) };
 
     unsafe { self.instance.destroy_surface_khr(self.surface, None) };
@@ -551,38 +546,6 @@ fn init_vulkan_device(instance: &Instance, surface: &vk::SurfaceKHR,
 
 
 #[allow(unsafe_code)]
-fn init_sampler(device: &Device, enable_anisotropy: &EnableAnisotropy)
-    -> Result<vk::Sampler>
-{
-  let mut sampler_info = vk::SamplerCreateInfo::builder()
-          .mag_filter(vk::Filter::LINEAR)
-          .min_filter(vk::Filter::LINEAR)
-          .address_mode_u(vk::SamplerAddressMode::REPEAT)
-          .address_mode_v(vk::SamplerAddressMode::REPEAT)
-          .address_mode_w(vk::SamplerAddressMode::REPEAT)
-          .border_color(vk::BorderColor::INT_OPAQUE_BLACK)
-          .unnormalized_coordinates(false)
-          .compare_enable(false)
-          .compare_op(vk::CompareOp::ALWAYS)
-          .mipmap_mode(vk::SamplerMipmapMode::LINEAR)
-          .mip_lod_bias(0.0)
-          .min_lod(0.0)
-          .max_lod(0.0);
-  sampler_info = if enable_anisotropy.0 {
-    sampler_info.anisotropy_enable(true)
-                .max_anisotropy(16.0)
-  } else {
-    sampler_info.anisotropy_enable(false)
-                .max_anisotropy(1.0)
-  };
-
-  let sampler = unsafe { device.create_sampler(&sampler_info, None) }?;
-
-  Ok(sampler)
-}
-
-
-#[allow(unsafe_code)]
 fn init_descriptor_set_layout(device: &Device)
     -> Result<vk::DescriptorSetLayout>
 {