Browse Source

Move FilterAvailableExtensions. Init glad context before calling the load function

Signed-off-by: Akio Gaule <[email protected]>
Akio Gaule 2 years ago
parent
commit
f19913b685

+ 1 - 1
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkDevice.h

@@ -73,6 +73,6 @@ namespace OpenXRVk
         AZStd::vector<XrCompositionLayerProjectionView> m_projectionLayerViews;
         AZStd::vector<XrCompositionLayerProjectionView> m_projectionLayerViews;
         AZStd::vector<XrView> m_views;
         AZStd::vector<XrView> m_views;
         uint32_t m_viewCountOutput = 0;
         uint32_t m_viewCountOutput = 0;
-        GladVulkanContext m_context;
+        GladVulkanContext m_context = {};
     };
     };
 }
 }

+ 1 - 4
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInstance.h

@@ -71,9 +71,6 @@ namespace OpenXRVk
         //! Ge the active VkPhysicalDevice.
         //! Ge the active VkPhysicalDevice.
         VkPhysicalDevice GetActivePhysicalDevice() const;
         VkPhysicalDevice GetActivePhysicalDevice() const;
 
 
-        //! Disable certain extensions because function pointers didn't load correctly.
-        void FilterAvailableExtensions(GladVulkanContext& context) const;
-
     protected:
     protected:
         // XR::Instance overrides...
         // XR::Instance overrides...
         AZ::RHI::ResultCode InitInstanceInternal() override;
         AZ::RHI::ResultCode InitInstanceInternal() override;
@@ -88,7 +85,7 @@ namespace OpenXRVk
         XrSystemId m_xrSystemId = XR_NULL_SYSTEM_ID;
         XrSystemId m_xrSystemId = XR_NULL_SYSTEM_ID;
         XR::RawStringList m_requiredLayers;
         XR::RawStringList m_requiredLayers;
         XR::RawStringList m_requiredExtensions;
         XR::RawStringList m_requiredExtensions;
-        GladVulkanContext m_context;
+        GladVulkanContext m_context = {};
         AZStd::unique_ptr<AZ::Vulkan::FunctionLoader> m_functionLoader;
         AZStd::unique_ptr<AZ::Vulkan::FunctionLoader> m_functionLoader;
         AZStd::vector<VkPhysicalDevice> m_supportedXRDevices;
         AZStd::vector<VkPhysicalDevice> m_supportedXRDevices;
         AZ::u32 m_physicalDeviceActiveIndex = 0;
         AZ::u32 m_physicalDeviceActiveIndex = 0;

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

@@ -63,4 +63,7 @@ namespace OpenXRVk
     //! Iterate through the characters while caching the starting pointer to a string
     //! Iterate through the characters while caching the starting pointer to a string
     //! and every time ' ' is encountered replace it with '\0' to indicate the end of a string.
     //! and every time ' ' is encountered replace it with '\0' to indicate the end of a string.
     AZStd::vector<const char*> ParseExtensionString(char* names);
     AZStd::vector<const char*> ParseExtensionString(char* names);
+
+    //! Disable certain extensions because function pointers didn't load correctly.
+    void FilterAvailableExtensions(GladVulkanContext& context);
 }
 }

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

@@ -94,10 +94,9 @@ namespace OpenXRVk
             VkPhysicalDevice xrVkPhysicalDevice = xrVkInstance->GetActivePhysicalDevice();
             VkPhysicalDevice xrVkPhysicalDevice = xrVkInstance->GetActivePhysicalDevice();
             // Now that we have created the device, load the function pointers for it.
             // Now that we have created the device, load the function pointers for it.
             const bool functionsLoaded = xrVkInstance->GetFunctionLoader().LoadProcAddresses(
             const bool functionsLoaded = xrVkInstance->GetFunctionLoader().LoadProcAddresses(
-                &xrVkInstance->GetContext(), xrVkInstance->GetNativeInstance(), xrVkPhysicalDevice, m_xrVkDevice);
-            m_context = xrVkInstance->GetContext();
+                &m_context, xrVkInstance->GetNativeInstance(), xrVkPhysicalDevice, m_xrVkDevice);
 
 
-            xrVkInstance->FilterAvailableExtensions(m_context);
+            FilterAvailableExtensions(m_context);
 
 
             if (!functionsLoaded)
             if (!functionsLoaded)
             {
             {

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

@@ -415,16 +415,6 @@ namespace OpenXRVk
         return m_supportedXRDevices[m_physicalDeviceActiveIndex];
         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
     XrInstance Instance::GetXRInstance() const
     {
     {
         return m_xrInstance;
         return m_xrInstance;

+ 10 - 0
Gems/OpenXRVk/Code/Source/OpenXRVkUtils.cpp

@@ -74,4 +74,14 @@ namespace OpenXRVk
         }
         }
         return list;
         return list;
     }
     }
+
+    void FilterAvailableExtensions(GladVulkanContext& context)
+    {
+        // 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;
+        }
+    }
 }
 }