Skip to content

Commit

Permalink
Merged stabilization/2310 -> main
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Galvan <[email protected]>
  • Loading branch information
cgalvan committed Oct 5, 2023
2 parents 8fa1bfd + 05aa2dc commit 7787b45
Show file tree
Hide file tree
Showing 1,004 changed files with 192,443 additions and 4,996 deletions.
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#
# Git LFS (see https://git-lfs.github.com/)
#
Expand Down Expand Up @@ -126,5 +125,10 @@ Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/marmoset_bake.tbs
Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/Brass/brass_bake.spp filter=lfs diff=lfs merge=lfs -text
Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/.wip/stone/stone_bake.spp filter=lfs diff=lfs merge=lfs -text
Gems/WarehouseAssets/docs/images/*.png filter= diff= merge= -text
Templates/Ros2FleetRobotTemplate/docs/images/*.png filter= diff= merge= -text
Gems/ROS2/docs/**/*.png -filter -diff -merge
Templates/Ros2ProjectTemplate/Screenshots/*.png filter= diff= merge= -text
Templates/Ros2FleetRobotTemplate/Screenshots/*.png filter= diff= merge= -text
Templates/Ros2RoboticManipulationTemplate/Screenshots/*.png filter= diff= merge= -text

*.pgm filter=lfs diff=lfs merge=lfs -text
5 changes: 4 additions & 1 deletion Gems/AzQtComponentsForPython/gem.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"documentation_url": "",
"dependencies": [
"EditorPythonBindings"
]
],
"repo_uri": "https://raw.githubusercontent.com/o3de/o3de-extras/development",
"download_source_uri": "https://github.com/o3de/o3de-extras/releases/download/2.0/azqtcomponentsforpython-1.0.0-gem.zip",
"version": "1.0.0"
}
12 changes: 9 additions & 3 deletions Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <XR/XRDevice.h>
#include <XR/XRSwapChain.h>
#include <OpenXRVk_Platform.h>
#include <Atom/RHI.Reflect/Vulkan/XRVkDescriptors.h>

namespace OpenXRVk
{
Expand All @@ -27,6 +28,7 @@ namespace OpenXRVk

//////////////////////////////////////////////////////////////////////////
// XR::Device overrides

// Create the xr specific native device object and populate the XRDeviceDescriptor with it.
AZ::RHI::ResultCode InitDeviceInternal(AZ::RHI::XRDeviceDescriptor* instanceDescriptor) override;
//! Get the Fov data of the view specified by view index
Expand All @@ -41,8 +43,11 @@ namespace OpenXRVk
//! Get the native device
VkDevice GetNativeDevice() const;

//! Get glad vulkan context.
const GladVulkanContext& GetContext() const;
//! Get the native physical device
VkPhysicalDevice GetNativePhysicalDevice() const;

//! Returns the graphic binding for a hardware queue
const AZ::Vulkan::XRDeviceDescriptor::GraphicsBinding& GetGraphicsBinding(AZ::RHI::HardwareQueueClass queueClass) const;

//! Reserve space for appropriate number of views
void InitXrViews(uint32_t numViews);
Expand All @@ -67,12 +72,13 @@ namespace OpenXRVk
//////////////////////////////////////////////////////////////////////////

VkDevice m_xrVkDevice = VK_NULL_HANDLE;
VkPhysicalDevice m_xrVkPhysicalDevice = VK_NULL_HANDLE;
AZStd::array<AZ::Vulkan::XRDeviceDescriptor::GraphicsBinding, AZ::RHI::HardwareQueueClassCount> m_xrQueueBinding;
XrFrameState m_frameState{ XR_TYPE_FRAME_STATE };
AZStd::vector<XrCompositionLayerBaseHeader*> m_xrLayers;
XrCompositionLayerProjection m_xrLayer{ XR_TYPE_COMPOSITION_LAYER_PROJECTION };
AZStd::vector<XrCompositionLayerProjectionView> m_projectionLayerViews;
AZStd::vector<XrView> m_views;
uint32_t m_viewCountOutput = 0;
GladVulkanContext m_context = {};
};
}
39 changes: 23 additions & 16 deletions Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@

#pragma once


#include <AzCore/std/containers/vector.h>
#include <Atom/RHI/ValidationLayer.h>
#include <Atom/RHI.Loader/FunctionLoader.h>
#include <OpenXRVk_Platform.h>
#include <OpenXRVk/OpenXRVkPhysicalDevice.h>
#include <Atom/RHI/ValidationLayer.h>
#include <Atom/RHI.Reflect/Vulkan/VulkanBus.h>
#include <XR/XRInstance.h>

namespace OpenXRVk
{
//! Vulkan specific XR instance back-end class that will help manage
//! XR specific vulkan native objects
class Instance final
: public XR::Instance
: public XR::Instance
, public AZ::Vulkan::InstanceRequirementBus::Handler
, public AZ::Vulkan::DeviceRequirementBus::Handler
, public AZ::Vulkan::InstanceNotificationBus::Handler
{
public:
AZ_CLASS_ALLOCATOR(Instance, AZ::SystemAllocator);
Expand All @@ -30,7 +34,6 @@ namespace OpenXRVk

//////////////////////////////////////////////////////////////////////////
// XR::Instance overrides
AZ::RHI::ResultCode InitNativeInstance(AZ::RHI::XRInstanceDescriptor* instanceDescriptor) override;
AZ::u32 GetNumPhysicalDevices() const override;
AZ::RHI::ResultCode GetXRPhysicalDevice(AZ::RHI::XRPhysicalDeviceDescriptor* physicalDeviceDescriptor, int32_t index) override;
//////////////////////////////////////////////////////////////////////////
Expand All @@ -56,26 +59,29 @@ namespace OpenXRVk
//! Get native VkInstance.
VkInstance GetNativeInstance() const;

//! Get glad vulkan context.
GladVulkanContext& GetContext();

//! Get function loader.
AZ::Vulkan::FunctionLoader& GetFunctionLoader();

//! Get XR environment blend mode.
XrEnvironmentBlendMode GetEnvironmentBlendMode() const;

//! Get XR configuration type.
XrViewConfigurationType GetViewConfigType() const;

//! Ge the active VkPhysicalDevice.
VkPhysicalDevice GetActivePhysicalDevice() const;

protected:
// XR::Instance overrides...
AZ::RHI::ResultCode InitInstanceInternal() override;
void ShutdownInternal() override;

// AZ::Vulkan::InstanceRequirementBus::Handler overrides..
void CollectAdditionalRequiredInstanceExtensions(AZStd::vector<AZStd::string>& extensions) override;
void CollectMinMaxVulkanAPIVersions(AZStd::vector<uint32_t>& min, AZStd::vector<uint32_t>& max) override;

// AZ::Vulkan::DeviceRequirementBus::Handler overrides...
void CollectAdditionalRequiredDeviceExtensions(AZStd::vector<AZStd::string>& extensions) override;
void FilterSupportedDevices(AZStd::vector<VkPhysicalDevice>& supportedDevices) override;

// AZ::Vulkan::InstanceNotificationBus::Handler overrides...
virtual void OnInstanceCreated([[maybe_unused]] VkInstance instance);
virtual void OnInstanceDestroyed();

private:
XrInstance m_xrInstance = XR_NULL_HANDLE;
VkInstance m_xrVkInstance = VK_NULL_HANDLE;
Expand All @@ -85,9 +91,10 @@ namespace OpenXRVk
XrSystemId m_xrSystemId = XR_NULL_SYSTEM_ID;
XR::RawStringList m_requiredLayers;
XR::RawStringList m_requiredExtensions;
GladVulkanContext m_context = {};
AZStd::unique_ptr<AZ::Vulkan::FunctionLoader> m_functionLoader;
XR::StringList m_requireVulkanInstanceExtensions;
XR::StringList m_requireVulkanDeviceExtensions;
AZStd::vector<VkPhysicalDevice> m_supportedXRDevices;
AZ::u32 m_physicalDeviceActiveIndex = 0;
uint32_t m_minVulkanAPIVersion = 0;
uint32_t m_maxVulkanAPIVersion = 0;
};
}
8 changes: 6 additions & 2 deletions Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkSystemComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <XR/XRFactory.h>
#include <OpenXRVk/OpenXRVkInstance.h>
#include <AzCore/Component/Component.h>

namespace OpenXRVk
Expand All @@ -24,8 +25,8 @@ namespace OpenXRVk
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void Reflect(AZ::ReflectContext* context);

SystemComponent();
~SystemComponent();
SystemComponent() = default;
~SystemComponent() = default;

//////////////////////////////////////////////////////////////////////////
// Component
Expand Down Expand Up @@ -59,5 +60,8 @@ namespace OpenXRVk
//! Create XR::Swapchain::Image object.
XR::Ptr<XR::SwapChain::Image> CreateSwapChainImage() override;
///////////////////////////////////////////////////////////////////

private:
XR::Ptr<OpenXRVk::Instance> m_instance;
};
}
3 changes: 0 additions & 3 deletions Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,4 @@ namespace OpenXRVk
//! Iterate through the characters while caching the starting pointer to a string
//! and every time ' ' is encountered replace it with '\0' to indicate the end of a string.
AZStd::vector<const char*> ParseExtensionString(char* names);

//! Disable certain extensions because function pointers didn't load correctly.
void FilterAvailableExtensions(GladVulkanContext& context);
}
105 changes: 13 additions & 92 deletions Gems/OpenXRVk/Code/Source/OpenXRVkDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <OpenXRVk/OpenXRVkSpace.h>
#include <OpenXRVk/OpenXRVkUtils.h>
#include <OpenXRVkCommon.h>
#include <Atom/RHI.Reflect/Vulkan/XRVkDescriptors.h>
#include <Atom/RHI.Reflect/VkAllocator.h>
#include <AzCore/Casting/numeric_cast.h>

namespace OpenXRVk
Expand All @@ -26,90 +26,9 @@ namespace OpenXRVk
AZ::RHI::ResultCode Device::InitDeviceInternal(AZ::RHI::XRDeviceDescriptor* deviceDescriptor)
{
AZ::Vulkan::XRDeviceDescriptor* xrDeviceDescriptor = static_cast<AZ::Vulkan::XRDeviceDescriptor*>(deviceDescriptor);
Instance* xrVkInstance = static_cast<Instance*>(GetDescriptor().m_instance.get());
XrVulkanDeviceCreateInfoKHR xrDeviceCreateInfo{ XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR };
xrDeviceCreateInfo.systemId = xrVkInstance->GetXRSystemId();
xrDeviceCreateInfo.pfnGetInstanceProcAddr = xrVkInstance->GetContext().GetInstanceProcAddr;
xrDeviceCreateInfo.vulkanCreateInfo = xrDeviceDescriptor->m_inputData.m_deviceCreateInfo;
xrDeviceCreateInfo.vulkanPhysicalDevice = xrVkInstance->GetActivePhysicalDevice();
xrDeviceCreateInfo.vulkanAllocator = nullptr;

PFN_xrGetVulkanDeviceExtensionsKHR pfnGetVulkanDeviceExtensionsKHR = nullptr;
XrResult result = xrGetInstanceProcAddr(
xrVkInstance->GetXRInstance(), "xrGetVulkanDeviceExtensionsKHR", reinterpret_cast<PFN_xrVoidFunction*>(&pfnGetVulkanDeviceExtensionsKHR));
ASSERT_IF_UNSUCCESSFUL(result);

AZ::u32 deviceExtensionNamesSize = 0;
result = pfnGetVulkanDeviceExtensionsKHR(xrVkInstance->GetXRInstance(), xrDeviceCreateInfo.systemId, 0, &deviceExtensionNamesSize, nullptr);
ASSERT_IF_UNSUCCESSFUL(result);

AZStd::vector<char> deviceExtensionNames(deviceExtensionNamesSize);
result = pfnGetVulkanDeviceExtensionsKHR(
xrVkInstance->GetXRInstance(), xrDeviceCreateInfo.systemId, deviceExtensionNamesSize, &deviceExtensionNamesSize, &deviceExtensionNames[0]);
ASSERT_IF_UNSUCCESSFUL(result);

AZStd::vector<const char*> extensions = ParseExtensionString(&deviceExtensionNames[0]);
for (uint32_t i = 0; i < xrDeviceCreateInfo.vulkanCreateInfo->enabledExtensionCount; ++i)
{
extensions.push_back(xrDeviceCreateInfo.vulkanCreateInfo->ppEnabledExtensionNames[i]);
}

if (GetDescriptor().m_validationMode == AZ::RHI::ValidationMode::Enabled)
{
AZ_Printf("OpenXRVk", "Vulkan device extensions to enable: (%i)\n", extensions.size());
for (const AZStd::string& extension : extensions)
{
AZ_Printf("OpenXRVk", "Name=%s\n", extension.c_str());
}
}

VkPhysicalDeviceFeatures features{};
memcpy(&features, xrDeviceCreateInfo.vulkanCreateInfo->pEnabledFeatures, sizeof(features));

VkPhysicalDeviceFeatures availableFeatures{};
xrVkInstance->GetContext().GetPhysicalDeviceFeatures(xrVkInstance->GetActivePhysicalDevice(), &availableFeatures);
if (availableFeatures.shaderStorageImageMultisample == VK_TRUE)
{
// Setting this quiets down a validation error triggered by the Oculus runtime
features.shaderStorageImageMultisample = VK_TRUE;
}

VkDeviceCreateInfo deviceInfo{ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
memcpy(&deviceInfo, xrDeviceCreateInfo.vulkanCreateInfo, sizeof(deviceInfo));
deviceInfo.pEnabledFeatures = &features;
deviceInfo.enabledExtensionCount = aznumeric_cast<AZ::u32>(extensions.size());
deviceInfo.ppEnabledExtensionNames = extensions.empty() ? nullptr : extensions.data();

//Create VkDevice
auto pfnCreateDevice = (PFN_vkCreateDevice)xrDeviceCreateInfo.pfnGetInstanceProcAddr(xrVkInstance->GetNativeInstance(), "vkCreateDevice");
VkResult vulkanResult = pfnCreateDevice(xrDeviceCreateInfo.vulkanPhysicalDevice, &deviceInfo, xrDeviceCreateInfo.vulkanAllocator, &m_xrVkDevice);
if (vulkanResult != VK_SUCCESS)
{
ShutdownInternal();
AZ_Error("OpenXRVk", false, "Failed to create the device.");
return AZ::RHI::ResultCode::Fail;
}

{
VkPhysicalDevice xrVkPhysicalDevice = xrVkInstance->GetActivePhysicalDevice();
// Now that we have created the device, load the function pointers for it.
const bool functionsLoaded = xrVkInstance->GetFunctionLoader().LoadProcAddresses(
&m_context, xrVkInstance->GetNativeInstance(), xrVkPhysicalDevice, m_xrVkDevice);

FilterAvailableExtensions(m_context);

if (!functionsLoaded)
{
ShutdownInternal();
AZ_Error("OpenXRVk", false, "Failed to initialize function loader for the device.");
return AZ::RHI::ResultCode::Fail;
}
}

//Populate the output data of the descriptor
xrDeviceDescriptor->m_outputData.m_xrVkDevice = m_xrVkDevice;
xrDeviceDescriptor->m_outputData.m_context = m_context;

m_xrVkDevice = xrDeviceDescriptor->m_inputData.m_xrVkDevice;
m_xrVkPhysicalDevice = xrDeviceDescriptor->m_inputData.m_xrVkPhysicalDevice;
m_xrQueueBinding = xrDeviceDescriptor->m_inputData.m_xrQueueBinding;
return AZ::RHI::ResultCode::Success;
}

Expand Down Expand Up @@ -258,9 +177,14 @@ namespace OpenXRVk
return m_xrVkDevice;
}

const GladVulkanContext& Device::GetContext() const
VkPhysicalDevice Device::GetNativePhysicalDevice() const
{
return m_xrVkPhysicalDevice;
}

const AZ::Vulkan::XRDeviceDescriptor::GraphicsBinding& Device::GetGraphicsBinding(AZ::RHI::HardwareQueueClass queueClass) const
{
return m_context;
return m_xrQueueBinding[static_cast<uint32_t>(queueClass)];
}

AZ::RHI::ResultCode Device::GetViewFov(AZ::u32 viewIndex, AZ::RPI::FovData& outFovData) const
Expand Down Expand Up @@ -304,10 +228,7 @@ namespace OpenXRVk
m_projectionLayerViews.clear();
m_views.clear();
m_xrLayers.clear();
if (m_xrVkDevice != VK_NULL_HANDLE)
{
m_context.DestroyDevice(m_xrVkDevice, nullptr);
m_xrVkDevice = VK_NULL_HANDLE;
}
m_xrVkDevice = VK_NULL_HANDLE;
m_xrVkPhysicalDevice = VK_NULL_HANDLE;
}
}
Loading

0 comments on commit 7787b45

Please sign in to comment.