Skip to content

Commit

Permalink
Enable WebGPU in WebKitTestRunner
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271744
rdar://125823851

Reviewed by Mike Wyrzykowski.

For some unknown and mysterious reason, enabling it in hardcodedFeaturesBasedOnPathForTest
was insufficient to actually enable WebGPU in WebKitTestRunner.  There's no reason to limit
its existence to just WebGPU tests.  Let's enable it in all tests.

I had written several tests with extra try/catch statements to work if WebGPU was enabled
or not.  Now that it's enabled in WebKitTestRunner, I can remove these and make the tests
more effective in catching regressions.

In order to make the tests run to completion on computers with different GPUs made by different
manufacturers, I had to reduce all the maxBindingsPerBindGroup values to less than 1000,
remove all requirements to have etc2 and astc texture compression extensions, and use a
more commonly supported texture format, which I arbitrarily chose to be rgb9e5ufloat.
Also minStorageBufferOffsetAlignment and minUniformBufferOffsetAlignment need to be 256.
These things were unrelated to the original issues for which I introduced the tests.

The iOS simulator is unfortunately currently unable to run WebGPU tests, so I skip them there.

In order to fix assertions in debug builds, I changed some types from CompletionHandler<void()>
to Function<void()> because StreamConnectionWorkQueue::dispatch is not actually guaranteed
to call the function if m_shouldQuit ever becomes true because stopAndWaitForCompletion is called.

* LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/fast/webgpu/accelerated-image-conversion-failure.html:
* LayoutTests/fast/webgpu/bind-group-layout-invalid.html:
* LayoutTests/fast/webgpu/command-buffer-after-destruction.html:
* LayoutTests/fast/webgpu/conversion-to-rg8unorm.html:
* LayoutTests/fast/webgpu/copy-texture-more-than-4gb.html:
* LayoutTests/fast/webgpu/forbid-bottom-struct-member.html:
* LayoutTests/fast/webgpu/image-data-8-bytes-per-pixel.html:
* LayoutTests/fast/webgpu/invalid-surface-height.html:
* LayoutTests/fast/webgpu/multidimensional-texture-bounds.html:
* LayoutTests/fast/webgpu/null-video-texture.html:
* LayoutTests/fast/webgpu/optional-media-identifier.html:
* LayoutTests/fast/webgpu/present-without-compute-pipeline.html:
* LayoutTests/fast/webgpu/queue-write-texture-offset.html:
* LayoutTests/fast/webgpu/render-bundle-validation-color-format.html:
* LayoutTests/fast/webgpu/repeated-out-of-memory-error.html:
* LayoutTests/fast/webgpu/type-checker-array-without-argument.html:
* LayoutTests/fast/webgpu/use-canvas-without-layer.html:
* LayoutTests/fast/webgpu/write-to-destroyed-buffer.html:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/mac/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/wincairo/fast/dom/navigator-detached-no-crash-expected.txt:
* LayoutTests/platform/wpe/fast/dom/navigator-detached-no-crash-expected.txt:
* Tools/TestRunnerShared/TestFeatures.cpp:
(WTR::hardcodedFeaturesBasedOnPathForTest):
(WTR::shouldEnableWebGPU): Deleted.
* Tools/WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

Canonical link: https://commits.webkit.org/277246@main
  • Loading branch information
achristensen07 committed Apr 9, 2024
1 parent 56976d0 commit 3929136
Show file tree
Hide file tree
Showing 35 changed files with 355 additions and 504 deletions.
2 changes: 2 additions & 0 deletions LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,7 @@ navigator.clipboard is OK
navigator.contacts is OK
navigator.cookieEnabled is OK
navigator.credentials is OK
navigator.gpu is OK
navigator.hardwareConcurrency is OK
navigator.javaEnabled() is OK
navigator.language is OK
Expand Down Expand Up @@ -39,6 40,7 @@ navigator.clipboard is OK
navigator.contacts is OK
navigator.cookieEnabled is OK
navigator.credentials is OK
navigator.gpu is OK
navigator.hardwareConcurrency is OK
navigator.javaEnabled() is OK
navigator.language is OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 14,9 @@
}

