WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-214187-20200710170614.patch (text/plain), 14.86 KB, created by
Sergio Villar Senin
on 2020-07-10 08:06:16 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sergio Villar Senin
Created:
2020-07-10 08:06:16 PDT
Size:
14.86 KB
patch
obsolete
>Subversion Revision: 264218 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7ad635e57fa8295575e3f33189ef82b5981bd26c..795f6cd9d5abb401217e25616d2fffd45bd39df4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2020-07-10 Sergio Villar Senin <svillar@igalia.com> >+ >+ [WebXR] Retrieve supported reference spaces from actual XR systems >+ https://bugs.webkit.org/show_bug.cgi?id=214187 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Each XR system supports a set of reference spaces which are used by WebXR to stablish >+ a spatial relationship with user's physical environment. The list of supported reference >+ spaces determine whether or not a session request succeeds or not, as it will refuse to >+ start a session with an unsupported reference space. >+ >+ So far, no reference spaces were retrieved from the actual devices. This patch adds the >+ required OpenXR machinery to retrieve them. In particular, we have to create a XrSession >+ (although we don't have to start it) in order to retrieve the reference spaces. Since we >+ don't need it to show content to the user we can create it in headless mode and then discard >+ it afterwards when no longer needed. >+ >+ * Modules/webxr/WebXRSession.cpp: >+ (WebCore::WebXRSession::WebXRSession): Clarify a comment. Also s/TODO/FIXME/g. >+ * platform/xr/openxr/PlatformXROpenXR.cpp: >+ (PlatformXR::isExtensionSupported): New method to check whether a specific extension >+ is supported. >+ (PlatformXR::Instance::Impl::checkInstanceExtensionProperties const): renamed from >+ enumerateInstanceExtensionProperties(). Returns whether or not the call succeeded. >+ (PlatformXR::Instance::Impl::Impl): Pass the list of enabled extensions to the instance. >+ (PlatformXR::Instance::enumerateImmersiveXRDevices): Log the systems found. >+ (PlatformXR::OpenXRDevice::OpenXRDevice): >+ (PlatformXR::OpenXRDevice::enumerateReferenceSpaces const): New method to list the >+ supported reference spaces by the XR system. >+ (PlatformXR::OpenXRDevice::collectSupportedSessionModes): Store reference spaces as >+ enabled features for supported modes. >+ (PlatformXR::OpenXRDevice::collectConfigurationViews): Renamed from >+ enumerateConfigurationViews(). >+ (PlatformXR::Instance::Impl::enumerateInstanceExtensionProperties const): Deleted. >+ (PlatformXR::OpenXRDevice::enumerateConfigurationViews): Deleted. >+ * platform/xr/openxr/PlatformXROpenXR.h: >+ > 2020-07-10 Zalan Bujtas <zalan@apple.com> > > [LFC][TreeConstruction] Create block level container for unsupported renderer >diff --git a/Source/WebCore/Modules/webxr/WebXRSession.cpp b/Source/WebCore/Modules/webxr/WebXRSession.cpp >index a33131a2e5e07d5a157cb71e2266a9fdb10c9a84..5f3a60146b6e441cc4107ac42d565604de9c67c2 100644 >--- a/Source/WebCore/Modules/webxr/WebXRSession.cpp >+++ b/Source/WebCore/Modules/webxr/WebXRSession.cpp >@@ -52,10 +52,8 @@ WebXRSession::WebXRSession(Document& document, WebXRSystem& system, XRSessionMod > , m_activeRenderState(WebXRRenderState::create(mode)) > , m_animationTimer(*this, &WebXRSession::animationTimerFired) > { >- // TODO: If no other features of the user agent have done so already, >- // perform the necessary platform-specific steps to initialize the device's >- // tracking and rendering capabilities, including showing any necessary >- // instructions to the user. >+ // FIXME: If no other features of the user agent have done so already, perform the necessary platform-specific steps to >+ // initialize the device's tracking and rendering capabilities, including showing any necessary instructions to the user. > suspendIfNeeded(); > } > >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >index 1a7efc48c5f63b774c5f628a9bf80c6317ac8d31..4b8ac74e81d7855a65fb484f2300b46e366d2b5f 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.cpp >@@ -24,6 +24,7 @@ > > #include "Logging.h" > #if USE_OPENXR >+#include <openxr/openxr_platform.h> > #include <wtf/Optional.h> > #include <wtf/text/StringConcatenateNumbers.h> > #include <wtf/text/WTFString.h> >@@ -55,10 +56,10 @@ String resultToString(XrResult value, XrInstance instance) > return makeString("<unknown ", int(value), ">"); > } > >-#define RETURN_IF_FAILED(result, call, instance) \ >+#define RETURN_IF_FAILED(result, call, instance, ...) \ > if (XR_FAILED(result)) { \ >- LOG(XR, "%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); \ >- return; \ >+ LOG(XR, "%s %s: %s\n", __func__, call, resultToString(result, instance).utf8().data()); \ >+ return __VA_ARGS__; \ > } \ > > #endif // USE_OPENXR >@@ -76,7 +77,7 @@ public: > private: > #if USE_OPENXR > void enumerateApiLayerProperties() const; >- void enumerateInstanceExtensionProperties() const; >+ bool checkInstanceExtensionProperties() const; > > XrInstance m_instance { XR_NULL_HANDLE }; > #endif // USE_OPENXR >@@ -107,14 +108,23 @@ void Instance::Impl::enumerateApiLayerProperties() const > LOG(XR, "xrEnumerateApiLayerProperties(): %zu properties\n", properties.size()); > } > >-void Instance::Impl::enumerateInstanceExtensionProperties() const >+static bool isExtensionSupported(const char* extensionName, Vector<XrExtensionProperties>& instanceExtensionProperties) >+{ >+ auto position = instanceExtensionProperties.findMatching([extensionName](auto& property) { >+ return !strcmp(property.extensionName, extensionName); >+ }); >+ return position != notFound; >+} >+ >+bool Instance::Impl::checkInstanceExtensionProperties() const > { > uint32_t propertyCountOutput { 0 }; > XrResult result = xrEnumerateInstanceExtensionProperties(nullptr, 0, &propertyCountOutput, nullptr); >- RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >+ RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties", m_instance, false); >+ > if (!propertyCountOutput) { > LOG(XR, "xrEnumerateInstanceExtensionProperties(): no properties\n"); >- return; >+ return false; > } > > Vector<XrExtensionProperties> properties(propertyCountOutput, >@@ -127,12 +137,18 @@ void Instance::Impl::enumerateInstanceExtensionProperties() const > > uint32_t propertyCountWritten { 0 }; > result = xrEnumerateInstanceExtensionProperties(nullptr, propertyCountOutput, &propertyCountWritten, properties.data()); >- RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties()", m_instance); >+ RETURN_IF_FAILED(result, "xrEnumerateInstanceExtensionProperties", m_instance, false); >+#if !LOG_DISABLED > LOG(XR, "xrEnumerateInstanceExtensionProperties(): %zu extension properties\n", properties.size()); >- for (auto& property : properties) { >- LOG(XR, " extension '%s', version %u\n", >- property.extensionName, property.extensionVersion); >+ for (auto& property : properties) >+ LOG(XR, " extension '%s', version %u\n", property.extensionName, property.extensionVersion); >+#endif >+ if (!isExtensionSupported(XR_MND_HEADLESS_EXTENSION_NAME, properties)) { >+ LOG(XR, "Required extension %s not supported", XR_MND_HEADLESS_EXTENSION_NAME); >+ return false; > } >+ >+ return true; > } > #endif // USE_OPENXR > >@@ -142,18 +158,25 @@ Instance::Impl::Impl() > LOG(XR, "OpenXR: initializing\n"); > > enumerateApiLayerProperties(); >- enumerateInstanceExtensionProperties(); >+ >+ if (!checkInstanceExtensionProperties()) >+ return; > > static const char* s_applicationName = "WebXR (WebKit)"; > static const uint32_t s_applicationVersion = 1; > >+ const char* const enabledExtensions[] = { >+ XR_MND_HEADLESS_EXTENSION_NAME, >+ }; >+ > auto createInfo = createStructure<XrInstanceCreateInfo, XR_TYPE_INSTANCE_CREATE_INFO>(); > createInfo.createFlags = 0; > std::memcpy(createInfo.applicationInfo.applicationName, s_applicationName, XR_MAX_APPLICATION_NAME_SIZE); > createInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; > createInfo.applicationInfo.applicationVersion = s_applicationVersion; > createInfo.enabledApiLayerCount = 0; >- createInfo.enabledExtensionCount = 0; >+ createInfo.enabledExtensionCount = sizeof(enabledExtensions) / sizeof(char*); >+ createInfo.enabledExtensionNames = enabledExtensions; > > XrInstance instance; > XrResult result = xrCreateInstance(&createInfo, &instance); >@@ -202,6 +225,13 @@ void Instance::enumerateImmersiveXRDevices() > XrResult result = xrGetSystem(m_impl->xrInstance(), &systemGetInfo, &systemId); > RETURN_IF_FAILED(result, "xrGetSystem", m_impl->xrInstance()); > >+#if !LOG_DISABLED >+ auto systemProperties = createStructure<XrSystemProperties, XR_TYPE_SYSTEM_PROPERTIES>(); >+ result = xrGetSystemProperties(m_impl->xrInstance(), systemId, &systemProperties); >+ if (result == XR_SUCCESS) >+ LOG(XR, "Found XRSystem %lu: \"%s\", vendor ID %d\n", systemProperties.systemId, systemProperties.systemName, systemProperties.vendorId); >+#endif >+ > m_immersiveXRDevices.append(makeUnique<OpenXRDevice>(systemId, m_impl->xrInstance())); > #endif // USE_OPENXR > } >@@ -219,7 +249,46 @@ OpenXRDevice::OpenXRDevice(XrSystemId id, XrInstance instance) > LOG(XR, "xrGetSystemProperties(): error %s\n", resultToString(result, m_instance).utf8().data()); > > collectSupportedSessionModes(); >- enumerateConfigurationViews(); >+ collectConfigurationViews(); >+} >+ >+Device::ListOfEnabledFeatures OpenXRDevice::enumerateReferenceSpaces(XrSession& session) const >+{ >+ uint32_t referenceSpacesCount; >+ auto result = xrEnumerateReferenceSpaces(session, 0, &referenceSpacesCount, nullptr); >+ RETURN_IF_FAILED(result, "xrEnumerateReferenceSpaces", m_instance, { }); >+ >+ Vector<XrReferenceSpaceType> referenceSpaces(referenceSpacesCount); >+ referenceSpaces.fill(XR_REFERENCE_SPACE_TYPE_VIEW, referenceSpacesCount); >+ result = xrEnumerateReferenceSpaces(session, referenceSpacesCount, &referenceSpacesCount, referenceSpaces.data()); >+ RETURN_IF_FAILED(result, "xrEnumerateReferenceSpaces", m_instance, { }); >+ >+ ListOfEnabledFeatures enabledFeatures; >+ for (auto& referenceSpace : referenceSpaces) { >+ switch (referenceSpace) { >+ case XR_REFERENCE_SPACE_TYPE_VIEW: >+ enabledFeatures.append(ReferenceSpaceType::Viewer); >+ LOG(XR, "\tDevice supports VIEW reference space"); >+ break; >+ case XR_REFERENCE_SPACE_TYPE_LOCAL: >+ enabledFeatures.append(ReferenceSpaceType::Local); >+ LOG(XR, "\tDevice supports LOCAL reference space"); >+ break; >+ case XR_REFERENCE_SPACE_TYPE_STAGE: >+ enabledFeatures.append(ReferenceSpaceType::LocalFloor); >+ enabledFeatures.append(ReferenceSpaceType::BoundedFloor); >+ LOG(XR, "\tDevice supports STAGE reference space"); >+ break; >+ case XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT: >+ enabledFeatures.append(ReferenceSpaceType::Unbounded); >+ LOG(XR, "\tDevice supports UNBOUNDED reference space"); >+ break; >+ default: >+ continue; >+ } >+ } >+ >+ return enabledFeatures; > } > > void OpenXRDevice::collectSupportedSessionModes() >@@ -232,6 +301,15 @@ void OpenXRDevice::collectSupportedSessionModes() > result = xrEnumerateViewConfigurations(m_instance, m_systemId, viewConfigurationCount, &viewConfigurationCount, viewConfigurations); > RETURN_IF_FAILED(result, "xrEnumerateViewConfigurations", m_instance); > >+ // Retrieving the supported reference spaces requires an initialized session. There is no need to initialize all the graphics >+ // stuff so we'll use a headless session that will be discarded after getting the info we need. >+ auto sessionCreateInfo = createStructure<XrSessionCreateInfo, XR_TYPE_SESSION_CREATE_INFO>(); >+ sessionCreateInfo.systemId = m_systemId; >+ XrSession ephemeralSession; >+ result = xrCreateSession(m_instance, &sessionCreateInfo, &ephemeralSession); >+ RETURN_IF_FAILED(result, "xrCreateSession", m_instance); >+ >+ ListOfEnabledFeatures features = enumerateReferenceSpaces(ephemeralSession); > for (uint32_t i = 0; i < viewConfigurationCount; ++i) { > auto viewConfigurationProperties = createStructure<XrViewConfigurationProperties, XR_TYPE_VIEW_CONFIGURATION_PROPERTIES>(); > result = xrGetViewConfigurationProperties(m_instance, m_systemId, viewConfigurations[i], &viewConfigurationProperties); >@@ -242,19 +320,20 @@ void OpenXRDevice::collectSupportedSessionModes() > auto configType = viewConfigurationProperties.viewConfigurationType; > switch (configType) { > case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO: >- setEnabledFeatures(SessionMode::Inline, { }); >+ setEnabledFeatures(SessionMode::Inline, features); > break; > case XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO: >- setEnabledFeatures(SessionMode::ImmersiveVr, { }); >+ setEnabledFeatures(SessionMode::ImmersiveVr, features); > break; > default: > continue; > }; > m_viewConfigurationProperties.add(configType, WTFMove(viewConfigurationProperties)); > } >+ xrDestroySession(ephemeralSession); > } > >-void OpenXRDevice::enumerateConfigurationViews() >+void OpenXRDevice::collectConfigurationViews() > { > for (auto& config : m_viewConfigurationProperties.values()) { > uint32_t viewCount; >@@ -288,7 +367,6 @@ WebCore::IntSize OpenXRDevice::recommendedResolution(SessionMode mode) > return Device::recommendedResolution(mode); > } > >- > #endif // USE_OPENXR > > } // namespace PlatformXR >diff --git a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >index 5baf88484a5f70bfdca11e6a57db5ab89d2999a5..c2815023a272a342ff2a9ac482569d503615837b 100644 >--- a/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >+++ b/Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h >@@ -47,7 +47,9 @@ public: > XrSystemId xrSystemId() const { return m_systemId; } > private: > void collectSupportedSessionModes(); >- void enumerateConfigurationViews(); >+ void collectConfigurationViews(); >+ >+ ListOfEnabledFeatures enumerateReferenceSpaces(XrSession&) const; > > WebCore::IntSize recommendedResolution(SessionMode) final; > >@@ -58,6 +60,7 @@ private: > > XrSystemId m_systemId; > XrInstance m_instance; >+ XrSession m_session; > }; > > } // namespace PlatformXR
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cgarcia
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 214187
: 403967