Commit f98a2005 authored by Lachlan Ford's avatar Lachlan Ford Committed by Commit Bot

Updated the OpenXR spec from 1.0.5 to 1.0.11

Updated the OpenXR spec which changes the way extension methods are
queried. I separated the extension support enumeration and method
querying.

Updating the spec retains backwards and forward compatibility with
apps as that is mediated through the loader which is unchanged.
Extension lookup is now dynamic, and after this change, we can
implement AR features on OpenXR (e.g. hand tracking, anchors etc.)

Change-Id: I8a4ae718ca244c91b85e02f9441525a9b1416b58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2406701Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarRafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Lachlan Ford <laford@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#816823}
parent e88ad0e4
...@@ -1244,7 +1244,7 @@ deps = { ...@@ -1244,7 +1244,7 @@ deps = {
Var('chromium_git') + '/openscreen' + '@' + 'a3f46f23c52688cc3c0de927b7fb8a86ff9e8dff', Var('chromium_git') + '/openscreen' + '@' + 'a3f46f23c52688cc3c0de927b7fb8a86ff9e8dff',
'src/third_party/openxr/src': { 'src/third_party/openxr/src': {
'url': Var('chromium_git') + '/external/github.com/KhronosGroup/OpenXR-SDK' + '@' + '9e97b73e7dd2bfc07745489d728f6a36665c648f', 'url': Var('chromium_git') + '/external/github.com/KhronosGroup/OpenXR-SDK' + '@' + 'e3a4e41d61544d8e2eba73f00da99b6818ec472b',
'condition': 'checkout_openxr', 'condition': 'checkout_openxr',
}, },
......
...@@ -383,6 +383,7 @@ config("cfi_linker") { ...@@ -383,6 +383,7 @@ config("cfi_linker") {
# tests with the full browser. # tests with the full browser.
config("delayloads") { config("delayloads") {
ldflags = [ ldflags = [
"/DELAYLOAD:api-ms-win-core-path-l1-1-0.dll",
"/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll",
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
"/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll",
......
...@@ -229,9 +229,10 @@ if (enable_vr) { ...@@ -229,9 +229,10 @@ if (enable_vr) {
"openxr/openxr_api_wrapper.h", "openxr/openxr_api_wrapper.h",
"openxr/openxr_controller.cc", "openxr/openxr_controller.cc",
"openxr/openxr_controller.h", "openxr/openxr_controller.h",
"openxr/openxr_defs.h",
"openxr/openxr_device.cc", "openxr/openxr_device.cc",
"openxr/openxr_device.h", "openxr/openxr_device.h",
"openxr/openxr_extension_helper.cc",
"openxr/openxr_extension_helper.h",
"openxr/openxr_input_helper.cc", "openxr/openxr_input_helper.cc",
"openxr/openxr_input_helper.h", "openxr/openxr_input_helper.h",
"openxr/openxr_interaction_profiles.h", "openxr/openxr_interaction_profiles.h",
...@@ -321,7 +322,8 @@ if (enable_openxr) { ...@@ -321,7 +322,8 @@ if (enable_openxr) {
include_dirs = [ "//third_party/openxr/src/include" ] include_dirs = [ "//third_party/openxr/src/include" ]
sources = [ sources = [
"openxr/openxr_defs.h", "openxr/openxr_extension_helper.cc",
"openxr/openxr_extension_helper.h",
"openxr/openxr_util.cc", "openxr/openxr_util.cc",
"openxr/openxr_util.h", "openxr/openxr_util.h",
"openxr/test/fake_openxr_impl_api.cc", "openxr/test/fake_openxr_impl_api.cc",
......
...@@ -271,7 +271,8 @@ bool OpenXrApiWrapper::UpdateAndGetSessionEnded() { ...@@ -271,7 +271,8 @@ bool OpenXrApiWrapper::UpdateAndGetSessionEnded() {
// objects that may have been created before the failure. // objects that may have been created before the failure.
XrResult OpenXrApiWrapper::InitSession( XrResult OpenXrApiWrapper::InitSession(
const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device, const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device,
std::unique_ptr<OpenXRInputHelper>* input_helper) { std::unique_ptr<OpenXRInputHelper>* input_helper,
const OpenXrExtensionHelper& extension_helper) {
DCHECK(d3d_device.Get()); DCHECK(d3d_device.Get());
DCHECK(IsInitialized()); DCHECK(IsInitialized());
...@@ -286,14 +287,13 @@ XrResult OpenXrApiWrapper::InitSession( ...@@ -286,14 +287,13 @@ XrResult OpenXrApiWrapper::InitSession(
CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_); CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_);
UpdateStageBounds(); UpdateStageBounds();
OpenXrExtensionHelper extension_helper; if (extension_helper.ExtensionEnumeration()->ExtensionSupported(
if (extension_helper.ExtensionSupported(
XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME)) { XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME)) {
RETURN_IF_XR_FAILED( RETURN_IF_XR_FAILED(
CreateSpace(XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT, &unbounded_space_)); CreateSpace(XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT, &unbounded_space_));
} }
RETURN_IF_XR_FAILED(CreateGamepadHelper(input_helper)); RETURN_IF_XR_FAILED(CreateGamepadHelper(input_helper, extension_helper));
// Since the objects in these arrays are used on every frame, // Since the objects in these arrays are used on every frame,
// we don't want to create and destroy these objects every frame, // we don't want to create and destroy these objects every frame,
...@@ -395,12 +395,13 @@ XrResult OpenXrApiWrapper::CreateSpace(XrReferenceSpaceType type, ...@@ -395,12 +395,13 @@ XrResult OpenXrApiWrapper::CreateSpace(XrReferenceSpaceType type,
} }
XrResult OpenXrApiWrapper::CreateGamepadHelper( XrResult OpenXrApiWrapper::CreateGamepadHelper(
std::unique_ptr<OpenXRInputHelper>* input_helper) { std::unique_ptr<OpenXRInputHelper>* input_helper,
const OpenXrExtensionHelper& extension_helper) {
DCHECK(HasSession()); DCHECK(HasSession());
DCHECK(HasSpace(XR_REFERENCE_SPACE_TYPE_LOCAL)); DCHECK(HasSpace(XR_REFERENCE_SPACE_TYPE_LOCAL));
return OpenXRInputHelper::CreateOpenXRInputHelper(instance_, session_, return OpenXRInputHelper::CreateOpenXRInputHelper(
local_space_, input_helper); instance_, extension_helper, session_, local_space_, input_helper);
} }
XrResult OpenXrApiWrapper::BeginSession() { XrResult OpenXrApiWrapper::BeginSession() {
...@@ -620,12 +621,19 @@ void OpenXrApiWrapper::GetHeadFromEyes(XrView* left, XrView* right) const { ...@@ -620,12 +621,19 @@ void OpenXrApiWrapper::GetHeadFromEyes(XrView* left, XrView* right) const {
*right = head_from_eye_views_[1]; *right = head_from_eye_views_[1];
} }
XrResult OpenXrApiWrapper::GetLuid(LUID* luid) const { XrResult OpenXrApiWrapper::GetLuid(
LUID* luid,
const OpenXrExtensionHelper& extension_helper) const {
DCHECK(IsInitialized()); DCHECK(IsInitialized());
if (extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR ==
nullptr)
return XR_ERROR_FUNCTION_UNSUPPORTED;
XrGraphicsRequirementsD3D11KHR graphics_requirements = { XrGraphicsRequirementsD3D11KHR graphics_requirements = {
XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR};
RETURN_IF_XR_FAILED(xrGetD3D11GraphicsRequirementsKHR( RETURN_IF_XR_FAILED(
extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR(
instance_, system_, &graphics_requirements)); instance_, system_, &graphics_requirements));
luid->LowPart = graphics_requirements.adapterLuid.LowPart; luid->LowPart = graphics_requirements.adapterLuid.LowPart;
......
...@@ -47,7 +47,8 @@ class OpenXrApiWrapper { ...@@ -47,7 +47,8 @@ class OpenXrApiWrapper {
bool UpdateAndGetSessionEnded(); bool UpdateAndGetSessionEnded();
XrResult InitSession(const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device, XrResult InitSession(const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device,
std::unique_ptr<OpenXRInputHelper>* input_helper); std::unique_ptr<OpenXRInputHelper>* input_helper,
const OpenXrExtensionHelper& extension_helper);
XrResult BeginFrame(Microsoft::WRL::ComPtr<ID3D11Texture2D>* texture); XrResult BeginFrame(Microsoft::WRL::ComPtr<ID3D11Texture2D>* texture);
XrResult EndFrame(); XrResult EndFrame();
...@@ -60,7 +61,8 @@ class OpenXrApiWrapper { ...@@ -60,7 +61,8 @@ class OpenXrApiWrapper {
gfx::Size GetViewSize() const; gfx::Size GetViewSize() const;
XrTime GetPredictedDisplayTime() const; XrTime GetPredictedDisplayTime() const;
XrResult GetLuid(LUID* luid) const; XrResult GetLuid(LUID* luid,
const OpenXrExtensionHelper& extension_helper) const;
bool GetStageParameters(XrExtent2Df* stage_bounds, bool GetStageParameters(XrExtent2Df* stage_bounds,
gfx::Transform* local_from_stage); gfx::Transform* local_from_stage);
void RegisterInteractionProfileChangeCallback( void RegisterInteractionProfileChangeCallback(
...@@ -89,8 +91,8 @@ class OpenXrApiWrapper { ...@@ -89,8 +91,8 @@ class OpenXrApiWrapper {
const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device); const Microsoft::WRL::ComPtr<ID3D11Device>& d3d_device);
XrResult CreateSwapchain(); XrResult CreateSwapchain();
XrResult CreateSpace(XrReferenceSpaceType type, XrSpace* space); XrResult CreateSpace(XrReferenceSpaceType type, XrSpace* space);
XrResult CreateGamepadHelper( XrResult CreateGamepadHelper(std::unique_ptr<OpenXRInputHelper>* input_helper,
std::unique_ptr<OpenXRInputHelper>* input_helper); const OpenXrExtensionHelper& extension_helper);
XrResult BeginSession(); XrResult BeginSession();
XrResult UpdateProjectionLayers(); XrResult UpdateProjectionLayers();
......
...@@ -143,7 +143,8 @@ XrResult OpenXrController::SuggestBindings( ...@@ -143,7 +143,8 @@ XrResult OpenXrController::SuggestBindings(
const bool extension_required = const bool extension_required =
interaction_profile.required_extension != nullptr; interaction_profile.required_extension != nullptr;
if (extension_required) { if (extension_required) {
const bool extension_enabled = extension_helper.ExtensionSupported( const bool extension_enabled =
extension_helper.ExtensionEnumeration()->ExtensionSupported(
interaction_profile.required_extension); interaction_profile.required_extension);
if (!extension_enabled) { if (!extension_enabled) {
continue; continue;
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_VR_OPENXR_OPENXR_DEFS_H_
#define DEVICE_VR_OPENXR_OPENXR_DEFS_H_
namespace device {
constexpr char kWin32AppcontainerCompatibleExtensionName[] =
"XR_EXT_win32_appcontainer_compatible";
constexpr char kExtSamsungOdysseyControllerExtensionName[] =
"XR_EXT_samsung_odyssey_controller";
constexpr char kExtHPMixedRealityControllerExtensionName[] =
"XR_EXT_hp_mixed_reality_controller";
} // namespace device
#endif // DEVICE_VR_OPENXR_OPENXR_DEFS_H_
...@@ -58,12 +58,13 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() { ...@@ -58,12 +58,13 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo() {
OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics) OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics)
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID), : VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
instance_(openxr_statics->GetXrInstance()), instance_(openxr_statics->GetXrInstance()),
extension_helper_(instance_, openxr_statics->GetExtensionEnumeration()),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo(); mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo();
SetVRDisplayInfo(std::move(display_info)); SetVRDisplayInfo(std::move(display_info));
SetArBlendModeSupported(IsArBlendModeSupported(openxr_statics)); SetArBlendModeSupported(IsArBlendModeSupported(openxr_statics));
#if defined(OS_WIN) #if defined(OS_WIN)
SetLuid(openxr_statics->GetLuid()); SetLuid(openxr_statics->GetLuid(extension_helper_));
#endif #endif
} }
...@@ -86,7 +87,7 @@ void OpenXrDevice::EnsureRenderLoop() { ...@@ -86,7 +87,7 @@ void OpenXrDevice::EnsureRenderLoop() {
auto on_info_changed = base::BindRepeating(&OpenXrDevice::SetVRDisplayInfo, auto on_info_changed = base::BindRepeating(&OpenXrDevice::SetVRDisplayInfo,
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
render_loop_ = std::make_unique<OpenXrRenderLoop>( render_loop_ = std::make_unique<OpenXrRenderLoop>(
std::move(on_info_changed), instance_); std::move(on_info_changed), instance_, extension_helper_);
} }
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "device/vr/openxr/openxr_util.h"
#include "device/vr/public/mojom/vr_service.mojom.h" #include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h" #include "device/vr/vr_device_base.h"
#include "device/vr/vr_export.h" #include "device/vr/vr_export.h"
...@@ -53,6 +54,7 @@ class DEVICE_VR_EXPORT OpenXrDevice ...@@ -53,6 +54,7 @@ class DEVICE_VR_EXPORT OpenXrDevice
bool IsArBlendModeSupported(OpenXrStatics* openxr_statics); bool IsArBlendModeSupported(OpenXrStatics* openxr_statics);
XrInstance instance_; XrInstance instance_;
OpenXrExtensionHelper extension_helper_;
std::unique_ptr<OpenXrRenderLoop> render_loop_; std::unique_ptr<OpenXrRenderLoop> render_loop_;
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{ mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/vr/openxr/openxr_extension_helper.h"
namespace device {
OpenXrExtensionEnumeration::OpenXrExtensionEnumeration() {
uint32_t extension_count;
if (XR_SUCCEEDED(xrEnumerateInstanceExtensionProperties(
nullptr, 0, &extension_count, nullptr))) {
extension_properties_.resize(extension_count,
{XR_TYPE_EXTENSION_PROPERTIES});
xrEnumerateInstanceExtensionProperties(nullptr, extension_count,
&extension_count,
extension_properties_.data());
}
}
OpenXrExtensionEnumeration::~OpenXrExtensionEnumeration() = default;
bool OpenXrExtensionEnumeration::ExtensionSupported(
const char* extension_name) const {
return std::find_if(
extension_properties_.begin(), extension_properties_.end(),
[&extension_name](const XrExtensionProperties& properties) {
return strcmp(properties.extensionName, extension_name) == 0;
}) != extension_properties_.end();
}
OpenXrExtensionHelper::~OpenXrExtensionHelper() = default;
OpenXrExtensionHelper::OpenXrExtensionHelper(
XrInstance instance,
const OpenXrExtensionEnumeration* const extension_enumeration)
: extension_enumeration_(extension_enumeration) {
// Failure results in a nullptr
(void)xrGetInstanceProcAddr(
instance, "xrGetD3D11GraphicsRequirementsKHR",
reinterpret_cast<PFN_xrVoidFunction*>(
const_cast<PFN_xrGetD3D11GraphicsRequirementsKHR*>(
&extension_methods_.xrGetD3D11GraphicsRequirementsKHR)));
}
} // namespace device
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_VR_OPENXR_OPENXR_EXTENSION_HELPER_H_
#define DEVICE_VR_OPENXR_OPENXR_EXTENSION_HELPER_H_
#include <d3d11.h>
#include <vector>
#include "base/logging.h"
#include "third_party/openxr/src/include/openxr/openxr.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h"
namespace device {
struct OpenXrExtensionMethods {
PFN_xrGetD3D11GraphicsRequirementsKHR xrGetD3D11GraphicsRequirementsKHR{
nullptr};
};
class OpenXrExtensionEnumeration {
public:
OpenXrExtensionEnumeration();
~OpenXrExtensionEnumeration();
bool ExtensionSupported(const char* extension_name) const;
private:
std::vector<XrExtensionProperties> extension_properties_;
};
class OpenXrExtensionHelper {
public:
OpenXrExtensionHelper(
XrInstance instance,
const OpenXrExtensionEnumeration* const extension_enumeration);
~OpenXrExtensionHelper();
const OpenXrExtensionEnumeration* ExtensionEnumeration() const {
return extension_enumeration_;
}
const OpenXrExtensionMethods& ExtensionMethods() const {
return extension_methods_;
}
private:
const OpenXrExtensionMethods extension_methods_;
const OpenXrExtensionEnumeration* const extension_enumeration_;
};
} // namespace device
#endif // DEVICE_VR_OPENXR_OPENXR_EXTENSION_HELPER_H_
...@@ -96,13 +96,14 @@ base::Optional<Gamepad> GetXrStandardGamepad( ...@@ -96,13 +96,14 @@ base::Optional<Gamepad> GetXrStandardGamepad(
XrResult OpenXRInputHelper::CreateOpenXRInputHelper( XrResult OpenXRInputHelper::CreateOpenXRInputHelper(
XrInstance instance, XrInstance instance,
const OpenXrExtensionHelper& extension_helper,
XrSession session, XrSession session,
XrSpace local_space, XrSpace local_space,
std::unique_ptr<OpenXRInputHelper>* helper) { std::unique_ptr<OpenXRInputHelper>* helper) {
std::unique_ptr<OpenXRInputHelper> new_helper = std::unique_ptr<OpenXRInputHelper> new_helper =
std::make_unique<OpenXRInputHelper>(session, local_space); std::make_unique<OpenXRInputHelper>(session, local_space);
RETURN_IF_XR_FAILED(new_helper->Initialize(instance)); RETURN_IF_XR_FAILED(new_helper->Initialize(instance, extension_helper));
*helper = std::move(new_helper); *helper = std::move(new_helper);
return XR_SUCCESS; return XR_SUCCESS;
} }
...@@ -114,7 +115,9 @@ OpenXRInputHelper::OpenXRInputHelper(XrSession session, XrSpace local_space) ...@@ -114,7 +115,9 @@ OpenXRInputHelper::OpenXRInputHelper(XrSession session, XrSpace local_space)
OpenXRInputHelper::~OpenXRInputHelper() = default; OpenXRInputHelper::~OpenXRInputHelper() = default;
XrResult OpenXRInputHelper::Initialize(XrInstance instance) { XrResult OpenXRInputHelper::Initialize(
XrInstance instance,
const OpenXrExtensionHelper& extension_helper) {
RETURN_IF_XR_FAILED(path_helper_->Initialize(instance)); RETURN_IF_XR_FAILED(path_helper_->Initialize(instance));
// This map is used to store bindings for different kinds of interaction // This map is used to store bindings for different kinds of interaction
...@@ -122,7 +125,6 @@ XrResult OpenXRInputHelper::Initialize(XrInstance instance) { ...@@ -122,7 +125,6 @@ XrResult OpenXRInputHelper::Initialize(XrInstance instance) {
// on availability. // on availability.
std::map<XrPath, std::vector<XrActionSuggestedBinding>> bindings; std::map<XrPath, std::vector<XrActionSuggestedBinding>> bindings;
OpenXrExtensionHelper extension_helper;
for (size_t i = 0; i < controller_states_.size(); i++) { for (size_t i = 0; i < controller_states_.size(); i++) {
RETURN_IF_XR_FAILED(controller_states_[i].controller.Initialize( RETURN_IF_XR_FAILED(controller_states_[i].controller.Initialize(
static_cast<OpenXrHandednessType>(i), instance, session_, static_cast<OpenXrHandednessType>(i), instance, session_,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "device/vr/openxr/openxr_controller.h" #include "device/vr/openxr/openxr_controller.h"
#include "device/vr/openxr/openxr_interaction_profiles.h" #include "device/vr/openxr/openxr_interaction_profiles.h"
#include "device/vr/openxr/openxr_util.h"
namespace device { namespace device {
...@@ -20,6 +21,7 @@ class OpenXRInputHelper { ...@@ -20,6 +21,7 @@ class OpenXRInputHelper {
public: public:
static XrResult CreateOpenXRInputHelper( static XrResult CreateOpenXRInputHelper(
XrInstance instance, XrInstance instance,
const OpenXrExtensionHelper& extension_helper,
XrSession session, XrSession session,
XrSpace local_space, XrSpace local_space,
std::unique_ptr<OpenXRInputHelper>* helper); std::unique_ptr<OpenXRInputHelper>* helper);
...@@ -38,7 +40,8 @@ class OpenXRInputHelper { ...@@ -38,7 +40,8 @@ class OpenXRInputHelper {
private: private:
base::Optional<Gamepad> GetWebXRGamepad(const OpenXrController& controller); base::Optional<Gamepad> GetWebXRGamepad(const OpenXrController& controller);
XrResult Initialize(XrInstance instance); XrResult Initialize(XrInstance instance,
const OpenXrExtensionHelper& extension_helper);
XrResult SyncActions(XrTime predicted_display_time); XrResult SyncActions(XrTime predicted_display_time);
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "device/gamepad/public/cpp/gamepad.h" #include "device/gamepad/public/cpp/gamepad.h"
#include "device/vr/openxr/openxr_defs.h"
#include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr.h"
namespace device { namespace device {
...@@ -370,7 +369,7 @@ constexpr OpenXrControllerInteractionProfile kHTCViveInteractionProfile = { ...@@ -370,7 +369,7 @@ constexpr OpenXrControllerInteractionProfile kHTCViveInteractionProfile = {
constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile = constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile =
{OpenXrInteractionProfileType::kSamsungOdyssey, {OpenXrInteractionProfileType::kSamsungOdyssey,
"/interaction_profiles/samsung/odyssey_controller", "/interaction_profiles/samsung/odyssey_controller",
kExtSamsungOdysseyControllerExtensionName, XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME,
GamepadMapping::kXrStandard, GamepadMapping::kXrStandard,
kSamsungOdysseyInputProfiles, kSamsungOdysseyInputProfiles,
base::size(kSamsungOdysseyInputProfiles), base::size(kSamsungOdysseyInputProfiles),
...@@ -384,7 +383,7 @@ constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile = ...@@ -384,7 +383,7 @@ constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile =
constexpr OpenXrControllerInteractionProfile kHPReverbG2InteractionProfile = { constexpr OpenXrControllerInteractionProfile kHPReverbG2InteractionProfile = {
OpenXrInteractionProfileType::kHPReverbG2, OpenXrInteractionProfileType::kHPReverbG2,
"/interaction_profiles/hp/mixed_reality_controller", "/interaction_profiles/hp/mixed_reality_controller",
kExtHPMixedRealityControllerExtensionName, XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME,
GamepadMapping::kXrStandard, GamepadMapping::kXrStandard,
kHPReverbG2InputProfiles, kHPReverbG2InputProfiles,
base::size(kHPReverbG2InputProfiles), base::size(kHPReverbG2InputProfiles),
......
...@@ -17,9 +17,11 @@ namespace device { ...@@ -17,9 +17,11 @@ namespace device {
OpenXrRenderLoop::OpenXrRenderLoop( OpenXrRenderLoop::OpenXrRenderLoop(
base::RepeatingCallback<void(mojom::VRDisplayInfoPtr)> base::RepeatingCallback<void(mojom::VRDisplayInfoPtr)>
on_display_info_changed, on_display_info_changed,
XrInstance instance) XrInstance instance,
const OpenXrExtensionHelper& extension_helper)
: XRCompositorCommon(), : XRCompositorCommon(),
instance_(instance), instance_(instance),
extension_helper_(extension_helper),
on_display_info_changed_(std::move(on_display_info_changed)) { on_display_info_changed_(std::move(on_display_info_changed)) {
DCHECK(instance_ != XR_NULL_HANDLE); DCHECK(instance_ != XR_NULL_HANDLE);
} }
...@@ -91,11 +93,11 @@ bool OpenXrRenderLoop::StartRuntime() { ...@@ -91,11 +93,11 @@ bool OpenXrRenderLoop::StartRuntime() {
texture_helper_.SetUseBGRA(true); texture_helper_.SetUseBGRA(true);
LUID luid; LUID luid;
if (XR_FAILED(openxr->GetLuid(&luid)) || if (XR_FAILED(openxr->GetLuid(&luid, extension_helper_)) ||
!texture_helper_.SetAdapterLUID(luid) || !texture_helper_.SetAdapterLUID(luid) ||
!texture_helper_.EnsureInitialized() || !texture_helper_.EnsureInitialized() ||
XR_FAILED( XR_FAILED(openxr->InitSession(texture_helper_.GetDevice(), &input_helper_,
openxr->InitSession(texture_helper_.GetDevice(), &input_helper_))) { extension_helper_))) {
texture_helper_.Reset(); texture_helper_.Reset();
return false; return false;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "device/vr/openxr/openxr_util.h"
#include "device/vr/windows/compositor_base.h" #include "device/vr/windows/compositor_base.h"
#include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr.h"
...@@ -24,7 +25,8 @@ class OpenXrRenderLoop : public XRCompositorCommon { ...@@ -24,7 +25,8 @@ class OpenXrRenderLoop : public XRCompositorCommon {
public: public:
OpenXrRenderLoop(base::RepeatingCallback<void(mojom::VRDisplayInfoPtr)> OpenXrRenderLoop(base::RepeatingCallback<void(mojom::VRDisplayInfoPtr)>
on_display_info_changed, on_display_info_changed,
XrInstance instance); XrInstance instance,
const OpenXrExtensionHelper& extension_helper_);
~OpenXrRenderLoop() override; ~OpenXrRenderLoop() override;
private: private:
...@@ -53,6 +55,7 @@ class OpenXrRenderLoop : public XRCompositorCommon { ...@@ -53,6 +55,7 @@ class OpenXrRenderLoop : public XRCompositorCommon {
// Owned by OpenXrStatics // Owned by OpenXrStatics
XrInstance instance_; XrInstance instance_;
const OpenXrExtensionHelper& extension_helper_;
std::unique_ptr<OpenXrApiWrapper> openxr_; std::unique_ptr<OpenXrApiWrapper> openxr_;
std::unique_ptr<OpenXRInputHelper> input_helper_; std::unique_ptr<OpenXRInputHelper> input_helper_;
......
...@@ -17,7 +17,8 @@ OpenXrStatics::~OpenXrStatics() { ...@@ -17,7 +17,8 @@ OpenXrStatics::~OpenXrStatics() {
} }
XrInstance OpenXrStatics::GetXrInstance() { XrInstance OpenXrStatics::GetXrInstance() {
if (instance_ == XR_NULL_HANDLE && XR_FAILED(CreateInstance(&instance_))) { if (instance_ == XR_NULL_HANDLE &&
XR_FAILED(CreateInstance(&instance_, extension_enumeration_))) {
return XR_NULL_HANDLE; return XR_NULL_HANDLE;
} }
return instance_; return instance_;
...@@ -39,7 +40,7 @@ bool OpenXrStatics::IsApiAvailable() { ...@@ -39,7 +40,7 @@ bool OpenXrStatics::IsApiAvailable() {
#if defined(OS_WIN) #if defined(OS_WIN)
// Returns the LUID of the adapter the OpenXR runtime is on. Returns {0, 0} if // Returns the LUID of the adapter the OpenXR runtime is on. Returns {0, 0} if
// the LUID could not be determined. // the LUID could not be determined.
LUID OpenXrStatics::GetLuid() { LUID OpenXrStatics::GetLuid(const OpenXrExtensionHelper& extension_helper) {
if (GetXrInstance() == XR_NULL_HANDLE) if (GetXrInstance() == XR_NULL_HANDLE)
return {0, 0}; return {0, 0};
...@@ -47,10 +48,15 @@ LUID OpenXrStatics::GetLuid() { ...@@ -47,10 +48,15 @@ LUID OpenXrStatics::GetLuid() {
if (XR_FAILED(GetSystem(instance_, &system))) if (XR_FAILED(GetSystem(instance_, &system)))
return {0, 0}; return {0, 0};
if (extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR ==
nullptr)
return {0, 0};
XrGraphicsRequirementsD3D11KHR graphics_requirements = { XrGraphicsRequirementsD3D11KHR graphics_requirements = {
XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR};
if (XR_FAILED(xrGetD3D11GraphicsRequirementsKHR(instance_, system, if (XR_FAILED(
&graphics_requirements))) extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR(
instance_, system, &graphics_requirements)))
return {0, 0}; return {0, 0};
return graphics_requirements.adapterLuid; return graphics_requirements.adapterLuid;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <memory> #include <memory>
#include "build/build_config.h" #include "build/build_config.h"
#include "device/vr/openxr/openxr_util.h"
#include "device/vr/vr_export.h" #include "device/vr/vr_export.h"
#include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h" #include "third_party/openxr/src/include/openxr/openxr_platform.h"
...@@ -22,17 +23,22 @@ class DEVICE_VR_EXPORT OpenXrStatics { ...@@ -22,17 +23,22 @@ class DEVICE_VR_EXPORT OpenXrStatics {
OpenXrStatics(); OpenXrStatics();
~OpenXrStatics(); ~OpenXrStatics();
const OpenXrExtensionEnumeration* GetExtensionEnumeration() const {
return &extension_enumeration_;
}
XrInstance GetXrInstance(); XrInstance GetXrInstance();
bool IsHardwareAvailable(); bool IsHardwareAvailable();
bool IsApiAvailable(); bool IsApiAvailable();
#if defined(OS_WIN) #if defined(OS_WIN)
LUID GetLuid(); LUID GetLuid(const OpenXrExtensionHelper& extension_helper);
#endif #endif
private: private:
XrInstance instance_; XrInstance instance_;
OpenXrExtensionEnumeration extension_enumeration_;
}; };
} // namespace device } // namespace device
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "device/vr/openxr/openxr_util.h" #include "device/vr/openxr/openxr_util.h"
#include "device/vr/openxr/openxr_defs.h"
#include <d3d11.h>
#include <string> #include <string>
#include <vector>
#include "base/check_op.h" #include "base/check_op.h"
#include "base/stl_util.h" #include "base/stl_util.h"
...@@ -15,7 +12,6 @@ ...@@ -15,7 +12,6 @@
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h"
namespace device { namespace device {
...@@ -56,30 +52,9 @@ bool IsRunningInWin32AppContainer() { ...@@ -56,30 +52,9 @@ bool IsRunningInWin32AppContainer() {
} }
#endif #endif
OpenXrExtensionHelper::OpenXrExtensionHelper() { XrResult CreateInstance(
uint32_t extension_count; XrInstance* instance,
if (XR_SUCCEEDED(xrEnumerateInstanceExtensionProperties( const OpenXrExtensionEnumeration& extension_enumeration) {
nullptr, 0, &extension_count, nullptr))) {
extension_properties_.resize(extension_count,
{XR_TYPE_EXTENSION_PROPERTIES});
xrEnumerateInstanceExtensionProperties(nullptr, extension_count,
&extension_count,
extension_properties_.data());
}
}
OpenXrExtensionHelper::~OpenXrExtensionHelper() = default;
bool OpenXrExtensionHelper::ExtensionSupported(
const char* extension_name) const {
return std::find_if(
extension_properties_.begin(), extension_properties_.end(),
[&extension_name](const XrExtensionProperties& properties) {
return strcmp(properties.extensionName, extension_name) == 0;
}) != extension_properties_.end();
}
XrResult CreateInstance(XrInstance* instance) {
XrInstanceCreateInfo instance_create_info = {XR_TYPE_INSTANCE_CREATE_INFO}; XrInstanceCreateInfo instance_create_info = {XR_TYPE_INSTANCE_CREATE_INFO};
std::string application_name = version_info::GetProductName() + " " + std::string application_name = version_info::GetProductName() + " " +
...@@ -121,15 +96,14 @@ XrResult CreateInstance(XrInstance* instance) { ...@@ -121,15 +96,14 @@ XrResult CreateInstance(XrInstance* instance) {
// Add the win32 app container compatible extension to our list of // Add the win32 app container compatible extension to our list of
// extensions. If this runtime does not support execution in an app // extensions. If this runtime does not support execution in an app
// container environment, one of xrCreateInstance or xrGetSystem will fail. // container environment, one of xrCreateInstance or xrGetSystem will fail.
extensions.push_back(kWin32AppcontainerCompatibleExtensionName); extensions.push_back(XR_EXT_WIN32_APPCONTAINER_COMPATIBLE_EXTENSION_NAME);
} }
// XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME, is required for optional // XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME, is required for optional
// functionality (unbounded reference spaces) and thus only requested if it is // functionality (unbounded reference spaces) and thus only requested if it is
// available. // available.
OpenXrExtensionHelper extension_helper;
const bool unboundedSpaceExtensionSupported = const bool unboundedSpaceExtensionSupported =
extension_helper.ExtensionSupported( extension_enumeration.ExtensionSupported(
XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME); XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME);
if (unboundedSpaceExtensionSupported) { if (unboundedSpaceExtensionSupported) {
extensions.push_back(XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME); extensions.push_back(XR_MSFT_UNBOUNDED_REFERENCE_SPACE_EXTENSION_NAME);
...@@ -138,17 +112,17 @@ XrResult CreateInstance(XrInstance* instance) { ...@@ -138,17 +112,17 @@ XrResult CreateInstance(XrInstance* instance) {
// Input extensions. These enable interaction profiles not defined in the core // Input extensions. These enable interaction profiles not defined in the core
// spec // spec
const bool samsungInteractionProfileExtensionSupported = const bool samsungInteractionProfileExtensionSupported =
extension_helper.ExtensionSupported( extension_enumeration.ExtensionSupported(
kExtSamsungOdysseyControllerExtensionName); XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME);
if (samsungInteractionProfileExtensionSupported) { if (samsungInteractionProfileExtensionSupported) {
extensions.push_back(kExtSamsungOdysseyControllerExtensionName); extensions.push_back(XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME);
} }
const bool hpControllerExtensionSupported = const bool hpControllerExtensionSupported =
extension_helper.ExtensionSupported( extension_enumeration.ExtensionSupported(
kExtHPMixedRealityControllerExtensionName); XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
if (hpControllerExtensionSupported) { if (hpControllerExtensionSupported) {
extensions.push_back(kExtHPMixedRealityControllerExtensionName); extensions.push_back(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME);
} }
instance_create_info.enabledExtensionCount = instance_create_info.enabledExtensionCount =
......
...@@ -5,23 +5,15 @@ ...@@ -5,23 +5,15 @@
#ifndef DEVICE_VR_OPENXR_OPENXR_UTIL_H_ #ifndef DEVICE_VR_OPENXR_OPENXR_UTIL_H_
#define DEVICE_VR_OPENXR_OPENXR_UTIL_H_ #define DEVICE_VR_OPENXR_OPENXR_UTIL_H_
#include <d3d11.h>
#include <vector> #include <vector>
#include "base/logging.h" #include "base/logging.h"
#include "device/vr/openxr/openxr_extension_helper.h"
#include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h"
namespace device { namespace device {
class OpenXrExtensionHelper {
public:
OpenXrExtensionHelper();
~OpenXrExtensionHelper();
bool ExtensionSupported(const char* extension_name) const;
private:
std::vector<XrExtensionProperties> extension_properties_;
};
// These macros aren't common in Chromium and generally discouraged, so define // These macros aren't common in Chromium and generally discouraged, so define
// all OpenXR helper macros here so they can be kept track of. This file // all OpenXR helper macros here so they can be kept track of. This file
// should not be included outside of device/vr/openxr. // should not be included outside of device/vr/openxr.
...@@ -58,7 +50,9 @@ XrPosef PoseIdentity(); ...@@ -58,7 +50,9 @@ XrPosef PoseIdentity();
XrResult GetSystem(XrInstance instance, XrSystemId* system); XrResult GetSystem(XrInstance instance, XrSystemId* system);
XrResult CreateInstance(XrInstance* instance); XrResult CreateInstance(
XrInstance* instance,
const OpenXrExtensionEnumeration& extension_enumeration);
std::vector<XrEnvironmentBlendMode> GetSupportedBlendModes(XrInstance instance, std::vector<XrEnvironmentBlendMode> GetSupportedBlendModes(XrInstance instance,
XrSystemId system); XrSystemId system);
......
...@@ -16,6 +16,8 @@ namespace { ...@@ -16,6 +16,8 @@ namespace {
OpenXrTestHelper g_test_helper; OpenXrTestHelper g_test_helper;
} // namespace } // namespace
// Extension methods
// Mock implementations of openxr runtime.dll APIs. // Mock implementations of openxr runtime.dll APIs.
// Please add new APIs in alphabetical order. // Please add new APIs in alphabetical order.
...@@ -903,3 +905,100 @@ XrResult xrWaitSwapchainImage(XrSwapchain swapchain, ...@@ -903,3 +905,100 @@ XrResult xrWaitSwapchainImage(XrSwapchain swapchain,
return XR_SUCCESS; return XR_SUCCESS;
} }
// Getter for extension methods. Casts the correct function dynamically based on
// the method name provided.
// Please add new OpenXR APIs below in alphabetical order.
XrResult XRAPI_PTR xrGetInstanceProcAddr(XrInstance instance,
const char* name,
PFN_xrVoidFunction* function) {
if (strcmp(name, "xrAcquireSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrAcquireSwapchainImage);
} else if (strcmp(name, "xrAttachSessionActionSets") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrAttachSessionActionSets);
} else if (strcmp(name, "xrBeginFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrBeginFrame);
} else if (strcmp(name, "xrBeginSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrBeginSession);
} else if (strcmp(name, "xrCreateAction") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateAction);
} else if (strcmp(name, "xrCreateActionSet") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateActionSet);
} else if (strcmp(name, "xrCreateActionSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateActionSpace);
} else if (strcmp(name, "xrCreateInstance") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateInstance);
} else if (strcmp(name, "xrCreateReferenceSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateReferenceSpace);
} else if (strcmp(name, "xrCreateSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateSession);
} else if (strcmp(name, "xrCreateSwapchain") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateSwapchain);
} else if (strcmp(name, "xrDestroyActionSet") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroyActionSet);
} else if (strcmp(name, "xrDestroyInstance") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroyInstance);
} else if (strcmp(name, "xrDestroySpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroySpace);
} else if (strcmp(name, "xrEndFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrEndFrame);
} else if (strcmp(name, "xrEndSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrEndSession);
} else if (strcmp(name, "xrEnumerateEnvironmentBlendModes") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateEnvironmentBlendModes);
} else if (strcmp(name, "xrEnumerateInstanceExtensionProperties") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(
xrEnumerateInstanceExtensionProperties);
} else if (strcmp(name, "xrEnumerateSwapchainImages") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateSwapchainImages);
} else if (strcmp(name, "xrEnumerateViewConfigurationViews") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateViewConfigurationViews);
} else if (strcmp(name, "xrGetD3D11GraphicsRequirementsKHR") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetD3D11GraphicsRequirementsKHR);
} else if (strcmp(name, "xrGetActionStateFloat") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateFloat);
} else if (strcmp(name, "xrGetActionStateBoolean") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateBoolean);
} else if (strcmp(name, "xrGetActionStateVector2f") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateVector2f);
} else if (strcmp(name, "xrGetActionStatePose") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStatePose);
} else if (strcmp(name, "xrGetCurrentInteractionProfile") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetCurrentInteractionProfile);
} else if (strcmp(name, "xrGetReferenceSpaceBoundsRect") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetReferenceSpaceBoundsRect);
} else if (strcmp(name, "xrGetSystem") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetSystem);
} else if (strcmp(name, "xrLocateSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrLocateSpace);
} else if (strcmp(name, "xrLocateViews") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrLocateViews);
} else if (strcmp(name, "xrPollEvent") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrPollEvent);
} else if (strcmp(name, "xrReleaseSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrReleaseSwapchainImage);
} else if (strcmp(name, "xrSuggestInteractionProfileBindings") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(
xrSuggestInteractionProfileBindings);
} else if (strcmp(name, "xrStringToPath") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrStringToPath);
} else if (strcmp(name, "xrPathToString") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrPathToString);
} else if (strcmp(name, "xrSyncActions") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrSyncActions);
} else if (strcmp(name, "xrWaitFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrWaitFrame);
} else if (strcmp(name, "xrWaitSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrWaitSwapchainImage);
} else {
return XR_ERROR_FUNCTION_UNSUPPORTED;
}
return XR_SUCCESS;
}
\ No newline at end of file
...@@ -17,110 +17,19 @@ ...@@ -17,110 +17,19 @@
// only be used to call the fake OpenXR APIs defined in // only be used to call the fake OpenXR APIs defined in
// fake_openxr_impl_api.cc. // fake_openxr_impl_api.cc.
// Please add new OpenXR APIs below in alphabetical order. XrResult XRAPI_PTR xrGetInstanceProcAddr(XrInstance instance,
XrResult XRAPI_PTR GetInstanceProcAddress(XrInstance instance,
const char* name, const char* name,
PFN_xrVoidFunction* function) { PFN_xrVoidFunction* function);
if (strcmp(name, "xrAcquireSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrAcquireSwapchainImage);
} else if (strcmp(name, "xrAttachSessionActionSets") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrAttachSessionActionSets);
} else if (strcmp(name, "xrBeginFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrBeginFrame);
} else if (strcmp(name, "xrBeginSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrBeginSession);
} else if (strcmp(name, "xrCreateAction") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateAction);
} else if (strcmp(name, "xrCreateActionSet") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateActionSet);
} else if (strcmp(name, "xrCreateActionSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateActionSpace);
} else if (strcmp(name, "xrCreateInstance") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateInstance);
} else if (strcmp(name, "xrCreateReferenceSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateReferenceSpace);
} else if (strcmp(name, "xrCreateSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateSession);
} else if (strcmp(name, "xrCreateSwapchain") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrCreateSwapchain);
} else if (strcmp(name, "xrDestroyActionSet") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroyActionSet);
} else if (strcmp(name, "xrDestroyInstance") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroyInstance);
} else if (strcmp(name, "xrDestroySpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrDestroySpace);
} else if (strcmp(name, "xrEndFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrEndFrame);
} else if (strcmp(name, "xrEndSession") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrEndSession);
} else if (strcmp(name, "xrEnumerateEnvironmentBlendModes") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateEnvironmentBlendModes);
} else if (strcmp(name, "xrEnumerateInstanceExtensionProperties") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(
xrEnumerateInstanceExtensionProperties);
} else if (strcmp(name, "xrEnumerateSwapchainImages") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateSwapchainImages);
} else if (strcmp(name, "xrEnumerateViewConfigurationViews") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrEnumerateViewConfigurationViews);
} else if (strcmp(name, "xrGetD3D11GraphicsRequirementsKHR") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetD3D11GraphicsRequirementsKHR);
} else if (strcmp(name, "xrGetActionStateFloat") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateFloat);
} else if (strcmp(name, "xrGetActionStateBoolean") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateBoolean);
} else if (strcmp(name, "xrGetActionStateVector2f") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStateVector2f);
} else if (strcmp(name, "xrGetActionStatePose") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetActionStatePose);
} else if (strcmp(name, "xrGetCurrentInteractionProfile") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetCurrentInteractionProfile);
} else if (strcmp(name, "xrGetReferenceSpaceBoundsRect") == 0) {
*function =
reinterpret_cast<PFN_xrVoidFunction>(xrGetReferenceSpaceBoundsRect);
} else if (strcmp(name, "xrGetSystem") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrGetSystem);
} else if (strcmp(name, "xrLocateSpace") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrLocateSpace);
} else if (strcmp(name, "xrLocateViews") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrLocateViews);
} else if (strcmp(name, "xrPollEvent") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrPollEvent);
} else if (strcmp(name, "xrReleaseSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrReleaseSwapchainImage);
} else if (strcmp(name, "xrSuggestInteractionProfileBindings") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(
xrSuggestInteractionProfileBindings);
} else if (strcmp(name, "xrStringToPath") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrStringToPath);
} else if (strcmp(name, "xrPathToString") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrPathToString);
} else if (strcmp(name, "xrSyncActions") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrSyncActions);
} else if (strcmp(name, "xrWaitFrame") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrWaitFrame);
} else if (strcmp(name, "xrWaitSwapchainImage") == 0) {
*function = reinterpret_cast<PFN_xrVoidFunction>(xrWaitSwapchainImage);
} else {
return XR_ERROR_FUNCTION_UNSUPPORTED;
}
return XR_SUCCESS;
}
// The single exported function in fake OpenXR Runtime DLL which the OpenXR // The single exported function in fake OpenXR Runtime DLL which the OpenXR
// loader calls for negotiation. GetInstanceProcAddress is returned to the // loader calls for negotiation. xrGetInstanceProcAddr is returned to the
// loader, which is then used by the loader to call OpenXR APIs. // loader, which is then used by the loader to call OpenXR APIs.
XrResult __stdcall xrNegotiateLoaderRuntimeInterface( XrResult __stdcall xrNegotiateLoaderRuntimeInterface(
const XrNegotiateLoaderInfo* loaderInfo, const XrNegotiateLoaderInfo* loaderInfo,
XrNegotiateRuntimeRequest* runtimeRequest) { XrNegotiateRuntimeRequest* runtimeRequest) {
runtimeRequest->runtimeInterfaceVersion = 1; runtimeRequest->runtimeInterfaceVersion = 1;
runtimeRequest->runtimeApiVersion = XR_MAKE_VERSION(1, 0, 1); runtimeRequest->runtimeApiVersion = XR_CURRENT_API_VERSION;
runtimeRequest->getInstanceProcAddr = GetInstanceProcAddress; runtimeRequest->getInstanceProcAddr = xrGetInstanceProcAddr;
return XR_SUCCESS; return XR_SUCCESS;
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "device/vr/openxr/openxr_defs.h"
#include "device/vr/test/test_hook.h" #include "device/vr/test/test_hook.h"
#include "third_party/openxr/src/include/openxr/openxr.h" #include "third_party/openxr/src/include/openxr/openxr.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h" #include "third_party/openxr/src/include/openxr/openxr_platform.h"
...@@ -130,7 +129,7 @@ class OpenXrTestHelper : public device::ServiceTestHook { ...@@ -130,7 +129,7 @@ class OpenXrTestHelper : public device::ServiceTestHook {
// Properties of the mock OpenXR runtime that do not change are created // Properties of the mock OpenXR runtime that do not change are created
static constexpr const char* const kExtensions[] = { static constexpr const char* const kExtensions[] = {
XR_KHR_D3D11_ENABLE_EXTENSION_NAME, XR_KHR_D3D11_ENABLE_EXTENSION_NAME,
device::kWin32AppcontainerCompatibleExtensionName}; XR_EXT_WIN32_APPCONTAINER_COMPATIBLE_EXTENSION_NAME};
static constexpr uint32_t kDimension = 128; static constexpr uint32_t kDimension = 128;
static constexpr uint32_t kSwapCount = 1; static constexpr uint32_t kSwapCount = 1;
static constexpr uint32_t kMinSwapchainBuffering = 3; static constexpr uint32_t kMinSwapchainBuffering = 3;
......
...@@ -24,7 +24,6 @@ if (enable_openxr) { ...@@ -24,7 +24,6 @@ if (enable_openxr) {
"src/src/common/extra_algorithms.h", "src/src/common/extra_algorithms.h",
"src/src/common/filesystem_utils.cpp", "src/src/common/filesystem_utils.cpp",
"src/src/common/filesystem_utils.hpp", "src/src/common/filesystem_utils.hpp",
"src/src/common/hex_and_handles.cpp",
"src/src/common/hex_and_handles.h", "src/src/common/hex_and_handles.h",
"src/src/common/loader_interfaces.h", "src/src/common/loader_interfaces.h",
"src/src/common/object_info.cpp", "src/src/common/object_info.cpp",
...@@ -59,6 +58,10 @@ if (enable_openxr) { ...@@ -59,6 +58,10 @@ if (enable_openxr) {
"src/src", "src/src",
] ]
if (is_win) {
libs = [ "Pathcch.lib" ]
}
deps = [ "//third_party/jsoncpp" ] deps = [ "//third_party/jsoncpp" ]
public_configs = [ ":config" ] public_configs = [ ":config" ]
...@@ -73,6 +76,7 @@ if (enable_openxr) { ...@@ -73,6 +76,7 @@ if (enable_openxr) {
"-Wno-microsoft-cast", "-Wno-microsoft-cast",
"-Wno-microsoft-include", "-Wno-microsoft-include",
"-Wno-unused-function", "-Wno-unused-function",
"-Wno-extra-semi",
] ]
} }
......
Name: OpenXR SDK Name: OpenXR SDK
Short Name: OpenXR Short Name: OpenXR
URL: https://github.com/KhronosGroup/OpenXR-SDK URL: https://github.com/KhronosGroup/OpenXR-SDK
Version: 1.0.5sd Version: 1.0.11sd
Revision: 9e97b73e7dd2bfc07745489d728f6a36665c648f Revision: e3a4e41d61544d8e2eba73f00da99b6818ec472b
License: Apache 2.0 License: Apache 2.0
License File: src/LICENSE License File: src/LICENSE
Security Critical: yes Security Critical: yes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment