Class VulkanModuleConfig

java.lang.Object
io.codetoil.curved_spacetime.vulkan.VulkanModuleConfig
All Implemented Interfaces:
ModuleConfig

public class VulkanModuleConfig extends Object implements ModuleConfig
The Vulkan module's settings, read from config/vulkan-module.config.

Two keys: validation turns the Vulkan validation layers on, which is expensive but reports API misuse the driver would otherwise ignore; preferredDeviceName names a GPU to use in preference to the automatic choice, which matters on machines with more than one. preferredDeviceName is genuinely optional and absent by default, so unlike other keys its absence does not mark the configuration dirty. In a future version preferredDeviceName will be added as a comment if no such comment is there and the option is absent.

  • Constructor Details

    • VulkanModuleConfig

      public VulkanModuleConfig(Logger logger)
      Creates a configuration that reports load problems to the given logger.
      Parameters:
      logger - the logger to warn through when a key is missing or invalid
  • Method Details

    • load

      public VulkanModuleConfig load() throws IOException
      Reads the configuration from disk, substituting defaults for anything missing.
      Specified by:
      load in interface ModuleConfig
      Returns:
      this configuration, so that construction and loading compose
      Throws:
      IOException - if the file exists but cannot be read
    • save

      public void save() throws IOException
      Writes the configuration to disk and clears the dirty flag.

      preferredDeviceName is omitted when unset, rather than written empty.

      Specified by:
      save in interface ModuleConfig
      Throws:
      IOException - if the file cannot be written
    • isDirty

      public boolean isDirty()
      Returns whether this configuration differs from what is on disk.

      Loading having substituted a default for validation is the usual cause; save() clears it. Note that an absent preferredDeviceName does not count, since that key is genuinely optional.

      Specified by:
      isDirty in interface ModuleConfig
      Returns:
      true if the file does not match this configuration and should be rewritten
    • validation

      public boolean validation()
      Returns whether the Vulkan validation layers should be enabled.
      Returns:
      true if validation was requested
    • getPreferredDeviceName

      public String getPreferredDeviceName()
      Returns the GPU to prefer over the automatic choice.
      Returns:
      the preferred device name, or null to select automatically