Parcourir la source

update

Signed-off-by: byrcolin <[email protected]>
byrcolin il y a 3 ans
Parent
commit
96df26feb8
26 fichiers modifiés avec 750 ajouts et 716 suppressions
  1. 7 4
      Gems/OpenXRVk/Code/CMakeLists.txt
  2. 27 16
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkDevice.h
  3. 31 33
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkFactory.h
  4. 18 16
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkGraphicsBinding.h
  5. 45 33
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInput.h
  6. 36 26
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInstance.h
  7. 28 5
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkPhysicalDevice.h
  8. 42 28
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSession.h
  9. 13 18
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSpace.h
  10. 67 47
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSwapChain.h
  11. 86 89
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSystem.h
  12. 8 9
      Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkUtils.h
  13. 2 2
      Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Windows/OpenXRVk_Windows.h
  14. 0 50
      Gems/OpenXRVk/Code/Source/Module.cpp
  15. 11 12
      Gems/OpenXRVk/Code/Source/OpenXRVkDevice.cpp
  16. 50 53
      Gems/OpenXRVk/Code/Source/OpenXRVkFactory.cpp
  17. 2 5
      Gems/OpenXRVk/Code/Source/OpenXRVkGraphicsBinding.cpp
  18. 25 27
      Gems/OpenXRVk/Code/Source/OpenXRVkInput.cpp
  19. 13 14
      Gems/OpenXRVk/Code/Source/OpenXRVkInstance.cpp
  20. 2 5
      Gems/OpenXRVk/Code/Source/OpenXRVkPhysicalDevice.cpp
  21. 47 42
      Gems/OpenXRVk/Code/Source/OpenXRVkSession.cpp
  22. 8 10
      Gems/OpenXRVk/Code/Source/OpenXRVkSpace.cpp
  23. 31 30
      Gems/OpenXRVk/Code/Source/OpenXRVkSwapChain.cpp
  24. 127 130
      Gems/OpenXRVk/Code/Source/OpenXRVkSystem.cpp
  25. 23 11
      Gems/OpenXRVk/Code/Source/OpenXRVkUtils.cpp
  26. 1 1
      Gems/OpenXRVk/Code/openxrvk_private_common_shared_files.cmake

+ 7 - 4
Gems/OpenXRVk/Code/CMakeLists.txt

@@ -19,7 +19,7 @@ if(NOT PAL_TRAIT_OPENXRVK_SUPPORTED)
 
     # Create stub modules. Once we support gem loading configuration, we can remove this stubbed targets
     ly_add_target(
-        NAME OpenXRVk.Private ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
+        NAME OpenXRVk ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
         NAMESPACE Gem
         FILES_CMAKE
             openxrvk_stub_module.cmake
@@ -36,7 +36,7 @@ if(NOT PAL_TRAIT_OPENXRVK_SUPPORTED)
 endif()
 
 ly_add_target(
-    NAME OpenXRVk.Private.Static STATIC
+    NAME OpenXRVk.Static STATIC
     NAMESPACE Gem
     FILES_CMAKE
         openxrvk_private_common_files.cmake
@@ -57,11 +57,13 @@ ly_add_target(
             AZ::AzFramework
             3rdParty::OpenXR
             3rdParty::glad_vulkan
+            AZ::AtomCore
             Gem::Atom_RPI.Public
+            Gem::XR
 )
 
 ly_add_target(
-    NAME OpenXRVk.Private ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
+    NAME OpenXRVk ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
     NAMESPACE Gem
     FILES_CMAKE
         openxrvk_private_common_shared_files.cmake
@@ -71,8 +73,9 @@ ly_add_target(
             ${pal_source_dir}
         PUBLIC
             Include
+            ${pal_include_dir}
     BUILD_DEPENDENCIES
         PRIVATE
-            
+            Gem::OpenXRVk.Static
 )
 

+ 27 - 16
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkDevice.h

@@ -8,23 +8,34 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRDevice.h>
+#include <XR/XRDevice.h>
 #include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class DeviceDescriptor final
+        : public XR::DeviceDescriptor
     {
-        // Class that will help manage VkDevice
-        class Device final
-            : public AZ::RPI::XR::Device
-        {
-        public:
-            static AZStd::intrusive_ptr<Device> Create();
-            AZ::RPI::XR::ResultCode InitDeviceInternal(AZ::RPI::XR::PhysicalDevice& physicalDevice) override;
-
-        private:
-            VkDevice m_nativeDevice;
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    public:
+        AZ_RTTI(DeviceDescriptor, "{B0DB4670-A233-4F3F-A5C7-5D2B76F6D911}", XR::DeviceDescriptor);
+
+        DeviceDescriptor() = default;
+        virtual ~DeviceDescriptor() = default;
+
+        //any extra info for a generic xr device
+    };
+
+    // Class that will help manage VkDevice
+    class Device final
+        : public XR::Device
+    {
+    public:
+        AZ_RTTI(Device, "{81FD9B99-EDA5-4381-90EC-335073554379}", XR::Device);
+
+        static AZStd::intrusive_ptr<Device> Create();
+        AZ::RHI::ResultCode InitDeviceInternal() override;
+
+    private:
+        VkDevice m_nativeDevice;
+    };
+}

+ 31 - 33
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkFactory.h

@@ -8,7 +8,8 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRFactory.h>
+#include <XR/XRFactory.h>
+#include <OpenXRVk_Platform.h>
 #include <OpenXRVk/OpenXRVkDevice.h>
 #include <OpenXRVk/OpenXRVkInstance.h>
 #include <OpenXRVk/OpenXRVkPhysicalDevice.h>
@@ -17,48 +18,45 @@
 #include <OpenXRVk/OpenXRVkSwapChain.h>
 #include <OpenXRVk/OpenXRVkGraphicsBinding.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    //! Interface responsible for creating all the XR objects which are
+    //! internally backed by concrete objects
+    class Factory final
+        : public XR::Factory
     {
-        //! Interface responsible for creating all the XR objects which are
-        //! internally backed by concrete objects
-        class Factory final
-            : public AZ::RPI::XR::Factory
-        {
-        public:
-            AZ_CLASS_ALLOCATOR(Factory, AZ::SystemAllocator, 0);
+    public:
+        AZ_CLASS_ALLOCATOR(Factory, AZ::SystemAllocator, 0);
 
-            AZ_DISABLE_COPY_MOVE(Factory);
+        AZ_DISABLE_COPY_MOVE(Factory);
 
-            Factory();
-            ~Factory();
+        Factory();
+        ~Factory();
 
-            // Create XR::Instance object
-            AZStd::intrusive_ptr<AZ::RPI::XR::Instance> CreateInstance() override;
+        // Create XR::Instance object
+        AZStd::intrusive_ptr<XR::Instance> CreateInstance() override;
 
-            // Create XR::Device object
-            AZStd::intrusive_ptr<AZ::RPI::XR::Device> CreateDevice() override;
+        // Create XR::Device object
+        AZStd::intrusive_ptr<XR::Device> CreateDevice() override;
 
-            // Return a list of XR::PhysicalDevice
-            AZStd::vector<AZStd::intrusive_ptr<AZ::RPI::XR::PhysicalDevice>> EnumerateDeviceList() override;
+        // Return a list of XR::PhysicalDevice
+        AZStd::vector<AZStd::intrusive_ptr<XR::PhysicalDevice>> EnumerateDeviceList() override;
 
-            // Create XR::Session object
-            AZStd::intrusive_ptr<AZ::RPI::XR::Session> CreateSession() override;
+        // Create XR::Session object
+        AZStd::intrusive_ptr<XR::Session> CreateSession() override;
 
-            // Create XR::Input object
-            AZStd::intrusive_ptr<AZ::RPI::XR::Input> CreateInput() override;
+        // Create XR::Input object
+        AZStd::intrusive_ptr<XR::Input> CreateInput() override;
 
-            // Create XR::SwapChain object
-            AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain> CreateSwapchain() override;
+        // Create XR::SwapChain object
+        AZStd::intrusive_ptr<XR::SwapChain> CreateSwapchain() override;
 
-            // Create XR::ViewSwapChain object
-            AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::View> CreateViewSwapchain() override;
+        // Create XR::ViewSwapChain object
+        AZStd::intrusive_ptr<XR::SwapChain::View> CreateViewSwapchain() override;
 
-            // Create RPI::XR::GraphicsBindingDescriptor that will contain
-            // renderer information needed to start a session
-            AZStd::intrusive_ptr<AZ::RPI::XR::GraphicsBinding::Descriptor> CreateGraphicsBindingDescriptor() override;
+        // Create RPI::XR::GraphicsBindingDescriptor that will contain
+        // renderer information needed to start a session
+        AZStd::intrusive_ptr<XR::GraphicsBindingDescriptor> CreateGraphicsBindingDescriptor() override;
 
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    };
+}

+ 18 - 16
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkGraphicsBinding.h

@@ -8,23 +8,25 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRGraphicsBinding.h>
+#include <XR/XRGraphicsBinding.h>
 #include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class GraphicsBindingDescriptor final
+        : public XR::GraphicsBindingDescriptor
     {
-        class GraphicsBinding final
-            : public AZ::RPI::XR::GraphicsBinding
-        {
-        public:
-            class Descriptor final
-                : public AZ::RPI::XR::GraphicsBinding::Descriptor
-            {
-            public:
-                XrGraphicsBindingVulkan2KHR m_graphicsBinding{ XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR };
-            };
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    public:
+        AZ_RTTI(GraphicsBindingDescriptor, "{1083C93E-FB2B-4441-B705-5C44427F2961}", XR::GraphicsBindingDescriptor);
+
+        XrGraphicsBindingVulkan2KHR m_graphicsBinding{ XR_TYPE_GRAPHICS_BINDING_VULKAN2_KHR };
+    };
+    
+    class GraphicsBinding final
+        : public XR::GraphicsBinding
+    {
+    public:
+        AZ_RTTI(GraphicsBinding, "{1001E681-EA2E-4898-AC08-B93AA5B63508}", XR::GraphicsBinding);
+
+    };
+}

+ 45 - 33
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInput.h

@@ -8,41 +8,53 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRinput.h>
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
+#include <XR/XRinput.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class InputDescriptor final
+        : public XR::InputDescriptor
     {
-        // Class that will help manage XrActionSet/XrAction
-        class Input final
-            : public AZ::RPI::XR::Input
+    public:
+        AZ_RTTI(InputDescriptor, "{5CE5E693-775B-42A5-9B32-7C1006C69975}", XR::InputDescriptor);
+
+        InputDescriptor() = default;
+        virtual ~InputDescriptor() = default;
+
+        //any extra info for a generic xr InputDescriptor
+    };
+
+    // Class that will help manage XrActionSet/XrAction
+    class Input final
+        : public XR::Input
+    {
+    public:
+        AZ_RTTI(Input, "{97ADD1FE-27DF-4F36-9F61-683F881F9477}", XR::Input);
+
+        Input() = default;
+        virtual ~Input() = default;
+
+        static AZStd::intrusive_ptr<XR::Input> Create();
+
+        AZ::RHI::ResultCode Init() override;
+        void InitializeActions() override;
+        void PollActions() override;
+        void PollEvents() override;
+
+    private:
+        struct InputState
         {
-        public:
-            static AZStd::intrusive_ptr<AZ::RPI::XR::Input> Create();
-
-            AZ::RPI::XR::ResultCode Init(AZ::RPI::XR::Input::Descriptor descriptor) override;
-            void InitializeActions() override;
-            void PollActions() override;
-            void PollEvents() override;
-
-        private:
-            struct InputState
-            {
-                XrActionSet actionSet{ XR_NULL_HANDLE };
-                XrAction grabAction{ XR_NULL_HANDLE };
-                XrAction poseAction{ XR_NULL_HANDLE };
-                XrAction vibrateAction{ XR_NULL_HANDLE };
-                XrAction quitAction{ XR_NULL_HANDLE };
-                AZStd::array<XrPath, Side::COUNT> handSubactionPath;
-                AZStd::array<XrSpace, Side::COUNT> handSpace;
-                AZStd::array<float, Side::COUNT> handScale = { { 1.0f, 1.0f } };
-                AZStd::array<XrBool32, Side::COUNT> handActive;
-            };
-            InputState m_input;
+            XrActionSet actionSet{ XR_NULL_HANDLE };
+            XrAction grabAction{ XR_NULL_HANDLE };
+            XrAction poseAction{ XR_NULL_HANDLE };
+            XrAction vibrateAction{ XR_NULL_HANDLE };
+            XrAction quitAction{ XR_NULL_HANDLE };
+            AZStd::array<XrPath, Side::COUNT> handSubactionPath;
+            AZStd::array<XrSpace, Side::COUNT> handSpace;
+            AZStd::array<float, Side::COUNT> handScale = { { 1.0f, 1.0f } };
+            AZStd::array<XrBool32, Side::COUNT> handActive;
         };
-    } // namespace OpenXRVk
-} // namespace AZ
+        InputState m_input;
+    };
+}

