evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::IPlatform Class Referenceabstract

Abstract interface for platform-specific functionality. More...

#include <headers/evan/IPlatform.hpp>

Inheritance diagram for evan::IPlatform:
Collaboration diagram for evan::IPlatform:

Public Member Functions

virtual ~IPlatform ()=default
 Virtual destructor.
 
virtual std::vector< std::string > getRequiredInstanceExtensions () const =0
 Get the required instance extensions for the platform.
 
virtual VkInstanceCreateFlags getInstanceCreateFlags () const
 Get platform-specific Vulkan instance creation flags.
 
virtual std::vector< std::string > getRequiredDeviceExtensions () const
 Get platform-specific required Vulkan device extensions.
 
virtual std::filesystem::path getPipelineCachePath () const
 Get the path where the Vulkan pipeline cache is persisted.
 
virtual bool shouldClose () const =0
 Check if the platform should close.
 
virtual std::vector< std::shared_ptr< utility::event::Event > > pollEvents (ADeviceBackend &deviceBackend)=0
 Poll for platform events.
 
virtual std::shared_ptr< ADeviceBackend > createDeviceBackend () const =0
 Create a device context for the platform.
 
virtual std::shared_ptr< ASwapchainContext > createSwapchainContext (const DeviceContext &deviceContext) const =0
 Get platform-specific instance creation information.
 
Error getLastError () const
 Get the last error recorded by the platform.
 

Protected Member Functions

virtual std::filesystem::path getDefaultCacheRoot () const =0
 Get the platform-specific cache root directory.
 

Protected Attributes

Error _lastError = Error::Ok
 Sticky error recorded by the platform while polling events.
 

Detailed Description

Abstract interface for platform-specific functionality.

Defines a common interface for platform implementations. Derived classes must implement platform-specific behavior.

Definition at line 33 of file IPlatform.hpp.

Constructor & Destructor Documentation

◆ ~IPlatform()

virtual evan::IPlatform::~IPlatform ( )
virtualdefault

Virtual destructor.

Ensures proper cleanup of derived class resources.

Member Function Documentation

◆ createDeviceBackend()

virtual std::shared_ptr< ADeviceBackend > evan::IPlatform::createDeviceBackend ( ) const
pure virtual

Create a device context for the platform.

Returns
A shared pointer to the created device context.

This method should create and return a device context that is compatible with the platform's requirements and capabilities.

Implemented in evan::IDesktopPlatform, and evan::IXrPlatform.

◆ createSwapchainContext()

virtual std::shared_ptr< ASwapchainContext > evan::IPlatform::createSwapchainContext ( const DeviceContext &  deviceContext) const
pure virtual

Get platform-specific instance creation information.

Parameters
deviceContextThe device context to use for creating the swapchain context.
Returns
A pointer to an XrBaseInStructure containing instance creation information, or nullptr if not applicable.

This method can be used to provide additional instance creation information specific to the platform, such as application info or extension-specific structures.

Implemented in evan::IDesktopPlatform, and evan::IXrPlatform.

◆ getDefaultCacheRoot()

virtual std::filesystem::path evan::IPlatform::getDefaultCacheRoot ( ) const
protectedpure virtual

Get the platform-specific cache root directory.

This is the directory the pipeline cache blob is stored under, before the EVAN_PIPELINE_CACHE_DIR override is applied. It is where the platform is allowed to write user data, for example ~/Library/Caches on macOS, XDG_CACHE_HOME or ~/.cache on Linux, LOCALAPPDATA% on Windows, and the application cache directory on Android.

Every concrete platform implements this method, because only the platform knows which directory it is allowed to write to. Returning an empty path disables persistence.

Returns
The cache root directory, or an empty path when the platform has no writable cache location.

Implemented in evan::LinuxDesktopPlatform, evan::MacOsDesktopPlatform, evan::WindowsDesktopPlatform, evan::AndroidXrPlatform, and evan::LinuxXrPlatform.

◆ getInstanceCreateFlags()

virtual VkInstanceCreateFlags evan::IPlatform::getInstanceCreateFlags ( ) const
inlinevirtual

Get platform-specific Vulkan instance creation flags.

Returns
Flags to OR into VkInstanceCreateInfo::flags.

Platforms that require special instance creation flags (e.g. the portability enumeration bit on macOS/MoltenVK) override this method.

Reimplemented in evan::MacOsDesktopPlatform.

Definition at line 62 of file IPlatform.hpp.

◆ getLastError()

Error evan::IPlatform::getLastError ( ) const
inline

Get the last error recorded by the platform.

Platforms record a sticky error while polling events (e.g. evan::Error::RuntimeLost when the OpenXR session is lost).

Returns
The last normalized error recorded by the platform.

Definition at line 159 of file IPlatform.hpp.

◆ getPipelineCachePath()

virtual std::filesystem::path evan::IPlatform::getPipelineCachePath ( ) const
virtual

Get the path where the Vulkan pipeline cache is persisted.

The returned path is where the cache blob written by PipelineCache::persist() is stored, and where the next run looks for a blob to reuse, so pipelines are not recompiled from scratch on every launch.

The default implementation honors two environment variables and then falls back to the per-user cache directory of the running platform:

  • EVAN_PIPELINE_CACHE_DISABLE, set to any non-empty value other than 0, disables persistence entirely.
  • EVAN_PIPELINE_CACHE_DIR overrides the cache root directory, which lets an application keep the blob next to its own build output.

Platforms without a writable cache location return an empty path, in which case the pipeline cache is kept in memory only.

Returns
The path of the pipeline cache blob, or an empty path to disable persistence.

◆ getRequiredDeviceExtensions()

virtual std::vector< std::string > evan::IPlatform::getRequiredDeviceExtensions ( ) const
inlinevirtual

Get platform-specific required Vulkan device extensions.

Returns
A vector of strings representing the required device extensions.

Platforms that require additional device extensions (e.g. the portability subset on macOS/MoltenVK) override this method.

Reimplemented in evan::MacOsDesktopPlatform.

Definition at line 76 of file IPlatform.hpp.

◆ getRequiredInstanceExtensions()

virtual std::vector< std::string > evan::IPlatform::getRequiredInstanceExtensions ( ) const
pure virtual

Get the required instance extensions for the platform.

Returns
A vector of strings representing the required instance extensions.

Implemented in evan::LinuxDesktopPlatform, evan::MacOsDesktopPlatform, evan::WindowsDesktopPlatform, evan::AndroidXrPlatform, evan::LinuxXrPlatform, evan::IDesktopPlatform, and evan::IXrPlatform.

◆ pollEvents()

virtual std::vector< std::shared_ptr< utility::event::Event > > evan::IPlatform::pollEvents ( ADeviceBackend &  deviceBackend)
pure virtual

Poll for platform events.

This method should be called regularly to process platform events.

Parameters
deviceBackendThe device backend to use for event processing, if needed.
Returns
A vector of shared pointers to Event objects representing the events that were polled from the platform. Each Event object contains information about the type of event, such as input events.

Implemented in evan::IDesktopPlatform, and evan::IXrPlatform.

◆ shouldClose()

virtual bool evan::IPlatform::shouldClose ( ) const
pure virtual

Check if the platform should close.

Returns
true if the platform should close, false otherwise.

Implemented in evan::IDesktopPlatform, and evan::IXrPlatform.

Member Data Documentation

◆ _lastError

Error evan::IPlatform::_lastError = Error::Ok
protected

Sticky error recorded by the platform while polling events.

Definition at line 186 of file IPlatform.hpp.


The documentation for this class was generated from the following file: