Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from gpuweb:main #18

Merged
merged 28 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
32f8ad2
Enable depth24plus, depth24plus-stencil8, depth32float-stencil8 in te…
greggman Oct 29, 2024
30ee073
Make textureLoad/Gather/Compare not load weights (#4018)
greggman Oct 30, 2024
bfbfd9e
Refactor to not render to rgba32float (#4020)
greggman Oct 30, 2024
8690def
Stop trying to filter sint/uint formats. (#4022)
greggman Oct 31, 2024
da475e7
Fix readTextureToTexelViews to handle all types of formats and viewDi…
greggman Nov 1, 2024
8328265
Re-enable linear with comparisons. (#4026)
greggman Nov 1, 2024
f2e2ada
Fix fragment shader subgroup builtin io test (#4024)
jiangzhaoming Nov 4, 2024
e4718ba
Don't test texture_depth_xxx with linear (#4028)
greggman Nov 4, 2024
d2bd876
Update webgpu/types to 0.1.50 (#4029)
Kangz Nov 4, 2024
8a80203
Test non-filterable textures can't be used with filtering sampler. (#…
greggman Nov 5, 2024
8a781f5
Compat: skip 'cube-array' validation tests. (#4032)
SenorBlanco Nov 5, 2024
0d22c00
Add tests for GPUDevice.adapterInfo (#4023)
beaufortfrancois Nov 6, 2024
447b667
Assert GPUAdapterInfo instances (#4034)
beaufortfrancois Nov 6, 2024
b9f32fd
Fragment subgroup_size test: Don't use broadcasting (#4035)
jiangzhaoming Nov 7, 2024
8d0aa85
test textureNumLevels/Layers/Samples with stages (#4036)
greggman Nov 12, 2024
ddc592b
Add Stages and ExternalTexture to textureDimension tests (#4037)
greggman Nov 13, 2024
3dbe9f3
Expand textureStorage tests (#4039)
greggman Nov 14, 2024
ec0b116
[Compat] Skip depthBiasClamp !== 0 cases (#4043)
shrekshao Nov 14, 2024
9904b91
Fix tests related to subgroup uniformity diagnostics (#4038)
alan-baker Nov 14, 2024
327fb7b
Try to relax textureSampleBias (#4044)
greggman Nov 15, 2024
467c899
Initial commit (#4016)
petermcneeleychromium Nov 19, 2024
990c238
Fix makeRandomDepthComparisonTexelGenerator (#4048)
greggman Nov 19, 2024
003cb57
Fix readTextureToTextureViews for multisampled textures (#4049)
greggman Nov 19, 2024
4f32a04
Do not query weights for `textureSampleBaseClampToEdge` (#4050)
greggman Nov 20, 2024
bc88622
Test texture mix weights separately (#4051)
greggman Nov 20, 2024
91a2cfe
Add warning in checkCallResults for compressed textures (#4053)
greggman Nov 21, 2024
0c09a66
Compat: Don't test depth textures with non-comparison samplers (#4054)
greggman Nov 22, 2024
4ff5ad7
Compat: Validate non-comparsion sampler + depth texture fails. (#4055)
greggman Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/w3c-image-capture": "^1.0.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@webgpu/types": "^0.1.49",
"@webgpu/types": "^0.1.51",
"ansi-colors": "4.1.3",
"babel-plugin-add-header-comment": "^1.0.3",
"babel-plugin-const-enum": "^1.2.0",
Expand Down
101 changes: 99 additions & 2 deletions src/webgpu/api/operation/adapter/info.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export const description = `
Tests GPUAdapter.info members formatting.
Tests for GPUAdapterInfo.
`;

import { Fixture } from '../../../../common/framework/fixture.js';
import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { keysOf } from '../../../../common/util/data_tables.js';
import { getGPU } from '../../../../common/util/navigator_gpu.js';
import { assert } from '../../../../common/util/util.js';
import { assert, objectEquals } from '../../../../common/util/util.js';

export const g = makeTestGroup(Fixture);

Expand Down Expand Up @@ -39,3 +40,99 @@ g.test('adapter_info')
`adapterInfo.device should be a normalized identifier. But it's '${adapterInfo.device}'`
);
});

g.test('same_object')
.desc(
`
GPUAdapter.info and GPUDevice.adapterInfo provide the same object each time they're accessed,
but different objects from one another.`
)
.fn(async t => {
const gpu = getGPU(t.rec);
const adapter = await gpu.requestAdapter();
assert(adapter !== null);
assert(adapter.info instanceof GPUAdapterInfo);

const adapterInfo1 = adapter.info;
const adapterInfo2 = adapter.info;
t.expect(adapterInfo1 === adapterInfo2, 'adapter.info should obey [SameObject]');

const device = await t.requestDeviceTracked(adapter);
assert(device !== null);
assert(device.adapterInfo instanceof GPUAdapterInfo);

const deviceAdapterInfo1 = device.adapterInfo;
const deviceAdapterInfo2 = device.adapterInfo;
t.expect(
deviceAdapterInfo1 === deviceAdapterInfo2,
'device.adapterInfo should obey [SameObject]'
);

t.expect(
adapter.info !== device.adapterInfo,
'adapter.info and device.adapterInfo should NOT return the same object'
);
});

g.test('device_matches_adapter')
.desc(
`
Test that GPUDevice.adapterInfo matches GPUAdapter.info. Cases access the members in
different orders to make sure that they are consistent regardless of the access order.`
)
.paramsSubcasesOnly(u =>
u.combine('testDeviceFirst', [true, false]).combine('testMembersFirst', [true, false])
)
.fn(async t => {
const { testDeviceFirst, testMembersFirst } = t.params;

const gpu = getGPU(t.rec);
const adapter = await gpu.requestAdapter();
assert(adapter !== null);

const device = await t.requestDeviceTracked(adapter);
assert(device !== null);

const deviceInfo: unknown[] = [];
const adapterInfo: unknown[] = [];

const kGPUAdapterInfoKeys = keysOf(GPUAdapterInfo.prototype);
if (testMembersFirst) {
if (testDeviceFirst) {
assert(device.adapterInfo instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
deviceInfo.push(device.adapterInfo[k]);
}
assert(adapter.info instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
adapterInfo.push(adapter.info[k]);
}
} else {
assert(adapter.info instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
adapterInfo.push(adapter.info[k]);
}
assert(device.adapterInfo instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
deviceInfo.push(device.adapterInfo[k]);
}
}
} else {
if (testDeviceFirst) {
assert(device.adapterInfo instanceof GPUAdapterInfo);
assert(adapter.info instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
deviceInfo.push(device.adapterInfo[k]);
adapterInfo.push(adapter.info[k]);
}
} else {
assert(adapter.info instanceof GPUAdapterInfo);
assert(device.adapterInfo instanceof GPUAdapterInfo);
for (const k of kGPUAdapterInfoKeys) {
adapterInfo.push(adapter.info[k]);
deviceInfo.push(device.adapterInfo[k]);
}
}
t.expect(objectEquals(deviceInfo, adapterInfo));
}
});
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
60 changes: 43 additions & 17 deletions src/webgpu/api/operation/vertex_state/correctness.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,25 +427,51 @@ struct VSOutputs {

case 'unorm': {
if (formatInfo.bytesPerComponent === 'packed') {
assert(format === 'unorm10-10-10-2'); // This is the only packed format for now.
assert(bitSize === 0);

/* prettier-ignore */
const data = [
[ 0, 0, 0, 0],
[1023, 1023, 1023, 3],
[ 243, 567, 765, 2],
];
const vertexData = new Uint32Array(data.map(makeRgb10a2)).buffer;
const expectedData = new Float32Array(data.flat().map(normalizeRgb10a2)).buffer;

return {
shaderBaseType: 'f32',
testComponentCount: data.flat().length,
expectedData,
vertexData,
floatTolerance: 0.1 / 1023,
};
switch (format) {
case 'unorm10-10-10-2': {
/* prettier-ignore */
const data = [
[ 0, 0, 0, 0],
[1023, 1023, 1023, 3],
[ 243, 567, 765, 2],
];
const vertexData = new Uint32Array(data.map(makeRgb10a2)).buffer;
const expectedData = new Float32Array(data.flat().map(normalizeRgb10a2)).buffer;

return {
shaderBaseType: 'f32',
testComponentCount: data.flat().length,
expectedData,
vertexData,
floatTolerance: 0.1 / 1023,
};
}

case 'unorm8x4-bgra': {
const data = [42, 0, 1, 2, 3, 4, 128, 255];
const vertexData = new Uint8Array(data).buffer;
const expectedData = new Float32Array(
data.map(v => normalizedIntegerAsFloat(v, 8, false))
);

for (let i = 0; i + 2 < expectedData.length; i += 4) {
const r = expectedData[i + 0];
const b = expectedData[i + 2];
expectedData[i + 0] = b;
expectedData[i + 2] = r;
}

return {
shaderBaseType: 'f32',
testComponentCount: data.length,
expectedData: expectedData.buffer,
vertexData,
floatTolerance: 0.1 / 255,
};
}
}
}

/* prettier-ignore */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ g.test('configure,at_over')

// This should not fail, even if the size is too large but it might fail
// if we're in a worker and HTMLCanvasElement does not exist.
const canvas = createCanvas(t, canvasType, size[0], size[1])!;
const canvas = createCanvas(t, canvasType, size[0], size[1]);
if (canvas) {
const context = canvas.getContext('webgpu') as GPUCanvasContext;
t.expect(!!context, 'should not fail to create context even if size is too large');
Expand Down Expand Up @@ -96,7 +96,7 @@ g.test('getCurrentTexture,at_over')
// Start with a small size so configure will succeed.
// This should not fail, even if the size is too large but it might fail
// if we're in a worker and HTMLCanvasElement does not exist.
const canvas = createCanvas(t, canvasType, 1, 1)!;
const canvas = createCanvas(t, canvasType, 1, 1);
if (canvas) {
const context = canvas.getContext('webgpu') as GPUCanvasContext;
t.expect(!!context, 'should not fail to create context even if size is too large');
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/api/validation/compute_pipeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ g.test('resource_compatibility')
!t.hasLanguageFeature('readonly_and_readwrite_storage_textures'),
'Storage textures require language feature'
);
t.skipIfTextureViewDimensionNotSupported(wgslResource.texture?.viewDimension);

const layout = t.device.createPipelineLayout({
bindGroupLayouts: [
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
Loading