Skip to content

[deno] Don't report support for native-only features #7813

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cts_runner/examples/hello-compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ function isTypedArrayEqual(a, b) {
const actual = new Uint32Array(data);
const expected = new Uint32Array([0, 2, 7, 55]);

console.error("actual", actual);
console.error("expected", expected);
console.log("actual", actual);
console.log("expected", expected);

if (!isTypedArrayEqual(actual, expected)) {
throw new TypeError("Actual does not equal expected!");
Expand Down
5 changes: 5 additions & 0 deletions cts_runner/tests/features.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const adapter = await navigator.gpu.requestAdapter();

if (adapter.features.has("mappable-primary-buffers")) {
throw new TypeError("Adapter should not report support for wgpu native-only features");
}
52 changes: 43 additions & 9 deletions cts_runner/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
use std::path::PathBuf;
// Tests for cts_runner
//
// As of June 2025, these tests are not run in CI.

use std::{
fmt::{self, Debug, Display},
path::PathBuf,
process::Command,
str,
};

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

#[test]
fn hello_compute_example() {
let output = std::process::Command::new(cts_runner_exe_path())
.arg("examples/hello-compute.js")
.spawn()
.unwrap()
.wait_with_output()
pub struct JsError;

impl Display for JsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "JavaScript test returned an error")
}
}

impl Debug for JsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
}
}

type JsResult = Result<(), JsError>;

fn exec_js_test(script: &str) -> JsResult {
let output = Command::new(cts_runner_exe_path())
.arg(script)
.output()
.unwrap();
assert!(output.status.success())
println!("{}", str::from_utf8(&output.stdout).unwrap());
eprintln!("{}", str::from_utf8(&output.stderr).unwrap());
output.status.success().then_some(()).ok_or(JsError)
}

#[test]
fn hello_compute_example() -> JsResult {
exec_js_test("examples/hello-compute.js")
}

#[test]
fn features() -> JsResult {
exec_js_test("tests/features.js")
}
2 changes: 2 additions & 0 deletions deno_webgpu/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ impl GPUAdapter {
fn features(&self, scope: &mut v8::HandleScope) -> v8::Global<v8::Object> {
self.features.get(scope, |scope| {
let features = self.instance.adapter_features(self.id);
// Only expose WebGPU features, not wgpu native-only features
let features = features & wgpu_types::Features::all_webgpu_mask();
let features = features_to_feature_names(features);
GPUSupportedFeatures::new(scope, features)
})
Expand Down