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

The WSI platform is a common platform for all platforms which support the VK_KHRSurface extension. The purpose of this class is to move all common code for WSI into this class and make the platform-specifics as minimal as possible. More...

#include <wsi.hpp>

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

Public Member Functions

virtual ~WSIPlatform ()
 Destructor.
 
virtual Result initialize () override
 Initialize the platform. Can be overriden by subclasses as long as they also call this method. More...
 
virtual void getCurrentSwapchain (std::vector< VkImage > *images, SwapchainDimensions *swapchain) override
 Gets the current swapchain. More...
 
virtual unsigned getNumSwapchainImages () const override
 Gets number of swapchain images used. More...
 
virtual Result acquireNextImage (unsigned *index) override
 At start of a frame, acquire the next swapchain image to render into. More...
 
virtual Result presentImage (unsigned index) override
 Presents an image to the swapchain. More...
 
void terminate () override
 Terminates the platform. Normally this would be handled by the destructor, but certain platforms need to be able to terminate before exit() and initialize multiple times.
 
- Public Member Functions inherited from MaliSDK::Platform
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...
 
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 Status getWindowStatus ()=0
 Gets current window status. More...
 
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...
 

Protected Member Functions

Result initVulkan (const SwapchainDimensions &swapchain, const std::vector< const char *> &instanceExtensions, const std::vector< const char *> &deviceExtensions)
 Initializes the Vulkan device. More...
 
Result initSwapchain (const SwapchainDimensions &swapchain)
 Explicitly initializes the swapchain. More...
 
void destroySwapchain ()
 Explicit tears down the swapchain.
 
- Protected Member Functions inherited from MaliSDK::Platform
 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...
 

Additional Inherited Members

- Public Types inherited from MaliSDK::Platform
enum  Status { STATUS_RUNNING, STATUS_TEARDOWN }
 Describes the status of the application lifecycle. More...
 
- Static Public Member Functions inherited from MaliSDK::Platform
static Platformget ()
 The platform is a singleton. More...
 
- Protected Attributes inherited from MaliSDK::Platform
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 WSI platform is a common platform for all platforms which support the VK_KHRSurface extension. The purpose of this class is to move all common code for WSI into this class and make the platform-specifics as minimal as possible.

Definition at line 36 of file wsi.hpp.

Member Function Documentation

◆ acquireNextImage()

Result MaliSDK::WSIPlatform::acquireNextImage ( unsigned *  index)
overridevirtual

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.

Implements MaliSDK::Platform.

Definition at line 688 of file wsi.cpp.

◆ getCurrentSwapchain()

void MaliSDK::WSIPlatform::getCurrentSwapchain ( std::vector< VkImage > *  images,
SwapchainDimensions swapchain 
)
overridevirtual

Gets the current swapchain.

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

Implements MaliSDK::Platform.

Definition at line 677 of file wsi.cpp.

◆ getNumSwapchainImages()

unsigned MaliSDK::WSIPlatform::getNumSwapchainImages ( ) const
overridevirtual

Gets number of swapchain images used.

Returns
Number of images.

Implements MaliSDK::Platform.

Definition at line 683 of file wsi.cpp.

◆ initialize()

Result MaliSDK::WSIPlatform::initialize ( )
overridevirtual

Initialize the platform. Can be overriden by subclasses as long as they also call this method.

Returns
Error code

Implements MaliSDK::Platform.

Reimplemented in MaliSDK::WaylandPlatform, and MaliSDK::XCBPlatform.

Definition at line 96 of file wsi.cpp.

◆ initSwapchain()

Result MaliSDK::WSIPlatform::initSwapchain ( const SwapchainDimensions swapchain)
protected

Explicitly initializes the swapchain.

This is implicitly called by initVulkan, so this should only be called if destroySwapchain has been called before.

Parameters
swapchainSwapchain dimensions.
Returns
Error code

Definition at line 551 of file wsi.cpp.

◆ initVulkan()

Result MaliSDK::WSIPlatform::initVulkan ( const SwapchainDimensions swapchain,
const std::vector< const char *> &  instanceExtensions,
const std::vector< const char *> &  deviceExtensions 
)
protected

Initializes the Vulkan device.

Parameters
swapchainThe requested swapchain dimensions and size. Can be overridden by WSI.
[out]instanceExtensionsThe required Vulkan instance extensions the platform requires.
[out]deviceExtensionsThe required Vulkan device extensions the platform requires.
Returns
Error code

Definition at line 133 of file wsi.cpp.

◆ presentImage()

Result MaliSDK::WSIPlatform::presentImage ( unsigned  index)
overridevirtual

Presents an image to the swapchain.

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

Implements MaliSDK::Platform.

Reimplemented in MaliSDK::WaylandPlatform, and MaliSDK::XCBPlatform.

Definition at line 728 of file wsi.cpp.


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