Skip to content

Commit 201b2fb

Browse files
[deno] Don't report support for native-only features (#7813)
1 parent e936c06 commit 201b2fb

File tree

5 files changed

+54
-22
lines changed

5 files changed

+54
-22
lines changed

cts_runner/examples/hello-compute.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ function isTypedArrayEqual(a, b) {
112112
const actual = new Uint32Array(data);
113113
const expected = new Uint32Array([0, 2, 7, 55]);
114114

115-
console.error("actual", actual);
116-
console.error("expected", expected);
115+
console.log("actual", actual);
116+
console.log("expected", expected);
117117

118118
if (!isTypedArrayEqual(actual, expected)) {
119119
throw new TypeError("Actual does not equal expected!");

cts_runner/test.lst

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,7 @@ webgpu:api,operation,compute,basic:memcpy:*
55
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*
66
webgpu:api,operation,compute_pipeline,overrides:*
77
webgpu:api,operation,device,lost:*
8-
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="valid"
9-
//FAIL: webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="invalid"
10-
// https://github.com/gfx-rs/wgpu/issues/7796 (Mac only)
11-
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="destroyed"
12-
webgpu:api,validation,encoding,cmds,clearBuffer:buffer,device_mismatch:*
13-
webgpu:api,validation,encoding,cmds,clearBuffer:default_args:*
14-
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_usage:*
15-
webgpu:api,validation,encoding,cmds,clearBuffer:size_alignment:*
16-
webgpu:api,validation,encoding,cmds,clearBuffer:offset_alignment:*
17-
webgpu:api,validation,encoding,cmds,clearBuffer:overflow:*
18-
webgpu:api,validation,encoding,cmds,clearBuffer:out_of_bounds:*
8+
webgpu:api,validation,encoding,cmds,clearBuffer:*
199
webgpu:api,validation,encoding,cmds,compute_pass:set_pipeline:*
2010
webgpu:api,validation,encoding,cmds,compute_pass:dispatch_sizes:*
2111
webgpu:api,validation,encoding,cmds,copyTextureToTexture:copy_with_invalid_or_destroyed_texture:*
@@ -39,6 +29,7 @@ webgpu:api,validation,encoding,encoder_state:*
3929
webgpu:api,validation,encoding,encoder_open_state:non_pass_commands:*
4030
webgpu:api,validation,encoding,encoder_open_state:render_pass_commands:*
4131
//FAIL: webgpu:api,validation,encoding,encoder_open_state:render_bundle_commands:*
32+
// https://github.com/gfx-rs/wgpu/issues/7857
4233
webgpu:api,validation,encoding,encoder_open_state:compute_pass_commands:*
4334
webgpu:api,validation,encoding,beginComputePass:*
4435
webgpu:api,validation,encoding,beginRenderPass:*

cts_runner/tests/features.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const adapter = await navigator.gpu.requestAdapter();
2+
3+
if (adapter.features.has("mappable-primary-buffers")) {
4+
throw new TypeError("Adapter should not report support for wgpu native-only features");
5+
}

cts_runner/tests/integration.rs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
use std::path::PathBuf;
1+
// Tests for cts_runner
2+
//
3+
// As of June 2025, these tests are not run in CI.
4+
5+
use std::{
6+
fmt::{self, Debug, Display},
7+
path::PathBuf,
8+
process::Command,
9+
str,
10+
};
211

312
pub fn target_dir() -> PathBuf {
413
let current_exe = std::env::current_exe().unwrap();
@@ -15,13 +24,38 @@ pub fn cts_runner_exe_path() -> PathBuf {
1524
p
1625
}
1726

18-
#[test]
19-
fn hello_compute_example() {
20-
let output = std::process::Command::new(cts_runner_exe_path())
21-
.arg("examples/hello-compute.js")
22-
.spawn()
23-
.unwrap()
24-
.wait_with_output()
27+
pub struct JsError;
28+
29+
impl Display for JsError {
30+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31+
write!(f, "JavaScript test returned an error")
32+
}
33+
}
34+
35+
impl Debug for JsError {
36+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37+
write!(f, "{}", self)
38+
}
39+
}
40+
41+
type JsResult = Result<(), JsError>;
42+
43+
fn exec_js_test(script: &str) -> JsResult {
44+
let output = Command::new(cts_runner_exe_path())
45+
.arg(script)
46+
.output()
2547
.unwrap();
26-
assert!(output.status.success())
48+
println!("{}", str::from_utf8(&output.stdout).unwrap());
49+
eprintln!("{}", str::from_utf8(&output.stderr).unwrap());
50+
output.status.success().then_some(()).ok_or(JsError)
51+
}
52+
53+
#[test]
54+
fn hello_compute_example() -> JsResult {
55+
exec_js_test("examples/hello-compute.js")
56+
}
57+
58+
#[test]
59+
fn features() -> JsResult {
60+
exec_js_test("tests/features.js")
2761
}

deno_webgpu/adapter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ impl GPUAdapter {
8484
fn features(&self, scope: &mut v8::HandleScope) -> v8::Global<v8::Object> {
8585
self.features.get(scope, |scope| {
8686
let features = self.instance.adapter_features(self.id);
87+
// Only expose WebGPU features, not wgpu native-only features
88+
let features = features & wgpu_types::Features::all_webgpu_mask();
8789
let features = features_to_feature_names(features);
8890
GPUSupportedFeatures::new(scope, features)
8991
})

0 commit comments

Comments
 (0)