Vulkan SDK for Android 1.1.1 Mali Developer Center
MaliSDK::Platform Class Referenceabstract

The platform class is to abstract the Vulkan implementation of a particular platform. It is not used directly by applications, but by the mainloop implementation which is OS specific. More...

#include <platform.hpp>

Inheritance diagram for MaliSDK::Platform:
MaliSDK::PNGPlatform MaliSDK::WSIPlatform MaliSDK::AndroidPlatform MaliSDK::DisplayPlatform MaliSDK::WaylandPlatform MaliSDK::XCBPlatform

Classes

struct  SwapchainDimensions
 Describes the size and format of the swapchain. More...
 

Public Types

enum  Status { STATUS_RUNNING, STATUS_TEARDOWN }
 Describes the status of the application lifecycle. More...
 

Public Member Functions

virtual ~Platform ()=default
 Destructor.
 
 Platform (Platform &&)=delete
 Disallow copies and moves.
 
void operator= (Platform &&)=delete
 Disallow copies and moves.
 
ContextgetContext ()
 Gets the context owned by the platform. More...
 
virtual Result initialize ()=0
 Initializes the platform. More...
 
void addExternalLayer (const char *pName)
 Adds an additional layer to be loaded on startup, if it exists. More...
 
void setExternalDebugCallback (PFN_vkDebugReportCallbackEXT callback, void *pUserData)
 Sets an external debug callback handler. The callback will be called if the platform receives debug report events. More...
 
PFN_vkDebugReportCallbackEXT getExternalDebugCallback () const
 Returns the currently set debug callback. More...
 
void * getExternalDebugCallbackUserData () const
 Returns the currently set debug callback. More...
 
virtual SwapchainDimensions getPreferredSwapchain ()=0
 Gets the preferred swapchain size. Not relevant for all platforms. More...
 
virtual Result createWindow (const SwapchainDimensions &swapchain)=0
 Creates a window with desired swapchain dimensions. More...
 
virtual void getCurrentSwapchain (std::vector< VkImage > *images, SwapchainDimensions *swapchain)=0
 Gets the current swapchain. More...
 
virtual unsigned getNumSwapchainImages () const =0
 Gets number of swapchain images used. More...
 
virtual Result acquireNextImage (unsigned *index)=0
 At start of a frame, acquire the next swapchain image to render into. More...
 
virtual Result presentImage (unsigned index)=0
 Presents an image to the swapchain. More...
 
virtual Status getWindowStatus ()=0
 Gets current window status. More...
 
virtual void terminate ()=0
 Terminates the platform.
 
VkDevice getDevice () const
 Gets the current Vulkan device. More...
 
VkPhysicalDevice getPhysicalDevice () const
 Gets the current Vulkan physical device. More...
 
VkInstance getInstance () const
 Gets the current Vulkan instance. More...
 
VkQueue getGraphicsQueue () const
 Gets the current Vulkan graphics queue. More...
 
unsigned getGraphicsQueueIndex () const
 Gets the current Vulkan graphics queue family index. More...
 
const VkPhysicalDeviceProperties & getGpuProperties () const
 Gets the current Vulkan GPU properties. More...
 
const VkPhysicalDeviceMemoryProperties & getMemoryProperties () const
 Gets the current Vulkan GPU memory properties. More...
 

Static Public Member Functions

static Platformget ()
 The platform is a singleton. More...
 

Protected Member Functions

 Platform ()=default
 Protected constructor. Only platform implementations can create this class.
 
void addExternalLayers (std::vector< const char *> &activeLayers, const std::vector< VkLayerProperties > &supportedLayers)
 Helper function to add external layers to a list of active ones. More...
 

Protected Attributes

VkInstance instance = VK_NULL_HANDLE
 The Vulkan instance.
 
VkPhysicalDevice gpu = VK_NULL_HANDLE
 The Vulkan physical device.
 
VkDevice device = VK_NULL_HANDLE
 The Vulkan device.
 
VkQueue queue = VK_NULL_HANDLE
 The Vulkan device queue.
 
ContextpContext = nullptr
 The Vulkan context.
 