+ 36 - 26
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInstance.h

@@ -8,34 +8,44 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRInstance.h>
-#include <Atom/RPI.Public/XR/XRResult.h>
+#include <XR/XRInstance.h>
 #include <AzCore/std/containers/vector.h>
 #include <AzCore/std/smart_ptr/intrusive_ptr.h>
-#include <glad/vulkan.h>
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class InstanceDescriptor final
+        : public XR::InstanceDescriptor
     {
-        // Class that will help manage XrInstance
-        class Instance final
-            : public AZ::RPI::XR::Instance
-        {
-        public:
-            static AZStd::intrusive_ptr<Instance> Create();
-            AZ::RPI::ResultCode InitInstanceInternal() override;
-
-        private:
-            XrInstance m_xrInstance{ XR_NULL_HANDLE };
-            AZStd::vector<XrApiLayerProperties> m_layers;
-            AZStd::vector<XrExtensionProperties> m_extensions;
-            XrFormFactor m_formFactor{ XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY };
-            XrSystemId m_systemId{ XR_NULL_SYSTEM_ID };
-            VkInstance m_instance = VK_NULL_HANDLE;
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    public:
+        AZ_RTTI(InstanceDescriptor, "{F7D29A7A-5841-4B6F-ADFE-3734316BC63D}", XR::InstanceDescriptor);
+
+        InstanceDescriptor() = default;
+        virtual ~InstanceDescriptor() = default;
+
+        //any extra info a openxr instance descriptor needs
+    };
+
+    // Class that will help manage XrInstance
+    class Instance final
+        : public XR::Instance
+    {
+    public:
+        AZ_RTTI(Instance, "{1A62DF32-2909-431C-A938-B1E841A50768}", XR::Instance);
+
+        Instance() = default;
+        virtual ~Instance() = default;
+
+        static AZStd::intrusive_ptr<Instance> Create();
+        virtual AZ::RHI::ResultCode InitInstanceInternal() override;
+
+    private:
+        XrInstance m_xrInstance{ XR_NULL_HANDLE };
+        AZStd::vector<XrApiLayerProperties> m_layers;
+        AZStd::vector<XrExtensionProperties> m_extensions;
+        XrFormFactor m_formFactor{ XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY };
+        XrSystemId m_systemId{ XR_NULL_SYSTEM_ID };
+        VkInstance m_instance = VK_NULL_HANDLE;
+    };
+}

+ 28 - 5
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkPhysicalDevice.h

