diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webxr/depth-sensing/cpu | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/depth-sensing/cpu')
5 files changed, 237 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html new file mode 100644 index 0000000000..e120f0b7dd --- /dev/null +++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/webxr_util.js"></script> +<script src="../../resources/webxr_test_asserts.js"></script> +<script src="../../resources/webxr_test_constants.js"></script> +<script src="../../resources/webxr_test_constants_fake_depth.js"></script> +<script src="../dataUnavailableTests.js"></script> + +<script> + +const fakeDeviceInitParams = { + supportedModes: ["immersive-ar"], + views: VALID_VIEWS, + supportedFeatures: ALL_FEATURES, + depthSensingData: DEPTH_SENSING_DATA, +}; + +xr_session_promise_test("Ensures depth data is not available when cleared in the controller, `cpu-optimized`", + dataUnavailableTestFunctionGenerator(/*isCpuOptimized=*/true), + fakeDeviceInitParams, + 'immersive-ar', { + requiredFeatures: ['depth-sensing'], + depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE, + }); + +</script> diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html new file mode 100644 index 0000000000..92c20cecbf --- /dev/null +++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/webxr_util.js"></script> +<script src="../../resources/webxr_test_asserts.js"></script> +<script src="../../resources/webxr_test_constants.js"></script> +<script src="../../resources/webxr_test_constants_fake_depth.js"></script> +<script src="../inactiveFrameTests.js"></script> + +<script> + +const fakeDeviceInitParams = { + supportedModes: ["immersive-ar"], + views: VALID_VIEWS, + supportedFeatures: ALL_FEATURES, +}; + +xr_session_promise_test("Ensures getDepthInformation() throws when not run in an active frame, `cpu-optimized`", + inactiveFrameTestFunctionGenerator(/*isCpuOptimized=*/true), + fakeDeviceInitParams, + 'immersive-ar', { + requiredFeatures: ['depth-sensing'], + depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE, + }); + +</script> diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html new file mode 100644 index 0000000000..44868d8cb0 --- /dev/null +++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/webxr_util.js"></script> +<script src="../../resources/webxr_test_asserts.js"></script> +<script src="../../resources/webxr_test_constants.js"></script> +<script src="../../resources/webxr_test_constants_fake_depth.js"></script> +<script src="../incorrectUsageTests.js"></script> + +<script> + +const fakeDeviceInitParams = { + supportedModes: ["immersive-ar"], + views: VALID_VIEWS, + supportedFeatures: ALL_FEATURES, +}; + +const incorrectUsagetestFunctionTryGetWebGLOnCpu = function (session, controller, t, sessionObjects) { + return session.requestReferenceSpace('viewer').then((viewerSpace) => { + let done = false; + + const glBinding = new XRWebGLBinding(session, sessionObjects.gl); + + session.requestAnimationFrame((time, frame) => { + const pose = frame.getViewerPose(viewerSpace); + for(const view of pose.views) { + t.step(() => { + assert_throws_dom("InvalidStateError", () => glBinding.getDepthInformation(view), + "XRWebGLBinding.getDepthInformation() should throw when depth sensing is in `cpu-optimized` usage mode"); + }); + } + + done = true; + }); + + return t.step_wait(() => done); + }); +}; + +xr_session_promise_test("Ensures XRWebGLDepthInformation is not obtainable in `cpu-optimized` usage mode", + incorrectUsagetestFunctionTryGetWebGLOnCpu, + fakeDeviceInitParams, + 'immersive-ar', { + requiredFeatures: ['depth-sensing'], + depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE, + }); + +</script> diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html new file mode 100644 index 0000000000..db88c42558 --- /dev/null +++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/webxr_util.js"></script> +<script src="../../resources/webxr_math_utils.js"></script> +<script src="../../resources/webxr_test_asserts.js"></script> +<script src="../../resources/webxr_test_constants.js"></script> +<script src="../../resources/webxr_test_constants_fake_depth.js"></script> + +<script> + +const fakeDeviceInitParams = { + supportedModes: ["immersive-ar"], + views: VALID_VIEWS, + supportedFeatures: ALL_FEATURES, + depthSensingData: DEPTH_SENSING_DATA, +}; + +const assert_depth_valid_at = function(depthInformation, row, column, deltaRow, deltaColumn) { + // column and row correspond to the depth buffer coordinates, + // *not* to normalized view coordinates the getDepthInMeters() expects. + + const expectedValue = getExpectedValueAt(column, row); + + // 1. Normalize: + let x = (column + deltaColumn) / depthInformation.width; + let y = (row + deltaRow) / depthInformation.height; + + // 2. Apply the transform that changes the origin and axes: + x = 1.0 - x; + y = 1.0 - y; + + const depthValue = depthInformation.getDepthInMeters(x, y); + assert_approx_equals(depthValue, expectedValue, FLOAT_EPSILON, + "Depth value at (" + column + "," + row + "), deltas=(" + deltaColumn + ", " + deltaRow + "), " + + "coordinates (" + x + "," + y + ") must match!"); +} + +const assert_depth_valid = function(depthInformation) { + + assert_true(depthInformation.data instanceof ArrayBuffer, + "XRCpuDepthInformation.data must be of type `ArrayBuffer`!"); + + for(let row = 0; row < depthInformation.height; row++) { + for(let column = 0; column < depthInformation.width; column++) { + // middle of the pixel: + assert_depth_valid_at(depthInformation, row, column, 0.5, 0.5); + + // corners of the pixel: + assert_depth_valid_at(depthInformation, row, column, FLOAT_EPSILON, FLOAT_EPSILON); + assert_depth_valid_at(depthInformation, row, column, FLOAT_EPSILON, 1 - FLOAT_EPSILON); + assert_depth_valid_at(depthInformation, row, column, 1 - FLOAT_EPSILON, FLOAT_EPSILON); + assert_depth_valid_at(depthInformation, row, column, 1 - FLOAT_EPSILON, 1 - FLOAT_EPSILON); + } + } + + // Verify out-of-bounds accesses throw: + assert_throws_js(RangeError, + () => depthInformation.getDepthInMeters(-FLOAT_EPSILON, 0.0), + "getDepthInMeters() should throw when run with invalid indices - negative x"); + assert_throws_js(RangeError, + () => depthInformation.getDepthInMeters(0.0, -FLOAT_EPSILON), + "getDepthInMeters() should throw when run with invalid indices - negative y"); + assert_throws_js(RangeError, + () => depthInformation.getDepthInMeters(1+FLOAT_EPSILON, 0.0), + "getDepthInMeters() should throw when run with invalid indices - too big x"); + assert_throws_js(RangeError, + () => depthInformation.getDepthInMeters(0.0, 1+FLOAT_EPSILON), + "getDepthInMeters() should throw when run with invalid indices - too big y"); +}; + +const testCpuOptimizedLuminanceAlpha = function(session, fakeDeviceController, t) { + return session.requestReferenceSpace('viewer').then((viewerSpace) => { + let done = false; + + const rafCallback = function(time, frame) { + const pose = frame.getViewerPose(viewerSpace); + if(pose) { + for(const view of pose.views) { + const depthInformation = frame.getDepthInformation(view); + + t.step(() => { + assert_not_equals(depthInformation, null, "XRCPUDepthInformation must not be null!"); + assert_approx_equals(depthInformation.width, DEPTH_SENSING_DATA.width, FLOAT_EPSILON); + assert_approx_equals(depthInformation.height, DEPTH_SENSING_DATA.height, FLOAT_EPSILON); + assert_approx_equals(depthInformation.rawValueToMeters, DEPTH_SENSING_DATA.rawValueToMeters, FLOAT_EPSILON); + assert_transform_approx_equals(depthInformation.normDepthBufferFromNormView, DEPTH_SENSING_DATA.normDepthBufferFromNormView); + assert_depth_valid(depthInformation); + }); + } + } + + done = true; + }; + + session.requestAnimationFrame(rafCallback); + + return t.step_wait(() => done); + }); +}; + +xr_session_promise_test("Ensures depth data is returned and values match expectation, cpu-optimized, luminance-alpha.", + testCpuOptimizedLuminanceAlpha, + fakeDeviceInitParams, + 'immersive-ar', { + 'requiredFeatures': ['depth-sensing'], + depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE, + }); + +</script> diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html new file mode 100644 index 0000000000..6a411ace45 --- /dev/null +++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../../resources/webxr_util.js"></script> +<script src="../../resources/webxr_test_asserts.js"></script> +<script src="../../resources/webxr_test_constants.js"></script> +<script src="../../resources/webxr_test_constants_fake_depth.js"></script> +<script src="../staleViewsTests.js"></script> + +<script> + +const fakeDeviceInitParams = { + supportedModes: ["immersive-ar"], + views: VALID_VIEWS, + supportedFeatures: ALL_FEATURES, +}; + +xr_session_promise_test("Ensures getDepthInformation() throws when run with stale XRView, `cpu-optimized`", + staleViewsTestFunctionGenerator(/*isCpuOptimized=*/true), + fakeDeviceInitParams, + 'immersive-ar', { + requiredFeatures: ['depth-sensing'], + depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE, + }); + +</script> |