0

Revert "Updated the OpenXR spec from 1.0.5 to 1.0.11"

This reverts commit f98a2005dd.

Reason for revert: suspected to be causing various test failures on win7
See https://crbug.com/1138151

Original change's description:
> 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/+/2406701
> Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
> Reviewed-by: Alexander Cooper <alcooper@chromium.org>
> Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
> Commit-Queue: Lachlan Ford <laford@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#816823}

TBR=brucedawson@chromium.org,rafael.cintron@microsoft.com,scottmg@chromium.org,martiniss@chromium.org,patrto@microsoft.com,alcooper@chromium.org,laford@microsoft.com

Bug: 1138151
Change-Id: Idbd194d1197dd82d02cfd016421637b027520586
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472913
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817243}
This commit is contained in:
Ben Pastene
2020-10-14 22:59:02 +00:00
committed by Commit Bot
parent c7721de5fe
commit ed4f78f287
25 changed files with 208 additions and 306 deletions

2
DEPS

@ -1245,7 +1245,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' + '@' + 'e3a4e41d61544d8e2eba73f00da99b6818ec472b', 'url': Var('chromium_git') + '/external/github.com/KhronosGroup/OpenXR-SDK' + '@' + '9e97b73e7dd2bfc07745489d728f6a36665c648f',
'condition': 'checkout_openxr', 'condition': 'checkout_openxr',
}, },

@ -383,7 +383,6 @@ 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,10 +229,9 @@ 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",
@ -322,8 +321,7 @@ if (enable_openxr) {
include_dirs = [ "//third_party/openxr/src/include" ] include_dirs = [ "//third_party/openxr/src/include" ]
sources = [ sources = [
"openxr/openxr_extension_helper.cc", "openxr/openxr_defs.h",
"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,8 +271,7 @@ 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());
@ -287,13 +286,14 @@ XrResult OpenXrApiWrapper::InitSession(
CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_); CreateSpace(XR_REFERENCE_SPACE_TYPE_STAGE, &stage_space_);
UpdateStageBounds(); UpdateStageBounds();
if (extension_helper.ExtensionEnumeration()->ExtensionSupported( OpenXrExtensionHelper extension_helper;
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, extension_helper)); RETURN_IF_XR_FAILED(CreateGamepadHelper(input_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,13 +395,12 @@ 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( return OpenXRInputHelper::CreateOpenXRInputHelper(instance_, session_,
instance_, extension_helper, session_, local_space_, input_helper); local_space_, input_helper);
} }
XrResult OpenXrApiWrapper::BeginSession() { XrResult OpenXrApiWrapper::BeginSession() {
@ -621,20 +620,13 @@ void OpenXrApiWrapper::GetHeadFromEyes(XrView* left, XrView* right) const {
*right = head_from_eye_views_[1]; *right = head_from_eye_views_[1];
} }
XrResult OpenXrApiWrapper::GetLuid( XrResult OpenXrApiWrapper::GetLuid(LUID* luid) const {
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( RETURN_IF_XR_FAILED(xrGetD3D11GraphicsRequirementsKHR(
extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR( instance_, system_, &graphics_requirements));
instance_, system_, &graphics_requirements));
luid->LowPart = graphics_requirements.adapterLuid.LowPart; luid->LowPart = graphics_requirements.adapterLuid.LowPart;
luid->HighPart = graphics_requirements.adapterLuid.HighPart; luid->HighPart = graphics_requirements.adapterLuid.HighPart;

@ -47,8 +47,7 @@ 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();
@ -61,8 +60,7 @@ class OpenXrApiWrapper {
gfx::Size GetViewSize() const; gfx::Size GetViewSize() const;
XrTime GetPredictedDisplayTime() const; XrTime GetPredictedDisplayTime() const;
XrResult GetLuid(LUID* luid, XrResult GetLuid(LUID* luid) const;
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(
@ -91,8 +89,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(std::unique_ptr<OpenXRInputHelper>* input_helper, XrResult CreateGamepadHelper(
const OpenXrExtensionHelper& extension_helper); std::unique_ptr<OpenXRInputHelper>* input_helper);
XrResult BeginSession(); XrResult BeginSession();
XrResult UpdateProjectionLayers(); XrResult UpdateProjectionLayers();

@ -143,9 +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 = const bool extension_enabled = extension_helper.ExtensionSupported(
extension_helper.ExtensionEnumeration()->ExtensionSupported( interaction_profile.required_extension);
interaction_profile.required_extension);
if (!extension_enabled) { if (!extension_enabled) {
continue; continue;
} }

@ -0,0 +1,19 @@
// 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,13 +58,12 @@ 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(extension_helper_)); SetLuid(openxr_statics->GetLuid());
#endif #endif
} }
@ -87,7 +86,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_, extension_helper_); std::move(on_info_changed), instance_);
} }
} }

@ -8,7 +8,6 @@
#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"
@ -54,7 +53,6 @@ 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_{

@ -1,46 +0,0 @@
// 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

@ -1,54 +0,0 @@
// 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,14 +96,13 @@ 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, extension_helper)); RETURN_IF_XR_FAILED(new_helper->Initialize(instance));
*helper = std::move(new_helper); *helper = std::move(new_helper);
return XR_SUCCESS; return XR_SUCCESS;
} }
@ -115,9 +114,7 @@ OpenXRInputHelper::OpenXRInputHelper(XrSession session, XrSpace local_space)
OpenXRInputHelper::~OpenXRInputHelper() = default; OpenXRInputHelper::~OpenXRInputHelper() = default;
XrResult OpenXRInputHelper::Initialize( XrResult OpenXRInputHelper::Initialize(XrInstance instance) {
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
@ -125,6 +122,7 @@ XrResult OpenXRInputHelper::Initialize(
// 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,7 +13,6 @@
#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 {
@ -21,7 +20,6 @@ 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);
@ -40,8 +38,7 @@ 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,6 +7,7 @@
#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 {
@ -380,7 +381,7 @@ constexpr OpenXrControllerInteractionProfile kHTCViveInteractionProfile = {
constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile = constexpr OpenXrControllerInteractionProfile kSamsungOdysseyInteractionProfile =
{OpenXrInteractionProfileType::kSamsungOdyssey, {OpenXrInteractionProfileType::kSamsungOdyssey,
"/interaction_profiles/samsung/odyssey_controller", "/interaction_profiles/samsung/odyssey_controller",
XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME, kExtSamsungOdysseyControllerExtensionName,
GamepadMapping::kXrStandard, GamepadMapping::kXrStandard,
kSamsungOdysseyInputProfiles, kSamsungOdysseyInputProfiles,
base::size(kSamsungOdysseyInputProfiles), base::size(kSamsungOdysseyInputProfiles),
@ -394,7 +395,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",
XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME, kExtHPMixedRealityControllerExtensionName,
GamepadMapping::kXrStandard, GamepadMapping::kXrStandard,
kHPReverbG2InputProfiles, kHPReverbG2InputProfiles,
base::size(kHPReverbG2InputProfiles), base::size(kHPReverbG2InputProfiles),

@ -17,11 +17,9 @@ 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);
} }
@ -93,11 +91,11 @@ bool OpenXrRenderLoop::StartRuntime() {
texture_helper_.SetUseBGRA(true); texture_helper_.SetUseBGRA(true);
LUID luid; LUID luid;
if (XR_FAILED(openxr->GetLuid(&luid, extension_helper_)) || if (XR_FAILED(openxr->GetLuid(&luid)) ||
!texture_helper_.SetAdapterLUID(luid) || !texture_helper_.SetAdapterLUID(luid) ||
!texture_helper_.EnsureInitialized() || !texture_helper_.EnsureInitialized() ||
XR_FAILED(openxr->InitSession(texture_helper_.GetDevice(), &input_helper_, XR_FAILED(
extension_helper_))) { openxr->InitSession(texture_helper_.GetDevice(), &input_helper_))) {
texture_helper_.Reset(); texture_helper_.Reset();
return false; return false;
} }

@ -10,7 +10,6 @@
#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"
@ -25,8 +24,7 @@ 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:
@ -55,7 +53,6 @@ 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,8 +17,7 @@ OpenXrStatics::~OpenXrStatics() {
} }
XrInstance OpenXrStatics::GetXrInstance() { XrInstance OpenXrStatics::GetXrInstance() {
if (instance_ == XR_NULL_HANDLE && if (instance_ == XR_NULL_HANDLE && XR_FAILED(CreateInstance(&instance_))) {
XR_FAILED(CreateInstance(&instance_, extension_enumeration_))) {
return XR_NULL_HANDLE; return XR_NULL_HANDLE;
} }
return instance_; return instance_;
@ -40,7 +39,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(const OpenXrExtensionHelper& extension_helper) { LUID OpenXrStatics::GetLuid() {
if (GetXrInstance() == XR_NULL_HANDLE) if (GetXrInstance() == XR_NULL_HANDLE)
return {0, 0}; return {0, 0};
@ -48,15 +47,10 @@ LUID OpenXrStatics::GetLuid(const OpenXrExtensionHelper& extension_helper) {
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( if (XR_FAILED(xrGetD3D11GraphicsRequirementsKHR(instance_, system,
extension_helper.ExtensionMethods().xrGetD3D11GraphicsRequirementsKHR( &graphics_requirements)))
instance_, system, &graphics_requirements)))
return {0, 0}; return {0, 0};
return graphics_requirements.adapterLuid; return graphics_requirements.adapterLuid;

@ -9,7 +9,6 @@
#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"
@ -23,22 +22,17 @@ 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(const OpenXrExtensionHelper& extension_helper); LUID GetLuid();
#endif #endif
private: private:
XrInstance instance_; XrInstance instance_;
OpenXrExtensionEnumeration extension_enumeration_;
}; };
} // namespace device } // namespace device

@ -3,8 +3,11 @@
// 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"
@ -12,6 +15,7 @@
#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 {
@ -52,9 +56,30 @@ bool IsRunningInWin32AppContainer() {
} }
#endif #endif
XrResult CreateInstance( OpenXrExtensionHelper::OpenXrExtensionHelper() {
XrInstance* instance, uint32_t extension_count;
const OpenXrExtensionEnumeration& extension_enumeration) { 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());
}
}
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() + " " +
@ -96,14 +121,15 @@ XrResult CreateInstance(
// 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(XR_EXT_WIN32_APPCONTAINER_COMPATIBLE_EXTENSION_NAME); extensions.push_back(kWin32AppcontainerCompatibleExtensionName);
} }
// 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_enumeration.ExtensionSupported( extension_helper.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);
@ -112,17 +138,17 @@ XrResult CreateInstance(
// 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_enumeration.ExtensionSupported( extension_helper.ExtensionSupported(
XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME); kExtSamsungOdysseyControllerExtensionName);
if (samsungInteractionProfileExtensionSupported) { if (samsungInteractionProfileExtensionSupported) {
extensions.push_back(XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME); extensions.push_back(kExtSamsungOdysseyControllerExtensionName);
} }
const bool hpControllerExtensionSupported = const bool hpControllerExtensionSupported =
extension_enumeration.ExtensionSupported( extension_helper.ExtensionSupported(
XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME); kExtHPMixedRealityControllerExtensionName);
if (hpControllerExtensionSupported) { if (hpControllerExtensionSupported) {
extensions.push_back(XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME); extensions.push_back(kExtHPMixedRealityControllerExtensionName);
} }
const bool handInteractionExtensionSupported = const bool handInteractionExtensionSupported =