@@ -8,11 +8,34 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRPhysicalDevice.h>
+#include <XR/XRPhysicalDevice.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class PhysicalDeviceDescriptor final
+        : public XR::PhysicalDeviceDescriptor
     {
-    }
-} // namespace AZ
+    public:
+        AZ_RTTI(PhysicalDeviceDescriptor, "{CB485C38-E723-4593-ADCF-DFE220A6A24B}", XR::PhysicalDeviceDescriptor);
+
+        PhysicalDeviceDescriptor() = default;
+        virtual ~PhysicalDeviceDescriptor() = default;
+
+        // Other data related to openxr physical device
+    };
+
+    // This class will be responsible for iterating over all the compatible physical
+    // devices and picking one that will be used for the app
+    class PhysicalDevice final
+        : public XR::PhysicalDevice
+    {
+    public:
+        AZ_RTTI(PhysicalDevice, "{7CE8D7C1-7CC6-4841-9505-DED2761617AC}", XR::PhysicalDevice);
+
+        PhysicalDevice() = default;
+        virtual ~PhysicalDevice() = default;
+
+    };
+} // namespace XR
+

+ 42 - 28
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSession.h

@@ -8,35 +8,49 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRSession.h>
+#include <XR/XRSession.h>
 #include <AzCore/std/smart_ptr/intrusive_ptr.h>
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class SessionDescriptor final
+        : public XR::SessionDescriptor 
     {
-        // Class that will help manage XrSession
-        class Session final
-            : public AZ::RPI::XR::Session
-        {
-        public:
-            static AZStd::intrusive_ptr<Session> Create();
-            AZ::RPI::XR::ResultCode InitSessionInternal(AZ::RPI::XR::Session::Descriptor descriptor) override;
-            void LogReferenceSpaces();
-            void HandleSessionStateChangedEvent(
-                const XrEventDataSessionStateChanged& stateChangedEvent, bool* exitRenderLoop, bool* requestRestart);
-            XrSession GetSession();
-            bool IsSessionFocused() const override;
-            AZ::RPI::XR::ResultCode InitInternal();
-
-        private:
-            XrSession m_session{ XR_NULL_HANDLE };
-            // Application's current lifecycle state according to the runtime
-            XrSessionState m_sessionState{ XR_SESSION_STATE_UNKNOWN };
-            XrFrameState m_frameState{ XR_TYPE_FRAME_STATE };
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    public:
+        AZ_RTTI(SessionDescriptor, "{775CCED3-9676-4F48-B419-BDADE0F7F447}", XR::SessionDescriptor);
+
+        SessionDescriptor() = default;
+        virtual ~SessionDescriptor() = default;
+
+        //any openxr specific session descriptor data
+    };
+
+    // Class that will help manage XrSession
+    class Session final
+        : public XR::Session
+    {
+    public:
+        AZ_RTTI(Session, "{6C899F0C-9A3D-4D79-8E4F-92AFB67E5EB1}", XR::Session);
+
+        static AZStd::intrusive_ptr<Session> Create();
+
+        virtual AZ::RHI::ResultCode InitSessionInternal() override;
+
+        void LogReferenceSpaces();
+        void HandleSessionStateChangedEvent(
+            const XrEventDataSessionStateChanged& stateChangedEvent,
+            bool* exitRenderLoop,
+            bool* requestRestart);
+        XrSession GetXrSession();
+        virtual bool IsSessionRunning() const override;
+        virtual bool IsSessionFocused() const override;
+        virtual AZ::RHI::ResultCode InitInternal();
+
+    private:
+        XrSession m_session{ XR_NULL_HANDLE };
+        // Application's current lifecycle state according to the runtime
+        XrSessionState m_sessionState{ XR_SESSION_STATE_UNKNOWN };
+        XrFrameState m_frameState{ XR_TYPE_FRAME_STATE };
+    };
+}

+ 13 - 18
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSpace.h

@@ -8,26 +8,21 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRSpace.h>
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
+#include <XR/XRSpace.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    // Class that will help manage XrSpaces
+    class Space final
+        : public XR::Space
     {
-        // Class that will help manage XrSpaces
-        class Space final
-            : public AZ::RPI::XR::Space
-        {
-        public:
-            static AZStd::intrusive_ptr<AZ::RPI::XR::Space> Create();
+    public:
+        static AZStd::intrusive_ptr<Space> Create();
 
-            XrSpaceLocation GetSpace(XrSpace space);
+        //XrSpaceLocation GetSpace(XrSpace space);
 
-        private:
-            XrSpace m_baseSpace{ XR_NULL_HANDLE };
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    private:
+        XrSpace m_baseSpace{ XR_NULL_HANDLE };
+    };
+}

+ 67 - 47
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSwapChain.h

@@ -8,58 +8,78 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRSwapChain.h>
-#include <glad/vulkan.h>
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
+#include <XR/XRSwapChain.h>
+#include <OpenXRVk_Platform.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class SwapChainDescriptor final
+        : public XR::SwapChainDescriptor
     {
-        // Class that will help manage XrSwapchain
-        class SwapChain final
-            : public AZ::RPI::XR::SwapChain
+    public:
+        AZ_RTTI(SwapChainDescriptor, "{0C6214B3-9271-4972-B6B0-13C4A23D9155}", XR::SwapChainDescriptor);
+
+        SwapChainDescriptor() = default;
+        virtual ~SwapChainDescriptor() = default;
+
+        //any extra info for a openxr swap chain descriptor
+    };
+
+    class SwapChainImageDescriptor final
+        : public XR::SwapChainImageDescriptor
+    {
+    public:
+        AZ_RTTI(SwapChainImageDescriptor, "{056D30CF-4B1E-4EC3-9990-A7D9C38C895B}", XR::SwapChainImageDescriptor);
+
+        SwapChainImageDescriptor() = default;
+        virtual ~SwapChainImageDescriptor() = default;
+
+        //any extra info for a openxr swap chain image descriptor
+    };
+
+    // Class that will help manage XrSwapchain
+    class SwapChain final
+        : public XR::SwapChain
+    {
+    public:
+        virtual ~SwapChain() = default;
+
+        static AZStd::intrusive_ptr<SwapChain> Create();
+
+        class Image final
+            : public XR::SwapChain::Image
         {
         public:
-            static AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain> Create();
-
-            class Image final
-                : public AZ::RPI::XR::SwapChain::Image
-            {
-            public:
-                class Descriptor final
-                    : public AZ::RPI::XR::SwapChain::Image::Descriptor
-                {
-                public:
-                };
-                static AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::Image> Create();
-
-            private:
-                VkImage m_image;
-                XrSwapchainImageBaseHeader* m_swapChainImageHeader;
-            };
-
-            class View final
-                : public AZ::RPI::XR::SwapChain::View
-            {
-            public:
-                static AZStd::intrusive_ptr<View> Create();
-                AZ::RPI::XR::ResultCode Init(XrSwapchain handle, uint32_t width, uint32_t height);
-
-            private:
-                XrSwapchain m_handle;
-                int32_t m_width;
-                int32_t m_height;
-            };
-
-            AZ::RPI::XR::ResultCode InitInternal() override;
+            AZ_RTTI(Image, "{717ABDD4-C050-4FDF-8E93-3784F81FE315}", XR::SwapChain::Image);
+
+            static AZStd::intrusive_ptr<Image> Create();
+
+        private:
+            VkImage m_image;
+            XrSwapchainImageBaseHeader* m_swapChainImageHeader;
+        };
+
+        class View final
+            : public XR::SwapChain::View
+        {
+        public:
+            AZ_RTTI(View, "{F8312427-AC2D-4737-9A8F-A16ADA5319D0}", XR::SwapChain::View);
+
+            static AZStd::intrusive_ptr<View> Create();
+            
+            AZ::RHI::ResultCode Init(XrSwapchain handle, AZ::u32 width, AZ::u32 height);
 
         private:
-            AZStd::vector<XrViewConfigurationView> m_configViews;
-            AZStd::vector<XrView> m_views;
-            int64_t m_colorSwapchainFormat{ -1 };
+            XrSwapchain m_handle;
+            AZ::u32 m_width;
+            AZ::u32 m_height;
         };
-    } // namespace OpenXRVk
-} // namespace AZ
+
+        AZ::RHI::ResultCode InitInternal() override;
+
+    private:
+        AZStd::vector<XrViewConfigurationView> m_configViews;
+        AZStd::vector<XrView> m_views;
+        int64_t m_colorSwapchainFormat{ -1 };
+    };
+}

