Changeset 271288 in webkit
- Timestamp:
- Jan 8, 2021 1:59:25 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r271284 r271288 1 2020-09-24 Sergio Villar Senin <svillar@igalia.com> 2 3 [WebXR] Initial implemention of device initialization/shutdown with OpenXR 4 https://bugs.webkit.org/show_bug.cgi?id=216925 5 6 Reviewed by Darin Adler. 7 8 Added a very basic initialization and shutdown processes of XR devices using OpenXR. So far we're just creating and destroying 9 the XR session. Follow up patches will add the required machinery to get frame data from OpenXR. 10 11 * Modules/webxr/WebXRSession.cpp: 12 (WebCore::WebXRSession::WebXRSession): Call initializeTrackingAndRendering(). 13 (WebCore::WebXRSession::~WebXRSession): Call shutdownTrackingAndRendering(). 14 (WebCore::WebXRSession::shutdown): Ditto. 15 * Modules/webxr/WebXRSystem.h: 16 * platform/xr/PlatformXR.h: New virtual methods to initialize/shutdown devices. 17 * platform/xr/openxr/PlatformXROpenXR.cpp: 18 (PlatformXR::OpenXRDevice::OpenXRDevice): Initialize m_session. 19 (PlatformXR::OpenXRDevice::~OpenXRDevice): Call shutdownTrackingAndRendering(). 20 (PlatformXR::toXrViewConfigurationType): New method. Translates from SessionMode to XrViewConfigurationType. 21 (PlatformXR::OpenXRDevice::initializeTrackingAndRendering): New method. Creates a session with a given mode. 22 (PlatformXR::OpenXRDevice::resetSession): Destroys session. 23 (PlatformXR::OpenXRDevice::shutdownTrackingAndRendering): 24 * platform/xr/openxr/PlatformXROpenXR.h: 25 * testing/WebFakeXRDevice.h: Added empty implementations for the new virtual methods. 26 1 27 2021-01-07 Zalan Bujtas <zalan@apple.com> 2 28 -
trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp
r266782 r271288 58 58 , m_animationTimer(*this, &WebXRSession::animationTimerFired) 59 59 { 60 // FIXME: If no other features of the user agent have done so already, perform the necessary platform-specific steps to61 // initialize the device's tracking and rendering capabilities, including showing any necessary instructions to the user. 60 m_device->initializeTrackingAndRendering(mode); 61 62 62 suspendIfNeeded(); 63 63 } 64 64 65 WebXRSession::~WebXRSession() = default; 65 WebXRSession::~WebXRSession() 66 { 67 if (!m_ended && m_device) 68 m_device->shutDownTrackingAndRendering(); 69 } 66 70 67 71 XREnvironmentBlendMode WebXRSession::environmentBlendMode() const … … 330 334 // 6.2. Deallocating any graphics resources acquired by session for presentation to the XR device. 331 335 // 6.3. Putting the XR device in a state such that a different source may be able to initiate a session with the same device if session is an immersive session. 336 if (m_device) 337 m_device->shutDownTrackingAndRendering(); 338 332 339 // 7. Queue a task that fires an XRSessionEvent named end on session. 333 340 auto event = XRSessionEvent::create(eventNames().endEvent, { makeRefPtr(*this) }); … … 343 350 // 1. Let promise be a new Promise. 344 351 // 2. Shut down the target XRSession object. 345 shutdown(); 352 if (!m_ended) 353 shutdown(); 346 354 347 355 // 3. Queue a task to perform the following steps: -
trunk/Source/WebCore/Modules/webxr/WebXRSystem.h
r270067 r271288 108 108 public: 109 109 DummyInlineDevice(); 110 111 private: 112 void initializeTrackingAndRendering(PlatformXR::SessionMode) final { } 113 void shutDownTrackingAndRendering() final { } 110 114 }; 111 115 DummyInlineDevice m_defaultInlineDevice; -
trunk/Source/WebCore/platform/xr/PlatformXR.h
r269032 r271288 60 60 bool supportsOrientationTracking() const { return m_supportsOrientationTracking; } 61 61 62 virtual void initializeTrackingAndRendering(SessionMode) = 0; 63 virtual void shutDownTrackingAndRendering() = 0; 64 62 65 protected: 63 66 Device() = default; -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp
r270067 r271288 25 25 #include "Logging.h" 26 26 #include <openxr/openxr_platform.h> 27 #include <wtf/NeverDestroyed.h> 27 28 #include <wtf/Optional.h> 28 29 #include <wtf/Scope.h> 29 30 #include <wtf/text/StringConcatenateNumbers.h> 30 31 #include <wtf/text/WTFString.h> 31 #include <wtf/NeverDestroyed.h>32 32 33 33 using namespace WebCore; … … 54 54 } 55 55 56 #define RETURN_IF_FAILED(result, call, instance, ...) 57 if (XR_FAILED(result)) { 58 LOG(XR, "%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); 59 return __VA_ARGS__; 60 } \56 #define RETURN_IF_FAILED(result, call, instance, ...) \ 57 if (XR_FAILED(result)) { \ 58 LOG(XR, "%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); \ 59 return __VA_ARGS__; \ 60 } 61 61 62 62 struct Instance::Impl { 63 WTF_MAKE_ FAST_ALLOCATED;64 public: 63 WTF_MAKE_STRUCT_FAST_ALLOCATED; 64 65 65 Impl(); 66 66 ~Impl(); … … 259 259 callOnMainThread(WTFMove(callback)); 260 260 }); 261 } 262 263 OpenXRDevice::~OpenXRDevice() 264 { 265 shutDownTrackingAndRendering(); 261 266 } 262 267 … … 378 383 } 379 384 385 XrViewConfigurationType toXrViewConfigurationType(SessionMode mode) 386 { 387 switch (mode) { 388 case SessionMode::ImmersiveVr: 389 return XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; 390 case SessionMode::Inline: 391 case SessionMode::ImmersiveAr: 392 return XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO; 393 }; 394 ASSERT_NOT_REACHED(); 395 return XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO; 396 } 397 398 void OpenXRDevice::initializeTrackingAndRendering(SessionMode mode) 399 { 400 m_queue.dispatch([this, mode]() { 401 ASSERT(m_instance != XR_NULL_HANDLE); 402 ASSERT(m_session == XR_NULL_HANDLE); 403 404 m_currentViewConfigurationType = toXrViewConfigurationType(mode); 405 ASSERT(m_configurationViews.contains(m_currentViewConfigurationType)); 406 407 // Create the session. 408 auto sessionCreateInfo = createStructure<XrSessionCreateInfo, XR_TYPE_SESSION_CREATE_INFO>(); 409 sessionCreateInfo.systemId = m_systemId; 410 auto result = xrCreateSession(m_instance, &sessionCreateInfo, &m_session); 411 RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties", m_instance); 412 }); 413 } 414 415 void OpenXRDevice::resetSession() 416 { 417 m_queue.dispatch([this]() { 418 if (m_session == XR_NULL_HANDLE) 419 return; 420 xrDestroySession(m_session); 421 m_session = XR_NULL_HANDLE; 422 }); 423 } 424 425 void OpenXRDevice::shutDownTrackingAndRendering() 426 { 427 resetSession(); 428 } 429 380 430 } // namespace PlatformXR 381 431 -
trunk/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h
r270067 r271288 45 45 public: 46 46 OpenXRDevice(XrSystemId, XrInstance, WorkQueue&, CompletionHandler<void()>&&); 47 ~OpenXRDevice(); 47 48 XrSystemId xrSystemId() const { return m_systemId; } 48 49 … … 55 56 WebCore::IntSize recommendedResolution(SessionMode) final; 56 57 58 void initializeTrackingAndRendering(SessionMode) final; 59 void shutDownTrackingAndRendering() final; 60 61 void resetSession(); 62 57 63 using ViewConfigurationPropertiesMap = HashMap<XrViewConfigurationType, XrViewConfigurationProperties, IntHash<XrViewConfigurationType>, WTF::StrongEnumHashTraits<XrViewConfigurationType>>; 58 64 ViewConfigurationPropertiesMap m_viewConfigurationProperties; … … 62 68 XrSystemId m_systemId; 63 69 XrInstance m_instance; 64 XrSession m_session ;70 XrSession m_session { XR_NULL_HANDLE }; 65 71 66 72 WorkQueue& m_queue; 73 74 XrViewConfigurationType m_currentViewConfigurationType; 67 75 }; 68 76 -
trunk/Source/WebCore/testing/WebFakeXRDevice.h
r264568 r271288 71 71 Vector<Ref<FakeXRView>>& views() { return m_views; } 72 72 private: 73 void initializeTrackingAndRendering(PlatformXR::SessionMode) final { } 74 void shutDownTrackingAndRendering() final { } 73 75 Optional<Vector<FakeXRBoundsPoint>> m_nativeBoundsGeometry; 74 76 RefPtr<WebXRRigidTransform> m_viewerOrigin;
Note: See TracChangeset
for help on using the changeset viewer.