@ -5,15 +5,23 @@
#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.
@ -50,9 +58,7 @@ XrPosef PoseIdentity();
XrResult GetSystem(XrInstance instance, XrSystemId* system); XrResult GetSystem(XrInstance instance, XrSystemId* system);
XrResult CreateInstance( XrResult CreateInstance(XrInstance* instance);
XrInstance* instance,
const OpenXrExtensionEnumeration& extension_enumeration);
std::vector<XrEnvironmentBlendMode> GetSupportedBlendModes(XrInstance instance, std::vector<XrEnvironmentBlendMode> GetSupportedBlendModes(XrInstance instance,
XrSystemId system); XrSystemId system);

@ -16,8 +16,6 @@ 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.
@ -905,100 +903,3 @@ 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;
}

@ -17,19 +17,110 @@
// 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.
XrResult XRAPI_PTR xrGetInstanceProcAddr(XrInstance instance, // Please add new OpenXR APIs below in alphabetical order.
const char* name, XrResult XRAPI_PTR GetInstanceProcAddress(XrInstance instance,
PFN_xrVoidFunction* function); 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;
}
// 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. xrGetInstanceProcAddr is returned to the // loader calls for negotiation. GetInstanceProcAddress 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_CURRENT_API_VERSION; runtimeRequest->runtimeApiVersion = XR_MAKE_VERSION(1, 0, 1);
runtimeRequest->getInstanceProcAddr = xrGetInstanceProcAddr; runtimeRequest->getInstanceProcAddr = GetInstanceProcAddress;
return XR_SUCCESS; return XR_SUCCESS;
} }

@ -17,6 +17,7 @@
#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"
@ -129,7 +130,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,
XR_EXT_WIN32_APPCONTAINER_COMPATIBLE_EXTENSION_NAME}; device::kWin32AppcontainerCompatibleExtensionName};
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,6 +24,7 @@ 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",
@ -58,10 +59,6 @@ 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" ]
@ -76,7 +73,6 @@ if (enable_openxr) {
"-Wno-microsoft-cast", "-Wno-microsoft-cast",
"-Wno-microsoft-include", "-Wno-microsoft-include",
"-Wno-unused-function", "-Wno-unused-function",
"-Wno-extra-semi",
] ]
} }

@ -1,8 +1,8 @@
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.11sd Version: 1.0.5sd
Revision: e3a4e41d61544d8e2eba73f00da99b6818ec472b Revision: 9e97b73e7dd2bfc07745489d728f6a36665c648f
License: Apache 2.0 License: Apache 2.0
License File: src/LICENSE License File: src/LICENSE
Security Critical: yes Security Critical: yes