2
0
byrcolin 3 жил өмнө
parent
commit
1a09399e7f

+ 5 - 4
Gems/XR/Code/CMakeLists.txt

@@ -19,7 +19,7 @@ if(NOT PAL_TRAIT_XR_SUPPORTED)
 
     # Create stub modules. Once we support gem loading configuration, we can remove this stubbed targets
     ly_add_target(
-        NAME XR.Private ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
+        NAME XR ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
         NAMESPACE Gem
         FILES_CMAKE
             xr_stub_module.cmake
@@ -36,7 +36,7 @@ if(NOT PAL_TRAIT_XR_SUPPORTED)
 endif()
 
 ly_add_target(
-    NAME XR.Private.Static STATIC
+    NAME XR.Static STATIC
     NAMESPACE Gem
     FILES_CMAKE
         xr_private_common_files.cmake
@@ -55,11 +55,12 @@ ly_add_target(
         PUBLIC
             AZ::AzCore
             AZ::AzFramework
+            AZ::AtomCore
             Gem::Atom_RPI.Public
 )
 
 ly_add_target(
-    NAME XR.Private ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
+    NAME XR ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
     NAMESPACE Gem
     FILES_CMAKE
         xr_private_common_shared_files.cmake
@@ -71,6 +72,6 @@ ly_add_target(
             Include
     BUILD_DEPENDENCIES
         PRIVATE
-            
+            Gem::XR.Static
 )
 

+ 0 - 3
Gems/XR/Code/Include/XR/Platform/Windows/XR_Windows.h

@@ -10,6 +10,3 @@
 #include <AzCore/base.h>
 #include <AzCore/PlatformIncl.h>
 #include <AzCore/std/algorithm.h>
-
-
-

+ 27 - 30
Gems/XR/Code/Include/XR/XRDevice.h

@@ -8,36 +8,33 @@
 
 #pragma once
 
-#include <Atom/RHI/Device_Platform.h>
-#include <Atom/RPI.Public/XR/XRPhysicalDevice.h>
-#include <Atom/RPI.Public/XR/XRResult.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class DeviceDescriptor
+        : public AZ::RPI::XRDeviceDescriptor
     {
-        namespace XR
-        {
-            // This class will be responsible for creating XR::Device instance
-            // which will then be passed to the renderer to be used as needed.
-            class Device
-            {
-            public:
-                Device() = default;
-                virtual ~Device() = default;
-
-                class Descriptor
-                {
-                public:
-                    Descriptor() = default;
-                    ~Descriptor() = default;
-
-                    PhysicalDevice* physicalDevice;
-                };
-
-                virtual ResultCode InitDeviceInternal(Device::Descriptor descriptor) = 0;
-                Device::Descriptor m_descriptor;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(DeviceDescriptor, "{1FF2D68D-DA6A-47B3-A5BE-18E3A100C830}");
+
+        DeviceDescriptor() = default;
+        virtual ~DeviceDescriptor() = default;
+
+        //any extra info for a generic xr device
+    };
+
+    class Device
+    {
+    public:
+        AZ_RTTI(Device, "{A31B0DC2-BD54-443E-9350-EB1B10670FF9}");
+
+        Device() = default;
+        virtual ~Device() = default;
+
+        AZStd::intrusive_ptr<DeviceDescriptor> m_descriptor;
+
+        virtual AZ::RHI::ResultCode InitDeviceInternal() = 0;
+    };
+} // namespace XR
+

+ 48 - 49
Gems/XR/Code/Include/XR/XRFactory.h

@@ -8,69 +8,68 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
 #include <AzCore/std/containers/vector.h>
 #include <AzCore/std/smart_ptr/intrusive_ptr.h>
-#include <Atom/RPI.Public/XR/XRPhysicalDevice.h>
-#include <Atom/RPI.Public/XR/XRInstance.h>
-#include <Atom/RPI.Public/XR/XRDevice.h>
-#include <Atom/RPI.Public/XR/XRSession.h>
-#include <Atom/RPI.Public/XR/XRInput.h>
-#include <Atom/RPI.Public/XR/XRSwapChain.h>
-#include <Atom/RPI.Public/XR/XRGraphicsBinding.h>
-
-namespace AZ
+#include <AzCore/Interface/Interface.h>
+
+#include <XR/XRPhysicalDevice.h>
+#include <XR/XRInstance.h>
+#include <XR/XRDevice.h>
+#include <XR/XRSession.h>
+#include <XR/XRInput.h>
+#include <XR/XRSwapChain.h>
+#include <XR/XRGraphicsBinding.h>
+
+namespace XR
 {
-    namespace RPI
+    //! Interface responsible for creating all the XR objects which are
+    //! internally backed by concrete objects
+    class Factory
     {
-        namespace XR
-        {
-            //! Interface responsible for creating all the XR objects which are
-            //! internally backed by concrete objects
-            class Factory
-            {
-            public:
-                AZ_TYPE_INFO(Factory, "{A3D7271A-64FD-442C-9116-DBC32224222F}");
+    public:
+        AZ_TYPE_INFO(Factory, "{A3D7271A-64FD-442C-9116-DBC32224222F}");
+
+        Factory() = default;
+        virtual ~Factory() = default;
+
+        AZ_DISABLE_COPY_MOVE(Factory);
 
-                Factory() = default;
-                virtual ~Factory() = default;
+        //! Registers the global factory instance.
+        static void Register(XR::Factory* instance);
 
-                AZ_DISABLE_COPY_MOVE(Factory);
+        //! Unregisters the global factory instance.
+        static void Unregister(XR::Factory* instance);
 
-                //! Registers the global factory instance.
-                static void Register(AZ::RPI::XR::Factory* instance);
+        //! Is the factory ready
+        static bool IsReady();
 
-                //! Unregisters the global factory instance.
-                static void Unregister(AZ::RPI::XR::Factory* instance);
+        //! Access the global factory instance.
+        static XR::Factory& Get();
 
-                //! Access the global factory instance.
-                static AZ::RPI::XR::Factory& Get();
+        // Create XR::Instance object
+        virtual AZStd::intrusive_ptr<XR::Instance> CreateInstance() = 0;
 
-                // Create XR::Instance object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::Instance> CreateInstance() = 0;
+        // Create XR::Device object
+        virtual AZStd::intrusive_ptr<XR::Device> CreateDevice() = 0;
 
-                // Create XR::Device object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::Device> CreateDevice() = 0;
+        // Return a list of XR::PhysicalDevice
+        virtual AZStd::vector<AZStd::intrusive_ptr<XR::PhysicalDevice>> EnumerateDeviceList() = 0;
 
-                // Return a list of XR::PhysicalDevice
-                virtual AZStd::vector<AZStd::intrusive_ptr<AZ::RPI::XR::PhysicalDevice>> EnumerateDeviceList() = 0;
+        // Create XR::Session object
+        virtual AZStd::intrusive_ptr<XR::Session> CreateSession() = 0;
 
-                // Create XR::Session object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::Session> CreateSession() = 0;
+        // Create XR::Input object
+        virtual AZStd::intrusive_ptr<XR::Input> CreateInput() = 0;
 
-                // Create XR::Input object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::Input> CreateInput() = 0;
+        // Create XR::SwapChain object
+        virtual AZStd::intrusive_ptr<XR::SwapChain> CreateSwapchain() = 0;
 
-                // Create XR::SwapChain object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain> CreateSwapchain() = 0;
+        // Create XR::ViewSwapChain object
+        virtual AZStd::intrusive_ptr<XR::SwapChain::View> CreateViewSwapchain() = 0;
 
-                // Create XR::ViewSwapChain object
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::SwapChain::View> CreateViewSwapchain() = 0;
+        // Create RPI::XR::GraphicsBindingDescriptor that will contain
+        // renderer information needed to start a session
+        virtual AZStd::intrusive_ptr<XR::GraphicsBindingDescriptor> CreateGraphicsBindingDescriptor() = 0;
+    };
+} // namespace XR
 
-                // Create RPI::XR::GraphicsBindingDescriptor that will contain
-                // renderer information needed to start a session
-                virtual AZStd::intrusive_ptr<AZ::RPI::XR::GraphicsBinding::Descriptor> CreateGraphicsBindingDescriptor() = 0;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ

+ 25 - 23
Gems/XR/Code/Include/XR/XRGraphicsBinding.h

@@ -8,29 +8,31 @@
 
 #pragma once
 
-#include <Atom/RHI/GraphicsBinding.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class GraphicsBindingDescriptor
+        : public AZ::RPI::XRGraphicsBindingDescriptor
     {
-        namespace XR
-        {
-            class GraphicsBinding
-                : public AZ::RHI::GraphicsBinding
-            {
-            public:
-                GraphicsBinding() = default;
-                ~GraphicsBinding() = default;
-
-                class Descriptor
-                    : public AZ::RHI::GraphicsBinding::Descriptor
-                {
-                public:
-                    Descriptor() = default;
-                    ~Descriptor() = default;
-                };
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(GraphicsBindingDescriptor, "{6027891C-8920-4B36-83B6-FDF4E3DDDEC7}");
+
+        GraphicsBindingDescriptor() = default;
+        virtual ~GraphicsBindingDescriptor() = default;
+
+        //any extra info for a generic xr GraphicsBindingDescriptor
+    };
+
+    class GraphicsBinding
+    {
+    public:
+        AZ_RTTI(GraphicsBinding, "{0520401C-26B2-49E0-8EFD-6AD8E0720E84}");
+
+        GraphicsBinding() = default;
+        virtual ~GraphicsBinding() = default;
+
+        AZStd::intrusive_ptr<GraphicsBindingDescriptor> m_descriptor;
+    };
+} // namespace XR
+

+ 34 - 36
Gems/XR/Code/Include/XR/XRInput.h

@@ -8,43 +8,41 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
 #include <AzCore/std/smart_ptr/intrusive_ptr.h>
-#include <Atom/RPI.Public/XR/XRSession.h>
+#include <XR/XRSession.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class InputDescriptor
     {
-        namespace XR
-        {
-            // This class will be responsible for creating XR::Input
-            // which manage event queue or poll actions
-            class Input
-            {
-            public:
-                Input() = default;
-                virtual ~Input() = default;
-
-                class Descriptor
-                {
-                public:
-                    Descriptor() = default;
-                    ~Descriptor() = default;
-
-                    Session* m_session;
-                };
-
-                ResultCode Init(Input::Descriptor descriptor);
-
-                virtual void InitializeActions() = 0;
-                virtual void PollActions() = 0;
-                virtual void PollEvents() = 0;
-                virtual ResultCode InitInternal() = 0;
-
-            private:
-                AZStd::intrusive_ptr<Session> m_session;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(InputDescriptor, "{C690ABBF-D8A9-4348-98E6-45BBF432D673}");
+
+        InputDescriptor() = default;
+        virtual ~InputDescriptor() = default;
+
+        //any extra info for a generic xr InputDescriptor
+        AZStd::intrusive_ptr<Session> m_session;
+    };
+
+    // This class will be responsible for creating XR::Input
+    // which manage event queue or poll actions
+    class Input
+    {
+    public:
+        AZ_RTTI(Input, "{DCDFC6A7-B457-414B-BC24-0831C2AC628B}");
+
+        Input() = default;
+        virtual ~Input() = default;
+
+        AZ::RHI::ResultCode Init();
+
+        virtual void InitializeActions() = 0;
+        virtual void PollActions() = 0;
+        virtual void PollEvents() = 0;
+        virtual AZ::RHI::ResultCode InitInternal() = 0;
+
+    private:
+        AZStd::intrusive_ptr<InputDescriptor> m_descriptor;
+    };
+} // namespace XR

+ 27 - 26
Gems/XR/Code/Include/XR/XRInstance.h

@@ -8,32 +8,33 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
-#include <Atom/RPI.Public/XR/XRPhysicalDevice.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class InstanceDescriptor
+        : public AZ::RPI::XRInstanceDescriptor
     {
-        namespace XR
-        {
-            // XR::Instance class. It will be responsible for collecting all the data like
-            // form factor, physical device etc that will be needed to initialize an instance
-            class Instance
-            {
-            public:
-                Instance() = default;
-                virtual ~Instance() = default;
-
-                class Descriptor
-                {
-                public:
-                    // Form Factor enum
-                    PhysicalDevice* physicalDevice;
-                };
-
-                virtual ResultCode InitInstanceInternal() = 0;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(InstanceDescriptor, "{1C457924-56A4-444F-BC72-4D31A097BA70}");
+
+        InstanceDescriptor() = default;
+        virtual ~InstanceDescriptor() = default;
+
+        //any extra info a generic xr instance descriptor needs
+    };
+
+    class Instance
+    {
+    public:
+        AZ_RTTI(Instance, "{1C457924-56A4-444F-BC72-4D31A097BA70}");
+
+        Instance() = default;
+        virtual ~Instance() = default;
+
+        AZStd::intrusive_ptr<InstanceDescriptor> m_descriptor;
+
+        virtual AZ::RHI::ResultCode InitInstanceInternal();
+    };
+
+} // namespace XR

+ 25 - 34
Gems/XR/Code/Include/XR/XRPhysicalDevice.h

@@ -8,40 +8,31 @@
 
 #pragma once
 
-#include <Atom/RHI/PhysicalDevice.h>
-#include <Atom/RHI.Reflect/PhysicalDeviceDescriptor.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class PhysicalDeviceDescriptor
     {
-        namespace XR
-        {
-            class PhysicalDeviceDescriptor
-                : public AZ::RHI::PhysicalDeviceDescriptor
-            {
-            public:
-                AZ_RTTI(PhysicalDeviceDescriptor, "{4E11244B-FDED-4CD6-89D7-DC3B4A1C33A8}", AZ::RHI::PhysicalDeviceDescriptor);
-
-                PhysicalDeviceDescriptor() = default;
-                virtual ~PhysicalDeviceDescriptor() = default;
-
-                // Other data related to xr 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
-                : public AZ::RHI::PhysicalDevice
-            {
-            public:
-                AZ_RTTI(PhysicalDevice, "{E7B78CC5-53A9-492E-AA1C-8815FB882E0A}", AZ::RHI::PhysicalDevice);
-
-                PhysicalDevice() = default;
-                virtual ~PhysicalDevice() = default;
-
-                PhysicalDeviceDescriptor m_descriptor;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(PhysicalDeviceDescriptor, "{4E11244B-FDED-4CD6-89D7-DC3B4A1C33A8}");
+
+        PhysicalDeviceDescriptor() = default;
+        virtual ~PhysicalDeviceDescriptor() = default;
+
+        // Other data related to 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
+    {
+    public:
+        AZ_RTTI(PhysicalDevice, "{E7B78CC5-53A9-492E-AA1C-8815FB882E0A}");
+
+        PhysicalDevice() = default;
+        virtual ~PhysicalDevice() = default;
+
+        AZStd::intrusive_ptr<PhysicalDeviceDescriptor> m_descriptor;
+    };
+} // namespace XR

+ 0 - 33
Gems/XR/Code/Include/XR/XRResult.h

@@ -1,33 +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
- *
- */
-
-#pragma once
-
-namespace AZ
-{
-    namespace RPI
-    {
-        namespace XR
-        {
-            enum class ResultCode : int
-            {
-                // The operation succeeded.
-                Success = 0,
-
-                // The operation failed with an unknown error.
-                Fail,
-
-                // The operation failed because the feature is unimplemented on the particular platform.
-                Unimplemented,
-
-                // The operation failed due to invalid arguments.
-                InvalidArgument
-            };
-        }
-    } // namespace RPI
-} // namespace AZ

+ 34 - 31
Gems/XR/Code/Include/XR/XRSession.h

@@ -8,37 +8,40 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
-#include <Atom/RPI.Public/XR/XRGraphicsBinding.h>
+#include <XR/XRGraphicsBinding.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class SessionDescriptor
     {
-        namespace XR
-        {
-            // This class will be responsible for creating XR::Session and
-            // all the code around managing the session state
-            class Session
-            {
-            public:
-                class Descriptor
-                {
-                public:
-                    // Graphics Binding will contain renderer related data to start a xr session
-                    GraphicsBinding* m_graphicsBinding;
-                };
-
-                ResultCode Init(Session::Descriptor sessionDesc);
-                bool IsSessionRunning() const;
-                bool IsSessionFocused() const;
-                virtual ResultCode InitSessionInternal(Session::Descriptor descriptor);
-
-            private:
-                Session::Descriptor m_descriptor;
-                bool m_sessionRunning = false;
-                bool m_sessionFocused = false;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(SessionDescriptor, "{F76B99EF-ED66-4AAA-BA35-578339CAB428}");
+
+        SessionDescriptor() = default;
+        virtual ~SessionDescriptor() = default;
+
+        // Graphics Binding will contain renderer related data to start a xr session
+        AZStd::intrusive_ptr<GraphicsBinding> m_graphicsBinding;
+    };
+
+    // This class will be responsible for creating XR::Session and
+    // all the code around managing the session state
+    class Session
+    {
+    public:
+        AZ_RTTI(Session, "{E7276FE1-94B8-423A-9C1D-1BCF1A0066BC}");
+
+        Session() = default;
+        virtual ~Session() = default;
+
+        AZ::RHI::ResultCode Init();
+        virtual bool IsSessionRunning() const;
+        virtual bool IsSessionFocused() const;
+        virtual AZ::RHI::ResultCode InitInternal();
+
+    private:
+        AZStd::intrusive_ptr<SessionDescriptor> m_descriptor;
+        bool m_sessionRunning = false;
+        bool m_sessionFocused = false;
+    };
+} // namespace XR

+ 10 - 14
Gems/XR/Code/Include/XR/XRSpace.h

@@ -8,20 +8,16 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
+#include <XR/XRResult.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    // This class will be responsible for managing XR Space
+    class Space
     {
-        namespace XR
-        {
-            // This class will be responsible for managing XR Space
-            class Space
-            {
-            public:
-                virtual ResultCode InitInternal() = 0;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    public:
+        AZ_RTTI(Space, "{A78A37F1-8861-4EB4-8FC6-0E9C11394EF1}");
+
+        virtual AZ::RHI::ResultCode InitInternal() = 0;
+    };
+} // namespace XR

+ 80 - 52
Gems/XR/Code/Include/XR/XRSwapChain.h

@@ -8,61 +8,89 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
 #include <AzCore/std/containers/vector.h>
 #include <AzCore/std/smart_ptr/intrusive_ptr.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class SwapChainDescriptor
     {
-        namespace XR
+    public:
+        AZ_RTTI(SwapChainDescriptor, "{EC10B9A1-9D32-4BC0-AE21-216B1503BBDA}");
+
+        SwapChainDescriptor() = default;
+        virtual ~SwapChainDescriptor() = default;
+
+        //any extra info for a generic xr swap chain descriptor
+    };
+
+    class SwapChainImageDescriptor
+        : public AZ::RPI::XRSwapChainImageDescriptor
+    {
+    public:
+        AZ_RTTI(SwapChainImageDescriptor, "{A42444A3-D1E1-489B-8E6F-C0285C7482F3}", AZ::RPI::XRSwapChainImageDescriptor);
+
+        SwapChainImageDescriptor() = default;
+        virtual ~SwapChainImageDescriptor() = default;
+
+        //any extra info for a generic xr swap chain
+        AZ::u16 m_width;
+        AZ::u16 m_height;
+        AZ::u16 m_arraySize;
+    };
+
+    // This class will be responsible for creating multiple XR::SwapChain::ViewSwapchains
+    // (one per view). Each XR::SwapChain::ViewSwapchain will then be responsible
+    // for manging and synchronizing multiple swap chain images
+    class SwapChain
+    {
+    public:
+        AZ_RTTI(SwapChain, "{0C666E76-E4B7-4097-8D14-713DC2C446EF}");
+
+        SwapChain() = default;
+        virtual ~SwapChain() = default;
+
+        class Image
         {
-            // This class will be responsible for creating multiple XR::SwapChain::ViewSwapchains
-            // (one per view). Each XR::SwapChain::ViewSwapchain will then be responsible
-            // for manging and synchronizing multiple swap chain images
-            class SwapChain
-            {
-            public:
-                virtual ~SwapChain() = default;
-
-                class Image
-                {
-                public:
-                    class Descriptor
-                    {
-                    public:
-                        uint16_t m_width;
-                        uint16_t m_height;
-                        uint16_t m_arraySize;
-                    };
-                    AZStd::intrusive_ptr<Descriptor> m_descriptor;
-                };
-
-                class View
-                {
-                public:
-                    //! All the images associated with this ViewSwapChain
-                    AZStd::vector<AZStd::intrusive_ptr<SwapChain::Image>> m_images;
-
-                    //! The current image index.
-                    uint32_t m_currentImageIndex = 0;
-                };
-
-                //! Returns the view swap chain related to the index
-                SwapChain::View* GetView(const uint32_t swapChainIndex) const;
-
-                //! Returns the image associated with the provided image
-                //! index and view swap chain index
-                SwapChain::Image* GetImage(uint32_t imageIndex, uint32_t swapChainIndex) const;
-
-                ResultCode Init();
-
-                virtual ResultCode InitInternal();
-
-            private:
-                AZStd::vector<AZStd::intrusive_ptr<SwapChain::View>> m_viewSwapchains;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+        public:
+            AZ_RTTI(Image, "{4037835D-F1BB-4407-BC98-2299CC7BE0A3}");
+
+            Image() = default;
+            virtual ~Image() = default;
+
+            AZStd::intrusive_ptr<SwapChainImageDescriptor> m_descriptor;
+        };
+
+        class View
+        {
+        public:
+            AZ_RTTI(View, "{774EB724-8261-4684-AA78-EDF6BBECD48A}");
+
+            View() = default;
+            virtual ~View() = default;
+
+            //! All the images associated with this ViewSwapChain
+            AZStd::vector<AZStd::intrusive_ptr<SwapChain::Image>> m_images;
+
+            //! The current image index.
+            AZ::u16 m_currentImageIndex = 0;
+        };
+
+        //! Returns the view swap chain related to the index
+        SwapChain::View* GetView(const AZ::u16 swapChainIndex) const;
+
+        //! Returns the image associated with the provided image
+        //! index and view swap chain index
+        SwapChain::Image* GetImage(AZ::u16 imageIndex, AZ::u16 swapChainIndex) const;
+
+        AZ::RHI::ResultCode Init();
+
+        virtual AZ::RHI::ResultCode InitInternal();
+
+        AZStd::intrusive_ptr<SwapChainDescriptor> m_descriptor;
+
+    private:
+        AZStd::vector<AZStd::intrusive_ptr<SwapChain::View>> m_viewSwapchains;
+    };
+} // namespace XR

+ 37 - 49
Gems/XR/Code/Include/XR/XRSystem.h

@@ -8,69 +8,57 @@
 
 #pragma once
 
-#include <Atom/RPI.Public/XR/XRResult.h>
-#include <Atom/RPI.Public/XR/XRDevice.h>
-#include <Atom/RPI.Public/XR/XRInstance.h>
-#include <Atom/RPI.Public/XR/XRSwapChain.h>
-#include <Atom/RPI.Public/XR/XRGraphicsBinding.h>
+#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    class System
+        : public AZ::RPI::XRSystemInterface
     {
-        namespace XR
-        {
-            class System
-            {
-            public:
-                AZ_RTTI(System, "{0B08E0D2-FB6C-4290-89BB-556F36CCF50A}");
+    public:
+        AZ_RTTI(System, "{C3E0291D-FB30-4E27-AB0D-14606A8C3C1F}" AZ::RPI::XRSystemInterface);
 
-                AZ_DISABLE_COPY_MOVE(System);
+        AZ_DISABLE_COPY_MOVE(System);
 
-                static System* Get();
+        static System* Get();
 
-                System() = default;
-                virtual ~System() = default;
+        // Creates the XR::Instance which is responsible for managing
+        // XrInstance (amongst other things) for OpenXR backend
+        // Also initializes the XR::Device
+        virtual AZ::RHI::ResultCode InitializeSystem() = 0;
 
-                // Creates the XR::Instance which is responsible for managing
-                // XrInstance (amongst other things) for OpenXR backend
-                // Also initializes the XR::Device
-                virtual ResultCode InitializeSystem() = 0;
+        // Create a Session and other basic session-level initialization.
+        virtual AZ::RHI::ResultCode InitializeSession() = 0;
 
-                // Create a Session and other basic session-level initialization.
-                virtual ResultCode InitializeSession(AZStd::intrusive_ptr<XR::GraphicsBinding> graphicsBinding) = 0;
+        // Start of the frame related XR work
+        virtual void BeginFrame() = 0;
 
-                // Start of the frame related XR work
-                virtual void BeginFrame() = 0;
+        // End of the frame related XR work
+        virtual void EndFrame() = 0;
 
-                // End of the frame related XR work
-                virtual void EndFrame() = 0;
+        // Start of the XR view related work
+        virtual void BeginView() = 0;
 
-                // Start of the XR view related work
-                virtual void BeginView() = 0;
+        // End of the XR view related work
+        virtual void EndView() = 0;
 
-                // End of the XR view related work
-                virtual void EndView() = 0;
+        // Manage session lifecycle to track if RenderFrame should be called.
+        virtual bool IsSessionRunning() const = 0;
 
-                // Manage session lifecycle to track if RenderFrame should be called.
-                virtual bool IsSessionRunning() const = 0;
+        // Create a swap chain which will responsible for managing
+        // multiple XR swap chains and multiple swap chain images within it
+        virtual void CreateSwapchain() = 0;
 
-                // Create a swap chain which will responsible for managing
-                // multiple XR swap chains and multiple swap chain images within it
-                virtual void CreateSwapchain() = 0;
+        // This will allow XR gem to provide device related data to RHI
+        virtual AZ::RPI::XRDeviceDescriptor* GetDeviceDescriptor() = 0;
 
-                // This will allow XR gem to provide device related data to RHI
-                virtual Device::Descriptor* GetDeviceDescriptor() = 0;
+        // Provide access to instance specific data to RHI
+        virtual AZ::RPI::XRInstanceDescriptor* GetInstanceDescriptor() = 0;
 
-                // Provide access to instance specific data to RHI
-                virtual Instance::Descriptor* GetInstanceDescriptor() = 0;
+        // Provide swap chain specific data to RHI
+        virtual AZ::RPI::XRSwapChainImageDescriptor* GetSwapChainImageDescriptor(int swapchainIndex) = 0;
 
-                // Provide swap chain specific data to RHI
-                virtual SwapChain::Image::Descriptor* GetSwapChainImageDescriptor(uint32_t swapchainIndex) = 0;
-
-                // Provide access to Graphics Binding specific data that RHI can populate
-                virtual XR::GraphicsBinding::Descriptor* GetGraphicsBindingDescriptor() = 0;
-            };
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+        // Provide access to Graphics Binding specific data that RHI can populate
+        virtual AZ::RPI::XRGraphicsBindingDescriptor* GetGraphicsBindingDescriptor() = 0;
+    };
+} // namespace XR

+ 1 - 7
Gems/XR/Code/Include/XR/XRUtils.h

@@ -8,13 +8,7 @@
 
 #pragma once
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
-    {
-        namespace XR
-        {
 
-        }
-    }
 }

+ 4 - 13
Gems/XR/Code/Source/XRDevice.cpp

@@ -6,18 +6,9 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRDevice.h>
+#include <XR/XRDevice.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
-    {
-        namespace XR
-        {
-            ResultCode Device::InitDeviceInternal(Device::Descriptor /* descriptor */)
-            {
-                return ResultCode::Success;
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+
+} // namespace XR

+ 25 - 21
Gems/XR/Code/Source/XRFactory.cpp

@@ -6,29 +6,33 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRFactory.h>
+#include <AzCore/Interface/Interface.h>
+#include <XR/XRFactory.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    //! Registers the global factory instance.
+    void Factory::Register(Factory* instance)
     {
-        namespace XR
-        {
-            //! Registers the global factory instance.
-            void Factory::Register(Factory* /*instance*/)
-            {
-            }
+        AZ::Interface<Factory>::Register(instance);
+    }
 
-            //! Unregisters the global factory instance.
-            void Factory::Unregister(Factory* /*instance*/)
-            {
-            }
+    //! Unregisters the global factory instance.
+    void Factory::Unregister(Factory* instance)
+    {
+        AZ::Interface<Factory>::Unregister(instance);
+    }
+
+    bool Factory::IsReady()
+    {
+        return AZ::Interface<Factory>::Get() != nullptr;
+    }
 
-            //! Access the global factory instance.
-            Factory& Factory::Get()
-            {
-                return;
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    //! Access the global factory instance.
+    Factory& Factory::Get()
+    {
+        Factory* factory = AZ::Interface<Factory>::Get();
+        AZ_Assert(factory, "XR::Factory failed to create!!!");
+        return *factory;
+    }
+} // namespace XR

+ 3 - 9
Gems/XR/Code/Source/XRGraphicsBinding.cpp

@@ -6,14 +6,8 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRGraphicsBinding.h>
+#include <XR/XRGraphicsBinding.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
-    {
-        namespace XR
-        {
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+} // namespace XR

+ 7 - 13
Gems/XR/Code/Source/XRInput.cpp

@@ -6,19 +6,13 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRInput.h>
+#include <XR/XRInput.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    AZ::RHI::ResultCode Input::Init()
     {
-        namespace XR
-        {
-            ResultCode Input::Init(Input::Descriptor descriptor)
-            {
-                m_session = descriptor.m_session;
-                return InitInternal();
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+        //m_session = descriptor.m_session;
+        return InitInternal();
+    }
+} // namespace XR

+ 6 - 13
Gems/XR/Code/Source/XRInstance.cpp

@@ -6,19 +6,12 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRInstance.h>
+#include <XR/XRInstance.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    AZ::RHI::ResultCode Instance::InitInstanceInternal()
     {
-        namespace XR
-        {
-            ResultCode Instance::InitInstanceInternal()
-            {
-                return ResultCode::Success;
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
-
+        return AZ::RHI::ResultCode::Success;
+    }
+} // namespace XR

+ 13 - 27
Gems/XR/Code/Source/XRModule.cpp

@@ -6,41 +6,27 @@
  *
  */
 
+#include <AzCore/Memory/SystemAllocator.h>
 #include <AzCore/Module/Module.h>
 
-namespace AZ
+namespace XR
 {
-    namespace XR
+    class Module
+        : public AZ::Module
     {
-        class Module
-            : public AZ::Module
-        {
-        public:
-            AZ_RTTI(Module, "{71A99524-7D31-42D3-955E-3F4774F310AC}", AZ::Module);
+    public:
+        AZ_RTTI(Module, "{71A99524-7D31-42D3-955E-3F4774F310AC}", AZ::Module);
+        AZ_CLASS_ALLOCATOR(Module, AZ::SystemAllocator, 0);
 
-            Module()
-            {
-                m_descriptors.insert(m_descriptors.end(), {
-                    ReflectSystemComponent::CreateDescriptor(),
-                    FactoryManagerSystemComponent::CreateDescriptor(),
-                    FactoryRegistrationFinalizerSystemComponent::CreateDescriptor()
-                });
-            }
-            ~Module() override = default;
+        Module()
+            : AZ::Module()
+        {
+        }
 
-            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(XR_Private, AZ::XR::Module)
+AZ_DECLARE_MODULE_CLASS(Gem_XR, XR::Module)

+ 3 - 9
Gems/XR/Code/Source/XRPhysicalDevice.cpp

@@ -6,15 +6,9 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRPhysicalDevice.h>
+#include <XR/XRPhysicalDevice.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
-    {
-        namespace XR
-        {
 
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+} // namespace XR

+ 18 - 24
Gems/XR/Code/Source/XRSession.cpp

@@ -6,33 +6,27 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRSession.h>
+#include <XR/XRSession.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    AZ::RHI::ResultCode Session::Init()
     {
-        namespace XR
-        {
-            ResultCode Session::Init(Session::Descriptor sessionDesc)
-            {
-                return InitSessionInternal(sessionDesc);
-            }
+        return Session::InitInternal();
+    }
 
-            bool Session::IsSessionRunning() const
-            {
-                return m_sessionRunning;
-            }
+    bool Session::IsSessionRunning() const
+    {
+        return m_sessionRunning;
+    }
 
-            bool Session::IsSessionFocused() const
-            {
-                return m_sessionFocused;
-            }
+    bool Session::IsSessionFocused() const
+    {
+        return m_sessionFocused;
+    }
 
-            ResultCode Session::InitSessionInternal(Session::Descriptor descriptor)
-            {
-                return ResultCode::Success;
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    AZ::RHI::ResultCode Session::InitInternal()
+    {
+        return AZ::RHI::ResultCode::Success;
+    }
+} // namespace XR

+ 6 - 12
Gems/XR/Code/Source/XRSpace.cpp

@@ -6,18 +6,12 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRSpace.h>
+#include <XR/XRSpace.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    ResultCode Space::InitInternal()
     {
-        namespace XR
-        {
-            ResultCode Space::InitInternal()
-            {
-                return ResultCode::Success;
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+        return ResultCode::Success;
+    }
+} // namespace XR

+ 17 - 23
Gems/XR/Code/Source/XRSwapChain.cpp

@@ -6,31 +6,25 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRSwapChain.h>
+#include <XR/XRSwapChain.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    //! Returns the view swap chain related to the index
+    SwapChain::View* SwapChain::GetView(const AZ::u16 swapchainIndex) const
     {
-        namespace XR
-        {
-            //! Returns the view swap chain related to the index
-            SwapChain::View* SwapChain::GetView(const uint32_t swapchainIndex) const
-            {
-                return m_viewSwapchains[swapchainIndex].get();
-            }
+        return m_viewSwapchains[swapchainIndex].get();
+    }
 
-            //! Returns the image associated with the provided image
-            //! index and view swap chain index
-            SwapChain::Image* SwapChain::GetImage(uint32_t imageIndex, uint32_t swapchainIndex) const
-            {
-                return GetView(swapchainIndex)->m_images[imageIndex].get();
-            }
+    //! Returns the image associated with the provided image
+    //! index and view swap chain index
+    SwapChain::Image* SwapChain::GetImage(AZ::u16 imageIndex, AZ::u16 swapchainIndex) const
+    {
+        return GetView(swapchainIndex)->m_images[imageIndex].get();
+    }
 
-            ResultCode SwapChain::Init()
-            {
-                return InitInternal();
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+    AZ::RHI::ResultCode SwapChain::Init()
+    {
+        return InitInternal();
+    }
+} // namespace XR

+ 6 - 12
Gems/XR/Code/Source/XRSystem.cpp

@@ -6,19 +6,13 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRSystemInterface.h>
 #include <AZCore/Interface/Interface.h>
+#include <XR/XRSystem.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
+    System* System::Get()
     {
-        namespace XR
-        {
-            SystemInterface* SystemInterface::Get()
-            {
-                return Interface<SystemInterface>::Get();
-            }
-        } // namespace XR
-    } // namespace RPI
-} // namespace AZ
+        return AZ::Interface<System>::Get();
+    }
+} // namespace XR

+ 2 - 8
Gems/XR/Code/Source/XRUtils.cpp

@@ -6,15 +6,9 @@
  *
  */
 
-#include <Atom/RPI.Public/XR/XRUtils.h>
+#include <XR/XRUtils.h>
 
-namespace AZ
+namespace XR
 {
-    namespace RPI
-    {
-        namespace XR
-        {
 
-        }
-    }
 }

+ 1 - 0
Gems/XR/Code/xr_private_common_files.cmake

@@ -23,6 +23,7 @@ set(FILES
     Source/XRGraphicsBinding.cpp
     Source/XRInput.cpp
     Source/XRInstance.cpp
+    Source/XRModule.cpp
     Source/XRPhysicalDevice.cpp
     Source/XRSession.cpp
     Source/XRSpace.cpp