+ 86 - 89
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSystem.h

@@ -8,8 +8,10 @@
 
 #pragma once
 
-#include <Atom/RHI/GraphicsBinding.h>
-#include <Atom/RPI.Public/XR/XRSystemInterface.h>
+#include <XR/XRSystem.h>
+
+#include <OpenXRVk_Platform.h>
+
 #include <OpenXRVk/OpenXRVkInstance.h>
 #include <OpenXRVk/OpenXRVkDevice.h>
 #include <OpenXRVk/OpenXRVkSwapChain.h>
@@ -19,92 +21,87 @@
 
 #include <AzCore/Component/TickBus.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    class System final
+        : public XR::System
+        , public AZ::SystemTickBus::Handler
     {
-        class System final
-            : public AZ::RPI::XR::SystemInterface
-            , public AZ::SystemTickBus::Handler
-        {
-        public:
-            AZ_RTTI(System, "{FBAFDEE2-0A03-4EA8-98E9-A1C8DB32DBCF}", SystemInterface);
-
-            virtual ~System() = default;
-
-            ///////////////////////////////////////////////////////////////////////////////////
-            // SystemInterface
-            // Accessor functions for RHI objects that are populated by backend XR gems
-            // This will allow XR gem to provide device related data to RHI
-            // Initialize XR instance and device
-            AZ::RPI::XR::ResultCode InitializeSystem() override;
-
-            // Initialize a XR session
-            AZ::RPI::XR::ResultCode InitializeSession(AZStd::intrusive_ptr<AZ::RPI::XR::GraphicsBinding> graphicsBinding) override;
-
-            // Indicate start of a frame
-            void BeginFrame() override;
-
-            // Indicate end of a frame
-            void EndFrame() override;
-
-            // Indicate start of a XR view to help with synchronizing XR swap chain
-            void BeginView() override;
-
-            // Indicate end of a XR view to help with synchronizing XR swap chain
-            void EndView() override;
-
-            // Manage session lifecycle to track if RenderFrame should be called.
-            bool IsSessionRunning() const override;
-
-            // Create a swap chain which will responsible for managing
-            // multiple XR swap chains and multiple swap chain images within it
-            AZ::RPI::XR::ResultCode CreateSwapchain() override;
-
-            AZ::RPI::XR::Device::Descriptor* GetDeviceDescriptor() override;
-
-            // Provide access to instance specific data to RHI
-            AZ::RPI::XR::Instance::Descriptor* GetInstanceDescriptor() override;
-
-            // Provide Swap chain specific data to RHI
-            AZ::RPI::XR::SwapChain::Image::Descriptor* GetSwapChainImageDescriptor(int swapchainIndex) override;
-
-            // Provide access to Graphics Binding specific data that RHI can populate
-            AZ::RHI::GraphicsBinding::Descriptor* GetGraphicsBindingDescriptor() override;
-            ///////////////////////////////////////////////////////////////////////////////////
-
-        public:
-            // Access supported Layers and extension names
-            const AZStd::vector<AZStd::string>& GetLayerNames();
-
-            const AZStd::vector<AZStd::string>& GetExtensionNames();
-
-            // Create XR instance object and initialize it
-            AZ::RPI::XR::ResultCode InitInstance();
-
-            // Create XR device object and initialize it
-            AZ::RPI::XR::ResultCode InitDevice();
-
-        private:
-            AZ::RPI::XR::ResultCode InitInstance();
-
-            ///////////////////////////////////////////////////////////////////////////////////
-            // SystemTickBus
-            // System Tick to poll input data
-            void OnSystemTick() override;
-            //////////////////////////////////////////////////////////////////////////////////
-
-            AZStd::intrusive_ptr<OpenXRVk::Instance> m_instance;
-            AZStd::intrusive_ptr<OpenXRVk::Device> m_device;
-            AZStd::intrusive_ptr<OpenXRVk::Session> m_session;
-            AZStd::intrusive_ptr<OpenXRVk::Input> m_input;
-            AZStd::intrusive_ptr<OpenXRVk::SwapChain> m_swapChain;
-            bool m_requestRestart = false;
-            bool m_exitRenderLoop = false;
-            AZStd::intrusive_ptr<OpenXRVk::Device::Descriptor> m_deviceDesc;
-            AZStd::intrusive_ptr<OpenXRVk::Instance::Descriptor> m_instanceDesc;
-            AZStd::intrusive_ptr<OpenXRVk::SwapChain::Descriptor> m_swapchainDesc;
-            AZStd::intrusive_ptr<OpenXRVk::GraphicsBinding::Descriptor> m_graphicsBindingDesc;
-        };
-    } // namespace OpenXRVk
-} // namespace AZ
+    public:
+        AZ_RTTI(System, "{FBAFDEE2-0A03-4EA8-98E9-A1C8DB32DBCF}", XR::System);
+
+        ///////////////////////////////////////////////////////////////////////////////////
+        // SystemInterface
+        // Accessor functions for RHI objects that are populated by backend XR gems
+        // This will allow XR gem to provide device related data to RHI
+        // Initialize XR instance and device
+        AZ::RHI::ResultCode InitializeSystem() override;
+
+        // Initialize a XR session
+        AZ::RHI::ResultCode InitializeSession() override;
+
+        // Indicate start of a frame
+        void BeginFrame() override;
+
+        // Indicate end of a frame
+        void EndFrame() override;
+
+        // Indicate start of a XR view to help with synchronizing XR swap chain
+        void BeginView() override;
+
+        // Indicate end of a XR view to help with synchronizing XR swap chain
+        void EndView() override;
+
+        // Manage session lifecycle to track if RenderFrame should be called.
+        bool IsSessionRunning() const override;
+
+        // Create a swap chain which will responsible for managing
+        // multiple XR swap chains and multiple swap chain images within it
+        AZ::RHI::ResultCode CreateSwapchain() override;
+
+        AZ::RPI::XRDeviceDescriptor* GetDeviceDescriptor() override;
+
+        // Provide access to instance specific data to RHI
+        AZ::RPI::XRInstanceDescriptor* GetInstanceDescriptor() override;
+
+        // Provide Swap chain specific data to RHI
+        AZ::RPI::XRSwapChainImageDescriptor* GetSwapChainImageDescriptor(int swapchainIndex) override;
+
+        // Provide access to Graphics Binding specific data that RHI can populate
+        AZ::RPI::XRGraphicsBindingDescriptor* GetGraphicsBindingDescriptor() override;
+        ///////////////////////////////////////////////////////////////////////////////////
+
+    public:
+        // Access supported Layers and extension names
+        const AZStd::vector<AZStd::string>& GetLayerNames();
+
+        const AZStd::vector<AZStd::string>& GetExtensionNames();
+
+        // Create XR instance object and initialize it
+        AZ::RHI::ResultCode InitInstance();
+
+        // Create XR device object and initialize it
+        AZ::RHI::ResultCode InitDevice();
+
+    private:
+        AZ::RHI::ResultCode InitInstance();
+
+        ///////////////////////////////////////////////////////////////////////////////////
+        // SystemTickBus
+        // System Tick to poll input data
+        void OnSystemTick() override;
+        //////////////////////////////////////////////////////////////////////////////////
+
+        AZStd::intrusive_ptr<OpenXRVk::Instance> m_instance;
+        AZStd::intrusive_ptr<OpenXRVk::Device> m_device;
+        AZStd::intrusive_ptr<OpenXRVk::Session> m_session;
+        AZStd::intrusive_ptr<OpenXRVk::Input> m_input;
+        AZStd::intrusive_ptr<OpenXRVk::SwapChain> m_swapChain;
+        bool m_requestRestart = false;
+        bool m_exitRenderLoop = false;
+        AZStd::intrusive_ptr<OpenXRVk::DeviceDescriptor> m_deviceDesc;
+        AZStd::intrusive_ptr<OpenXRVk::InstanceDescriptor> m_instanceDesc;
+        AZStd::intrusive_ptr<OpenXRVk::SwapChainDescriptor> m_swapchainDesc;
+        AZStd::intrusive_ptr<OpenXRVk::GraphicsBindingDescriptor> m_graphicsBindingDesc;
+    };
+}

