Blender V5.3
GHOST_XrGraphicsBindingVulkan Class Reference

Graphics binding between OpenXR and Vulkan. More...

#include <GHOST_XrGraphicsBindingVulkan.hh>

Inherits GHOST_IXrGraphicsBinding.

Public Member Functions

bool loadExtensionFunctions (XrInstance instance) override
 load the functions for the graphics binding.
bool checkVersionRequirements (GHOST_Context &ghost_ctx, XrInstance instance, XrSystemId system_id, std::string *r_requirement_info) const override
void initFromGhostContext (GHOST_Context &ghost_ctx, XrInstance instance, XrSystemId system_id) override
std::optional< int64_t > chooseSwapchainFormat (const std::vector< int64_t > &runtime_formats, GHOST_TXrSwapchainFormat &r_format, bool &r_is_srgb_format) const override
std::vector< XrSwapchainImageBaseHeader * > createSwapchainImages (uint32_t image_count) override
void submitToSwapchainBegin () override
void submitToSwapchainImage (XrSwapchainImageBaseHeader &swapchain_image, const GHOST_XrDrawViewInfo &draw_info) override
void submitToSwapchainEnd () override
bool needsUpsideDownDrawing (GHOST_Context &ghost_ctx) const override
Constructor
 GHOST_XrGraphicsBindingVulkan (GHOST_Context &ghost_ctx)
Destroying resources.
 ~GHOST_XrGraphicsBindingVulkan () override
Public Member Functions inherited from GHOST_IXrGraphicsBinding
virtual ~GHOST_IXrGraphicsBinding ()=default

Additional Inherited Members

Public Attributes inherited from GHOST_IXrGraphicsBinding
union  oxr_binding
Protected Member Functions inherited from GHOST_IXrGraphicsBinding
 GHOST_IXrGraphicsBinding ()=default

Detailed Description

Graphics binding between OpenXR and Vulkan.

OpenXR and Blender can have different requirements for a Vulkan device to be used. Some platforms require extensions that Blender didn't enable and other want to use a specific device.

Depending on the enabled extensions and device selection process one of the next three behaviors can be done.

Note
See #152482 for the initial design.

Reusing Blender Vulkan Instance

Blender tries to reuse the already created vulkan instance of GHOST_ContextVK. This is only possible when:

  • XR_KHR_vulkan_enable is supported by the Xr platform
  • xrGetVulkanGraphicsDeviceKHR returns the same device
  • extensions returned by xrGetVulkanInstanceExtensionsKHR are all enabled by GHOST_ContextVK
  • extensions returned by xrGetVulkanDeviceExtensionsKHR are all enabled by GHOST_ContextVK

This is typically the fastest way as almost everything can be done using Blenders' rendergraph.

Create a OpenXR Vulkan Instance

When we cannot reuse the existing instance an Xr specific Vulkan instance is being created. The data is transferred using external memory. Additional synchronization is needed as part of the pipeline cannot be done by Blender.

  • XR_KHR_vulkan_enable2 is supported by the Xr platform
  • Created physical device is the same as GHOST_ContextVK

Use CPU transfer

This is a fallback when devices don't match. In that case the results are transferred from the device that Blender is using to draw the UI to RAM and then transferred to the GPU that OpenXR is using.

Definition at line 69 of file GHOST_XrGraphicsBindingVulkan.hh.

Constructor & Destructor Documentation

◆ GHOST_XrGraphicsBindingVulkan()

GHOST_XrGraphicsBindingVulkan::GHOST_XrGraphicsBindingVulkan ( GHOST_Context & ghost_ctx)

◆ ~GHOST_XrGraphicsBindingVulkan()

GHOST_XrGraphicsBindingVulkan::~GHOST_XrGraphicsBindingVulkan ( )
override

Definition at line 40 of file GHOST_XrGraphicsBindingVulkan.cc.

Member Function Documentation

◆ checkVersionRequirements()

bool GHOST_XrGraphicsBindingVulkan::checkVersionRequirements ( GHOST_Context & ghost_ctx,
XrInstance instance,
XrSystemId system_id,
std::string * r_requirement_info ) const
overridevirtual

Check the version requirements to use OpenXR with the Vulkan backend.

Implements GHOST_IXrGraphicsBinding.

Definition at line 122 of file GHOST_XrGraphicsBindingVulkan.cc.

References CLOG_INFO, and LOG_GHOST_XR.

◆ chooseSwapchainFormat()

std::optional< int64_t > GHOST_XrGraphicsBindingVulkan::chooseSwapchainFormat ( const std::vector< int64_t > & runtime_formats,
GHOST_TXrSwapchainFormat & r_format,
bool & r_is_srgb_format ) const
overridevirtual

◆ createSwapchainImages()

std::vector< XrSwapchainImageBaseHeader * > GHOST_XrGraphicsBindingVulkan::createSwapchainImages ( uint32_t image_count)
overridevirtual

Implements GHOST_IXrGraphicsBinding.

Definition at line 611 of file GHOST_XrGraphicsBindingVulkan.cc.

References image.

◆ initFromGhostContext()

void GHOST_XrGraphicsBindingVulkan::initFromGhostContext ( GHOST_Context & ghost_ctx,
XrInstance instance,
XrSystemId system_id )
overridevirtual

◆ loadExtensionFunctions()

bool GHOST_XrGraphicsBindingVulkan::loadExtensionFunctions ( XrInstance instance)
overridevirtual

load the functions for the graphics binding.

A graphic binding uses an extension. These extensions provide graphics platform specific functions. This function is called before checkVersionRequirements allowing to preload the function pointers.

Parameters
instanceXrInstance where to retrieve the functions from.
Returns
true when the extensions functions were successfully loaded, return false when the extension functions could not be loaded or would not allow to use the binding.
Note
These functions should be stored as instance variable as they can differ between XrSessions.

Implements GHOST_IXrGraphicsBinding.

Definition at line 91 of file GHOST_XrGraphicsBindingVulkan.cc.

References CLOG_INFO, LOAD_FUNCTION, and LOG_GHOST_XR.

◆ needsUpsideDownDrawing()

bool GHOST_XrGraphicsBindingVulkan::needsUpsideDownDrawing ( GHOST_Context & ghost_ctx) const
overridevirtual

◆ submitToSwapchainBegin()

void GHOST_XrGraphicsBindingVulkan::submitToSwapchainBegin ( )
overridevirtual

Implements GHOST_IXrGraphicsBinding.

Definition at line 625 of file GHOST_XrGraphicsBindingVulkan.cc.

◆ submitToSwapchainEnd()

void GHOST_XrGraphicsBindingVulkan::submitToSwapchainEnd ( )
overridevirtual

Implements GHOST_IXrGraphicsBinding.

Definition at line 647 of file GHOST_XrGraphicsBindingVulkan.cc.

◆ submitToSwapchainImage()

void GHOST_XrGraphicsBindingVulkan::submitToSwapchainImage ( XrSwapchainImageBaseHeader & swapchain_image,
const GHOST_XrDrawViewInfo & draw_info )
overridevirtual

Implements GHOST_IXrGraphicsBinding.

Definition at line 626 of file GHOST_XrGraphicsBindingVulkan.cc.


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