Skip to content

Commit fd6f16f

Browse files
Revive the CTS job (#7675)
Includes the following minor functional fixes to deno_webgpu: * Don't throw an error immediately when `create_buffer` is called with invalid usage flags. * Implement `on_submitted_work_done`. * Correct validation of GPUExtent3D element count. * Run without tracing (instead of panic) if the DENO_WEBGPU_TRACE env var is not set. Fixes #6838
1 parent d7e6a0e commit fd6f16f

File tree

11 files changed

+184
-44
lines changed

11 files changed

+184
-44
lines changed

.github/workflows/cts.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: CTS
2+
3+
on:
4+
pull_request:
5+
types: [labeled, opened, synchronize]
6+
schedule:
7+
- cron: '33 2 * * *'
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_INCREMENTAL: false
12+
CARGO_TERM_COLOR: always
13+
RUST_BACKTRACE: full
14+
MSRV: "1.84"
15+
16+
jobs:
17+
cts:
18+
# For pull requests, only run if we add the "PR: run CTS" label
19+
if: "github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'PR: run CTS')"
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
include:
25+
# Windows
26+
- name: Windows x86_64
27+
os: windows-2022
28+
target: x86_64-pc-windows-msvc
29+
backends: dx12
30+
31+
# Linux
32+
#- name: Linux x86_64
33+
# os: ubuntu-20.04
34+
# target: x86_64-unknown-linux-gnu
35+
# backends: vulkan # gl
36+
37+
name: CTS ${{ matrix.name }}
38+
runs-on: ${{ matrix.os }}
39+
40+
steps:
41+
- name: checkout repo
42+
uses: actions/checkout@v4
43+
with:
44+
path: wgpu
45+
46+
- name: checkout cts
47+
run: |
48+
git clone https://github.com/gpuweb/cts.git
49+
cd cts
50+
git checkout $(cat ../wgpu/cts_runner/revision.txt)
51+
52+
- name: Install Repo MSRV toolchain
53+
run: |
54+
rustup toolchain install ${{ env.MSRV }} --no-self-update --profile=minimal --target ${{ matrix.target }}
55+
rustup override set ${{ env.MSRV }}
56+
cargo -V
57+
58+
- name: caching
59+
uses: Swatinem/rust-cache@v2
60+
with:
61+
key: cts-b # suffix for cache busting
62+
workspaces: wgpu
63+
64+
# We enable line numbers for panics, but that's it
65+
- name: disable debug
66+
shell: bash
67+
run: |
68+
mkdir -p wgpu/.cargo
69+
echo """[profile.dev]
70+
debug = 1" > wgpu/.cargo/config.toml
71+
72+
- name: build CTS runner
73+
run: |
74+
cargo build --manifest-path wgpu/cts_runner/Cargo.toml
75+
76+
- name: run CTS
77+
shell: bash
78+
run: |
79+
cd cts;
80+
for backend in ${{ matrix.backends }}; do
81+
echo "======= CTS TESTS $backend ======";
82+
grep -v '^//' ../wgpu/cts_runner/test.lst | while IFS=$' \t\r\n' read test; do
83+
echo "=== Running $test ===";
84+
DENO_WEBGPU_BACKEND=$backend cargo run --manifest-path ../wgpu/cts_runner/Cargo.toml --frozen -- ./tools/run_deno --verbose "$test";
85+
done
86+
done
87+
echo;
88+
echo "Note: Summary reflects only the last test suite, not the entire run."

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ web-sys = { version = "0.3.77", default-features = false }
231231
web-time = "1"
232232

233233
# deno dependencies
234-
deno_console = "0.190.0"
235-
deno_core = "0.336.0"
236-
deno_url = "0.190.0"
237-
deno_web = "0.221.0"
238-
deno_webidl = "0.190.0"
234+
deno_console = "0.192.0"
235+
deno_core = "0.338.0"
236+
deno_url = "0.192.0"
237+
deno_web = "0.224.0"
238+
deno_webidl = "0.192.0"
239239
deno_webgpu = { version = "0.157.0", path = "./deno_webgpu" }
240240
deno_unsync = "0.4.2"
241241
deno_error = "0.5.5"

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,12 @@ If you are a user and want a way to help contribute to wgpu, we always need more
214214

215215
WebGPU includes a Conformance Test Suite to validate that implementations are working correctly. We can run this CTS against wgpu.
216216

217-
To run the CTS, first, you need to check it out:
217+
To have GitHub run the CTS against a pull request, you can add the `PR: run CTS` label to the PR.
218+
219+
To run the CTS locally, first, you need to check it out:
218220

219221
```
222+
# In the root of your wgpu tree:
220223
git clone https://github.com/gpuweb/cts.git
221224
cd cts
222225
# works in bash and powershell

cts_runner/revision.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7ea73ba6f44c9f6fedfffc06f14c73ea9f2eaa11
1+
049916a6191725aad5a5692e5a22df47d45c88fa

cts_runner/src/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import * as performance from "ext:deno_web/15_performance.js";
2929
import { loadWebGPU } from "ext:deno_webgpu/00_init.js";
3030
import * as imageData from "ext:deno_web/16_image_data.js";
3131
const webgpu = loadWebGPU();
32+
webgpu.initGPU();
3233

3334
// imports needed to pass module evaluation
3435
import "ext:deno_url/01_urlpattern.js";

cts_runner/test.lst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
unittests:*
22
webgpu:api,operation,command_buffer,basic:*
3-
webgpu:api,operation,compute,basic:*
3+
webgpu:api,operation,compute,basic:memcpy:*
4+
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*
5+
webgpu:api,operation,device,lost:*
46
webgpu:api,operation,rendering,basic:clear:*
57
webgpu:api,operation,rendering,basic:fullscreen_quad:*
68
//FAIL: webgpu:api,operation,rendering,basic:large_draw:*
7-
webgpu:api,operation,rendering,blending:*
8-
webgpu:api,operation,rendering,blending:GPUBlendComponent:*
9+
webgpu:api,operation,rendering,color_target_state:blending,GPUBlendComponent:*
10+
webgpu:api,operation,rendering,color_target_state:blending,formats:*
11+
webgpu:api,operation,rendering,color_target_state:blend_constant,setting:*
912
webgpu:api,operation,rendering,depth:*
1013
webgpu:api,operation,rendering,draw:*
14+
// https://github.com/gfx-rs/wgpu/issues/7391
15+
//FAIL: webgpu:api,operation,uncapturederror:*

deno_webgpu/adapter.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ impl GPUAdapter {
126126
let required_limits =
127127
serde_json::from_value(serde_json::to_value(descriptor.required_limits)?)?;
128128

129-
let webgpu_trace = std::env::var_os("DENO_WEBGPU_TRACE").unwrap();
129+
let trace = std::env::var_os("DENO_WEBGPU_TRACE")
130+
.map(|path| wgpu_types::Trace::Directory(std::path::PathBuf::from(path)))
131+
.unwrap_or_default();
130132

131133
let wgpu_descriptor = wgpu_types::DeviceDescriptor {
132134
label: crate::transform_label(descriptor.label.clone()),
@@ -135,7 +137,7 @@ impl GPUAdapter {
135137
),
136138
required_limits,
137139
memory_hints: Default::default(),
138-
trace: wgpu_types::Trace::Directory(std::path::PathBuf::from(webgpu_trace)),
140+
trace,
139141
};
140142

141143
let (device, queue) =

deno_webgpu/device.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl GPUDevice {
119119
fn queue(&self, scope: &mut v8::HandleScope) -> v8::Global<v8::Object> {
120120
self.queue_obj.get(scope, |_| GPUQueue {
121121
id: self.queue,
122+
device: self.id,
122123
error_handler: self.error_handler.clone(),
123124
instance: self.instance.clone(),
124125
label: self.label.clone(),
@@ -134,15 +135,17 @@ impl GPUDevice {
134135

135136
#[required(1)]
136137
#[cppgc]
137-
fn create_buffer(
138-
&self,
139-
#[webidl] descriptor: super::buffer::GPUBufferDescriptor,
140-
) -> Result<GPUBuffer, JsErrorBox> {
138+
fn create_buffer(&self, #[webidl] descriptor: super::buffer::GPUBufferDescriptor) -> GPUBuffer {
139+
// Validation of the usage needs to happen on the device timeline, so
140+
// don't raise an error immediately if it isn't valid. wgpu will
141+
// reject `BufferUsages::empty()`.
142+
let usage = wgpu_types::BufferUsages::from_bits(descriptor.usage)
143+
.unwrap_or(wgpu_types::BufferUsages::empty());
144+
141145
let wgpu_descriptor = wgpu_core::resource::BufferDescriptor {
142146
label: crate::transform_label(descriptor.label.clone()),
143147
size: descriptor.size,
144-
usage: wgpu_types::BufferUsages::from_bits(descriptor.usage)
145-
.ok_or_else(|| JsErrorBox::type_error("usage is not valid"))?,
148+
usage,
146149
mapped_at_creation: descriptor.mapped_at_creation,
147150
};
148151

@@ -152,7 +155,7 @@ impl GPUDevice {
152155

153156
self.error_handler.push_error(err);
154157

155-
Ok(GPUBuffer {
158+
GPUBuffer {
156159
instance: self.instance.clone(),
157160
error_handler: self.error_handler.clone(),
158161
id,
@@ -171,7 +174,7 @@ impl GPUDevice {
171174
None
172175
}),
173176
mapped_js_buffers: RefCell::new(vec![]),
174-
})
177+
}
175178
}
176179

177180
#[required(1)]

0 commit comments

Comments
 (0)