Commit 1daae6df authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Remove Oculus VR Runtime and SDK/Lib

The Oculus runtime is no longer considered for selecting an appropriate
VR Runtime, as our plan is to unify behind OpenXR as the single,
supported runtime. This removes the unused Oculus runtime.

Fixed: 1121625
Change-Id: I327619423e7a3d6c160a176dffca1354515af4af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2435722
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816478}
parent a9ed6397
......@@ -41,7 +41,6 @@ gclient_gn_args = [
'checkout_google_benchmark',
'checkout_ios_webkit',
'checkout_nacl',
'checkout_oculus_sdk',
'checkout_openxr',
'cros_boards',
'cros_boards_with_qemu_images',
......@@ -115,9 +114,6 @@ vars = {
# Fetch clang-tidy into the same bin/ directory as our clang binary.
'checkout_clang_tidy': False,
# By default do not check out the Oculus SDK. Only available for Googlers.
'checkout_oculus_sdk' : 'checkout_src_internal and checkout_win',
# By default checkout the OpenXR loader library only on Windows. The OpenXR
# backend for VR in Chromium is currently only supported for Windows, but
# support for other platforms may be added in the future.
......@@ -4832,20 +4828,6 @@ hooks = [
'src/third_party/arcore-android-sdk/test-apks/update.py',
],
},
# Download Oculus SDK if appropriate.
{
'name': 'libovr',
'pattern': '.',
'condition': 'checkout_oculus_sdk',
'action': ['python',
'src/third_party/depot_tools/download_from_google_storage.py',
'--bucket', 'chrome-oculus-sdk',
'--recursive',
'--num_threads=10',
'--directory',
'src/third_party/libovr/src',
],
},
# Download common ink resources for chromeos.
{
'name': 'ink-build',
......
......@@ -174,15 +174,6 @@ constexpr device::mojom::XRSessionFeature kOpenXRFeatures[] = {
};
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
constexpr device::mojom::XRSessionFeature kOculusFeatures[] = {
device::mojom::XRSessionFeature::REF_SPACE_VIEWER,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL,
device::mojom::XRSessionFeature::REF_SPACE_LOCAL_FLOOR,
device::mojom::XRSessionFeature::REF_SPACE_BOUNDED_FLOOR,
};
#endif
bool ContainsFeature(
base::span<const device::mojom::XRSessionFeature> feature_list,
device::mojom::XRSessionFeature feature) {
......@@ -261,11 +252,6 @@ bool BrowserXRRuntimeImpl::SupportsFeature(
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
return ContainsFeature(kGVRDeviceFeatures, feature);
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
return ContainsFeature(kOculusFeatures, feature);
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
return ContainsFeature(kWindowsMixedRealityFeatures, feature);
......@@ -298,10 +284,6 @@ bool BrowserXRRuntimeImpl::SupportsCustomIPD() const {
case device::mojom::XRDeviceId::ORIENTATION_DEVICE_ID:
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
return false;
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
return true;
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
return true;
......@@ -323,9 +305,6 @@ bool BrowserXRRuntimeImpl::SupportsNonEmulatedHeight() const {
case device::mojom::XRDeviceId::ORIENTATION_DEVICE_ID:
return false;
case device::mojom::XRDeviceId::GVR_DEVICE_ID:
#if BUILDFLAG(ENABLE_OCULUS_VR)
case device::mojom::XRDeviceId::OCULUS_DEVICE_ID:
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
case device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID:
#endif
......
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "content/browser/xr/service/xr_runtime_manager_impl.h"
#include "content/public/browser/xr_runtime_manager.h"
#include <string>
#include <utility>
......@@ -19,6 +18,7 @@
#include "content/public/browser/device_service.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_utils.h"
#include "content/public/browser/xr_runtime_manager.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "device/base/features.h"
......@@ -198,12 +198,6 @@ BrowserXRRuntimeImpl* XRRuntimeManagerImpl::GetImmersiveVrRuntime() {
return openxr;
#endif
#if BUILDFLAG(ENABLE_OCULUS_VR)
auto* oculus = GetRuntime(device::mojom::XRDeviceId::OCULUS_DEVICE_ID);
if (oculus)
return oculus;
#endif
#if BUILDFLAG(ENABLE_WINDOWS_MR)
auto* wmr = GetRuntime(device::mojom::XRDeviceId::WINDOWS_MIXED_REALITY_ID);
if (wmr)
......
......@@ -125,7 +125,7 @@ if (enable_vr) {
configs += [ "//third_party/gvr-android-sdk:libgvr_config" ]
}
if (enable_oculus_vr || enable_windows_mr || enable_openxr) {
if (enable_windows_mr || enable_openxr) {
sources += [
"test/test_hook.h",
"windows/compositor_base.cc",
......@@ -133,7 +133,7 @@ if (enable_vr) {
]
}
if (is_win && (enable_oculus_vr || enable_windows_mr || enable_openxr)) {
if (is_win && (enable_windows_mr || enable_openxr)) {
libs = [
"d3d11.lib",
"DXGI.lib",
......@@ -218,21 +218,6 @@ if (enable_vr) {
]
}
if (enable_oculus_vr) {
deps += [ "//third_party/libovr" ]
sources += [
"oculus/oculus_device.cc",
"oculus/oculus_device.h",
"oculus/oculus_gamepad_helper.cc",
"oculus/oculus_gamepad_helper.h",
"oculus/oculus_render_loop.cc",
"oculus/oculus_render_loop.h",
"oculus/oculus_type_converters.cc",
"oculus/oculus_type_converters.h",
]
}
if (enable_openxr) {
deps += [
"//components/version_info",
......
......@@ -7,7 +7,6 @@ include_rules = [
"+services/device/public",
"+services/metrics/public/cpp/ukm_builders.h",
"+third_party/gvr-android-sdk/src",
"+third_party/libovr/src",
"+third_party/skia/include/core/SkColor.h",
"+ui/display",
"+ui/gfx",
......
......@@ -20,7 +20,6 @@ towards OpenXR being the only API used on desktops.
| AR Core | Android | AR | Yes |
| Google VR | Android | VR | Yes |
| Windows Mixed Reality | Windows | VR | No |
| Oculus | Windows | VR | No |
- \* OpenXR may support multiple OSes and AR use cases as well. Currently we
only use it for VR on Windows since that's what the majority of existing
......
......@@ -10,7 +10,6 @@ buildflag_header("buildflags") {
header = "buildflags.h"
flags = [
"ENABLE_ARCORE=$enable_arcore",
"ENABLE_OCULUS_VR=$enable_oculus_vr",
"ENABLE_VR=$enable_vr",
"ENABLE_WINDOWS_MR=$enable_windows_mr",
"ENABLE_OPENXR=$enable_openxr",
......
......@@ -17,19 +17,13 @@ declare_args() {
# To build with OpenXR support, the OpenXR Loader needs to be pulled to
# third_party/openxr.
enable_openxr = checkout_openxr && is_win
# To build with Oculus support, the Oculus SDK for Windows will need to be
# installed in third_party/libovr/src. See
# third_party/libovr/README.chromium for details.
enable_oculus_vr = checkout_oculus_sdk && is_chrome_branded && is_win
}
declare_args() {
# Enable VR device support whenever VR device SDK(s) are supported.
# We enable VR on Linux even though VR features aren't usable because
# the binary size impact is small and allows many VR tests to run on Linux
enable_vr = enable_gvr_services || enable_oculus_vr || enable_windows_mr ||
enable_openxr ||
enable_vr = enable_gvr_services || enable_windows_mr || enable_openxr ||
(is_linux && (current_cpu == "x64" || current_cpu == "x86") &&
!is_chromecast)
......
# Metadata information for this directory.
#
# For more information on DIR_METADATA files, see:
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/README.md
#
# For the schema of this file, see Metadata message:
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/proto/dir_metadata.proto
monorail {
component: "Internals>XR>VR"
}
team_email: "xr-dev@chromium.org"
\ No newline at end of file
per-file *_type_converter*.*=set noparent
per-file *_type_converter*.*=file://ipc/SECURITY_OWNERS
// Copyright (c) 2017 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/oculus/oculus_device.h"
#include <math.h>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/math_constants.h"
#include "build/build_config.h"
#include "device/vr/oculus/oculus_render_loop.h"
#include "device/vr/oculus/oculus_type_converters.h"
#include "device/vr/util/stage_utils.h"
#include "device/vr/util/transform_utils.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
#include "third_party/libovr/src/Include/OVR_CAPI_D3D.h"
#include "ui/gfx/geometry/angle_conversions.h"
namespace device {
namespace {
mojom::VREyeParametersPtr GetEyeDetails(ovrSession session,
const ovrHmdDesc& hmd_desc,
ovrEyeType eye) {
auto eye_parameters = mojom::VREyeParameters::New();
auto render_desc =
ovr_GetRenderDesc(session, eye, hmd_desc.DefaultEyeFov[eye]);
eye_parameters->field_of_view = mojom::VRFieldOfView::New();
eye_parameters->field_of_view->up_degrees =
gfx::RadToDeg(atanf(render_desc.Fov.UpTan));
eye_parameters->field_of_view->down_degrees =
gfx::RadToDeg(atanf(render_desc.Fov.DownTan));
eye_parameters->field_of_view->left_degrees =
gfx::RadToDeg(atanf(render_desc.Fov.LeftTan));
eye_parameters->field_of_view->right_degrees =
gfx::RadToDeg(atanf(render_desc.Fov.RightTan));
// TODO(crbug.com/999353): Query eye-to-head transform from the device and use
// that instead of just building a transformation matrix from the translation
// component. This requireds updating libovr to v1.25 because v1.16 doesn't
// have HmdToEyePose (tracked by crbug.com/999355).
auto offset = render_desc.HmdToEyeOffset;
eye_parameters->head_from_eye =
vr_utils::MakeTranslationTransform(offset.x, offset.y, offset.z);
auto texture_size =
ovr_GetFovTextureSize(session, eye, render_desc.Fov, 1.0f);
eye_parameters->render_width = texture_size.w;
eye_parameters->render_height = texture_size.h;
return eye_parameters;
}
mojom::VRDisplayInfoPtr CreateVRDisplayInfo(ovrSession session) {
mojom::VRDisplayInfoPtr display_info = mojom::VRDisplayInfo::New();
ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session);
display_info->left_eye = GetEyeDetails(session, hmdDesc, ovrEye_Left);
display_info->right_eye = GetEyeDetails(session, hmdDesc, ovrEye_Right);
display_info->stage_parameters = mojom::VRStageParameters::New();
ovr_SetTrackingOriginType(session, ovrTrackingOrigin_FloorLevel);
ovrTrackingState ovr_state = ovr_GetTrackingState(session, 0, true);
float floor_height = ovr_state.HeadPose.ThePose.Position.y;
ovr_SetTrackingOriginType(session, ovrTrackingOrigin_EyeLevel);
gfx::Transform mojo_from_floor;
mojo_from_floor.Translate3d(0, -1 * floor_height, 0);
display_info->stage_parameters->mojo_from_floor = mojo_from_floor;
ovrVector3f boundary_size;
ovr_GetBoundaryDimensions(session, ovrBoundary_PlayArea, &boundary_size);
display_info->stage_parameters->bounds =
vr_utils::GetStageBoundsFromSize(boundary_size.x, boundary_size.z);
return display_info;
}
} // namespace
OculusDevice::OculusDevice()
: VRDeviceBase(mojom::XRDeviceId::OCULUS_DEVICE_ID),
main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
weak_ptr_factory_(this) {
render_loop_ = std::make_unique<OculusRenderLoop>();
}
bool OculusDevice::IsHwAvailable() {
auto result = ovr_Detect(0);
return result.IsOculusHMDConnected;
}
bool OculusDevice::IsApiAvailable() {
auto result = ovr_Detect(0);
return result.IsOculusServiceRunning;
}
mojo::PendingRemote<mojom::XRCompositorHost>
OculusDevice::BindCompositorHost() {
return compositor_host_receiver_.BindNewPipeAndPassRemote();
}
OculusDevice::~OculusDevice() {
// Wait for the render loop to stop before completing destruction. This will
// ensure that bindings are closed on the correct thread.
if (render_loop_ && render_loop_->IsRunning())
render_loop_->Stop();
StopOvrSession();
}
void OculusDevice::RequestSession(
mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) {
if (!EnsureValidDisplayInfo()) {
std::move(callback).Run(nullptr, mojo::NullRemote());
return;
}
DCHECK_EQ(options->mode, mojom::XRSessionMode::kImmersiveVr);
StopOvrSession();
if (!render_loop_->IsRunning()) {
render_loop_->Start();
if (!render_loop_->IsRunning()) {
std::move(callback).Run(nullptr, mojo::NullRemote());
StartOvrSession();
return;
}
if (overlay_receiver_) {
render_loop_->task_runner()->PostTask(
FROM_HERE, base::BindOnce(&XRCompositorCommon::RequestOverlay,
base::Unretained(render_loop_.get()),
std::move(overlay_receiver_)));
}
}
auto on_request_present_result =
base::BindOnce(&OculusDevice::OnRequestSessionResult,
weak_ptr_factory_.GetWeakPtr(), std::move(callback));
auto on_presentation_ended = base::BindOnce(
&OculusDevice::OnPresentationEnded, weak_ptr_factory_.GetWeakPtr());
render_loop_->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&XRCompositorCommon::RequestSession,
base::Unretained(render_loop_.get()),
std::move(on_presentation_ended),
base::DoNothing::Repeatedly<mojom::XRVisibilityState>(),
std::move(options), std::move(on_request_present_result)));
outstanding_session_requests_count_++;
}
bool OculusDevice::EnsureValidDisplayInfo() {
// Ensure we have had a valid display_info set at least once.
if (!have_real_display_info_) {
// Initialize Oculus briefly.
StartOvrSession();
if (!session_) {
return false;
}
SetVRDisplayInfo(CreateVRDisplayInfo(session_));
have_real_display_info_ = true;
}
return have_real_display_info_;
}
void OculusDevice::OnRequestSessionResult(
mojom::XRRuntime::RequestSessionCallback callback,
bool result,
mojom::XRSessionPtr session) {
outstanding_session_requests_count_--;
if (!result) {
std::move(callback).Run(nullptr, mojo::NullRemote());
// Start magic window again.
if (outstanding_session_requests_count_ == 0)
StartOvrSession();
return;
}
OnStartPresenting();
session->display_info = display_info_.Clone();
std::move(callback).Run(
std::move(session),
exclusive_controller_receiver_.BindNewPipeAndPassRemote());
// Unretained is safe because the error handler won't be called after the
// binding has been destroyed.
exclusive_controller_receiver_.set_disconnect_handler(
base::BindOnce(&OculusDevice::OnPresentingControllerMojoConnectionError,
base::Unretained(this)));
}
bool OculusDevice::IsAvailable() {
auto result = ovr_Detect(0);
return result.IsOculusHMDConnected && result.IsOculusServiceRunning;
}
// XRSessionController
void OculusDevice::SetFrameDataRestricted(bool restricted) {
// Presentation sessions can not currently be restricted.
DCHECK(false);
}
void OculusDevice::OnPresentingControllerMojoConnectionError() {
render_loop_->task_runner()->PostTask(
FROM_HERE, base::BindOnce(&XRCompositorCommon::ExitPresent,
base::Unretained(render_loop_.get())));
OnExitPresent();
exclusive_controller_receiver_.reset();
}
void OculusDevice::OnPresentationEnded() {
// If we are no-longer presenting, and there are no outstanding requests to
// start presenting, start the Oculus API to allow magic-window.
if (outstanding_session_requests_count_ == 0)
StartOvrSession();
}
void OculusDevice::StartOvrSession() {
DCHECK_EQ(outstanding_session_requests_count_, 0);
ovrInitParams initParams = {ovrInit_RequestVersion | ovrInit_Invisible,
OVR_MINOR_VERSION, NULL, 0, 0};
ovrResult result = ovr_Initialize(&initParams);
if (OVR_FAILURE(result)) {
return;
}
ovrGraphicsLuid luid;
result = ovr_Create(&session_, &luid);
if (OVR_FAILURE(result)) {
return;
}
}
void OculusDevice::StopOvrSession() {
if (session_) {
// Shut down our current session so the presentation session can begin.
ovr_Destroy(session_);
session_ = nullptr;
ovr_Shutdown();
}
}
void OculusDevice::CreateImmersiveOverlay(
mojo::PendingReceiver<mojom::ImmersiveOverlay> overlay_receiver) {
if (render_loop_->IsRunning()) {
render_loop_->task_runner()->PostTask(
FROM_HERE, base::BindOnce(&XRCompositorCommon::RequestOverlay,
base::Unretained(render_loop_.get()),
std::move(overlay_receiver)));
} else {
overlay_receiver_ = std::move(overlay_receiver);
}
}
} // namespace device
// Copyright 2017 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_OCULUS_OCULUS_DEVICE_H_
#define DEVICE_VR_OCULUS_OCULUS_DEVICE_H_
#include <memory>
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device_base.h"
#include "device/vr/vr_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
namespace device {
class XRCompositorCommon;
class DEVICE_VR_EXPORT OculusDevice
: public VRDeviceBase,
public mojom::XRSessionController,
public mojom::XRCompositorHost {
public:
OculusDevice();
~OculusDevice() override;
static bool IsHwAvailable();
static bool IsApiAvailable();
// VRDeviceBase
void RequestSession(
mojom::XRRuntimeSessionOptionsPtr options,
mojom::XRRuntime::RequestSessionCallback callback) override;
void OnRequestSessionResult(mojom::XRRuntime::RequestSessionCallback callback,
bool result,
mojom::XRSessionPtr session);
bool IsAvailable();
mojo::PendingRemote<mojom::XRCompositorHost> BindCompositorHost();
private:
// XRSessionController
void SetFrameDataRestricted(bool restricted) override;
void OnPresentingControllerMojoConnectionError();
// XRCompositorHost
void CreateImmersiveOverlay(
mojo::PendingReceiver<mojom::ImmersiveOverlay> overlay_receiver) override;
void OnPresentationEnded();
bool EnsureValidDisplayInfo();
void StartOvrSession();
void StopOvrSession();
int outstanding_session_requests_count_ = 0;
bool have_real_display_info_ = false;
std::unique_ptr<XRCompositorCommon> render_loop_;
ovrSession session_ = nullptr;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
mojo::Receiver<mojom::XRSessionController> exclusive_controller_receiver_{
this};
mojo::Receiver<mojom::XRCompositorHost> compositor_host_receiver_{this};
mojo::PendingReceiver<mojom::ImmersiveOverlay> overlay_receiver_;
base::WeakPtrFactory<OculusDevice> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(OculusDevice);
};
} // namespace device
#endif // DEVICE_VR_OCULUS_OCULUS_DEVICE_H_
// Copyright 2017 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/oculus/oculus_gamepad_helper.h"
#include <algorithm>
#include <memory>
#include "base/logging.h"
#include "device/gamepad/public/cpp/gamepads.h"
#include "device/vr/util/xr_standard_gamepad_builder.h"
#include "device/vr/vr_device.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/transform_util.h"
namespace device {
namespace {
float ApplyTriggerDeadzone(float value) {
// Trigger value should be between 0 and 1. We apply a deadzone for small
// values so a loose controller still reports a value of 0 when not in use.
float kTriggerDeadzone = 0.01f;
return (value < kTriggerDeadzone) ? 0 : value;
}
device::mojom::XRHandedness OculusToMojomHand(ovrHandType hand) {
switch (hand) {
case ovrHand_Left:
return device::mojom::XRHandedness::LEFT;
case ovrHand_Right:
return device::mojom::XRHandedness::RIGHT;
default:
return device::mojom::XRHandedness::NONE;
}
}
class OculusGamepadBuilder : public XRStandardGamepadBuilder {
public:
OculusGamepadBuilder(ovrInputState state, ovrHandType hand)
: XRStandardGamepadBuilder(OculusToMojomHand(hand)),
state_(state),
ovr_hand_(hand) {
switch (ovr_hand_) {
case ovrHand_Left:
SetPrimaryButton(GetTouchTriggerButton(ovrTouch_LIndexTrigger,
state_.IndexTrigger[ovr_hand_]));
SetSecondaryButton(GetTriggerButton(state_.HandTrigger[ovr_hand_]));
SetThumbstickData(GetThumbstickData(ovrButton_LThumb));
AddOptionalButtonData(GetStandardButton(ovrButton_X));
AddOptionalButtonData(GetStandardButton(ovrButton_Y));
AddOptionalButtonData(GetTouchButton(ovrTouch_LThumbRest));
break;
case ovrHand_Right:
SetPrimaryButton(GetTouchTriggerButton(ovrTouch_RIndexTrigger,
state_.IndexTrigger[ovr_hand_]));
SetSecondaryButton(GetTriggerButton(state_.HandTrigger[ovr_hand_]));
SetThumbstickData(GetThumbstickData(ovrButton_RThumb));
AddOptionalButtonData(GetStandardButton(ovrButton_A));
AddOptionalButtonData(GetStandardButton(ovrButton_B));
AddOptionalButtonData(GetTouchButton(ovrTouch_RThumbRest));
break;
default:
DLOG(WARNING) << "Unsupported hand configuration.";
}
}
~OculusGamepadBuilder() override = default;
private:
GamepadButton GetStandardButton(ovrButton id) {
bool pressed = (state_.Buttons & id) != 0;
bool touched = (state_.Touches & id) != 0;
double value = pressed ? 1.0 : 0.0;
return GamepadButton(pressed, touched, value);
}
GamepadButton GetTouchButton(ovrTouch id) {
bool touched = (state_.Touches & id) != 0;
return GamepadButton(false, touched, 0.0f);
}
GamepadButton GetTriggerButton(float value) {
value = ApplyTriggerDeadzone(value);
bool pressed = value != 0;
bool touched = pressed;
return GamepadButton(pressed, touched, value);
}
GamepadButton GetTouchTriggerButton(ovrTouch id, float value) {
value = ApplyTriggerDeadzone(value);
bool pressed = value != 0;
bool touched = (state_.Touches & id) != 0;
return GamepadButton(pressed, touched, value);
}
GamepadBuilder::ButtonData GetThumbstickData(ovrButton id) {
GamepadButton button = GetStandardButton(id);
GamepadBuilder::ButtonData data;
data.touched = button.touched;
data.pressed = button.pressed;
data.value = button.value;
// Invert the y axis because -1 is up in the Gamepad API but down in Oculus.
data.type = GamepadBuilder::ButtonData::Type::kThumbstick;
data.x_axis = state_.Thumbstick[ovr_hand_].x;
data.y_axis = -state_.Thumbstick[ovr_hand_].y;
return data;
}
private:
ovrInputState state_;
ovrHandType ovr_hand_;
DISALLOW_COPY_AND_ASSIGN(OculusGamepadBuilder);
};
} // namespace
// Order of buttons 1-4 is dictated by the xr-standard Gamepad mapping.
// Buttons 5-7 are in order of decreasing importance.
// 1) index trigger (primary trigger/button)
// 2) hand trigger (secondary trigger/button)
// 3) EMPTY (no touchpad press)
// 4) thumbstick press
// 5) A or X
// 6) B or Y
// 7) thumbrest touch sensor
//
// Order of axes 1-4 is dictated by the xr-standard Gamepad mapping.
// 1) EMPTY (no touchpad)
// 2) EMPTY (no touchpad)
// 3) thumbstick X
// 4) thumbstick Y
base::Optional<Gamepad> OculusGamepadHelper::CreateGamepad(ovrSession session,
ovrHandType hand) {
ovrInputState input_touch;
bool have_touch = OVR_SUCCESS(
ovr_GetInputState(session, ovrControllerType_Touch, &input_touch));
if (!have_touch) {
return base::nullopt;
}
OculusGamepadBuilder touch(input_touch, hand);
return touch.GetGamepad();
}
} // namespace device
// Copyright 2017 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_OCULUS_OCULUS_GAMEPAD_HELPER_H_
#define DEVICE_VR_OCULUS_OCULUS_GAMEPAD_HELPER_H_
#include "base/optional.h"
#include "device/gamepad/public/cpp/gamepads.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
namespace device {
class OculusGamepadHelper {
public:
static base::Optional<Gamepad> CreateGamepad(ovrSession session,
ovrHandType hand);
};
} // namespace device
#endif // DEVICE_VR_OCULUS_OCULUS_GAMEPAD_HELPER_H_
This diff is collapsed.
// Copyright (c) 2017 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_OCULUS_RENDER_LOOP_H
#define DEVICE_VR_OCULUS_RENDER_LOOP_H
#include "base/memory/scoped_refptr.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "device/vr/vr_device.h"
#include "device/vr/windows/compositor_base.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
#include "ui/gfx/geometry/rect_f.h"
#if defined(OS_WIN)
#include "device/vr/windows/d3d11_texture_helper.h"
#endif
namespace device {
const int kMaxOculusRenderLoopInputId = (ovrControllerType_Remote + 1);
class OculusRenderLoop : public XRCompositorCommon {
public:
OculusRenderLoop();
~OculusRenderLoop() override;
private:
// XRDeviceAbstraction:
mojom::XRFrameDataPtr GetNextFrameData() override;
bool StartRuntime() override;
void StopRuntime() override;
void OnSessionStart() override;
bool PreComposite() override;
bool SubmitCompositedFrame() override;
void OnLayerBoundsChanged() override;
// Helpers to implement XRDeviceAbstraction:
void CreateOvrSwapChain();
void DestroyOvrSwapChain();
std::vector<mojom::XRInputSourceStatePtr> GetInputState(
const ovrTrackingState& tracking_state);
device::mojom::XRInputSourceStatePtr GetTouchData(
ovrControllerType type,
const ovrPoseStatef& pose,
const ovrInputState& input_state,
ovrHandType hand);
long long ovr_frame_index_ = 0;
ovrSession session_ = nullptr;
ovrGraphicsLuid luid_ = {};
ovrPosef last_render_pose_;
ovrTextureSwapChain texture_swap_chain_ = 0;
gfx::Size swap_chain_size_;
double sensor_time_;
bool primary_input_pressed[kMaxOculusRenderLoopInputId];
bool primary_squeeze_pressed[kMaxOculusRenderLoopInputId];
DISALLOW_COPY_AND_ASSIGN(OculusRenderLoop);
};
} // namespace device
#endif // DEVICE_VR_OCULUS_RENDER_LOOP_H
// Copyright (c) 2017 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/oculus/oculus_type_converters.h"
#include <math.h>
#include <iterator>
#include <vector>
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
namespace mojo {
device::mojom::VRPosePtr
TypeConverter<device::mojom::VRPosePtr, ovrPosef>::Convert(
const ovrPosef& hmd_pose) {
device::mojom::VRPosePtr pose = device::mojom::VRPose::New();
pose->orientation =
gfx::Quaternion(hmd_pose.Orientation.x, hmd_pose.Orientation.y,
hmd_pose.Orientation.z, hmd_pose.Orientation.w);
pose->position = gfx::Point3F(hmd_pose.Position.x, hmd_pose.Position.y,
hmd_pose.Position.z);
// TODO: If we want linear/angular velocity, we need to convert a
// ovrPoseStatef.
return pose;
}
} // namespace mojo
// Copyright (c) 2017 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_OPENVR_TYPE_CONVERTERS_H
#define DEVICE_VR_OPENVR_TYPE_CONVERTERS_H
#include "device/vr/public/mojom/vr_service.mojom.h"
#include "third_party/libovr/src/Include/OVR_CAPI.h"
namespace mojo {
template <>
struct TypeConverter<device::mojom::VRPosePtr, ovrPosef> {
static device::mojom::VRPosePtr Convert(const ovrPosef& hmd_pose);
};
} // namespace mojo
#endif // DEVICE_VR_OPENVR_TYPE_CONVERTERS_H
......@@ -25,9 +25,6 @@ mojom_component("mojom") {
]
enabled_features = []
if (enable_oculus_vr) {
enabled_features += [ "enable_oculus_vr" ]
}
if (enable_windows_mr) {
enabled_features += [ "enable_windows_mr" ]
}
......
......@@ -30,7 +30,7 @@ enum XRDeviceId {
ORIENTATION_DEVICE_ID = 2,
GVR_DEVICE_ID = 3,
// OPENVR_DEVICE_ID = 4,
[EnableIf=enable_oculus_vr] OCULUS_DEVICE_ID = 5,
// OCULUS_DEVICE_ID = 5,
[EnableIf=enable_windows_mr] WINDOWS_MIXED_REALITY_ID = 6,
ARCORE_DEVICE_ID = 7,
[EnableIf=enable_openxr] OPENXR_DEVICE_ID = 8,
......
......@@ -24,7 +24,7 @@ enum class VrViewerType {
// OPENVR_UNKNOWN = 20,
// OPENVR_VIVE = 21,
// OPENVR_RIFT_CV1 = 22,
OCULUS_UNKNOWN = 40, // Going through Oculus APIs
// OCULUS_UNKNOWN = 40, // Going through Oculus APIs
WINDOWS_MIXED_REALITY_UNKNOWN = 60, // Going through WMR APIs
OPENXR_UNKNOWN = 70, // Going through OpenXR APIs
};
......
src/**/*.cpp
src/**/*.c
src/**/*.h
\ No newline at end of file
# Copyright 2017 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.
config("libovr-config") {
if (is_clang) {
cflags = [ "-Wno-unused-function" ]
}
}
static_library("libovr") {
include_dirs = [ "src/Include" ]
sources = [
"src/Include/Extras/OVR_CAPI_Util.h",
"src/Include/Extras/OVR_Math.h",
"src/Include/Extras/OVR_StereoProjection.h",
"src/Include/OVR_CAPI.h",
"src/Include/OVR_CAPI_D3D.h",
"src/Include/OVR_CAPI_GL.h",
"src/Include/OVR_CAPI_Keys.h",
"src/Include/OVR_CAPI_Vk.h",
"src/Include/OVR_ErrorCode.h",
"src/Include/OVR_Version.h",
"src/OVR_CAPIShim.c",
"src/OVR_CAPI_Prototypes.h",
"src/OVR_CAPI_Util.cpp",
"src/OVR_StereoProjection.cpp",
]
configs += [ ":libovr-config" ]
}
Copyright © 2014-2017 Oculus VR, LLC. All rights reserved.
\ No newline at end of file
alcooper@chromium.org
bajones@chromium.org
# TEAM: xr-dev@chromium.org
# COMPONENT: Internals>XR>VR
Name: Oculus SDK for Windows
Short Name: libovr
URL: https://developer.oculus.com/downloads/package/oculus-sdk-for-windows/
Version: 1.16.0
License: By exception only
License File: LICENSE
Security Critical: yes
License Android Compatible: no
Description:
The Oculus Windows API supports VR headsets from Oculus running on Windows.
Googler update instructions:
third_party\depot_tools\upload_to_google_storage.py path\to\file.h -b
chrome-oculus-sdk
Then, commit the modified sha1. Only Googlers have access to this bucket. Be
sure to get OWNER approval before adding new files.
Local Modifications:
Only includes headers and a loader shim.
The directory structure of third_party/libovr/src mirrors the LibOVR folder in
the Oculus SDK for Windows.
Oculus-required attribution in LICENSE.
Removed WINCRYPT32API from OVR_CAPIShim.c in order to build with Clang.
Changed OVR_StereoProjection.h to #include "OVR_Math.h" to solve DEP issue.
Changed OVR_CAPI_Util.h to #include "../OVR_CAPI.h" to solve include issue.
Remove extra semicolons.
\ No newline at end of file
1b3ba32d6b56915b0fd179b52edff2f9c0c76de6
\ No newline at end of file
255adc8cab8f72374e5b06dffcd23b38ab81d2da
\ No newline at end of file
24d793cea809395c2006894a50a401ba39b21d1e
\ No newline at end of file
8d53bd779df72eb4195e640ce936fcd992c943c7
\ No newline at end of file
a2b38fcd4d618922ba00b58e024b8ee546b2bc14
\ No newline at end of file
1e0be49c9ba6a622ef33e1623367eb6dfc77977c
\ No newline at end of file
120d1d3d1506c1a47a79045d4c279d760e468629
\ No newline at end of file
89dcbfd32c81a0e1df5c321eea50fa30348ba4a2
\ No newline at end of file
77fc8a13dd9b947a24703eec78639c1c5e862fc3
\ No newline at end of file
4eeb533ee42b199f5f5c57409448ad00485b14e1
\ No newline at end of file
c8235e8e486a73d85a8e1f3221d74f9f93ce2e7c
\ No newline at end of file
0588604435704be9a0017f7a4f9d56b9d8560e8a
\ No newline at end of file
5f3e1e83ce37ba0e6c62156b2aee27607015c4ca
\ No newline at end of file
c245697735368aa7a561e68797fa9304140457b2
\ No newline at end of file
......@@ -428,11 +428,6 @@ PATH_SPECIFIC_WHITELISTED_LICENSES = {
'UNKNOWN',
],
# The following files have a special license.
'third_party/libovr/src': [
'UNKNOWN',
],
# The following files lack license headers, but are trivial.
'third_party/libusb/src/libusb/os/poll_posix.h': [
'UNKNOWN',
......
......@@ -339,7 +339,6 @@ KNOWN_NON_IOS_LIBRARIES = set([
os.path.join('third_party', 'libXNVCtrl'),
os.path.join('third_party', 'libevent'),
os.path.join('third_party', 'libjpeg'),
os.path.join('third_party', 'libovr'),
os.path.join('third_party', 'libusb'),
os.path.join('third_party', 'libxslt'),
os.path.join('third_party', 'lss'),
......
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