Fix WebXR light probe test
Since XRSession::preferredReflectionFormat() returns "rgba16f" by
default, this means that using the preferred reflection format requires
half float texture support. A new check was added to the test to make
sure half float textures are supported before using them.
Bug: chromium:1204234
Change-Id: I2d7b05e326d226528a2ec39c033381e9d0f1599f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2935237
Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Commit-Queue: Alexis Hetu <sugoi@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#888644}
diff --git a/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html b/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html
index b46f448..a68a0f2 100644
--- a/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html
+++ b/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html
@@ -9,72 +9,79 @@
let testName = "Test that getReflectionCubeMap returns or throws appropriately without a reflection map.";
let testFunction = (session, controller, t, sessionObjects) => new Promise((resolve) => {
+ let halfFloatExt = sessionObjects.gl.getExtension('OES_texture_half_float');
+ // The preferredReflectionFormat used below is set to "rgba16f" by default.
+ // This means half float textures must be supported in order to run this test
+ if (!halfFloatExt) {
+ resolve(session.end());
+ } else {
let debug = xr_debug.bind(this, 'testFunction');
let lightProbe1 = null;
let binding1 = new XRWebGLBinding(session, sessionObjects.gl);
- // Request a default lightProbe
- session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat }).then((probe) => {
- // Stash and end session.
- lightProbe1 = probe;
+ // Request a default lightProbe
+ session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat }).then((probe) => {
+ // Stash and end session.
+ lightProbe1 = probe;
- debug("Querying first pair");
- t.step(() => {
- assert_equals(
- binding1.getReflectionCubeMap(lightProbe1),
- null,
- "Active binding and light probe shouldn't throw when requesting cube map");
- });
+ debug("Querying first pair");
+ t.step(() => {
+ assert_equals(
+ binding1.getReflectionCubeMap(lightProbe1),
+ null,
+ "Active binding and light probe shouldn't throw when requesting cube map");
+ });
- return session.end();
- }).then(() => {
- // Need to request a new session.
- navigator.xr.test.simulateUserActivation( () => {
- navigator.xr.requestSession('immersive-ar', { 'requiredFeatures': ['light-estimation'] })
- .then((newSession) => {
- let newBinding = new XRWebGLBinding(newSession, sessionObjects.gl);
- newSession.requestLightProbe({ reflectionFormat: newSession.preferredReflectionFormat }).then((newProbe) => {
- t.step(() => {
- debug("Querying second pair");
- assert_equals(
- newBinding.getReflectionCubeMap(newProbe),
- null,
- "Newly created binding and light probe shouldn't throw");
-
- debug("Querying old pair");
- assert_throws_dom(
- "InvalidStateError",
- () => binding1.getReflectionCubeMap(lightProbe1),
- "Binding created with an ended session should throw InvalidStateError");
- debug("Querying mismatched pair");
- assert_throws_dom(
- "InvalidStateError",
- () => newBinding.getReflectionCubeMap(lightProbe1),
- "Querying binding with a probe with a different backing session should throw InvalidStateError");
- });
- debug("losing context");
-
- // Trigger a context loss and verify that we are unable to get the reflectionCubeMap.
- let lose_context_ext = sessionObjects.gl.getExtension('WEBGL_lose_context');
-
- sessionObjects.gl.canvas.addEventListener('webglcontextlost', (ev) => {
- ev.preventDefault();
-
+ return session.end();
+ }).then(() => {
+ // Need to request a new session.
+ navigator.xr.test.simulateUserActivation( () => {
+ navigator.xr.requestSession('immersive-ar', { 'requiredFeatures': ['light-estimation'] })
+ .then((newSession) => {
+ let newBinding = new XRWebGLBinding(newSession, sessionObjects.gl);
+ newSession.requestLightProbe({ reflectionFormat: newSession.preferredReflectionFormat }).then((newProbe) => {
t.step(() => {
+ debug("Querying second pair");
+ assert_equals(
+ newBinding.getReflectionCubeMap(newProbe),
+ null,
+ "Newly created binding and light probe shouldn't throw");
+
+ debug("Querying old pair");
assert_throws_dom(
"InvalidStateError",
- () => newBinding.getReflectionCubeMap(newProbe),
- "Querying for reflection cube map on a binding with context loss should throw InvalidStateError");
+ () => binding1.getReflectionCubeMap(lightProbe1),
+ "Binding created with an ended session should throw InvalidStateError");
+ debug("Querying mismatched pair");
+ assert_throws_dom(
+ "InvalidStateError",
+ () => newBinding.getReflectionCubeMap(lightProbe1),
+ "Querying binding with a probe with a different backing session should throw InvalidStateError");
+ });
+ debug("losing context");
+
+ // Trigger a context loss and verify that we are unable to get the reflectionCubeMap.
+ let lose_context_ext = sessionObjects.gl.getExtension('WEBGL_lose_context');
+
+ sessionObjects.gl.canvas.addEventListener('webglcontextlost', (ev) => {
+ ev.preventDefault();
+
+ t.step(() => {
+ assert_throws_dom(
+ "InvalidStateError",
+ () => newBinding.getReflectionCubeMap(newProbe),
+ "Querying for reflection cube map on a binding with context loss should throw InvalidStateError");
+ });
+
+ resolve(newSession.end());
});
- resolve(newSession.end());
- });
-
- lose_context_ext.loseContext();
- }); // Request second light probe
- }); // Request second session
- }); // SimulateUserActivation
- }); // .then on session end
+ lose_context_ext.loseContext();
+ }); // Request second light probe
+ }); // Request second session
+ }); // SimulateUserActivation
+ }); // .then on session end
+ } // halfFloatExt
}); // testFunction
xr_session_promise_test(