summaryrefslogtreecommitdiff
path: root/chromium/device/vr/openxr
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/device/vr/openxr')
-rw-r--r--chromium/device/vr/openxr/openxr_device.cc13
-rw-r--r--chromium/device/vr/openxr/openxr_device.h3
-rw-r--r--chromium/device/vr/openxr/openxr_statics.cc23
-rw-r--r--chromium/device/vr/openxr/openxr_statics.h7
-rw-r--r--chromium/device/vr/openxr/openxr_util.h1
5 files changed, 42 insertions, 5 deletions
diff --git a/chromium/device/vr/openxr/openxr_device.cc b/chromium/device/vr/openxr/openxr_device.cc
index 2b7a8cf0fc9..7e2c2cc0315 100644
--- a/chromium/device/vr/openxr/openxr_device.cc
+++ b/chromium/device/vr/openxr/openxr_device.cc
@@ -7,8 +7,10 @@
#include <string>
#include "base/bind_helpers.h"
+#include "build/build_config.h"
#include "device/vr/openxr/openxr_api_wrapper.h"
#include "device/vr/openxr/openxr_render_loop.h"
+#include "device/vr/openxr/openxr_statics.h"
#include "device/vr/util/transform_utils.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
@@ -53,10 +55,17 @@ mojom::VRDisplayInfoPtr CreateFakeVRDisplayInfo(device::mojom::XRDeviceId id) {
} // namespace
-OpenXrDevice::OpenXrDevice()
+// OpenXrDevice must not take ownership of the OpenXrStatics passed in.
+// The OpenXrStatics object is owned by IsolatedXRRuntimeProvider.
+OpenXrDevice::OpenXrDevice(OpenXrStatics* openxr_statics)
: VRDeviceBase(device::mojom::XRDeviceId::OPENXR_DEVICE_ID),
weak_ptr_factory_(this) {
- SetVRDisplayInfo(CreateFakeVRDisplayInfo(GetId()));
+ mojom::VRDisplayInfoPtr display_info = CreateFakeVRDisplayInfo(GetId());
+ SetVRDisplayInfo(std::move(display_info));
+
+#if defined(OS_WIN)
+ SetLuid(openxr_statics->GetLuid());
+#endif
}
OpenXrDevice::~OpenXrDevice() {
diff --git a/chromium/device/vr/openxr/openxr_device.h b/chromium/device/vr/openxr/openxr_device.h
index 5b1d1dc3b1c..237223a3318 100644
--- a/chromium/device/vr/openxr/openxr_device.h
+++ b/chromium/device/vr/openxr/openxr_device.h
@@ -18,13 +18,14 @@
namespace device {
class OpenXrRenderLoop;
+class OpenXrStatics;
class DEVICE_VR_EXPORT OpenXrDevice
: public VRDeviceBase,
public mojom::XRSessionController,
public mojom::XRCompositorHost {
public:
- OpenXrDevice();
+ OpenXrDevice(OpenXrStatics* openxr_statics);
~OpenXrDevice() override;
// VRDeviceBase
diff --git a/chromium/device/vr/openxr/openxr_statics.cc b/chromium/device/vr/openxr/openxr_statics.cc
index 4b6096f31ad..c10611cb143 100644
--- a/chromium/device/vr/openxr/openxr_statics.cc
+++ b/chromium/device/vr/openxr/openxr_statics.cc
@@ -31,4 +31,25 @@ bool OpenXrStatics::IsApiAvailable() {
XR_SUCCEEDED(CreateInstance(&instance_));
}
-} // namespace device \ No newline at end of file
+#if defined(OS_WIN)
+// Returns the LUID of the adapter the OpenXR runtime is on. Returns {0, 0} if
+// the LUID could not be determined.
+LUID OpenXrStatics::GetLuid() {
+ if (!IsApiAvailable())
+ return {0, 0};
+
+ XrSystemId system;
+ if (XR_FAILED(GetSystem(instance_, &system)))
+ return {0, 0};
+
+ XrGraphicsRequirementsD3D11KHR graphics_requirements = {
+ XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR};
+ if (XR_FAILED(xrGetD3D11GraphicsRequirementsKHR(instance_, system,
+ &graphics_requirements)))
+ return {0, 0};
+
+ return graphics_requirements.adapterLuid;
+}
+#endif
+
+} // namespace device
diff --git a/chromium/device/vr/openxr/openxr_statics.h b/chromium/device/vr/openxr/openxr_statics.h
index 0b41f576574..4663b8a41fa 100644
--- a/chromium/device/vr/openxr/openxr_statics.h
+++ b/chromium/device/vr/openxr/openxr_statics.h
@@ -8,6 +8,7 @@
#include <d3d11.h>
#include <memory>
+#include "build/build_config.h"
#include "device/vr/vr_export.h"
#include "third_party/openxr/src/include/openxr/openxr.h"
#include "third_party/openxr/src/include/openxr/openxr_platform.h"
@@ -22,10 +23,14 @@ class DEVICE_VR_EXPORT OpenXrStatics {
bool IsHardwareAvailable();
bool IsApiAvailable();
+#if defined(OS_WIN)
+ LUID GetLuid();
+#endif
+
private:
XrInstance instance_;
};
} // namespace device
-#endif // DEVICE_VR_WINDOWS_MIXED_REALITY_MIXED_REALITY_STATICS_H_ \ No newline at end of file
+#endif // DEVICE_VR_WINDOWS_MIXED_REALITY_MIXED_REALITY_STATICS_H_
diff --git a/chromium/device/vr/openxr/openxr_util.h b/chromium/device/vr/openxr/openxr_util.h
index ed5ed7c6e9c..80aaeae67cb 100644
--- a/chromium/device/vr/openxr/openxr_util.h
+++ b/chromium/device/vr/openxr/openxr_util.h
@@ -5,6 +5,7 @@
#ifndef DEVICE_VR_OPENXR_OPENXR_UTIL_H_
#define DEVICE_VR_OPENXR_OPENXR_UTIL_H_
+#include "base/logging.h"
#include "third_party/openxr/src/include/openxr/openxr.h"
namespace device {