Axmol 3.0.0-89d6d9a
Loading...
Searching...
No Matches
GraphicsCore Class Reference

Centralized manager for graphics driver lifecycle and shader environment. More...

#include <GraphicsCore.h>

Static Public Member Functions

static void setPreferredBackend (GraphicsBackend backend)
 Sets the preferred rendering backend (RHI).
static void setVulkanMinAndroidApiLevel (int apiLevel)
 Sets the minimum Android API level required to enable Vulkan.
static void setVulkanInterop (VulkanInterop *interop)
 Sets the Vulkan interoperability interface for external API integration.
static void setBackendPriority (GraphicsBackend backend, int prio)
 Sets the priority value for a specific rendering backend.
static int getBackendPriority (GraphicsBackend backend)
 Retrieves the current priority value for a specific rendering backend.
static void initialize ()
 Selects and prepares the active graphics device.
static void activate ()
 Activates the active graphics device (OpenGL only).
static void shutdown ()
 Releases and destroys the active graphics device, freeing all associated resources.
static GraphicsDevice * device ()
 Returns the active graphics device instance, or nullptr if not initialized.
static GraphicsBackend backend ()
 Returns the active (actually initialized) graphics backend.
static int shaderLanguage ()
 Returns the shader language (e.g.
static int shaderProfile ()
 Returns the shader profile version used by the active backend.
static int shaderILProfile ()
 Returns the shader intermediate-language profile used by the active backend.
static void setShaderILProfile (int profile)
 Sets the shader intermediate-language profile for the active backend.

Detailed Description

Centralized manager for graphics driver lifecycle and shader environment.

GraphicsCore provides a unified interface to create, activate, and destroy rendering drivers across multiple backends (D3D, Vulkan, Metal, OpenGL). It abstracts backend differences and ensures consistent shader language/profile setup for the current driver.

Note
GraphicsCore is the system-level entry point for all rendering operations. For actual GPU resource creation (e.g., textures, buffers, pipelines), use GraphicsCore::device() to obtain the active driver instance.

Member Function Documentation

◆ setPreferredBackend()

void setPreferredBackend ( GraphicsBackend backend)
static

Sets the preferred rendering backend (RHI).

This static method allows selecting a specific rendering backend for the engine, such as OpenGL, D3D11, D3D12, Vulkan, or Metal. If no preference is explicitly set, the default value is GraphicsBackend::Auto.

Parameters
backendThe desired rendering backend.

◆ setVulkanMinAndroidApiLevel()

void setVulkanMinAndroidApiLevel ( int apiLevel)
static

Sets the minimum Android API level required to enable Vulkan.

This function allows applications to restrict Vulkan usage based on the device's Android OS version. If the current device reports Vulkan support but its API level is lower than the configured minimum, Vulkan will be skipped during driver selection and the engine will fall back to the next available backend (e.g. OpenGL ES).

Note
This call is optional. If not invoked, Vulkan will be considered only on devices running Android 12 (API level 31) or higher, which is the default minimum requirement.
Warning
To ensure the restriction takes effect, this function should be invoked as early as possible (e.g. in the application delegate's constructor/applicationWillLaunch), before any rendering context or driver initialization occurs.
Parameters
apiLevelThe minimum Android API level required to allow Vulkan usage. Default is 31 (Android 12). References:

◆ setVulkanInterop()

void setVulkanInterop ( VulkanInterop * interop)
static

Sets the Vulkan interoperability interface for external API integration.

This function allows external rendering frameworks (such as OpenXR for VR/AR) to share Vulkan resources with the engine's internal Vulkan driver. The provided VulkanInterop instance serves as a bridge between the engine and the external API, enabling coordinated Vulkan instance and device management.

The typical use case is when the engine is used within an OpenXR application:

  • OpenXR runtime creates and manages the Vulkan instance and physical device
  • The engine needs to use the same Vulkan instance/device for rendering
  • VulkanInterop provides the necessary handles and synchronization primitives
Note
This function must be called before GraphicsCore::initialize() to take effect. Once the driver is initialized, changing the interop object has no effect.
Warning
The caller is responsible for ensuring the VulkanInterop object remains valid for the entire lifetime of the Vulkan driver. The engine does not take ownership of the pointer.
Parameters
interopPointer to a VulkanInterop implementation that provides the external Vulkan handles. Pass nullptr to clear the interop interface and revert to engine-managed Vulkan instance creation.
See also
VulkanInterop
initialize()

◆ setBackendPriority()

void setBackendPriority ( GraphicsBackend backend,
int prio )
static

Sets the priority value for a specific rendering backend.

This function allows advanced users to override the default backend selection order by assigning a custom priority to a given backend. Higher values indicate higher preference when selecting the active backend.

Note
This call is optional. If not invoked, the engine will use built-in default priorities to select the backend. It is primarily intended for advanced users who need fine-grained control over backend selection.
Warning
To ensure the priority takes effect, this function should be invoked as early as possible, typically in the application delegate's constructor/applicationWillLaunch, before any rendering context or window is created. Late changes may not apply if the backend has already been initialized. This API does not affect the fallback OpenGL backend.
Parameters
backendThe backend to assign a priority to.
prioThe priority value (higher means more preferred).

◆ getBackendPriority()

int getBackendPriority ( GraphicsBackend backend)
static

Retrieves the current priority value for a specific rendering backend.

This function returns the priority value previously assigned to the given backend, either by default or via setBackendPriority().

Parameters
backendThe backend to query.
Returns
The priority value associated with the backend.

◆ initialize()

void initialize ( )
static

Selects and prepares the active graphics device.

This function chooses the most suitable device implementation based on the configured priorities and available backends. For non-OpenGL backends, the device is created and automatically initialized. For OpenGL, only the device object is constructed here; initialization must be deferred until a valid window/context is available.

◆ activate()

void activate ( )
static

Activates the active graphics device (OpenGL only).

This function is only required when using OpenGL, since its initialization cannot be performed at construction time. It should be called after the window and GL context have been created, to complete the device setup.

For non-OpenGL backends, initialization is already performed during initialize(), so this function is not needed and will typically be a no-op.

◆ shaderLanguage()

int shaderLanguage ( )
static

Returns the shader language (e.g.

GLSL, ESSL, HLSL, SPIRV, MSL) used by the active backend.

◆ setShaderILProfile()

void setShaderILProfile ( int profile)
static

Sets the shader intermediate-language profile for the active backend.

Parameters
profileThe shader IL profile value.

The documentation for this class was generated from the following file:
  • GraphicsCore.h