+ 8 - 9
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkUtils.h

@@ -7,14 +7,13 @@
  */
 
 #pragma once
-#include <openxr/openxr.h>
-#include <openxr/openxr_platform.h>
-#include <openxr/openxr_reflection.h>
 
-namespace AZ
+#include <Atom/RHI.Reflect/Base.h>
+
+#include <OpenXRVk_Platform.h>
+
+namespace OpenXRVk
 {
-    namespace OpenXRVk
-    {
-        bool IsSuccess(XrResult result);
-    }
-} // namespace AZ
+    AZ::RHI::ResultCode ConvertResult(XrResult xrResult);
+    bool IsSuccess(XrResult result);
+}

+ 2 - 2
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Windows/OpenXRVk_Windows.h

@@ -11,8 +11,8 @@
 #include <AzCore/PlatformIncl.h>
 #include <AzCore/std/algorithm.h>
 #include <limits.h>
+
+#include <glad/vulkan.h>
 #include <openxr/openxr.h>
 #include <openxr/openxr_platform.h>
 #include <openxr/openxr_reflection.h>
-
-

+ 0 - 50
Gems/OpenXRVk/Code/Source/Module.cpp

@@ -1,50 +0,0 @@
-/*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
-
-#include <AzCore/Module/Module.h>
-
-namespace AZ
-{
-    namespace OpenXRVk
-    {
-        /**
-        * This module is in charge of loading the RHI reflection descriptor and the
-        * system components in charge of managing the different factory backends.
-        */
-        class PlatformModule
-            : public AZ::Module
-        {
-        public:
-            AZ_RTTI(PlatformModule, "{C34AA64E-0983-4D30-A33C-0D7C7676A20E}", Module);
-
-            PlatformModule()
-            {
-                m_descriptors.insert(m_descriptors.end(), {
-                    ReflectSystemComponent::CreateDescriptor(),
-                    FactoryManagerSystemComponent::CreateDescriptor(),
-                    FactoryRegistrationFinalizerSystemComponent::CreateDescriptor()
-                });
-            }
-            ~PlatformModule() override = default;
-
-            AZ::ComponentTypeList GetRequiredSystemComponents() const override
-            {
-                return AZ::ComponentTypeList
-                {
-                    azrtti_typeid<FactoryManagerSystemComponent>(),
-                    azrtti_typeid<FactoryRegistrationFinalizerSystemComponent>()
-                };
-            }
-        };
-    }
-}
-
-// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
-// The first parameter should be GemName_GemIdLower
-// The second should be the fully qualified name of the class above
-AZ_DECLARE_MODULE_CLASS(Gem_OpenXRVk_Private, AZ::OpenXRVk::PlatformModule)

+ 11 - 12
Gems/OpenXRVk/Code/Source/OpenXRVkDevice.cpp

@@ -8,18 +8,17 @@
 
 #include <OpenXRVk/OpenXRVkDevice.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZStd::intrusive_ptr<Device> Device::Create()
     {
-        static AZStd::intrusive_ptr<Device> Device::Create()
-        {
-        }
+        return nullptr;
+    }
 
-        XR::ResultCode Device::InitDeviceInternal(XR::PhysicalDevice& physicalDevice)
-        {
-            // Create Vulkan Device
-            return AZ::RPI::XR::ResultCode::Success;
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    AZ::RHI::ResultCode Device::InitDeviceInternal()
+    {
+        // Create Vulkan Device
+        //m_nativeDevice = Create();
+        return AZ::RHI::ResultCode::Success;
+    }
+}

+ 50 - 53
Gems/OpenXRVk/Code/Source/OpenXRVkFactory.cpp

@@ -9,67 +9,64 @@
 #include <OpenXRVk/OpenXRVkFactory.h>
 #include <AzCore/Memory/Memory.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    Factory::Factory()
     {
-        Factory::Factory()
-        {
-            RPI::XR::Factory::Register(this);
-        }
+        XR::Factory::Register(this);
+    }
 
-        Factory::~Factory()
-        {
-            RPI::XR::Factory::Unregister(this);
-        }
+    Factory::~Factory()
+    {
+        XR::Factory::Unregister(this);
+    }
 
-        // Create XR::Instance object
-        AZStd::intrusive_ptr<AZ::RPI::XR::Instance> CreateInstance()
-        {
-            return aznew AZ::OpenXRVk::Instance;
-        }
+    // Create XR::Instance object
+    AZStd::intrusive_ptr<XR::Instance> CreateInstance()
+    {
+        return aznew OpenXRVk::Instance;
+    }
 
-        // Create XR::Device object
-        AZStd::intrusive_ptr<AZ::RPI::XR::Device> CreateDevice()
-        {
-            return aznew AZ::OpenXRVk::Device;
-        }
+    // Create XR::Device object
+    AZStd::intrusive_ptr<XR::Device> CreateDevice()
+    {
+        return aznew OpenXRVk::Device;
+    }
 
-        // Return a list of XR::PhysicalDevice
-        AZStd::vector<AZStd::intrusive_ptr<AZ::RPI::XR::PhysicalDevice>> EnumerateDeviceList()
-        {
-            return AZ::OpenXRVk::PhysicalDevice::EnumerateList();
-        }
+    // Return a list of XR::PhysicalDevice
+    AZStd::vector<AZStd::intrusive_ptr<XR::PhysicalDevice>> EnumerateDeviceList()
+    {
+        return OpenXRVk::PhysicalDevice::EnumerateList();
+    }
 
-        // Create XR::Session object
-        AZStd::intrusive_ptr<AZ::RPI::XR::Session> CreateSession()
-        {
-            return aznew AZ::OpenXRVk::Session;
-        }
+    // Create XR::Session object
+    AZStd::intrusive_ptr<XR::Session> CreateSession()
+    {
+        return aznew OpenXRVk::Session;
+    }
 
-        // Create XR::Input object
-        AZStd::intrusive_ptr<AZ::RPI::XR::Input> CreateInput()
-        {
-            return aznew AZ::OpenXRVk::Input;
-        }
+    // Create XR::Input object
+    AZStd::intrusive_ptr<XR::Input> CreateInput()
+    {
+        return aznew OpenXRVk::Input;
+    }
 
-        // Create XR::SwapChain object
-        AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain> CreateSwapchain()
-        {
-            return aznew AZ::OpenXRVk::SwapChain;
-        }
+    // Create XR::SwapChain object
+    AZStd::intrusive_ptr<XR::SwapChain> CreateSwapchain()
+    {
+        return aznew OpenXRVk::SwapChain;
+    }
 
