Query LUID from OpenXR runtime and send back to browser process
When initializing the OpenXR runtime, send the LUID of the GPU adapter the VR headset is plugged into back to the browser process. This change is one part of a series of changes to add multi-GPU support for VR. crrev.com/c/2216166 added the LUID of the GPU that the GPU process is using. A subsequent CL will compare these two LUIDs to determine whether the GPU process needs to be restarted and initialized on the correct GPU to be XR compatible. This change adds a XRDeviceData struct that wraps around a LUID so that the LUID is only enabled on Windows with minimal "#if defined(OS_WIN)" wrappers. A subsequent change specified by crbug.com/1090029 will consolidate all information about an XR device into this XRDeviceData struct. Bug: 792657 Change-Id: If38fd6d0b16c39b36d529d4aaa02c22fe0bcff0a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225366 Commit-Queue: Patrick To <patrto@microsoft.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Alexander Cooper <alcooper@chromium.org> Reviewed-by: Alex Gough <ajgo@chromium.org> Cr-Commit-Position: refs/heads/master@{#776324}
This commit is contained in:
chrome/browser/android/vr/arcore_device
content
browser
xr
services
isolated_xr_device
device/vr
gpu/ipc/common
@ -16,6 +16,7 @@ ArCoreDeviceProvider::~ArCoreDeviceProvider() = default;
|
||||
void ArCoreDeviceProvider::Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
@ -24,9 +25,9 @@ void ArCoreDeviceProvider::Initialize(
|
||||
DVLOG(2) << __func__ << ": ARCore is supported, creating device";
|
||||
arcore_device_ = std::make_unique<ArCoreDevice>();
|
||||
|
||||
add_device_callback.Run(arcore_device_->GetId(),
|
||||
arcore_device_->GetVRDisplayInfo(),
|
||||
arcore_device_->BindXRRuntime());
|
||||
add_device_callback.Run(
|
||||
arcore_device_->GetId(), arcore_device_->GetVRDisplayInfo(),
|
||||
arcore_device_->GetDeviceData(), arcore_device_->BindXRRuntime());
|
||||
}
|
||||
initialized_ = true;
|
||||
std::move(initialization_complete).Run();
|
||||
|
@ -22,6 +22,7 @@ class ArCoreDeviceProvider : public VRDeviceProvider {
|
||||
void Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
|
@ -213,9 +213,11 @@ bool ContainsFeature(
|
||||
|
||||
BrowserXRRuntimeImpl::BrowserXRRuntimeImpl(
|
||||
device::mojom::XRDeviceId id,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> runtime,
|
||||
device::mojom::VRDisplayInfoPtr display_info)
|
||||
: id_(id),
|
||||
device_data_(std::move(device_data)),
|
||||
runtime_(std::move(runtime)),
|
||||
display_info_(ValidateVRDisplayInfo(display_info.get(), id)) {
|
||||
DVLOG(2) << __func__ << ": id=" << id;
|
||||
@ -558,4 +560,10 @@ void BrowserXRRuntimeImpl::BeforeRuntimeRemoved() {
|
||||
StopImmersiveSession(base::DoNothing());
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
base::Optional<LUID> BrowserXRRuntimeImpl::GetLuid() const {
|
||||
return device_data_->luid;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace content
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/observer_list_types.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/browser/xr/service/vr_service_impl.h"
|
||||
#include "content/public/browser/browser_xr_runtime.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
@ -35,6 +36,7 @@ class BrowserXRRuntimeImpl : public content::BrowserXRRuntime,
|
||||
base::OnceCallback<void(device::mojom::XRSessionPtr)>;
|
||||
explicit BrowserXRRuntimeImpl(
|
||||
device::mojom::XRDeviceId id,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> runtime,
|
||||
device::mojom::VRDisplayInfoPtr info);
|
||||
~BrowserXRRuntimeImpl() override;
|
||||
@ -71,6 +73,10 @@ class BrowserXRRuntimeImpl : public content::BrowserXRRuntime,
|
||||
|
||||
device::mojom::XRDeviceId GetId() const { return id_; }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
base::Optional<LUID> GetLuid() const;
|
||||
#endif
|
||||
|
||||
// BrowserXRRuntime
|
||||
void AddObserver(Observer* observer) override;
|
||||
void RemoveObserver(Observer* observer) override;
|
||||
@ -100,6 +106,7 @@ class BrowserXRRuntimeImpl : public content::BrowserXRRuntime,
|
||||
void OnInstallFinished(bool succeeded);
|
||||
|
||||
device::mojom::XRDeviceId id_;
|
||||
device::mojom::XRDeviceDataPtr device_data_;
|
||||
mojo::Remote<device::mojom::XRRuntime> runtime_;
|
||||
mojo::Remote<device::mojom::XRSessionController>
|
||||
immersive_session_controller_;
|
||||
|
@ -18,6 +18,7 @@ namespace content {
|
||||
void IsolatedVRDeviceProvider::Initialize(
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId,
|
||||
device::mojom::VRDisplayInfoPtr,
|
||||
device::mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId)>
|
||||
@ -37,8 +38,10 @@ bool IsolatedVRDeviceProvider::Initialized() {
|
||||
void IsolatedVRDeviceProvider::OnDeviceAdded(
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> device,
|
||||
mojo::PendingRemote<device::mojom::XRCompositorHost> compositor_host,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
device::mojom::XRDeviceId device_id) {
|
||||
add_device_callback_.Run(device_id, nullptr, std::move(device));
|
||||
add_device_callback_.Run(device_id, nullptr, std::move(device_data),
|
||||
std::move(device));
|
||||
|
||||
auto* integration_client = GetXrIntegrationClient();
|
||||
if (!integration_client)
|
||||
|
@ -30,6 +30,7 @@ class IsolatedVRDeviceProvider
|
||||
base::RepeatingCallback<void(
|
||||
device::mojom::XRDeviceId,
|
||||
device::mojom::VRDisplayInfoPtr,
|
||||
device::mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime>)> add_device_callback,
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId)>
|
||||
remove_device_callback,
|
||||
@ -43,6 +44,7 @@ class IsolatedVRDeviceProvider
|
||||
void OnDeviceAdded(
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> device,
|
||||
mojo::PendingRemote<device::mojom::XRCompositorHost> compositor_host,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
device::mojom::XRDeviceId device_id) override;
|
||||
void OnDeviceRemoved(device::mojom::XRDeviceId id) override;
|
||||
void OnDevicesEnumerated() override;
|
||||
@ -53,8 +55,10 @@ class IsolatedVRDeviceProvider
|
||||
int retry_count_ = 0;
|
||||
mojo::Remote<device::mojom::IsolatedXRRuntimeProvider> device_provider_;
|
||||
|
||||
// TODO(crbug.com/1090029): Wrap XRDeviceId + VRDisplayInfo into XRDeviceData
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId,
|
||||
device::mojom::VRDisplayInfoPtr,
|
||||
device::mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime>)>
|
||||
add_device_callback_;
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId)>
|
||||
|
@ -392,14 +392,15 @@ bool XRRuntimeManagerImpl::AreAllProvidersInitialized() {
|
||||
void XRRuntimeManagerImpl::AddRuntime(
|
||||
device::mojom::XRDeviceId id,
|
||||
device::mojom::VRDisplayInfoPtr info,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> runtime) {
|
||||
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
|
||||
DCHECK(runtimes_.find(id) == runtimes_.end());
|
||||
|
||||
TRACE_EVENT_INSTANT1("xr", "AddRuntime", TRACE_EVENT_SCOPE_THREAD, "id", id);
|
||||
|
||||
runtimes_[id] = std::make_unique<BrowserXRRuntimeImpl>(id, std::move(runtime),
|
||||
std::move(info));
|
||||
runtimes_[id] = std::make_unique<BrowserXRRuntimeImpl>(
|
||||
id, std::move(device_data), std::move(runtime), std::move(info));
|
||||
|
||||
for (Observer& obs : g_xr_runtime_manager_observers.Get())
|
||||
obs.OnRuntimeAdded(runtimes_[id].get());
|
||||
|
@ -101,6 +101,7 @@ class CONTENT_EXPORT XRRuntimeManagerImpl
|
||||
|
||||
void AddRuntime(device::mojom::XRDeviceId id,
|
||||
device::mojom::VRDisplayInfoPtr info,
|
||||
device::mojom::XRDeviceDataPtr device_data,
|
||||
mojo::PendingRemote<device::mojom::XRRuntime> runtime);
|
||||
void RemoveRuntime(device::mojom::XRDeviceId id);
|
||||
|
||||
|
@ -40,16 +40,22 @@ namespace {
|
||||
constexpr base::TimeDelta kTimeBetweenPollingEvents =
|
||||
base::TimeDelta::FromSecondsD(5);
|
||||
|
||||
template <typename VrDeviceT>
|
||||
std::unique_ptr<VrDeviceT> CreateDevice() {
|
||||
return std::make_unique<VrDeviceT>();
|
||||
}
|
||||
|
||||
template <typename VrDeviceT>
|
||||
std::unique_ptr<VrDeviceT> EnableRuntime(
|
||||
device::mojom::IsolatedXRRuntimeProviderClient* client) {
|
||||
auto device = std::make_unique<VrDeviceT>();
|
||||
device::mojom::IsolatedXRRuntimeProviderClient* client,
|
||||
base::OnceCallback<std::unique_ptr<VrDeviceT>()> create_device) {
|
||||
auto device = std::move(create_device).Run();
|
||||
TRACE_EVENT_INSTANT1("xr", "HardwareAdded", TRACE_EVENT_SCOPE_THREAD, "id",
|
||||
static_cast<int>(device->GetId()));
|
||||
// "Device" here refers to a runtime + hardware pair, not necessarily
|
||||
// a physical device.
|
||||
client->OnDeviceAdded(device->BindXRRuntime(), device->BindCompositorHost(),
|
||||
device->GetId());
|
||||
device->GetDeviceData(), device->GetId());
|
||||
return device;
|
||||
}
|
||||
|
||||
@ -64,12 +70,14 @@ void DisableRuntime(device::mojom::IsolatedXRRuntimeProviderClient* client,
|
||||
}
|
||||
|
||||
template <typename VrHardwareT>
|
||||
void SetRuntimeStatus(device::mojom::IsolatedXRRuntimeProviderClient* client,
|
||||
IsolatedXRRuntimeProvider::RuntimeStatus status,
|
||||
std::unique_ptr<VrHardwareT>* out_device) {
|
||||
void SetRuntimeStatus(
|
||||
device::mojom::IsolatedXRRuntimeProviderClient* client,
|
||||
IsolatedXRRuntimeProvider::RuntimeStatus status,
|
||||
base::OnceCallback<std::unique_ptr<VrHardwareT>()> create_device,
|
||||
std::unique_ptr<VrHardwareT>* out_device) {
|
||||
if (status == IsolatedXRRuntimeProvider::RuntimeStatus::kEnable &&
|
||||
!*out_device) {
|
||||
*out_device = EnableRuntime<VrHardwareT>(client);
|
||||
*out_device = EnableRuntime<VrHardwareT>(client, std::move(create_device));
|
||||
} else if (status == IsolatedXRRuntimeProvider::RuntimeStatus::kDisable &&
|
||||
*out_device) {
|
||||
DisableRuntime(client, std::move(*out_device));
|
||||
@ -211,7 +219,9 @@ bool IsolatedXRRuntimeProvider::IsOculusVrHardwareAvailable() {
|
||||
}
|
||||
|
||||
void IsolatedXRRuntimeProvider::SetOculusVrRuntimeStatus(RuntimeStatus status) {
|
||||
SetRuntimeStatus(client_.get(), status, &oculus_device_);
|
||||
SetRuntimeStatus(client_.get(), status,
|
||||
base::BindOnce(&CreateDevice<device::OculusDevice>),
|
||||
&oculus_device_);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_OCULUS_VR)
|
||||
|
||||
@ -223,7 +233,9 @@ bool IsolatedXRRuntimeProvider::IsOpenVrHardwareAvailable() {
|
||||
}
|
||||
|
||||
void IsolatedXRRuntimeProvider::SetOpenVrRuntimeStatus(RuntimeStatus status) {
|
||||
SetRuntimeStatus(client_.get(), status, &openvr_device_);
|
||||
SetRuntimeStatus(client_.get(), status,
|
||||
base::BindOnce(&CreateDevice<device::OpenVRDevice>),
|
||||
&openvr_device_);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_OPENVR)
|
||||
|
||||
@ -233,7 +245,9 @@ bool IsolatedXRRuntimeProvider::IsWMRHardwareAvailable() {
|
||||
}
|
||||
|
||||
void IsolatedXRRuntimeProvider::SetWMRRuntimeStatus(RuntimeStatus status) {
|
||||
SetRuntimeStatus(client_.get(), status, &wmr_device_);
|
||||
SetRuntimeStatus(client_.get(), status,
|
||||
base::BindOnce(&CreateDevice<device::MixedRealityDevice>),
|
||||
&wmr_device_);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_WINDOWS_MR)
|
||||
|
||||
@ -243,7 +257,17 @@ bool IsolatedXRRuntimeProvider::IsOpenXrHardwareAvailable() {
|
||||
}
|
||||
|
||||
void IsolatedXRRuntimeProvider::SetOpenXrRuntimeStatus(RuntimeStatus status) {
|
||||
SetRuntimeStatus(client_.get(), status, &openxr_device_);
|
||||
SetRuntimeStatus(
|
||||
client_.get(), status,
|
||||
base::BindOnce(
|
||||
[](device::OpenXrStatics* openxr_statics) {
|
||||
// This does not give any ownership of the OpenXrStatics object to
|
||||
// OpenXrDevice. The OpenXrStatics is only used in the constructor
|
||||
// and a reference is not kept.
|
||||
return std::make_unique<device::OpenXrDevice>(openxr_statics);
|
||||
},
|
||||
openxr_statics_.get()),
|
||||
&openxr_device_);
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_OPENXR)
|
||||
|
||||
|
@ -17,6 +17,7 @@ GvrDeviceProvider::~GvrDeviceProvider() = default;
|
||||
void GvrDeviceProvider::Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
@ -32,6 +33,7 @@ void GvrDeviceProvider::Initialize(
|
||||
}
|
||||
if (vr_device_) {
|
||||
add_device_callback.Run(vr_device_->GetId(), vr_device_->GetVRDisplayInfo(),
|
||||
vr_device_->GetDeviceData(),
|
||||
vr_device_->BindXRRuntime());
|
||||
}
|
||||
initialized_ = true;
|
||||
|
@ -24,6 +24,7 @@ class DEVICE_VR_EXPORT GvrDeviceProvider : public VRDeviceProvider {
|
||||
void Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
|
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -31,4 +31,25 @@ bool OpenXrStatics::IsApiAvailable() {
|
||||
XR_SUCCEEDED(CreateInstance(&instance_));
|
||||
}
|
||||
|
||||
} // namespace device
|
||||
#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
|
||||
|
@ -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_
|
||||
#endif // DEVICE_VR_WINDOWS_MIXED_REALITY_MIXED_REALITY_STATICS_H_
|
||||
|
@ -22,13 +22,14 @@ VROrientationDeviceProvider::~VROrientationDeviceProvider() = default;
|
||||
void VROrientationDeviceProvider::Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
base::OnceClosure initialization_complete) {
|
||||
if (device_ && device_->IsAvailable()) {
|
||||
add_device_callback.Run(device_->GetId(), device_->GetVRDisplayInfo(),
|
||||
device_->BindXRRuntime());
|
||||
device_->GetDeviceData(), device_->BindXRRuntime());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,6 +56,7 @@ void VROrientationDeviceProvider::DeviceInitialized() {
|
||||
// If the device successfully connected to the orientation APIs, provide it.
|
||||
if (device_->IsAvailable()) {
|
||||
add_device_callback_.Run(device_->GetId(), device_->GetVRDisplayInfo(),
|
||||
device_->GetDeviceData(),
|
||||
device_->BindXRRuntime());
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class COMPONENT_EXPORT(VR_ORIENTATION) VROrientationDeviceProvider
|
||||
void Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
@ -46,6 +47,7 @@ class COMPONENT_EXPORT(VR_ORIENTATION) VROrientationDeviceProvider
|
||||
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback_;
|
||||
base::OnceClosure initialized_callback_;
|
||||
|
@ -84,10 +84,12 @@ class VROrientationDeviceProviderTest : public testing::Test {
|
||||
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime> device)>
|
||||
DeviceAndIdCallbackFailIfCalled() {
|
||||
return base::BindRepeating(
|
||||
[](device::mojom::XRDeviceId id, mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime> device) { FAIL(); });
|
||||
}
|
||||
|
||||
@ -98,14 +100,16 @@ class VROrientationDeviceProviderTest : public testing::Test {
|
||||
|
||||
base::RepeatingCallback<void(device::mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime> device)>
|
||||
DeviceAndIdCallbackMustBeCalled(base::RunLoop* loop) {
|
||||
return base::BindRepeating(
|
||||
[](base::OnceClosure quit_closure, device::mojom::XRDeviceId id,
|
||||
mojom::VRDisplayInfoPtr info,
|
||||
mojom::VRDisplayInfoPtr info, mojom::XRDeviceDataPtr data,
|
||||
mojo::PendingRemote<mojom::XRRuntime> device) {
|
||||
ASSERT_TRUE(device);
|
||||
ASSERT_TRUE(info);
|
||||
ASSERT_TRUE(data);
|
||||
std::move(quit_closure).Run();
|
||||
},
|
||||
loop->QuitClosure());
|
||||
|
@ -23,6 +23,7 @@ class COMPONENT_EXPORT(VR_PUBLIC_CPP) VRDeviceProvider {
|
||||
virtual void Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId id,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId id)>
|
||||
|
@ -6,6 +6,8 @@ module device.mojom;
|
||||
|
||||
import "device/vr/public/mojom/browser_test_interfaces.mojom";
|
||||
import "device/vr/public/mojom/vr_service.mojom";
|
||||
[EnableIf=is_win]
|
||||
import "gpu/ipc/common/luid.mojom";
|
||||
import "mojo/public/mojom/base/time.mojom";
|
||||
import "ui/gfx/geometry/mojom/geometry.mojom";
|
||||
|
||||
@ -110,6 +112,15 @@ interface XRCompositorHost {
|
||||
CreateImmersiveOverlay(pending_receiver<ImmersiveOverlay> overlay);
|
||||
};
|
||||
|
||||
// Information about a particular XR device that is available. All information
|
||||
// about an available XR device should be wrapped in this struct.
|
||||
// TODO(crbug.com/1090029): Wrap XRDeviceId + VRDisplayInfo in this struct
|
||||
struct XRDeviceData {
|
||||
[EnableIf=is_win]
|
||||
// The LUID of the GPU that the device is plugged into.
|
||||
gpu.mojom.Luid? luid;
|
||||
};
|
||||
|
||||
// Notify the browser process about a set of runtimes. The browser process
|
||||
// implements this interface to be notified about runtime changes from the XR
|
||||
// device service.
|
||||
@ -118,6 +129,7 @@ interface IsolatedXRRuntimeProviderClient {
|
||||
// attached and become available.
|
||||
OnDeviceAdded(pending_remote<XRRuntime> runtime,
|
||||
pending_remote<XRCompositorHost> compositor_host,
|
||||
XRDeviceData device_data,
|
||||
device.mojom.XRDeviceId device_id);
|
||||
|
||||
// Called when runtimes become unavailable - for example if the hardware is
|
||||
|
@ -17,9 +17,9 @@ void FakeVRDeviceProvider::AddDevice(std::unique_ptr<VRDeviceBase> device) {
|
||||
VRDeviceBase* device_base = static_cast<VRDeviceBase*>(device.get());
|
||||
devices_.push_back(std::move(device));
|
||||
if (initialized_)
|
||||
add_device_callback_.Run(device_base->GetId(),
|
||||
device_base->GetVRDisplayInfo(),
|
||||
device_base->BindXRRuntime());
|
||||
add_device_callback_.Run(
|
||||
device_base->GetId(), device_base->GetVRDisplayInfo(),
|
||||
device_base->GetDeviceData(), device_base->BindXRRuntime());
|
||||
}
|
||||
|
||||
void FakeVRDeviceProvider::RemoveDevice(mojom::XRDeviceId device_id) {
|
||||
@ -36,6 +36,7 @@ void FakeVRDeviceProvider::RemoveDevice(mojom::XRDeviceId device_id) {
|
||||
void FakeVRDeviceProvider::Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
@ -45,9 +46,9 @@ void FakeVRDeviceProvider::Initialize(
|
||||
|
||||
for (std::unique_ptr<VRDeviceBase>& device : devices_) {
|
||||
auto* device_base = static_cast<VRDeviceBase*>(device.get());
|
||||
add_device_callback_.Run(device_base->GetId(),
|
||||
device_base->GetVRDisplayInfo(),
|
||||
device_base->BindXRRuntime());
|
||||
add_device_callback_.Run(
|
||||
device_base->GetId(), device_base->GetVRDisplayInfo(),
|
||||
device_base->GetDeviceData(), device_base->BindXRRuntime());
|
||||
}
|
||||
initialized_ = true;
|
||||
std::move(initialization_complete).Run();
|
||||
|
@ -28,6 +28,7 @@ class DEVICE_VR_EXPORT FakeVRDeviceProvider : public VRDeviceProvider {
|
||||
void Initialize(
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback,
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback,
|
||||
@ -39,6 +40,7 @@ class DEVICE_VR_EXPORT FakeVRDeviceProvider : public VRDeviceProvider {
|
||||
bool initialized_;
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId,
|
||||
mojom::VRDisplayInfoPtr,
|
||||
mojom::XRDeviceDataPtr,
|
||||
mojo::PendingRemote<mojom::XRRuntime>)>
|
||||
add_device_callback_;
|
||||
base::RepeatingCallback<void(mojom::XRDeviceId)> remove_device_callback_;
|
||||
|
@ -19,6 +19,10 @@ mojom::XRDeviceId VRDeviceBase::GetId() const {
|
||||
return id_;
|
||||
}
|
||||
|
||||
mojom::XRDeviceDataPtr VRDeviceBase::GetDeviceData() const {
|
||||
return device_data_.Clone();
|
||||
}
|
||||
|
||||
void VRDeviceBase::PauseTracking() {}
|
||||
|
||||
void VRDeviceBase::ResumeTracking() {}
|
||||
@ -75,6 +79,15 @@ void VRDeviceBase::OnVisibilityStateChanged(
|
||||
listener_->OnVisibilityStateChanged(visibility_state);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
void VRDeviceBase::SetLuid(const LUID& luid) {
|
||||
if (luid.HighPart != 0 || luid.LowPart != 0) {
|
||||
// Only set the LUID if it exists and is nonzero.
|
||||
device_data_.luid = base::make_optional<LUID>(luid);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mojo::PendingRemote<mojom::XRRuntime> VRDeviceBase::BindXRRuntime() {
|
||||
DVLOG(2) << __func__;
|
||||
return runtime_receiver_.BindNewPipeAndPassRemote();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/component_export.h"
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "device/vr/public/mojom/vr_service.mojom.h"
|
||||
#include "device/vr/vr_device.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
@ -35,6 +36,7 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime {
|
||||
void ShutdownSession(mojom::XRRuntime::ShutdownSessionCallback) override;
|
||||
|
||||
device::mojom::XRDeviceId GetId() const;
|
||||
device::mojom::XRDeviceDataPtr GetDeviceData() const;
|
||||
|
||||
bool HasExclusiveSession();
|
||||
|
||||
@ -61,6 +63,9 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime {
|
||||
bool IsPresenting() { return presenting_; } // Exposed for test.
|
||||
void SetVRDisplayInfo(mojom::VRDisplayInfoPtr display_info);
|
||||
void OnVisibilityStateChanged(mojom::XRVisibilityState visibility_state);
|
||||
#if defined(OS_WIN)
|
||||
void SetLuid(const LUID& luid);
|
||||
#endif
|
||||
|
||||
mojom::VRDisplayInfoPtr display_info_;
|
||||
|
||||
@ -73,6 +78,8 @@ class COMPONENT_EXPORT(DEVICE_VR_BASE) VRDeviceBase : public mojom::XRRuntime {
|
||||
|
||||
device::mojom::XRDeviceId id_;
|
||||
|
||||
device::mojom::XRDeviceData device_data_;
|
||||
|
||||
mojo::Receiver<mojom::XRRuntime> runtime_receiver_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(VRDeviceBase);
|
||||
|
@ -214,6 +214,10 @@ mojom("interfaces") {
|
||||
"vulkan_ycbcr_info.mojom",
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
sources += [ "luid.mojom" ]
|
||||
}
|
||||
|
||||
public_deps = [
|
||||
":gpu_preferences_interface",
|
||||
"//mojo/public/mojom/base",
|
||||
@ -269,6 +273,24 @@ mojom("interfaces") {
|
||||
},
|
||||
]
|
||||
|
||||
if (is_win) {
|
||||
shared_cpp_typemaps += [
|
||||
{
|
||||
types = [
|
||||
{
|
||||
mojom = "gpu.mojom.Luid"
|
||||
cpp = "::LUID"
|
||||
},
|
||||
]
|
||||
traits_headers = [ "luid_mojom_traits.h" ]
|
||||
traits_public_deps = [
|
||||
":mojom_traits",
|
||||
"//gpu/config",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
cpp_typemaps = shared_cpp_typemaps
|
||||
blink_cpp_typemaps = shared_cpp_typemaps
|
||||
|
||||
@ -399,10 +421,6 @@ mojom("interfaces") {
|
||||
mojom = "gpu.mojom.ImageDecodeAcceleratorSupportedProfile"
|
||||
cpp = "::gpu::ImageDecodeAcceleratorSupportedProfile"
|
||||
},
|
||||
{
|
||||
mojom = "gpu.mojom.Luid"
|
||||
cpp = "::LUID"
|
||||
},
|
||||
]
|
||||
traits_sources = [ "gpu_info_mojom_traits.cc" ]
|
||||
traits_headers = [ "gpu_info_mojom_traits.h" ]
|
||||
@ -584,6 +602,9 @@ source_set("mojom_traits") {
|
||||
if (is_android) {
|
||||
sources += [ "vulkan_ycbcr_info_mojom_traits.h" ]
|
||||
}
|
||||
if (is_win) {
|
||||
sources += [ "luid_mojom_traits.h" ]
|
||||
}
|
||||
if (enable_vulkan) {
|
||||
deps += [ ":vulkan_types_mojom_traits" ]
|
||||
}
|
||||
|
@ -6,19 +6,14 @@
|
||||
module gpu.mojom;
|
||||
|
||||
import "gpu/ipc/common/dx_diag_node.mojom";
|
||||
[EnableIf=is_win]
|
||||
import "gpu/ipc/common/luid.mojom";
|
||||
import "mojo/public/mojom/base/time.mojom";
|
||||
import "ui/gfx/geometry/mojom/geometry.mojom";
|
||||
|
||||
[EnableIf=supports_vulkan]
|
||||
import "gpu/ipc/common/vulkan_info.mojom";
|
||||
|
||||
// Corresponds to LUID in dxgi.h
|
||||
[EnableIf=is_win]
|
||||
struct Luid {
|
||||
int32 high;
|
||||
uint32 low;
|
||||
};
|
||||
|
||||
// gpu::GPUInfo::GPUDevice
|
||||
struct GpuDevice {
|
||||
uint32 vendor_id;
|
||||
|
@ -378,15 +378,6 @@ bool StructTraits<gpu::mojom::OverlayInfoDataView, gpu::OverlayInfo>::Read(
|
||||
return data.ReadYuy2OverlaySupport(&out->yuy2_overlay_support) &&
|
||||
data.ReadNv12OverlaySupport(&out->nv12_overlay_support);
|
||||
}
|
||||
|
||||
// static
|
||||
bool StructTraits<gpu::mojom::LuidDataView, LUID>::Read(
|
||||
gpu::mojom::LuidDataView data,
|
||||
LUID* out) {
|
||||
out->HighPart = data.high();
|
||||
out->LowPart = data.low();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo>::Read(
|
||||
|
@ -257,15 +257,6 @@ struct StructTraits<gpu::mojom::OverlayInfoDataView, gpu::OverlayInfo> {
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::LuidDataView, LUID> {
|
||||
static bool Read(gpu::mojom::LuidDataView data, LUID* out);
|
||||
|
||||
static int32_t high(const LUID& input) { return input.HighPart; }
|
||||
|
||||
static uint32_t low(const LUID& input) { return input.LowPart; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <>
|
||||
|
12
gpu/ipc/common/luid.mojom
Normal file
12
gpu/ipc/common/luid.mojom
Normal file
@ -0,0 +1,12 @@
|
||||
// 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.
|
||||
|
||||
module gpu.mojom;
|
||||
|
||||
// Corresponds to LUID in dxgi.h
|
||||
[EnableIf=is_win]
|
||||
struct Luid {
|
||||
int32 high;
|
||||
uint32 low;
|
||||
};
|
27
gpu/ipc/common/luid_mojom_traits.h
Normal file
27
gpu/ipc/common/luid_mojom_traits.h
Normal file
@ -0,0 +1,27 @@
|
||||
// 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 GPU_IPC_COMMON_LUID_MOJOM_TRAITS_H_
|
||||
#define GPU_IPC_COMMON_LUID_MOJOM_TRAITS_H_
|
||||
|
||||
#include "gpu/ipc/common/luid.mojom-shared.h"
|
||||
|
||||
namespace mojo {
|
||||
|
||||
template <>
|
||||
struct StructTraits<gpu::mojom::LuidDataView, LUID> {
|
||||
static bool Read(gpu::mojom::LuidDataView data, LUID* out) {
|
||||
out->HighPart = data.high();
|
||||
out->LowPart = data.low();
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t high(const LUID& input) { return input.HighPart; }
|
||||
|
||||
static uint32_t low(const LUID& input) { return input.LowPart; }
|
||||
};
|
||||
|
||||
} // namespace mojo
|
||||
|
||||
#endif // GPU_IPC_COMMON_LUID_MOJOM_TRAITS_H_
|
Reference in New Issue
Block a user