summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js')
-rw-r--r--testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js88
1 files changed, 62 insertions, 26 deletions
diff --git a/testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js b/testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js
index 9df16bf5ef..e156a6170d 100644
--- a/testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js
+++ b/testing/web-platform/mozilla/tests/webgpu/webgpu/web_platform/copyToTexture/video.spec.js
@@ -3,15 +3,21 @@
**/export const description = `
copyToTexture with HTMLVideoElement and VideoFrame.
-- videos with various encodings/formats (webm vp8, webm vp9, ogg theora, mp4), color spaces
- (bt.601, bt.709, bt.2020)
+- videos with various encodings/formats (webm vp8, webm vp9, ogg theora, mp4), video color spaces
+ (bt.601, bt.709, bt.2020) and dst color spaces(display-p3, srgb).
+
+ TODO: Test video in BT.2020 color space
`;import { makeTestGroup } from '../../../common/framework/test_group.js';
import { GPUTest, TextureTestMixin } from '../../gpu_test.js';
import {
startPlayingAndWaitForVideo,
getVideoElement,
getVideoFrameFromVideoElement,
- kVideoExpectations } from
+ convertToUnorm8,
+ kPredefinedColorSpace,
+ kVideoNames,
+ kVideoInfo,
+ kVideoExpectedColors } from
'../../web_platform/util.js';
const kFormat = 'rgba8unorm';
@@ -36,17 +42,17 @@ It creates HTMLVideoElement with videos under Resource folder.
- Valid 'flipY' config in 'GPUImageCopyExternalImage' (named 'srcDoFlipYDuringCopy' in cases)
- TODO: partial copy tests should be added
- TODO: all valid dstColorFormat tests should be added.
- - TODO: dst color space tests need to be added
`
).
params((u) =>
u //
-.combineWithParams(kVideoExpectations).
+.combine('videoName', kVideoNames).
combine('sourceType', ['VideoElement', 'VideoFrame']).
-combine('srcDoFlipYDuringCopy', [true, false])
+combine('srcDoFlipYDuringCopy', [true, false]).
+combine('dstColorSpace', kPredefinedColorSpace)
).
fn(async (t) => {
- const { videoName, sourceType, srcDoFlipYDuringCopy } = t.params;
+ const { videoName, sourceType, srcDoFlipYDuringCopy, dstColorSpace } = t.params;
if (sourceType === 'VideoFrame' && typeof VideoFrame === 'undefined') {
t.skip('WebCodec is not supported');
@@ -58,8 +64,8 @@ fn(async (t) => {
let source, width, height;
if (sourceType === 'VideoFrame') {
source = await getVideoFrameFromVideoElement(t, videoElement);
- width = source.codedWidth;
- height = source.codedHeight;
+ width = source.displayWidth;
+ height = source.displayHeight;
} else {
source = videoElement;
width = source.videoWidth;
@@ -82,33 +88,63 @@ fn(async (t) => {
{
texture: dstTexture,
origin: { x: 0, y: 0 },
- colorSpace: 'srgb',
+ colorSpace: dstColorSpace,
premultipliedAlpha: true
},
{ width, height, depthOrArrayLayers: 1 }
);
+ const srcColorSpace = kVideoInfo[videoName].colorSpace;
+ const presentColors = kVideoExpectedColors[srcColorSpace][dstColorSpace];
+
+ // visible rect is whole frame, no clipping.
+ const expect = kVideoInfo[videoName].display;
+
if (srcDoFlipYDuringCopy) {
t.expectSinglePixelComparisonsAreOkInTexture({ texture: dstTexture }, [
- // Top-left should be blue.
- { coord: { x: width * 0.25, y: height * 0.25 }, exp: t.params._blueExpectation },
- // Top-right should be green.
- { coord: { x: width * 0.75, y: height * 0.25 }, exp: t.params._greenExpectation },
- // Bottom-left should be yellow.
- { coord: { x: width * 0.25, y: height * 0.75 }, exp: t.params._yellowExpectation },
- // Bottom-right should be red.
- { coord: { x: width * 0.75, y: height * 0.75 }, exp: t.params._redExpectation }]
+ // Flipped top-left.
+ {
+ coord: { x: width * 0.25, y: height * 0.25 },
+ exp: convertToUnorm8(presentColors[expect.bottomLeftColor])
+ },
+ // Flipped top-right.
+ {
+ coord: { x: width * 0.75, y: height * 0.25 },
+ exp: convertToUnorm8(presentColors[expect.bottomRightColor])
+ },
+ // Flipped bottom-left.
+ {
+ coord: { x: width * 0.25, y: height * 0.75 },
+ exp: convertToUnorm8(presentColors[expect.topLeftColor])
+ },
+ // Flipped bottom-right.
+ {
+ coord: { x: width * 0.75, y: height * 0.75 },
+ exp: convertToUnorm8(presentColors[expect.topRightColor])
+ }]
);
} else {
t.expectSinglePixelComparisonsAreOkInTexture({ texture: dstTexture }, [
- // Top-left should be yellow.
- { coord: { x: width * 0.25, y: height * 0.25 }, exp: t.params._yellowExpectation },
- // Top-right should be red.
- { coord: { x: width * 0.75, y: height * 0.25 }, exp: t.params._redExpectation },
- // Bottom-left should be blue.
- { coord: { x: width * 0.25, y: height * 0.75 }, exp: t.params._blueExpectation },
- // Bottom-right should be green.
- { coord: { x: width * 0.75, y: height * 0.75 }, exp: t.params._greenExpectation }]
+ // Top-left.
+ {
+ coord: { x: width * 0.25, y: height * 0.25 },
+ exp: convertToUnorm8(presentColors[expect.topLeftColor])
+ },
+ // Top-right.
+ {
+ coord: { x: width * 0.75, y: height * 0.25 },
+ exp: convertToUnorm8(presentColors[expect.topRightColor])
+ },
+ // Bottom-left.
+ {
+ coord: { x: width * 0.25, y: height * 0.75 },
+ exp: convertToUnorm8(presentColors[expect.bottomLeftColor])
+ },
+ // Bottom-right.
+ {
+ coord: { x: width * 0.75, y: height * 0.75 },
+ exp: convertToUnorm8(presentColors[expect.bottomRightColor])
+ }]
);
}