-        // Create XR::ViewSwapChain object
-        AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::View> CreateViewSwapchain()
-        {
-            return aznew AZ::OpenXRVk::SwapChain::View;
-        }
+    // Create XR::ViewSwapChain object
+    AZStd::intrusive_ptr<XR::SwapChain::View> CreateViewSwapchain()
+    {
+        return aznew OpenXRVk::SwapChain::View;
+    }
 
-        // Create RPI::XR::GraphicsBindingDescriptor that will contain
-        // renderer information needed to start a session
-        AZStd::intrusive_ptr<AZ::RPI::XR::GraphicsBinding::Descriptor> CreateGraphicsBindingDescriptor()
-        {
-            return aznew AZ::OpenXRVk::SwapChain::View;
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    // Create RPI::XR::GraphicsBindingDescriptor that will contain
+    // renderer information needed to start a session
+    AZStd::intrusive_ptr<XR::GraphicsBindingDescriptor> CreateGraphicsBindingDescriptor()
+    {
+        return aznew OpenXRVk::SwapChain::View;
+    }
+}

+ 2 - 5
Gems/OpenXRVk/Code/Source/OpenXRVkGraphicsBinding.cpp

@@ -8,10 +8,7 @@
 
 #include <OpenXRVk/OpenXRVkGraphicsBinding.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
-    {
 
-    } // namespace OpenXRVk
-} // namespace AZ
+}

+ 25 - 27
Gems/OpenXRVk/Code/Source/OpenXRVkInput.cpp

@@ -8,36 +8,34 @@
 
 #include <OpenXRVk/OpenXRVkInput.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZStd::intrusive_ptr<XR::Input> Input::Create()
     {
-        AZStd::intrusive_ptr<AZ::RPI::XR::Input> Input::Create()
-        {
-        }
+        return nullptr;
+    }
 
-        AZ::RPI::XR::ResultCode Input::Init()
-        {
-            InitializeActions();
-        }
+    AZ::RHI::ResultCode Input::Init()
+    {
+        InitializeActions();
+    }
 
-        void Input::InitializeActions()
-        {
-            // Code to populate m_input
-            // xrCreateActionSet
-            // xrCreateAction
-            // xrCreateActionSpace
-            // xrAttachSessionActionSets
-        }
+    void Input::InitializeActions()
+    {
+        // Code to populate m_input
+        // xrCreateActionSet
+        // xrCreateAction
+        // xrCreateActionSpace
+        // xrAttachSessionActionSets
+    }
 
-        void Input::PollActions()
-        {
-            // xrSyncActions
-        }
+    void Input::PollActions()
+    {
+        // xrSyncActions
+    }
 
-        void Input::PollEvents()
-        {
-            // m_session->HandleSessionStateChangedEvent
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    void Input::PollEvents()
+    {
+        // m_session->HandleSessionStateChangedEvent
+    }
+}

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

@@ -8,20 +8,19 @@
 
 #include <OpenXRVk/OpenXRVkInstance.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZStd::intrusive_ptr<Instance> Instance::Create();
     {
-        AZStd::intrusive_ptr<Instance> Instance::Create();
-        {
-        }
+        return nullptr;
+    }
 
-        XR::ResultCode Instance::InitInstanceInternal();
-        {
-            // xrCreateInstance(m_xrInstance)
-            // xrGetSystem(m_systemId)
-            // vkCreateInstance(m_instance)
-            return AZ::RPI::XR::ResultCode::Success;
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    AZ::RHI::ResultCode Instance::InitInstanceInternal();
+    {
+        AZ::RHI::ResultCode res = XR::Instance::InitInstanceInternal();
+        // xrCreateInstance(m_xrInstance)
+        // xrGetSystem(m_systemId)
+        // vkCreateInstance(m_instance)
+        return res;
+    }
+}

+ 2 - 5
Gems/OpenXRVk/Code/Source/OpenXRVkPhysicalDevice.cpp

@@ -8,9 +8,6 @@
 
 #include <OpenXRVk/OpenXRVkPhysicalDevice.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
-    {
-    } // OpenXRVk
-} // namespace AZ
+}

+ 47 - 42
Gems/OpenXRVk/Code/Source/OpenXRVkSession.cpp

@@ -8,46 +8,51 @@
 
 #include <OpenXRVk/OpenXRVkSession.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
-    {
-        AZStd::intrusive_ptr<Session> Session::Create();
-        {
-        }
-
-        AZ::RPI::XR::ResultCode Session::InitSessionInternal(AZ::RPI::XR::Session::Descriptor descriptor) override
-        {
-            // AZStd::intrusive_ptr<GraphicsBinding> gBinding = static_cast<GraphicsBinding>(descriptor.m_graphicsBinding);
-            // xrCreateSession(..m_session,gBinding,..)
-            return AZ::RPI::XR::ResultCode::Success;
-        }
-
-        void Session::LogReferenceSpaces()
-        {
-            //..xrEnumerateReferenceSpaces/
-        }
-
-        void Session::HandleSessionStateChangedEvent(
-            const XrEventDataSessionStateChanged& stateChangedEvent, bool* exitRenderLoop, bool* requestRestart)
-        {
-            // Handle Session state changes
-        }
-
-        XrSession Session::GetSession()
-        {
-            return m_session;
-        }
-
-        bool Session::IsSessionFocused() const override
-        {
-            return m_sessionState == XR_SESSION_STATE_FOCUSED;
-        }
-
-        AZ::RPI::XR::ResultCode Session::InitInternal()
-        {
-            // Init specific code
-            return AZ::RPI::XR::ResultCode::Success;
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    AZStd::intrusive_ptr<Session> Session::Create();
+    {
+        return nullptr;
+    }
+
+    AZ::RHI::ResultCode Session::InitInternal()
+    {
+        // AZStd::intrusive_ptr<GraphicsBinding> gBinding = static_cast<GraphicsBinding>(descriptor.m_graphicsBinding);
+        // xrCreateSession(..m_session,gBinding,..)
+        return AZ::RHI::ResultCode::Success;
+    }
+
+    void Session::LogReferenceSpaces()
+    {
+        //..xrEnumerateReferenceSpaces/
+    }
+
+    void Session::HandleSessionStateChangedEvent(
+        const XrEventDataSessionStateChanged& stateChangedEvent,
+        bool* exitRenderLoop,
+        bool* requestRestart)
+    {
+        // Handle Session state changes
+    }
+
+    XrSession Session::GetXrSession()
+    {
+        return m_session;
+    }
+
+    bool Session::IsSessionRunning() const
+    {
+        return true;
+    }
+
+    bool Session::IsSessionFocused() const
+    {
+        return m_sessionState == XR_SESSION_STATE_FOCUSED;
+    }
+
+    AZ::RHI::ResultCode Session::InitInternal()
+    {
+        // Init specific code
+        return AZ::RHI::ResultCode::Success;
+    }
+}

+ 8 - 10
Gems/OpenXRVk/Code/Source/OpenXRVkSpace.cpp

@@ -8,16 +8,14 @@
 
 #include <OpenXRVk/OpenXRVkSpace.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZStd::intrusive_ptr<AZ::RPI::XR::Space> Space::Create()
     {
-        AZStd::intrusive_ptr<AZ::RPI::XR::Space> Space::Create()
-        {
-        }
+    }
 
-        XrSpaceLocation GetSpace(XrSpace space)
-        {
-        }
-    } // namespace OpenXRVk
-} // namespace AZ
+    //XrSpaceLocation GetSpace(XrSpace space)
+    //{
+     //   return XrSpaceLocation()
+    //}
+}

+ 31 - 30
Gems/OpenXRVk/Code/Source/OpenXRVkSwapChain.cpp

@@ -7,43 +7,44 @@
  */
 
 #include <OpenXRVk/OpenXRVkSwapChain.h>