VkPhysicalDeviceProperties gpuProperties
 The Vulkan physical device properties.
 
VkPhysicalDeviceMemoryProperties memoryProperties
 The Vulkan physical device memory properties.
 
std::vector< VkQueueFamilyProperties > queueProperties
 The Vulkan physical device queue properties.
 
unsigned graphicsQueueIndex
 The queue family index where graphics work will be submitted.
 
std::vector< std::string > externalLayers
 List of external layers to load.
 
PFN_vkDebugReportCallbackEXT externalDebugCallback = nullptr
 External debug callback.
 
void * pExternalDebugCallbackUserData = nullptr
 User-data for external debug callback.
 

Detailed Description

The platform class is to abstract the Vulkan implementation of a particular platform. It is not used directly by applications, but by the mainloop implementation which is OS specific.

Definition at line 38 of file platform.hpp.

Member Enumeration Documentation

◆ Status

Describes the status of the application lifecycle.

Enumerator
STATUS_RUNNING 

The application is running.

STATUS_TEARDOWN 

The application should exit as the user has requested it.

Definition at line 65 of file platform.hpp.

Member Function Documentation

◆ acquireNextImage()

virtual Result MaliSDK::Platform::acquireNextImage ( unsigned *  index)
pure virtual

At start of a frame, acquire the next swapchain image to render into.

Parameters
[out]indexThe acquired index.
Returns
Error code. Can return RESULT_ERROR_OUTDATED_SWAPCHAIN. If this happens, acquireNextImage should be called again and VulkanApplication::updateSwapchain must be called.

Implemented in MaliSDK::PNGPlatform, and MaliSDK::WSIPlatform.

◆ addExternalLayer()

void MaliSDK::Platform::addExternalLayer ( const char *  pName)
inline

Adds an additional layer to be loaded on startup, if it exists.

Parameters
pNameName of the layer.

Definition at line 87 of file platform.hpp.

◆ addExternalLayers()

void MaliSDK::Platform::addExternalLayers ( std::vector< const char *> &  activeLayers,
const std::vector< VkLayerProperties > &  supportedLayers 
)
inlineprotected

Helper function to add external layers to a list of active ones.

Parameters
activeLayersList of active layers to be used.
supportedLayersList of supported layers.

Definition at line 250 of file platform.hpp.

◆ createWindow()

virtual Result MaliSDK::Platform::createWindow ( const SwapchainDimensions swapchain)
pure virtual

Creates a window with desired swapchain dimensions.

The swapchain parameters might not necessarily be honored by the platform. Use getCurrentSwapchain to query the dimensions we actually initialized.

Returns
Error code.

Implemented in MaliSDK::WaylandPlatform, MaliSDK::AndroidPlatform, MaliSDK::PNGPlatform, MaliSDK::DisplayPlatform, and MaliSDK::XCBPlatform.

◆ get()

Platform & MaliSDK::Platform::get ( )
static

The platform is a singleton.

Returns
The platform

Definition at line 26 of file android.cpp.

◆ getContext()

Context& MaliSDK::Platform::getContext ( )
inline

Gets the context owned by the platform.

Returns
The context.

Definition at line 76 of file platform.hpp.

◆ getCurrentSwapchain()

virtual void MaliSDK::Platform::getCurrentSwapchain ( std::vector< VkImage > *  images,
SwapchainDimensions swapchain 
)
pure virtual

Gets the current swapchain.

Parameters
[out]imagesVkImages which application can render into.
[out]swapchainThe swapchain dimensions currently used.

Implemented in MaliSDK::PNGPlatform, and MaliSDK::WSIPlatform.

◆ getDevice()

VkDevice MaliSDK::Platform::getDevice ( ) const
inline

Gets the current Vulkan device.

Returns
Vulkan device.

Definition at line 160 of file platform.hpp.

◆ getExternalDebugCallback()

PFN_vkDebugReportCallbackEXT MaliSDK::Platform::getExternalDebugCallback ( ) const
inline

Returns the currently set debug callback.

Returns
The callback, or nullptr if not set.

