Skip to content

Commit

Permalink
Rename copy types following the deprecation in webgpu/types
Browse files Browse the repository at this point in the history
  • Loading branch information
Kangz committed Nov 4, 2024
1 parent efcde6c commit 9856759
Show file tree
Hide file tree
Showing 15 changed files with 80 additions and 80 deletions.
22 changes: 11 additions & 11 deletions src/webgpu/api/operation/command_buffer/image_copy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const altDataGenerator = new DataArrayGenerator();

class ImageCopyTest extends TextureTestMixin(GPUTest) {
/**
* This is used for testing passing undefined members of `GPUImageDataLayout` instead of actual
* This is used for testing passing undefined members of `GPUTexelCopyBufferLayout` instead of actual
* values where possible. Passing arguments as values and not as objects so that they are passed
* by copy and not by reference.
*/
Expand All @@ -135,7 +135,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
rowsPerImage: number | undefined,
bytesPerRow: number | undefined,
changeBeforePass: ChangeBeforePass
): GPUImageDataLayout {
): GPUTexelCopyBufferLayout {
if (changeBeforePass === 'undefined') {
if (offset === 0) {
offset = undefined;
Expand All @@ -151,7 +151,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
}

/**
* This is used for testing passing undefined members of `GPUImageCopyTexture` instead of actual
* This is used for testing passing undefined members of `GPUTexelCopyTextureInfo` instead of actual
* values where possible and also for testing passing the origin as `[number, number, number]`.
* Passing arguments as values and not as objects so that they are passed by copy and not by
* reference.
Expand All @@ -163,7 +163,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
origin_z: number | undefined,
mipLevel: number | undefined,
changeBeforePass: ChangeBeforePass
): GPUImageCopyTexture {
): GPUTexelCopyTextureInfo {
let origin: GPUOrigin3D | undefined = { x: origin_x, y: origin_y, z: origin_z };

if (changeBeforePass === 'undefined') {
Expand Down Expand Up @@ -225,7 +225,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
buffer: GPUBuffer,
format: ColorTextureFormat,
size: Required<GPUExtent3DDict>,
dataLayout: Required<GPUImageDataLayout>
dataLayout: Required<GPUTexelCopyBufferLayout>
) {
if (isCompressedTextureFormat(format)) {
this.expectGPUBufferValuesEqual(buffer, expected);
Expand Down Expand Up @@ -323,7 +323,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
/** Run a CopyT2B command with appropriate arguments corresponding to `ChangeBeforePass` */
copyTextureToBufferWithAppliedArguments(
buffer: GPUBuffer,
{ offset, rowsPerImage, bytesPerRow }: Required<GPUImageDataLayout>,
{ offset, rowsPerImage, bytesPerRow }: Required<GPUTexelCopyBufferLayout>,
{ width, height, depthOrArrayLayers }: Required<GPUExtent3DDict>,
{ texture, mipLevel, origin }: TextureCopyViewWithRequiredOrigin,
changeBeforePass: ChangeBeforePass
Expand Down Expand Up @@ -363,7 +363,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
/** Put data into a part of the texture with an appropriate method. */
uploadLinearTextureDataToTextureSubBox(
textureCopyView: TextureCopyViewWithRequiredOrigin,
textureDataLayout: GPUImageDataLayout & { bytesPerRow: number },
textureDataLayout: GPUTexelCopyBufferLayout & { bytesPerRow: number },
copySize: Required<GPUExtent3DDict>,
partialData: Uint8Array,
method: InitMethod,
Expand Down Expand Up @@ -432,7 +432,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
copySize: Required<GPUExtent3DDict>,
format: ColorTextureFormat,
expected: Uint8Array,
expectedDataLayout: Required<GPUImageDataLayout>
expectedDataLayout: Required<GPUTexelCopyBufferLayout>
): void {
const size = [
actualTexture.width,
Expand Down Expand Up @@ -507,7 +507,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
checkSize: Required<GPUExtent3DDict>,
format: ColorTextureFormat,
expected: Uint8Array,
expectedDataLayout: Required<GPUImageDataLayout>,
expectedDataLayout: Required<GPUTexelCopyBufferLayout>,
changeBeforePass: ChangeBeforePass = 'none'
): void {
// The alignment is necessary because we need to copy and map data from this buffer.
Expand Down Expand Up @@ -573,7 +573,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
copyWholeTextureToBufferAndCheckContentsWithUpdatedData(
{ texture, mipLevel, origin }: TextureCopyViewWithRequiredOrigin,
fullTextureCopyLayout: TextureCopyLayout,
texturePartialDataLayout: Required<GPUImageDataLayout>,
texturePartialDataLayout: Required<GPUTexelCopyBufferLayout>,
copySize: Required<GPUExtent3DDict>,
format: ColorTextureFormat,
fullData: GPUBuffer,
Expand Down Expand Up @@ -632,7 +632,7 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
checkMethod,
changeBeforePass = 'none',
}: {
textureDataLayout: Required<GPUImageDataLayout>;
textureDataLayout: Required<GPUTexelCopyBufferLayout>;
copySize: Required<GPUExtent3DDict>;
dataSize: number;
mipLevel?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { ValidationTest } from '../../validation_test.js';

class F extends ValidationTest {
TestCopyTextureToTexture(
source: GPUImageCopyTexture,
destination: GPUImageCopyTexture,
source: GPUTexelCopyTextureInfo,
destination: GPUTexelCopyTextureInfo,
copySize: GPUExtent3D,
expectation: 'Success' | 'FinishError' | 'SubmitError'
): void {
Expand Down Expand Up @@ -691,7 +691,7 @@ TODO: Extend to 1D and 3D textures.`
g.test('copy_aspects')
.desc(
`
Test the validations on the member 'aspect' of GPUImageCopyTexture in CopyTextureToTexture().
Test the validations on the member 'aspect' of GPUTexelCopyTextureInfo in CopyTextureToTexture().
- for all the color and depth-stencil formats: the texture copy aspects must be both 'all'.
- for all the depth-only formats: the texture copy aspects must be either 'all' or 'depth-only'.
- for all the stencil-only formats: the texture copy aspects must be either 'all' or 'stencil-only'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { ValidationTest } from '../validation_test.js';

class ImageCopyTest extends ValidationTest {
testCopyBufferToTexture(
source: GPUImageCopyBuffer,
destination: GPUImageCopyTexture,
source: GPUTexelCopyBufferInfo,
destination: GPUTexelCopyTextureInfo,
copySize: GPUExtent3DStrict,
isSuccess: boolean
): void {
Expand All @@ -29,8 +29,8 @@ class ImageCopyTest extends ValidationTest {
}

testCopyTextureToBuffer(
source: GPUImageCopyTexture,
destination: GPUImageCopyBuffer,
source: GPUTexelCopyTextureInfo,
destination: GPUTexelCopyBufferInfo,
copySize: GPUExtent3DStrict,
isSuccess: boolean
): void {
Expand All @@ -40,9 +40,9 @@ class ImageCopyTest extends ValidationTest {
}

testWriteTexture(
destination: GPUImageCopyTexture,
destination: GPUTexelCopyTextureInfo,
uploadData: Uint8Array,
dataLayout: GPUImageDataLayout,
dataLayout: GPUTexelCopyBufferLayout,
copySize: GPUExtent3DStrict,
isSuccess: boolean
): void {
Expand Down
6 changes: 3 additions & 3 deletions src/webgpu/api/validation/image_copy/image_copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { ValidationTest } from '../validation_test.js';

export class ImageCopyTest extends ValidationTest {
testRun(
textureCopyView: GPUImageCopyTexture,
textureDataLayout: GPUImageDataLayout,
textureCopyView: GPUTexelCopyTextureInfo,
textureDataLayout: GPUTexelCopyBufferLayout,
size: GPUExtent3D,
{
method,
Expand Down Expand Up @@ -122,7 +122,7 @@ export class ImageCopyTest extends ValidationTest {
testBuffer(
buffer: GPUBuffer,
texture: GPUTexture,
textureDataLayout: GPUImageDataLayout,
textureDataLayout: GPUTexelCopyBufferLayout,
size: GPUExtent3D,
{
method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class CopyExternalImageToTextureTest extends ValidationTest {
}

runTest(
imageBitmapCopyView: GPUImageCopyExternalImage,
textureCopyView: GPUImageCopyTextureTagged,
imageBitmapCopyView: GPUCopyExternalImageSourceInfo,
textureCopyView: GPUCopyExternalImageDestInfo,
copySize: GPUExtent3D,
validationScopeSuccess: boolean,
exceptionName?: string
Expand Down
14 changes: 7 additions & 7 deletions src/webgpu/gpu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ export interface TextureTestMixinType {
* to the expected TexelView passes without error.
*/
expectTexelViewComparisonIsOkInTexture(
src: GPUImageCopyTexture,
src: GPUTexelCopyTextureInfo,
exp: TexelView,
size: GPUExtent3D,
comparisonOptions?: TexelCompareOptions
Expand All @@ -1307,7 +1307,7 @@ export interface TextureTestMixinType {
* their expected colors without error.
*/
expectSinglePixelComparisonsAreOkInTexture<E extends PixelExpectation>(
src: GPUImageCopyTexture,
src: GPUTexelCopyTextureInfo,
exp: PerPixelComparison<E>[],
comparisonOptions?: TexelCompareOptions
): void;
Expand Down Expand Up @@ -1383,7 +1383,7 @@ export interface TextureTestMixinType {
* Gets a byte offset to a texel
*/
getTexelOffsetInBytes(
textureDataLayout: Required<GPUImageDataLayout>,
textureDataLayout: Required<GPUTexelCopyBufferLayout>,
format: ColorTextureFormat,
texel: Required<GPUOrigin3DDict>,
origin?: Required<GPUOrigin3DDict>
Expand Down Expand Up @@ -1481,7 +1481,7 @@ function getPipelineToRenderTextureToRGB8UnormTexture(
}

type LinearCopyParameters = {
dataLayout: Required<GPUImageDataLayout>;
dataLayout: Required<GPUTexelCopyBufferLayout>;
origin: Required<GPUOrigin3DDict>;
data: Uint8Array;
};
Expand Down Expand Up @@ -1511,7 +1511,7 @@ export function TextureTestMixin<F extends FixtureClass<GPUTest>>(
}

expectTexelViewComparisonIsOkInTexture(
src: GPUImageCopyTexture,
src: GPUTexelCopyTextureInfo,
exp: TexelView,
size: GPUExtent3D,
comparisonOptions = {
Expand All @@ -1526,7 +1526,7 @@ export function TextureTestMixin<F extends FixtureClass<GPUTest>>(
}

expectSinglePixelComparisonsAreOkInTexture<E extends PixelExpectation>(
src: GPUImageCopyTexture,
src: GPUTexelCopyTextureInfo,
exp: PerPixelComparison<E>[],
comparisonOptions = {
maxIntDiff: 0,
Expand Down Expand Up @@ -1836,7 +1836,7 @@ export function TextureTestMixin<F extends FixtureClass<GPUTest>>(

/** Offset for a particular texel in the linear texture data */
getTexelOffsetInBytes(
textureDataLayout: Required<GPUImageDataLayout>,
textureDataLayout: Required<GPUTexelCopyBufferLayout>,
format: ColorTextureFormat,
texel: Required<GPUOrigin3DDict>,
origin: Required<GPUOrigin3DDict> = { x: 0, y: 0, z: 0 }
Expand Down
4 changes: 2 additions & 2 deletions src/webgpu/util/copy_to_texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export class TextureUploadingUtils extends TextureTestMixin(GPUTest) {
}

doTestAndCheckResult(
imageCopyExternalImage: GPUImageCopyExternalImage,
dstTextureCopyView: GPUImageCopyTextureTagged,
imageCopyExternalImage: GPUCopyExternalImageSourceInfo,
dstTextureCopyView: GPUCopyExternalImageDestInfo,
expTexelView: TexelView,
copySize: Required<GPUExtent3DDict>,
texelCompareOptions: TexelCompareOptions
Expand Down
4 changes: 2 additions & 2 deletions src/webgpu/util/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ const s_copyBufferToTextureViaRenderPipelines = new WeakMap<
function copyBufferToTextureViaRender(
t: GPUTest,
encoder: GPUCommandEncoder,
source: GPUImageCopyBuffer,
source: GPUTexelCopyBufferInfo,
sourceFormat: GPUTextureFormat,
dest: GPUImageCopyTexture,
dest: GPUTexelCopyTextureInfo,
size: GPUExtent3D
) {
const { format: textureFormat, sampleCount } = dest.texture;
Expand Down
2 changes: 1 addition & 1 deletion src/webgpu/util/texture/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function validateRowsPerImage({
}

interface DataBytesForCopyArgs {
layout: GPUImageDataLayout;
layout: GPUTexelCopyBufferLayout;
format: SizedTextureFormat;
copySize: Readonly<GPUExtent3DDict> | readonly number[];
method: ImageCopyType;
Expand Down
4 changes: 2 additions & 2 deletions src/webgpu/util/texture/texture_ok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function comparePerComponent(
/** Create a new mappable GPUBuffer, and copy a subrectangle of GPUTexture data into it. */
function createTextureCopyForMapRead(
t: GPUTest,
source: GPUImageCopyTexture,
source: GPUTexelCopyTextureInfo,
copySize: GPUExtent3D,
{ format }: { format: EncodableTextureFormat }
): { buffer: GPUBuffer; bytesPerRow: number; rowsPerImage: number } {
Expand Down Expand Up @@ -298,7 +298,7 @@ ${generatePrettyTable(opts, [
*/
export async function textureContentIsOKByT2B(
t: GPUTest,
source: GPUImageCopyTexture,
source: GPUTexelCopyTextureInfo,
copySize_: GPUExtent3D,
{ expTexelView }: { expTexelView: TexelView },
texelCompareOptions: TexelCompareOptions,
Expand Down
24 changes: 12 additions & 12 deletions src/webgpu/web_platform/copyToTexture/ImageBitmap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ g.test('from_ImageData')
Then call copyExternalImageToTexture() to do a full copy to the 0 mipLevel
of dst texture, and read the contents out to compare with the ImageBitmap contents.
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUImageCopyTextureTagged'
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUCopyExternalImageDestInfo'
is set to 'true' and do unpremultiply alpha if it is set to 'false'.
If 'flipY' in 'GPUImageCopyExternalImage' is set to 'true', copy will ensure the result
If 'flipY' in 'GPUCopyExternalImageSourceInfo' is set to 'true', copy will ensure the result
is flipped.
The tests covers:
- Valid dstFormat of copyExternalImageToTexture()
- Valid source image alphaMode
- Valid dest alphaMode
- Valid 'flipY' config in 'GPUImageCopyExternalImage' (named 'srcFlipYInCopy' in cases)
- Valid 'flipY' config in 'GPUCopyExternalImageSourceInfo' (named 'srcFlipYInCopy' in cases)
And the expected results are all passed.
`
Expand Down Expand Up @@ -151,18 +151,18 @@ g.test('from_canvas')
Then call copyExternalImageToTexture() to do a full copy to the 0 mipLevel
of dst texture, and read the contents out to compare with the ImageBitmap contents.
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUImageCopyTextureTagged'
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUCopyExternalImageDestInfo'
is set to 'true' and do unpremultiply alpha if it is set to 'false'.
If 'flipY' in 'GPUImageCopyExternalImage' is set to 'true', copy will ensure the result
If 'flipY' in 'GPUCopyExternalImageSourceInfo' is set to 'true', copy will ensure the result
is flipped.
The tests covers:
- Valid 2D canvas
- Valid dstFormat of copyExternalImageToTexture()
- Valid source image alphaMode
- Valid dest alphaMode
- Valid 'flipY' config in 'GPUImageCopyExternalImage' (named 'srcFlipYInCopy' in cases)
- Valid 'flipY' config in 'GPUCopyExternalImageSourceInfo' (named 'srcFlipYInCopy' in cases)
And the expected results are all passed.
`
Expand Down Expand Up @@ -299,18 +299,18 @@ g.test('copy_subrect_from_ImageData')
rect info list, to the 0 mipLevel of dst texture, and read the contents out to compare
with the ImageBitmap contents.
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUImageCopyTextureTagged'
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUCopyExternalImageDestInfo'
is set to 'true' and do unpremultiply alpha if it is set to 'false'.
If 'flipY' in 'GPUImageCopyExternalImage' is set to 'true', copy will ensure the result
If 'flipY' in 'GPUCopyExternalImageSourceInfo' is set to 'true', copy will ensure the result
is flipped, and origin is top-left consistantly.
The tests covers:
- Source WebGPU Canvas lives in the same GPUDevice or different GPUDevice as test
- Valid dstFormat of copyExternalImageToTexture()
- Valid source image alphaMode
- Valid dest alphaMode
- Valid 'flipY' config in 'GPUImageCopyExternalImage' (named 'srcFlipYInCopy' in cases)
- Valid 'flipY' config in 'GPUCopyExternalImageSourceInfo' (named 'srcFlipYInCopy' in cases)
- Valid subrect copies.
And the expected results are all passed.
Expand Down Expand Up @@ -416,18 +416,18 @@ g.test('copy_subrect_from_2D_Canvas')
rect info list, to the 0 mipLevel of dst texture, and read the contents out to compare
with the ImageBitmap contents.
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUImageCopyTextureTagged'
Do premultiply alpha during copy if 'premultipliedAlpha' in 'GPUCopyExternalImageDestInfo'
is set to 'true' and do unpremultiply alpha if it is set to 'false'.
If 'flipY' in 'GPUImageCopyExternalImage' is set to 'true', copy will ensure the result
If 'flipY' in 'GPUCopyExternalImageSourceInfo' is set to 'true', copy will ensure the result
is flipped, and origin is top-left consistantly.
The tests covers:
- Source WebGPU Canvas lives in the same GPUDevice or different GPUDevice as test
- Valid dstFormat of copyExternalImageToTexture()
- Valid source image alphaMode
- Valid dest alphaMode
- Valid 'flipY' config in 'GPUImageCopyExternalImage' (named 'srcFlipYInCopy' in cases)
- Valid 'flipY' config in 'GPUCopyExternalImageSourceInfo' (named 'srcFlipYInCopy' in cases)
- Valid subrect copies.
And the expected results are all passed.
Expand Down
Loading

0 comments on commit 9856759

Please sign in to comment.