Bläddra i källkod

Add function context copy to OpenXRVk instance

Signed-off-by: Akio Gaule <[email protected]>
Akio Gaule 2 år sedan
förälder
incheckning
a000699361

+ 3 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInstance.h

@@ -71,6 +71,9 @@ namespace OpenXRVk
         //! Ge the active VkPhysicalDevice.
         VkPhysicalDevice GetActivePhysicalDevice() const;
 
+        //! Disable certain extensions because function pointers didn't load correctly.
+        void FilterAvailableExtensions(GladVulkanContext& context) const;
+
     protected:
         // XR::Instance overrides...
         AZ::RHI::ResultCode InitInstanceInternal() override;

+ 2 - 6
Gems/OpenXRVk/Code/Source/OpenXRVkDevice.cpp

@@ -96,12 +96,8 @@ namespace OpenXRVk
             const bool functionsLoaded = xrVkInstance->GetFunctionLoader().LoadProcAddresses(
                 &xrVkInstance->GetContext(), xrVkInstance->GetNativeInstance(), xrVkPhysicalDevice, m_xrVkDevice);
             m_context = xrVkInstance->GetContext();
-            // In some cases (like when running with the GPU profiler on Quest2) the extension is reported as available
-            // but the function pointers do not load. Disable the extension if that's the case.
-            if (m_context.EXT_debug_utils && !m_context.CmdBeginDebugUtilsLabelEXT)
-            {
-                m_context.EXT_debug_utils = 0;
-            }
+
+            xrVkInstance->FilterAvailableExtensions(m_context);
 
             if (!functionsLoaded)
             {

+ 13 - 0
Gems/OpenXRVk/Code/Source/OpenXRVkInstance.cpp

@@ -355,8 +355,11 @@ namespace OpenXRVk
             return AZ::RHI::ResultCode::Fail;
         }
 
+        FilterAvailableExtensions(m_context);
+
         //Populate the instance descriptor with the correct VkInstance
         xrInstanceDescriptor->m_outputData.m_xrVkInstance = m_xrVkInstance;
+        xrInstanceDescriptor->m_outputData.m_context = m_context;
 
         //Get the list of Physical devices
         m_supportedXRDevices = PhysicalDevice::EnumerateDeviceList(m_xrSystemId, m_xrInstance, m_xrVkInstance);
@@ -412,6 +415,16 @@ namespace OpenXRVk
         return m_supportedXRDevices[m_physicalDeviceActiveIndex];
     }
 
+    void Instance::FilterAvailableExtensions(GladVulkanContext& context) const
+    {
+        // In some cases (like when running with the GPU profiler on Quest2) the extension is reported as available
+        // but the function pointers do not load. Disable the extension if that's the case.
+        if (context.EXT_debug_utils && !context.CmdBeginDebugUtilsLabelEXT)
+        {
+            context.EXT_debug_utils = 0;
+        }
+    }
+
     XrInstance Instance::GetXRInstance() const
     {
         return m_xrInstance;