+#include <OpenXRVk/OpenXRVkFactory.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZStd::intrusive_ptr<SwapChain> SwapChain::Create()
     {
-        AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain> SwapChain::Create()
-        {
-        }
+        return nullptr;
+    }
 
-        AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::Image> SwapChain::Image::Create()
-        {
-        }
+    AZStd::intrusive_ptr<SwapChain::Image> SwapChain::Image::Create()
+    {
+        return nullptr;
+    }
 
-        AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::View> SwapChain::View::Create()
-        {
-        }
+    AZStd::intrusive_ptr<SwapChain::View> SwapChain::View::Create()
+    {
+        return nullptr;
+    }
 
-        AZ::RPI::XR::ResultCode SwapChain::View::Init(XrSwapchain handle, uint32_t width, uint32_t height)
-        {
-            return AZ::RPI::XR::ResultCode::Success;
-        }
+    AZ::RHI::ResultCode SwapChain::View::Init(XrSwapchain handle, AZ::u32 width, AZ::u32 height)
+    {
+        return AZ::RHI::ResultCode::Success;
+    }
 
-        AZ::RPI::XR::ResultCode SwapChain::InitInternal()
+    AZ::RHI::ResultCode SwapChain::InitInternal()
+    {
+        // xrEnumerateViewConfigurationViews
+        for (int i = 0; i < m_views.size(); i++)
         {
-            // xrEnumerateViewConfigurationViews
-            for (int i = 0; i < m_views.size(); i++)
-            {
-                // xrCreateSwapchain
-                AZStd::intrusive_ptr<SwapChain::View> vSwapChain = Factory::Get()->ViewSwapChain();
+            // xrCreateSwapchain
+            //AZStd::intrusive_ptr<SwapChain::View> vSwapChain = OpenXRVk::Factory::Get()->ViewSwapChain();
 
-                if (vSwapChain)
-                {
-                    xrCreateSwapchain(.., xrSwapchainHandle, .) vSwapChain->Init(xrSwapchainHandle, ..);
-                    m_viewSwapchains.push_back(vSwapChain);
-                }
-            }
-            return AZ::RPI::XR::ResultCode::Success;
+            //if (vSwapChain)
+            //{
+                //xrCreateSwapchain(.., xrSwapchainHandle, .) vSwapChain->Init(xrSwapchainHandle, ..);
+                //m_viewSwapchains.push_back(vSwapChain);
+            //}
         }
-    } // namespace OpenXRVk
-} // namespace AZ
+        return AZ::RHI::ResultCode::Success;
+    }
+}

+ 127 - 130
Gems/OpenXRVk/Code/Source/OpenXRVkSystem.cpp

@@ -8,170 +8,167 @@
 
 #include <OpenXRVk/OpenXRVkSystem.h>
 
-namespace AZ
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    // Accessor functions for RHI objects that are populated by backend XR gems
+    // This will allow XR gem to provide device related data to RHI
+    AZ::RPI::XRDeviceDescriptor* OpenXRVk::System::GetDeviceDescriptor()
     {
-        // Accessor functions for RHI objects that are populated by backend XR gems
-        // This will allow XR gem to provide device related data to RHI
-        AZ::RPI::XR::Device::Descriptor* OpenXRVk::System::GetDeviceDescriptor()
-        {
-            return m_deviceDesc.get();
-        }
-
-        // Provide access to instance specific data to RHI
-        RPI::XR::Instance::Descriptor* OpenXRVk::System::GetInstanceDescriptor()
-        {
-            return m_instanceDesc.get();
-        }
+        return m_deviceDesc.get();
+    }
 
-        // Provide Swapchain specific data to RHI
-        RPI::XR::SwapChain::Image::Descriptor* OpenXRVk::System::GetSwapChainImageDescriptor(int swapchainIndex)
-        {
-            return m_swapchainDesc->m_descriptor.get();
-        }
+    // Provide access to instance specific data to RHI
+    AZ::RPI::XRInstanceDescriptor* OpenXRVk::System::GetInstanceDescriptor()
+    {
+        return m_instanceDesc.get();
+    }
 
-        // Provide access to Graphics Binding specific data that RHI can populate
-        RHI::GraphicsBinding::Descriptor* OpenXRVk::System::GetGraphicsBindingDescriptor()
-        {
-            return m_graphicsBindingDesc.get();
-        }
+    // Provide Swapchain specific data to RHI
+    AZ::RPI::XRSwapChainImageDescriptor* OpenXRVk::System::GetSwapChainImageDescriptor(int swapchainIndex)
+    {
+        return m_swapchainDesc->m_descriptor.get();
+    }
 
-        // Access supported Layers and extension names
-        const AZStd::vector<AZStd::string>& OpenXRVk::System::GetLayerNames()
-        {
-        }
+    // Provide access to Graphics Binding specific data that RHI can populate
+    AZ::RPI::XRGraphicsBindingDescriptor* OpenXRVk::System::GetGraphicsBindingDescriptor()
+    {
+        return m_graphicsBindingDesc.get();
+    }
 
-        const AZStd::vector<AZStd::string>& OpenXRVk::System::GetExtensionNames()
-        {
-        }
+    // Access supported Layers and extension names
+    const AZStd::vector<AZStd::string>& OpenXRVk::System::GetLayerNames()
+    {
+    }
 
-        // Create XR instance object and initialize it
-        AZ::RPI::XR::ResultCode OpenXRVk::System::InitInstance()
-        {
-            m_instance = Factory::Get()->CreateXRInstance();
+    const AZStd::vector<AZStd::string>& OpenXRVk::System::GetExtensionNames()
+    {
+    }
 
-            if (m_instance)
-            {
-                return m_instance->InitInstanceInternal();
-            }
-            return AZ::RPI::XR::ResultCode::Fail;
-        }
+    // Create XR instance object and initialize it
+    AZ::RHI::ResultCode OpenXRVk::System::InitInstance()
+    {
+        m_instance = XR::Factory::Get()->CreateInstance();
 
-        // Create XR device object and initialize it
-        AZ::RPI::XR::ResultCode OpenXRVk::System::InitDevice()
+        if (m_instance)
         {
-            m_device = Factory::Get()->CreateXRDevice();
+            return m_instance->InitInstanceInternal();
+        }
+        return AZ::RPI::XR::ResultCode::Fail;
+    }
 
-            // Get a list of XR compatible devices
-            AZStd::vector<AZStd::intrusive_ptr<PhysicalDevice>> physicalDeviceList = Factory::Get()->EnumerateDeviceList();
+    // Create XR device object and initialize it
+    AZ::RHI::ResultCode OpenXRVk::System::InitDevice()
+    {
+        m_device = XR::Factory::Get()->CreateDevice();
 
-            // Code to pick the correct device.
-            // For now we can just pick the first device in the list
+        // Get a list of XR compatible devices
+        AZStd::vector<AZStd::intrusive_ptr<PhysicalDevice>> physicalDeviceList = Factory::Get()->EnumerateDeviceList();
 
-            if (m_device)
-            {
-                return m_device->InitDeviceInternal();
-            }
-            return AZ::RPI::XR::ResultCode::Fail;
-        }
+        // Code to pick the correct device.
+        // For now we can just pick the first device in the list
 
-        // Initialize XR instance and device
-        AZ::RPI::XR::ResultCode OpenXRVk::System::InitializeSystem() override
+        if (m_device)
         {
-            AZ::RPI::XR::ResultCode instResult = InitInstance();
-            if (instResult != AZ::RPI::XR::ResultCode::Success)
-            {
-                AZ_Assert(false, "XR Instance creation failed");
-                return instResult;
-            }
-
-            AZ::RPI::XR::ResultCode deviceResult = InitDevice();
-            if (deviceResult != AZ::RPI::XR::ResultCode::Success)
-            {
-                AZ_Assert(false, "XR device creation failed");
-                return deviceResult;
-            }
-            return AZ::RPI::XR::ResultCode::Success;
+            return m_device->InitDeviceInternal();
         }
