Skip to content

Commit

Permalink
Remove orientation from several texture copy tests (gpuweb#2914)
Browse files Browse the repository at this point in the history
* Remove orientation from several texture copy tests

The orientation argument for these tests was copied from tests which
use an ImageBitmap source. Because CreateImageBitmap has an
imageOrientation option it made sense to test against all variants
of it. However, other tests, such as those that consume ImageData
directly, don't have any native mechanism for Y-flipping the source.
The data could be generated Y-flipped, but that doesn't increase
coverage of any implementation features. Despite not flipping the
source orientation, however, the test was still expected the data
to be flipped.

By removing this argument and no longer testing for flipped source
data, these tests all begin passing with no loss of platform coverage.

Bug: dawn:2017

* Lint fix
  • Loading branch information
toji authored Aug 29, 2023
1 parent 7f4eced commit 03819a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
17 changes: 4 additions & 13 deletions src/webgpu/web_platform/copyToTexture/ImageData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ g.test('from_ImageData')
)
.params(u =>
u
.combine('orientation', ['none', 'flipY'] as const)
.combine('srcDoFlipYDuringCopy', [true, false])
.combine('dstColorFormat', kValidTextureFormatsForCopyE2T)
.combine('dstPremultiplied', [true, false])
Expand All @@ -51,14 +50,7 @@ g.test('from_ImageData')
t.skipIfTextureFormatNotSupported(t.params.dstColorFormat);
})
.fn(t => {
const {
width,
height,
orientation,
dstColorFormat,
dstPremultiplied,
srcDoFlipYDuringCopy,
} = t.params;
const { width, height, dstColorFormat, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;

const testColors = kTestColorsAll;

Expand Down Expand Up @@ -87,7 +79,7 @@ g.test('from_ImageData')
});

const expFormat = kTextureFormatInfo[dstColorFormat].baseFormat ?? dstColorFormat;
const flipSrcBeforeCopy = orientation === 'flipY';
const flipSrcBeforeCopy = false;
const texelViewExpected = t.getExpectedDstPixelsFromSrcPixels({
srcPixels: imageData.data,
srcOrigin: [0, 0],
Expand Down Expand Up @@ -155,14 +147,13 @@ g.test('copy_subrect_from_ImageData')
)
.params(u =>
u
.combine('orientation', ['none', 'flipY'] as const)
.combine('srcDoFlipYDuringCopy', [true, false])
.combine('dstPremultiplied', [true, false])
.beginSubcases()
.combine('copySubRectInfo', kCopySubrectInfo)
)
.fn(t => {
const { copySubRectInfo, orientation, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;
const { copySubRectInfo, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;

const testColors = kTestColorsAll;
const { srcOrigin, dstOrigin, srcSize, dstSize, copyExtent } = copySubRectInfo;
Expand Down Expand Up @@ -192,7 +183,7 @@ g.test('copy_subrect_from_ImageData')
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
});

const flipSrcBeforeCopy = orientation === 'flipY';
const flipSrcBeforeCopy = false;
const texelViewExpected = t.getExpectedDstPixelsFromSrcPixels({
srcPixels: imageData.data,
srcOrigin,
Expand Down
17 changes: 4 additions & 13 deletions src/webgpu/web_platform/copyToTexture/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ g.test('from_image')
)
.params(u =>
u
.combine('orientation', ['none', 'flipY'] as const)
.combine('srcDoFlipYDuringCopy', [true, false])
.combine('dstColorFormat', kValidTextureFormatsForCopyE2T)
.combine('dstPremultiplied', [true, false])
Expand All @@ -66,14 +65,7 @@ g.test('from_image')
if (typeof HTMLImageElement === 'undefined') t.skip('HTMLImageElement not available');
})
.fn(async t => {
const {
width,
height,
orientation,
dstColorFormat,
dstPremultiplied,
srcDoFlipYDuringCopy,
} = t.params;
const { width, height, dstColorFormat, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;

const imageCanvas = document.createElement('canvas');
imageCanvas.width = width;
Expand Down Expand Up @@ -117,7 +109,7 @@ g.test('from_image')
});

const expFormat = kTextureFormatInfo[dstColorFormat].baseFormat ?? dstColorFormat;
const flipSrcBeforeCopy = orientation === 'flipY';
const flipSrcBeforeCopy = false;
const texelViewExpected = t.getExpectedDstPixelsFromSrcPixels({
srcPixels: imageData.data,
srcOrigin: [0, 0],
Expand Down Expand Up @@ -186,7 +178,6 @@ g.test('copy_subrect_from_2D_Canvas')
)
.params(u =>
u
.combine('orientation', ['none', 'flipY'] as const)
.combine('srcDoFlipYDuringCopy', [true, false])
.combine('dstPremultiplied', [true, false])
.beginSubcases()
Expand All @@ -196,7 +187,7 @@ g.test('copy_subrect_from_2D_Canvas')
if (typeof HTMLImageElement === 'undefined') t.skip('HTMLImageElement not available');
})
.fn(async t => {
const { copySubRectInfo, orientation, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;
const { copySubRectInfo, dstPremultiplied, srcDoFlipYDuringCopy } = t.params;

const { srcOrigin, dstOrigin, srcSize, dstSize, copyExtent } = copySubRectInfo;
const kColorFormat = 'rgba8unorm';
Expand Down Expand Up @@ -242,7 +233,7 @@ g.test('copy_subrect_from_2D_Canvas')
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
});

const flipSrcBeforeCopy = orientation === 'flipY';
const flipSrcBeforeCopy = false;
const texelViewExpected = t.getExpectedDstPixelsFromSrcPixels({
srcPixels: imageData.data,
srcOrigin,
Expand Down

0 comments on commit 03819a5

Please sign in to comment.