onload = async () => {
try {
let video1 = await videoWithData();
let imageBitmap4 = await createImageBitmap(video1);
let videoFrame7 = new VideoFrame(imageBitmap4, {timestamp: 0});
} catch { }
let video1 = await videoWithData();
let imageBitmap4 = await createImageBitmap(video1);
let videoFrame7 = new VideoFrame(imageBitmap4, {timestamp: 0});
if (window.testRunner) { testRunner.notifyDone() }
};
</script>
Expand Down
9 changes: 2 additions & 7 deletions LayoutTests/fast/webgpu/bind-group-layout-invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 3,13 @@
const log = globalThis.$vm?.print ?? console.log;

onload = async () => {
try {
adapter1 = await navigator.gpu.requestAdapter( { } );
let promise3 = adapter1.requestDevice(
{
label: 'a',
requiredFeatures: [
'depth-clip-control',
'depth32float-stencil8',
'texture-compression-etc2',
'texture-compression-astc',
'indirect-first-instance',
'shader-f16',
'rg11b10ufloat-renderable',
Expand All @@ -22,12 19,11 @@
maxVertexAttributes: 22,
maxVertexBufferArrayStride: 60002,
maxStorageTexturesPerShaderStage: 36,
maxBindingsPerBindGroup: 9205,
maxBindingsPerBindGroup: 205,
},
}
);


let device1 = await promise3;

let pipelineLayout2 = device1.createPipelineLayout(
Expand Down Expand Up @@ -164,8 160,7 @@
);

bindGroupLayout11.label = '\u0afc';
} catch { }
if (window.testRunner) { testRunner.notifyDone() }
if (window.testRunner) { testRunner.notifyDone() }
};
</script>
This test passes if it does not crash.
11 changes: 4 additions & 7 deletions LayoutTests/fast/webgpu/command-buffer-after-destruction.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 12,6 @@
});
}
onload = async () => {
try {
let adapter0 = await navigator.gpu.requestAdapter(
{
}
Expand All @@ -23,7 22,6 @@
requiredFeatures: [
'depth-clip-control',
'depth32float-stencil8',
'texture-compression-astc',
'indirect-first-instance',
'shader-f16',
'rg11b10ufloat-renderable'
Expand All @@ -32,12 30,12 @@
maxColorAttachmentBytesPerSample: 34,
maxVertexBufferArrayStride: 8035,
maxStorageTexturesPerShaderStage: 9,
maxBindingsPerBindGroup: 6910,
maxBindingsPerBindGroup: 910,
maxTextureArrayLayers: 980,
maxTextureDimension1D: 8875,
maxTextureDimension2D: 14193,
minStorageBufferOffsetAlignment: 32,
minUniformBufferOffsetAlignment: 128,
minStorageBufferOffsetAlignment: 256,
minUniformBufferOffsetAlignment: 256,
},
}
);
Expand All @@ -60,8 58,7 @@
device1.destroy();
let texture10 = gpuCanvasContext1.getCurrentTexture();
let video3 = await videoWithData();
} catch { }
if (window.testRunner) { testRunner.notifyDone() }
if (window.testRunner) { testRunner.notifyDone() }
};
</script>
This test passes if it does not crash.
8 changes: 2 additions & 6 deletions LayoutTests/fast/webgpu/conversion-to-rg8unorm.html
Original file line number Diff line number Diff line change
@@ -1,7 1,6 @@
<script>
if (window.testRunner) { testRunner.dumpAsText(); testRunner.waitUntilDone() }
onload = async () => {
try {
let adapter0 = await navigator.gpu.requestAdapter(
{
}
Expand All @@ -12,8 11,6 @@
label: 'a',
requiredFeatures: [
'depth-clip-control',
'texture-compression-etc2',
'texture-compression-astc',
'indirect-first-instance',
'shader-f16',
'rg11b10ufloat-renderable',
Expand All @@ -23,7 20,7 @@
maxVertexAttributes: 23,
maxVertexBufferArrayStride: 46861,
maxStorageTexturesPerShaderStage: 33,
maxBindingsPerBindGroup: 1499,
maxBindingsPerBindGroup: 499,
},
}
);
Expand Down Expand Up @@ -73,8 70,7 @@
4191
]
);
} catch { }
if (window.testRunner) { testRunner.notifyDone() }
if (window.testRunner) { testRunner.notifyDone() }
};
</script>
This test passes if it does not crash.
118 changes: 57 additions & 61 deletions LayoutTests/fast/webgpu/copy-texture-more-than-4gb.html
Original file line number Diff line number Diff line change
@@ -1,68 1,64 @@
<script>
if (window.testRunner) { testRunner.waitUntilDone(); testRunner.dumpAsText() }
onload = async () => {
try {
let adapter0 = await navigator.gpu.requestAdapter();
let device0 = await adapter0.requestDevice(
{
label: '\u0a1d',
requiredFeatures: [
'depth-clip-control',
'depth32float-stencil8',
'texture-compression-etc2',
'texture-compression-astc',
'indirect-first-instance',
'shader-f16',
'rg11b10ufloat-renderable',
'bgra8unorm-storage'
],
}
);
let adapter0 = await navigator.gpu.requestAdapter();
let device0 = await adapter0.requestDevice(
{
label: '\u0a1d',
requiredFeatures: [
'depth-clip-control',
'depth32float-stencil8',
'indirect-first-instance',
'shader-f16',
'rg11b10ufloat-renderable',
'bgra8unorm-storage'
],
}
);

let imageData1 = new ImageData(104, 188);
let texture17 = device0.createTexture(
{
label: '\u2801',
size: {
width: 1177,
height: 963,
depthOrArrayLayers: 319,
},
mipLevelCount: 1,
sampleCount: 1,
dimension: '3d',
format: 'bgra8unorm-srgb',
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
viewFormats: [
'bgra8unorm',
'bgra8unorm-srgb',
'bgra8unorm-srgb',
'bgra8unorm-srgb',
'bgra8unorm',
'bgra8unorm-srgb',
'bgra8unorm',
'bgra8unorm',
'bgra8unorm-srgb'
],
}
);
device0.queue.copyExternalImageToTexture(
{
source: imageData1,
origin: { x: 45, y: 127 },
flipY: true,
},
{
texture: texture17,
mipLevel: 0,
origin: { x: 261, y: 0, z: 114 },
aspect: 'all',
colorSpace: 'srgb',
premultipliedAlpha: true,
},
{width: 56, height: 1, depthOrArrayLayers: 0}
);
} catch {}
let imageData1 = new ImageData(104, 188);
let texture17 = device0.createTexture(
{
label: '\u2801',
size: {
width: 1177,
height: 963,
depthOrArrayLayers: 319,
},
mipLevelCount: 1,
sampleCount: 1,
dimension: '3d',
format: 'bgra8unorm-srgb',
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC,
viewFormats: [
'bgra8unorm',
'bgra8unorm-srgb',
'bgra8unorm-srgb',
'bgra8unorm-srgb',
'bgra8unorm',
'bgra8unorm-srgb',
'bgra8unorm',
'bgra8unorm',
'bgra8unorm-srgb'
],
}
);
device0.queue.copyExternalImageToTexture(
{
source: imageData1,
origin: { x: 45, y: 127 },
flipY: true,
},
{
texture: texture17,
mipLevel: 0,
origin: { x: 261, y: 0, z: 114 },
aspect: 'all',
colorSpace: 'srgb',
premultipliedAlpha: true,
},
{width: 56, height: 1, depthOrArrayLayers: 0}
);
if (window.testRunner) { testRunner.notifyDone() }
};
</script>
Expand Down
18 changes: 8 additions & 10 deletions LayoutTests/fast/webgpu/forbid-bottom-struct-member.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 2,14 @@
<body>
<script>
const doTest = async () => {
try {
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const module = device.createShaderModule({
code: `
struct S { x : u23 }
@must_use fn foo() -> S { return S(); }
`,
});
} catch (e) { }
const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();
const module = device.createShaderModule({
code: `
struct S { x : u23 }
@must_use fn foo() -> S { return S(); }
`,
});
if (window.testRunner) { testRunner.notifyDone() }
};
if (window.testRunner) { testRunner.waitUntilDone(); testRunner.dumpAsText() }
Expand Down
Loading

0 comments on commit 3929136

Please sign in to comment.