Definition at line 104 of file platform.hpp.

◆ getExternalDebugCallbackUserData()

void* MaliSDK::Platform::getExternalDebugCallbackUserData ( ) const
inline

Returns the currently set debug callback.

Returns
The callback, or nullptr if not set.

Definition at line 111 of file platform.hpp.

◆ getGpuProperties()

const VkPhysicalDeviceProperties& MaliSDK::Platform::getGpuProperties ( ) const
inline

Gets the current Vulkan GPU properties.

Returns
GPU properties.

Definition at line 195 of file platform.hpp.

◆ getGraphicsQueue()

VkQueue MaliSDK::Platform::getGraphicsQueue ( ) const
inline

Gets the current Vulkan graphics queue.

Returns
Vulkan queue.

Definition at line 181 of file platform.hpp.

◆ getGraphicsQueueIndex()

unsigned MaliSDK::Platform::getGraphicsQueueIndex ( ) const
inline

Gets the current Vulkan graphics queue family index.

Returns
Vulkan queue family index.

Definition at line 188 of file platform.hpp.

◆ getInstance()

VkInstance MaliSDK::Platform::getInstance ( ) const
inline

Gets the current Vulkan instance.

Returns
Vulkan instance.

Definition at line 174 of file platform.hpp.

◆ getMemoryProperties()

const VkPhysicalDeviceMemoryProperties& MaliSDK::Platform::getMemoryProperties ( ) const
inline

Gets the current Vulkan GPU memory properties.

Returns
GPU memory properties.

Definition at line 202 of file platform.hpp.

◆ getNumSwapchainImages()

virtual unsigned MaliSDK::Platform::getNumSwapchainImages ( ) const
pure virtual

Gets number of swapchain images used.

Returns
Number of images.

Implemented in MaliSDK::PNGPlatform, and MaliSDK::WSIPlatform.

◆ getPhysicalDevice()

VkPhysicalDevice MaliSDK::Platform::getPhysicalDevice ( ) const
inline

Gets the current Vulkan physical device.

Returns
Vulkan physical device.

Definition at line 167 of file platform.hpp.

◆ getPreferredSwapchain()

virtual SwapchainDimensions MaliSDK::Platform::getPreferredSwapchain ( )
pure virtual

Gets the preferred swapchain size. Not relevant for all platforms.

Returns
Error code.

Implemented in MaliSDK::WaylandPlatform, MaliSDK::AndroidPlatform, MaliSDK::PNGPlatform, MaliSDK::DisplayPlatform, and MaliSDK::XCBPlatform.

◆ getWindowStatus()

virtual Status MaliSDK::Platform::getWindowStatus ( )
pure virtual

Gets current window status.

Returns
Window status.

Implemented in MaliSDK::WaylandPlatform, MaliSDK::PNGPlatform, MaliSDK::AndroidPlatform, MaliSDK::DisplayPlatform, and MaliSDK::XCBPlatform.

◆ initialize()

virtual Result MaliSDK::Platform::initialize ( )
pure virtual

Initializes the platform.

Returns
Error code.

Implemented in MaliSDK::WaylandPlatform, MaliSDK::WSIPlatform, MaliSDK::PNGPlatform, and MaliSDK::XCBPlatform.

◆ presentImage()

virtual Result MaliSDK::Platform::presentImage ( unsigned  index)
pure virtual

Presents an image to the swapchain.

Parameters
indexThe swapchain index previously obtained from acquireNextImage.
Returns
Error code.

Implemented in MaliSDK::WaylandPlatform, MaliSDK::PNGPlatform, MaliSDK::WSIPlatform, and MaliSDK::XCBPlatform.

◆ setExternalDebugCallback()

void MaliSDK::Platform::setExternalDebugCallback ( PFN_vkDebugReportCallbackEXT  callback,
void *  pUserData 
)
inline

Sets an external debug callback handler. The callback will be called if the platform receives debug report events.

Parameters
callbackThe callback, may be nullptr to disable callback.
pUserDataUser data, may be nullptr.

Definition at line 96 of file platform.hpp.


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