Changeset 263503 in webkit
- Timestamp:
- Jun 25, 2020 3:49:42 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r263500 r263503 1 2020-06-23 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Check device orientation support when requesting a reference space 4 https://bugs.webkit.org/show_bug.cgi?id=213519 5 6 Reviewed by Carlos Garcia Campos. 7 8 When requesting a local reference space the specs mandate us to check whether or not the device 9 supports orientation tracking. This was not implemented in the OpenXR backend, so we were unconditionally 10 returning true. 11 12 The OpenXR devices now properly check whether or not orientation tracking is initialized. We took the chance 13 to refactor a bit the OpenXR backend moving all the device initialization code to the OpenXRDevice class. 14 15 The current tests already check this functionality. 16 17 * Modules/webxr/WebXRSession.cpp: 18 (WebCore::WebXRSession::referenceSpaceIsSupported const): Call supportsOrientationTracking() on device. 19 * platform/xr/PlatformXR.h: 20 (PlatformXR::Device::supportsOrientationTracking const): Added. 21 * platform/xr/openxr/PlatformXROpenXR.cpp: 22 (PlatformXR::Instance::enumerateImmersiveXRDevices): Just create the OpenXR device, it will automatically 23 initialize itself. 24 (PlatformXR::OpenXRDevice::OpenXRDevice): Get XrSystem and XrInstance as parametters. 25 (PlatformXR::OpenXRDevice::collectSupportedSessionModes): Moved from Instance::Impl. 26 (PlatformXR::Instance::Impl::collectSupportedSessionModes): Deleted. 27 * platform/xr/openxr/PlatformXROpenXR.h: 28 * testing/WebFakeXRDevice.h: Mark the SimulatedXRDevice as supporting orientation tracking. 29 1 30 2020-06-24 James Savage <james.savage@apple.com> 2 31 -
trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp
r263256 r263503 109 109 110 110 // 4. If type is local or local-floor, and the XR device supports reporting orientation data, return true. 111 // TODO: add API to PlatformXR::Device 112 return true; 113 } 114 111 if (m_device->supportsOrientationTracking()) 112 return true; 113 } 115 114 116 115 // 5. If type is bounded-floor and session is an immersive session, return the result of whether bounded -
trunk/Source/WebCore/platform/xr/PlatformXR.h
r263447 r263503 54 54 ListOfEnabledFeatures enabledFeatures(SessionMode mode) const { return m_enabledFeaturesMap.get(mode); } 55 55 56 bool supportsOrientationTracking() const { return m_supportsOrientationTracking; } 57 56 58 protected: 57 59 Device() = default; … … 62 64 using EnabledFeaturesPerModeMap = WTF::HashMap<SessionMode, ListOfEnabledFeatures, WTF::IntHash<SessionMode>, WTF::StrongEnumHashTraits<SessionMode>>; 63 65 EnabledFeaturesPerModeMap m_enabledFeaturesMap; 66 67 bool m_supportsOrientationTracking { false }; 64 68 }; 65 69 -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp
r263447 r263503 169 169 #if USE_OPENXR 170 170 171 Optional<Vector<SessionMode>> Instance::Impl::collectSupportedSessionModes(OpenXRDevice& device)172 {173 uint32_t viewConfigurationCount;174 auto result = xrEnumerateViewConfigurations(m_instance, device.xrSystemId(), 0, &viewConfigurationCount, nullptr);175 if (result != XR_SUCCESS) {176 LOG(XR, "xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data());177 return WTF::nullopt;178 }179 180 XrViewConfigurationType viewConfigurations[viewConfigurationCount];181 result = xrEnumerateViewConfigurations(m_instance, device.xrSystemId(), viewConfigurationCount, &viewConfigurationCount, viewConfigurations);182 if (result != XR_SUCCESS) {183 LOG(XR, "xrEnumerateViewConfigurations(): error %s\n", resultToString(result, m_instance).utf8().data());184 return WTF::nullopt;185 }186 187 Vector<SessionMode> supportedModes;188 for (uint32_t i = 0; i < viewConfigurationCount; ++i) {189 auto viewConfigurationProperties = createStructure<XrViewConfigurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES>();190 result = xrGetViewConfigurationProperties(m_instance, device.xrSystemId(), viewConfigurations[i], &viewConfigurationProperties);191 if (result != XR_SUCCESS) {192 LOG(XR, "xrGetViewConfigurationProperties(): error %s\n", resultToString(result, m_instance).utf8().data());193 return WTF::nullopt;194 }195 switch (viewConfigurationProperties.viewConfigurationType) {196 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO:197 supportedModes.append(SessionMode::ImmersiveAr);198 break;199 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO:200 supportedModes.append(SessionMode::ImmersiveVr);201 break;202 default:203 break;204 };205 }206 return supportedModes;207 }208 209 171 #endif // USE_OPENXR 210 172 … … 238 200 XrSystemId systemId; 239 201 XrResult result = xrGetSystem(m_impl->xrInstance(), &systemGetInfo, &systemId); 240 if (result != XR_SUCCESS) { 241 LOG(XR, "xrGetSystem(): error %s\n", resultToString(result, m_impl->xrInstance()).utf8().data()); 242 return; 243 } 244 245 auto device = makeUnique<OpenXRDevice>(); 246 device->setXrSystemId(systemId); 247 auto sessionModes = m_impl->collectSupportedSessionModes(*device); 248 if (sessionModes) { 249 for (auto& mode : sessionModes.value()) { 250 // TODO: fill in features 251 device->setEnabledFeatures(mode, { }); 202 RETURN_IF_FAILED(result, "xrGetSystem", m_impl->xrInstance()); 203 204 m_immersiveXRDevices.append(makeUnique<OpenXRDevice>(systemId, m_impl->xrInstance())); 205 #endif // USE_OPENXR 206 } 207 208 OpenXRDevice::OpenXRDevice(XrSystemId id, XrInstance instance) 209 : m_systemId(id) 210 , m_instance(instance) 211 { 212 auto systemProperties = createStructure<XrSystemProperties, XR_TYPE_SYSTEM_PROPERTIES>(); 213 XrResult result = xrGetSystemProperties(instance, m_systemId, &systemProperties); 214 if (result == XR_SUCCESS) 215 m_supportsOrientationTracking = systemProperties.trackingProperties.orientationTracking == XR_TRUE; 216 else 217 LOG(XR, "xrGetSystemProperties(): error %s\n", resultToString(result, m_impl->xrInstance()).utf8().data()); 218 219 collectSupportedSessionModes(); 220 } 221 222 void OpenXRDevice::collectSupportedSessionModes() 223 { 224 uint32_t viewConfigurationCount; 225 auto result = xrEnumerateViewConfigurations(m_instance, m_systemId, 0, &viewConfigurationCount, nullptr); 226 RETURN_IF_FAILED(result, "xrEnumerateViewConfigurations", m_instance); 227 228 XrViewConfigurationType viewConfigurations[viewConfigurationCount]; 229 result = xrEnumerateViewConfigurations(m_instance, m_systemId, viewConfigurationCount, &viewConfigurationCount, viewConfigurations); 230 RETURN_IF_FAILED(result, "xrEnumerateViewConfigurations", m_instance); 231 232 for (uint32_t i = 0; i < viewConfigurationCount; ++i) { 233 auto viewConfigurationProperties = createStructure<XrViewConfigurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES>(); 234 result = xrGetViewConfigurationProperties(m_instance, m_systemId, viewConfigurations[i], &viewConfigurationProperties); 235 if (result != XR_SUCCESS) { 236 LOG(XR, "xrGetViewConfigurationProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); 237 continue; 252 238 } 253 } 254 255 m_immersiveXRDevices.append(WTFMove(device)); 256 #endif // USE_OPENXR 239 switch (viewConfigurationProperties.viewConfigurationType) { 240 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO: 241 setEnabledFeatures(SessionMode::ImmersiveAr, { }); 242 break; 243 case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO: 244 setEnabledFeatures(SessionMode::ImmersiveVr, { }); 245 break; 246 default: 247 break; 248 }; 249 } 257 250 } 258 251 -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h
r262838 r263503 42 42 class OpenXRDevice final : public Device { 43 43 public: 44 void setXrSystemId(XrSystemId id) { m_systemId = id; }44 OpenXRDevice(XrSystemId, XrInstance); 45 45 XrSystemId xrSystemId() const { return m_systemId; } 46 46 private: 47 void collectSupportedSessionModes(); 48 47 49 XrSystemId m_systemId; 50 XrInstance m_instance; 48 51 }; 49 52 -
trunk/Source/WebCore/testing/WebFakeXRDevice.h
r262188 r263503 64 64 WTF_MAKE_FAST_ALLOCATED; 65 65 public: 66 SimulatedXRDevice() { m_supportsOrientationTracking = true; } 66 67 void setNativeBoundsGeometry(Vector<FakeXRBoundsPoint> geometry) { m_nativeBoundsGeometry = geometry; } 67 68 void setViewerOrigin(RefPtr<WebXRRigidTransform>&& origin) { m_viewerOrigin = WTFMove(origin); }
Note: See TracChangeset
for help on using the changeset viewer.