Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added wpt webxr tests for XR layer's viewports and framebuffer
- Loading branch information
Alan Jeffrey
committed
Jul 18, 2019
1 parent
aa0a72d
commit f2766cf
Showing
5 changed files
with
89 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/wpt/metadata/webxr/xrWebGLLayer_framebuffer.https.html.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[xrWebGLLayer_framebuffer.https.html] | ||
[XRWebGLLayer reports a valid framebuffer for inline sessions] | ||
expected: FAIL | ||
|
58 changes: 58 additions & 0 deletions
58
tests/wpt/web-platform-tests/webxr/xrWebGLLayer_framebuffer.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/webxr_test_constants.js"></script> | ||
<script src="resources/webxr_util.js"></script> | ||
<canvas></canvas> | ||
|
||
<script> | ||
|
||
let immersiveTestName = "XRWebGLLayer reports a valid framebuffer for immersive sessions"; | ||
let inlineTestName = "XRWebGLLayer reports a valid framebuffer for inline sessions"; | ||
|
||
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; | ||
|
||
let testFunction = function(session, fakeDeviceController, t) { | ||
return session.requestReferenceSpace('viewer') | ||
.then((space) => new Promise((resolve) => { | ||
function onFrame(time, xrFrame) { | ||
let layer = xrFrame.session.renderState.baseLayer; | ||
let gl = layer.context; | ||
|
||
// The layer's framebuffer is a WebGL framebuffer | ||
assert_not_equals(layer.framebuffer, null); | ||
assert_true(layer.framebuffer instanceof WebGLFramebuffer); | ||
|
||
// The XR framebuffer is not bound to the GL context by default. | ||
assert_not_equals(layer.framebuffer, gl.getParameter(gl.FRAMEBUFFER_BINDING)); | ||
|
||
// The XR framebuffer can be bound to the GL context. | ||
gl.bindFramebuffer(gl.FRAMEBUFFER, layer.framebuffer); | ||
assert_equals(layer.framebuffer, gl.getParameter(gl.FRAMEBUFFER_BINDING)); | ||
|
||
// The XR framebuffer has a 2D texture | ||
let attachment = gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE); | ||
assert_equals(attachment, gl.TEXTURE); | ||
|
||
// Check that each viewport fits inside the framebuffer dimensions | ||
let viewer_pose = xrFrame.getViewerPose(space); | ||
for (view of viewer_pose.views) { | ||
let viewport = layer.getViewport(view); | ||
assert_less_than_equal(viewport.x + viewport.width, layer.framebufferWidth); | ||
assert_less_than_equal(viewport.y + viewport.height, layer.framebufferHeight); | ||
} | ||
|
||
// Finished test. | ||
resolve(); | ||
} | ||
|
||
session.requestAnimationFrame(onFrame); | ||
})); | ||
}; | ||
|
||
xr_session_promise_test(immersiveTestName, testFunction, | ||
fakeDeviceInitParams, 'immersive-vr'); | ||
xr_session_promise_test(inlineTestName, testFunction, | ||
fakeDeviceInitParams, 'inline'); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters