Bug 1570075 - WebXR: Extend VRDisplayState and VRDisplayCapabilityFlags r=imanol
authorKearwood "Kip" Gilbert <kgilbert@mozilla.com>
Wed, 31 Jul 2019 11:46:48 +0000
changeset 486014 a6476898a0642d18a816856c9307f9c3c5dc4113
parent 486013 1de6425af33d2397fc35bbb1cd30a51e0ff28d91
child 486015 f173d38fe963073fd746860706e1a763987d5378
push id36380
push userbtara@mozilla.com
push dateSat, 03 Aug 2019 09:46:28 +0000
treeherdermozilla-central@4a49d88894d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersimanol
bugs1570075
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1570075 - WebXR: Extend VRDisplayState and VRDisplayCapabilityFlags r=imanol In order to support the WebXR implementation, VRDisplayState is being extended to enumerate the type of sessions a device supports (Inline, Immersive-VR, or Immersive-AR) and to report if the blend mode for AR would be additive or alpha blended). Differential Revision: https://phabricator.services.mozilla.com/D39916
dom/vr/VRServiceTest.cpp
gfx/vr/external_api/moz_external_vr.h
gfx/vr/service/OSVRSession.cpp
gfx/vr/service/OculusSession.cpp
gfx/vr/service/OpenVRSession.cpp
--- a/dom/vr/VRServiceTest.cpp
+++ b/dom/vr/VRServiceTest.cpp
@@ -82,17 +82,19 @@ void VRMockDisplay::Create() {
   state.isConnected = true;
   state.isMounted = false;
   state.capabilityFlags = VRDisplayCapabilityFlags::Cap_None |
                           VRDisplayCapabilityFlags::Cap_Orientation |
                           VRDisplayCapabilityFlags::Cap_Position |
                           VRDisplayCapabilityFlags::Cap_External |
                           VRDisplayCapabilityFlags::Cap_Present |
                           VRDisplayCapabilityFlags::Cap_StageParameters |
-                          VRDisplayCapabilityFlags::Cap_MountDetection;
+                          VRDisplayCapabilityFlags::Cap_MountDetection |
+                          VRDisplayCapabilityFlags::Cap_ImmersiveVR;
+  state.blendMode = VRDisplayBlendMode::Opaque;
 
   // 1836 x 2040 resolution is arbitrary and can be overridden.
   // This default resolution was chosen to be within range of a
   // typical VR eye buffer size.  This value is derived by
   // scaling a 1080x1200 per-eye panel resolution by the
   // commonly used pre-lens-distortion pass scaling factor of 1.7x.
   // 1.7x is commonly used in HMD's employing fresnel lenses to ensure
   // a sufficient fragment shading rate in the peripheral area of the
--- a/gfx/vr/external_api/moz_external_vr.h
+++ b/gfx/vr/external_api/moz_external_vr.h
@@ -35,17 +35,17 @@ namespace mozilla {
 #ifdef MOZILLA_INTERNAL_API
 namespace dom {
 enum class GamepadHand : uint8_t;
 enum class GamepadCapabilityFlags : uint16_t;
 }  // namespace dom
 #endif  //  MOZILLA_INTERNAL_API
 namespace gfx {
 
-static const int32_t kVRExternalVersion = 8;
+static const int32_t kVRExternalVersion = 9;
 
 // We assign VR presentations to groups with a bitmask.
 // Currently, we will only display either content or chrome.
 // Later, we will have more groups to support VR home spaces and
 // multitasking environments.
 // These values are not exposed to regular content and only affect
 // chrome-only API's.  They may be changed at any time.
 static const uint32_t kVRGroupNone = 0;
@@ -113,16 +113,18 @@ enum class ControllerCapabilityFlags : u
   /**
    * Cap_All used for validity checking during IPC serialization
    */
   Cap_All = (1 << 5) - 1
 };
 
 #endif  // ifndef MOZILLA_INTERNAL_API
 
+enum class VRDisplayBlendMode : uint8_t { Opaque, Additive, AlphaBlend };
+
 enum class VRDisplayCapabilityFlags : uint16_t {
   Cap_None = 0,
   /**
    * Cap_Position is set if the VRDisplay is capable of tracking its position.
    */
   Cap_Position = 1 << 1,
   /**
    * Cap_Orientation is set if the VRDisplay is capable of tracking its
@@ -167,23 +169,41 @@ enum class VRDisplayCapabilityFlags : ui
   Cap_MountDetection = 1 << 8,
   /**
    * Cap_PositionEmulated is set if the VRDisplay is capable of setting a
    * emulated position (e.g. neck model) even if still doesn't support 6DOF
    * tracking.
    */
   Cap_PositionEmulated = 1 << 9,
   /**
+   * Cap_Inline is set if the device can be used for WebXR inline sessions
+   * where the content is displayed within an element on the page.
+   */
+  Cap_Inline = 1 << 10,
+  /**
+   * Cap_ImmersiveVR is set if the device can give exclusive access to the
+   * XR device display and that content is not intended to be integrated
+   * with the user's environment
+   */
+  Cap_ImmersiveVR = 1 << 11,
+  /**
+   * Cap_ImmersiveAR is set if the device can give exclusive access to the
+   * XR device display and that content is intended to be integrated with
+   * the user's environment.
+   */
+  Cap_ImmersiveAR = 1 << 12,
+  /**
    * Cap_All used for validity checking during IPC serialization
    */
-  Cap_All = (1 << 10) - 1
+  Cap_All = (1 << 13) - 1
 };
 
 #ifdef MOZILLA_INTERNAL_API
 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VRDisplayCapabilityFlags)
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VRDisplayBlendMode)
 #endif  // MOZILLA_INTERNAL_API
 
 struct VRPose {
   float orientation[4];
   float position[3];
   float angularVelocity[3];
   float angularAcceleration[3];
   float linearVelocity[3];
@@ -270,16 +290,17 @@ struct VRDisplayState {
   uint32_t minRestartInterval;
   char displayName[kVRDisplayNameMaxLen];
   // eight byte character code identifier
   // LSB first, so "ABCDEFGH" -> ('H'<<56) + ('G'<<48) + ('F'<<40) +
   //                             ('E'<<32) + ('D'<<24) + ('C'<<16) +
   //                             ('B'<<8) + 'A').
   uint64_t eightCC;
   VRDisplayCapabilityFlags capabilityFlags;
+  VRDisplayBlendMode blendMode;
   VRFieldOfView eyeFOV[VRDisplayState::NumEyes];
   Point3D_POD eyeTranslation[VRDisplayState::NumEyes];
   IntSize_POD eyeResolution;
   bool suppressFrames;
   bool isConnected;
   bool isMounted;
   FloatSize_POD stageSize;
   // We can't use a Matrix4x4 here unless we ensure it's a POD type
--- a/gfx/vr/service/OSVRSession.cpp
+++ b/gfx/vr/service/OSVRSession.cpp
@@ -341,17 +341,19 @@ bool OSVRSession::InitState(mozilla::gfx
   state.eightCC = GFX_VR_EIGHTCC('O', 'S', 'V', 'R', ' ', ' ', ' ', ' ');
   state.isConnected = true;
   state.isMounted = false;
   state.capabilityFlags = (VRDisplayCapabilityFlags)(
       (int)VRDisplayCapabilityFlags::Cap_None |
       (int)VRDisplayCapabilityFlags::Cap_Orientation |
       (int)VRDisplayCapabilityFlags::Cap_Position |
       (int)VRDisplayCapabilityFlags::Cap_External |
-      (int)VRDisplayCapabilityFlags::Cap_Present);
+      (int)VRDisplayCapabilityFlags::Cap_Present |
+      (int)VRDisplayCapabilityFlags::Cap_ImmersiveVR);
+  state.blendMode = VRDisplayBlendMode::Opaque;
   state.reportsDroppedFrames = false;
 
   // XXX OSVR display topology allows for more than one viewer
   // will assume only one viewer for now (most likely stay that way)
 
   OSVR_EyeCount numEyes;
   osvr_ClientGetNumEyesForViewer(m_display, 0, &numEyes);
 
--- a/gfx/vr/service/OculusSession.cpp
+++ b/gfx/vr/service/OculusSession.cpp
@@ -1007,16 +1007,18 @@ bool OculusSession::InitState(VRSystemSt
   if (desc.AvailableTrackingCaps & ovrTrackingCap_Position) {
     state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_Position;
     state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_LinearAcceleration;
     state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_StageParameters;
   }
   state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_External;
   state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_MountDetection;
   state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_Present;
+  state.capabilityFlags |= VRDisplayCapabilityFlags::Cap_ImmersiveVR;
+  state.blendMode = VRDisplayBlendMode::Opaque;
   state.reportsDroppedFrames = true;
 
   mFOVPort[VRDisplayState::Eye_Left] = desc.DefaultEyeFov[ovrEye_Left];
   mFOVPort[VRDisplayState::Eye_Right] = desc.DefaultEyeFov[ovrEye_Right];
 
   state.eyeFOV[VRDisplayState::Eye_Left] =
       FromFovPort(mFOVPort[VRDisplayState::Eye_Left]);
   state.eyeFOV[VRDisplayState::Eye_Right] =
--- a/gfx/vr/service/OpenVRSession.cpp
+++ b/gfx/vr/service/OpenVRSession.cpp
@@ -889,17 +889,19 @@ bool OpenVRSession::InitState(VRSystemSt
       mVRSystem->IsTrackedDeviceConnected(::vr::k_unTrackedDeviceIndex_Hmd);
   state.isMounted = false;
   state.capabilityFlags = (VRDisplayCapabilityFlags)(
       (int)VRDisplayCapabilityFlags::Cap_None |
       (int)VRDisplayCapabilityFlags::Cap_Orientation |
       (int)VRDisplayCapabilityFlags::Cap_Position |
       (int)VRDisplayCapabilityFlags::Cap_External |
       (int)VRDisplayCapabilityFlags::Cap_Present |
-      (int)VRDisplayCapabilityFlags::Cap_StageParameters);
+      (int)VRDisplayCapabilityFlags::Cap_StageParameters |
+      (int)VRDisplayCapabilityFlags::Cap_ImmersiveVR);
+  state.blendMode = VRDisplayBlendMode::Opaque;
   state.reportsDroppedFrames = true;
 
   ::vr::ETrackedPropertyError err;
   bool bHasProximitySensor = mVRSystem->GetBoolTrackedDeviceProperty(
       ::vr::k_unTrackedDeviceIndex_Hmd, ::vr::Prop_ContainsProximitySensor_Bool,
       &err);
   if (err == ::vr::TrackedProp_Success && bHasProximitySensor) {
     state.capabilityFlags = (VRDisplayCapabilityFlags)(