+        return AZ::RHI::ResultCode::Fail;
+    }
 
-        // Initialize a XR session
-        AZ::RPI::XR::ResultCode OpenXRVk::System::InitializeSession(AZStd::intrusive_ptr<GraphicsBinding> graphicsBinding) override
+    // Initialize XR instance and device
+    AZ::RHI::ResultCode OpenXRVk::System::InitializeSystem()
+    {
+        AZ::RHI::ResultCode instResult = InitInstance();
+        if (instResult != AZ::RHI::ResultCode::Success)
         {
-            m_session = Factory::Get()->CreateXRSession();
-
-            if (m_session)
-            {
-                AZ::RPI::XR::Session::Descriptor sessionDesc;
-                m_gbDesc = Factory::Get()->CreateGraphicsBindingDescriptor();
-                sessionDesc.m_graphicsBinding = RPISystem::Get()->PopulateGrapicsBinding(m_graphicsBindingDesc);
-                ResultCode sessionResult = m_session->Init(sessionDesc);
-                AZ_Assert(sessionResult == ResultCode::Success, "Session init failed");
-
-                m_xrInput = Factory::Get()->CreateXRInput();
-                return m_xrInput->InitializeActions();
-            }
-            return AZ::RPI::XR::ResultCode::Fail;
+            AZ_Assert(false, "XR Instance creation failed");
+            return instResult;
         }
 
-        // Manage session lifecycle to track if RenderFrame should be called.
-        bool OpenXRVk::System::IsSessionRunning() const override
+        AZ::RHI::ResultCode deviceResult = InitDevice();
+        if (deviceResult != AZ::RHI::ResultCode::Success)
         {
-            return m_session->IsSessionRunning();
+            AZ_Assert(false, "XR device creation failed");
+            return deviceResult;
         }
+        return AZ::RHI::ResultCode::Success;
+    }
 
-        // Create a Swapchain which will responsible for managing
-        // multiple XR swapchains and multiple swapchain images within it
-        AZ::RPI::XR::ResultCode OpenXRVk::System::CreateSwapchain() override
-        {
-            m_swapChain = Factory::Get()->CreateSwapchain();
-
-            if (m_swapChain)
-            {
-                ResultCode swapchainCreationResult = m_swapChain->Init(sessionDesc);
-                AZ_Assert(sessionResult == ResultCode::Success, "Swapchain init failed");
-                return swapchainCreationResult;
-            }
-            return AZ::RPI::XR::ResultCode::Fail;
-        }
+    // Initialize a XR session
+    AZ::RHI::ResultCode OpenXRVk::System::InitializeSession(AZStd::intrusive_ptr<GraphicsBinding> graphicsBinding)
+    {
+        m_session = XR::Factory::Get()->CreateSession();
 
-        // Indicate start of a frame
-        void OpenXRVk::System::BeginFrame() override
+        if (m_session)
         {
-        }
+            XR::SessionDescriptor sessionDesc;
+            m_gbDesc = XR::Factory::Get()->CreateGraphicsBindingDescriptor();
+            sessionDesc.m_graphicsBinding = RPISystem::Get()->PopulateGrapicsBinding(m_graphicsBindingDesc);
+            AZ::RHI::ResultCode sessionResult = m_session->Init(sessionDesc);
+            AZ_Assert(sessionResult == AZ::RHI::ResultCode::Success, "Session init failed");
 
-        // Indicate end of a frame
-        void OpenXRVk::System::EndFrame() override
-        {
+            m_xrInput = XR::Factory::Get()->CreateInput();
+            return m_xrInput->InitializeActions();
         }
+        return AZ::RHI::ResultCode::Fail;
+    }
 
-        // Indicate start of a XR view to help with synchronizing XR swapchain
-        void OpenXRVk::System::BeginXRView() override
-        {
-        }
+    // Manage session lifecycle to track if RenderFrame should be called.
+    bool OpenXRVk::System::IsSessionRunning() const
+    {
+        return m_session->IsSessionRunning();
+    }
+
+    // Create a Swapchain which will responsible for managing
+    // multiple XR swapchains and multiple swapchain images within it
+    AZ::RHI::ResultCode OpenXRVk::System::CreateSwapchain()
+    {
+        m_swapChain = XR::Factory::Get()->CreateSwapchain();
 
-        // Indicate end of a XR view to help with synchronizing XR swapchain
-        void OpenXRVk::System::EndXRView() override
+        if (m_swapChain)
         {
+            ResultCode swapchainCreationResult = m_swapChain->Init(sessionDesc);
+            AZ_Assert(sessionResult == ResultCode::Success, "Swapchain init failed");
+            return swapchainCreationResult;
         }
+        return AZ::RHI::ResultCode::Fail;
+    }
 
-        AZ::RPI::XR::ResultCode OpenXRVk::System::InitInstance()
+    // Indicate start of a frame
+    void OpenXRVk::System::BeginFrame()
+    {
+    }
+
+    // Indicate end of a frame
+    void OpenXRVk::System::EndFrame()
+    {
+    }
+
+    // Indicate start of a XR view to help with synchronizing XR swapchain
+    void OpenXRVk::System::BeginView()
+    {
+    }
+
+    // Indicate end of a XR view to help with synchronizing XR swapchain
+    void OpenXRVk::System::EndView()
+    {
+    }
+
+    AZ::RHI::ResultCode OpenXRVk::System::InitInstance()
+    {
+    }
+
+    // System Tick to poll input data
+    void OpenXRVk::System::OnSystemTick()
+    {
+        m_input->PollEvents();
+        if (exitRenderLoop)
         {
+            break;
         }
 
-        // System Tick to poll input data
-        void OpenXRVk::System::OnSystemTick() override
+        if (IsSessionRunning())
         {
-            m_input->PollEvents();
-            if (exitRenderLoop)
-            {
-                break;
-            }
-
-            if (IsSessionRunning())
-            {
-                m_input->PollActions();
-            }
+            m_input->PollActions();
         }
-    } // namespace OpenXRVk
-} // namespace AZ
+    }
+}

+ 23 - 11
Gems/OpenXRVk/Code/Source/OpenXRVkUtils.cpp

@@ -6,18 +6,30 @@
  *
  */
 
-namespace AZ
+#include <OpenXRVk/OpenXRVkUtils.h>
+
+namespace OpenXRVk
 {
-    namespace OpenXRVk
+    AZ::RHI::ResultCode ConvertResult(XrResult xrResult)
+    {
+        switch (xrResult)
+        {
+        case XR_SUCCESS:
+            return AZ::RHI::ResultCode::Success;
+        case XR_ERROR_OUT_OF_MEMORY:
+            return AZ::RHI::ResultCode::OutOfMemory;
+        default:
+            return AZ::RHI::ResultCode::Fail;
+        }
+    }
+
+    bool IsSuccess(XrResult result)
     {
-        bool IsSuccess(XrResult result)
+        if (result != XR_SUCCESS)
         {
-            if (result != XR_SUCCESS)
-            {
-                AZ_Error("XR", false, "ERROR: XR API method failed: %s", GetResultString(result));
-                return false;
-            }
-            return true;
+            AZ_Error("XR", false, "ERROR: XR API method failed: %s", GetResultString(result));
+            return false;
         }
-    } // namespace OpenXRVk
-} // namespace AZ
+        return true;
+    }
+}

+ 1 - 1
Gems/OpenXRVk/Code/openxrvk_private_common_shared_files.cmake

@@ -7,5 +7,5 @@
 #
 
 set(FILES
-    Source/Module.cpp
+    Source/OpenXRVkModule.cpp
 )