Skip to content

Commit 7b2aedb

Browse files
alcooper91chromium-wpt-export-bot
authored andcommitted
Refactor Xr Depth Data to be per view
The WebXR Spec requires that a view be passed in to receive depth data. The current implementation simply sends depth data alongside with the rest of the frame data and process it independently in the blink XrSession. This is fine because the current only platform that supports depth sensing is ARCore, which only has one View. However, in order to implement Depth Sensing for OpenXR (which has multiple views), this needed to be changed to allow sending up data per-view. This required refactoring the XrDepthManager to be owned by an XrViewData (since the actual XRView objects are created per-frame and largely wrap this data). Since XRViewData's can *theoretically* (though likely not usually done in practice), be recreated mid session if e.g. the count/order of views changes, this now requires storing the depth_config in XrSession to allow for this re-creation. Rather than simply storing the depth config, this change opts to store the entire device_config and thus remove a few other unnecessary member variables. As part of this update to update Depth as part of the XRViews, a few other refactors were made, as well as some tangientially related cleanups. A few of these arose because it seemed like it was necessary to switch XrFrameData to be passed by value rather than const& to steal the Views and subsequent DepthData off of it. While that turns out to not have been necessary (because const& to a pointer doesn't prevent stealing data from the underlying struct...), many of these changes are left in as it improves both the overall readability and intent behind the const& and later usage. These other changes are, in general: * UpdateViews now handles the deferred update logic that happened several lines later in views(). This is more consistent with what a reader would likely expect from the calls. * The UpdateViews refactor removes the need to keep the `pending_views_` variable. It is removed, and it's usages updated as appropriate. * XrDepthManager is no longer exposed to XrSession, so the DepthData and DepthFormat strings (that the page receives off of XrSession) now live in XrSession. * The Mojom XrDepthDataUpdated::time_delta member was unused outside of the device process, and thus is now removed from the interface. * XrFrameProvider manually updated some additional state after calling `UpdatePresentationFrameState`. This state was updated regardless of session type, and as such was moved inside of `UpdatePresentationFrameState`, to facilitate std::move'ing the FrameData to that method. The comments around UpdateFrameState were also outdated/indirect and updated/clarified. Note that the ordering of some of these additional updates is different after this CL. * XrFrameProvider stored a few variables whose storage seemed to now be unnecessary, these variables were removed and their usage was ported to closer to where they were needed. * Because XrFrameProvider no longer needed to split off the VRPosePtr, from the FrameData, it was removed as a separate argument to the UpdatePresentationFrameState. Bug: 342213635 Change-Id: I2fd8f3d609e955c84aff2e21b147443aeb987c02 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5565198 Reviewed-by: Brandon Jones <[email protected]> Reviewed-by: Tom Sepez <[email protected]> Commit-Queue: Alexander Cooper <[email protected]> Cr-Commit-Position: refs/heads/main@{#1307066}
1 parent 1c59e64 commit 7b2aedb

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

resources/chromium/webxr-test.js

+21-14
Original file line numberDiff line numberDiff line change
@@ -1312,27 +1312,34 @@ class MockRuntime {
13121312
return;
13131313
}
13141314

1315+
let newDepthData;
1316+
13151317
// If we don't have a current depth data, we'll return null
13161318
// (i.e. no data is not a valid data, so it cannot be "StillValid").
13171319
if (this.depthSensingData_ == null) {
1318-
frameData.depthData = null;
1319-
return;
1320+
newDepthData = null;
1321+
} else if(!this.depthSensingDataDirty_) {
1322+
newDepthData = { dataStillValid: {}};
1323+
} else {
1324+
newDepthData = {
1325+
updatedDepthData: {
1326+
timeDelta: frameData.timeDelta,
1327+
normTextureFromNormView: this.depthSensingData_.normDepthBufferFromNormView,
1328+
rawValueToMeters: this.depthSensingData_.rawValueToMeters,
1329+
size: { width: this.depthSensingData_.width, height: this.depthSensingData_.height },
1330+
pixelData: { bytes: this.depthSensingData_.depthData }
1331+
}
1332+
};
13201333
}
13211334

1322-
if(!this.depthSensingDataDirty_) {
1323-
frameData.depthData = { dataStillValid: {}};
1324-
return;
1335+
for (let i = 0; i < this.primaryViews_.length; i++) {
1336+
this.primaryViews_[i].depthData = newDepthData;
13251337
}
1326-
1327-
frameData.depthData = {
1328-
updatedDepthData: {
1329-
timeDelta: frameData.timeDelta,
1330-
normTextureFromNormView: this.depthSensingData_.normDepthBufferFromNormView,
1331-
rawValueToMeters: this.depthSensingData_.rawValueToMeters,
1332-
size: { width: this.depthSensingData_.width, height: this.depthSensingData_.height },
1333-
pixelData: { bytes: this.depthSensingData_.depthData }
1338+
if (this.enabledFeatures_.includes(xrSessionMojom.XRSessionFeature.SECONDARY_VIEWS)) {
1339+
for (let i = 0; i < this.secondaryViews_.length; i++) {
1340+
this.secondaryViews_[i].depthData = newDepthData;
13341341
}
1335-
};
1342+
}
13361343

13371344
this.depthSensingDataDirty_ = false;
13381345
}

0 commit comments

Comments
 (0)