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

This commit is contained in:
Andy Leiserson 2025-06-27 10:05:13 -07:00 committed by GitHub
parent e936c065fc
commit 201b2fba76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 55 additions and 23 deletions

View File

@ -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!");

View File

@ -5,17 +5,7 @@ webgpu:api,operation,compute,basic:memcpy:*
//FAIL: webgpu:api,operation,compute,basic:large_dispatch:*
webgpu:api,operation,compute_pipeline,overrides:*
webgpu:api,operation,device,lost:*
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="valid"
//FAIL: webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="invalid"
// https://github.com/gfx-rs/wgpu/issues/7796 (Mac only)
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_state:bufferState="destroyed"
webgpu:api,validation,encoding,cmds,clearBuffer:buffer,device_mismatch:*
webgpu:api,validation,encoding,cmds,clearBuffer:default_args:*
webgpu:api,validation,encoding,cmds,clearBuffer:buffer_usage:*
webgpu:api,validation,encoding,cmds,clearBuffer:size_alignment:*
webgpu:api,validation,encoding,cmds,clearBuffer:offset_alignment:*
webgpu:api,validation,encoding,cmds,clearBuffer:overflow:*
webgpu:api,validation,encoding,cmds,clearBuffer:out_of_bounds:*
webgpu:api,validation,encoding,cmds,clearBuffer:*
webgpu:api,validation,encoding,cmds,compute_pass:set_pipeline:*
webgpu:api,validation,encoding,cmds,compute_pass:dispatch_sizes:*
webgpu:api,validation,encoding,cmds,copyTextureToTexture:copy_with_invalid_or_destroyed_texture:*
@ -39,6 +29,7 @@ webgpu:api,validation,encoding,encoder_state:*
webgpu:api,validation,encoding,encoder_open_state:non_pass_commands:*
webgpu:api,validation,encoding,encoder_open_state:render_pass_commands:*
//FAIL: webgpu:api,validation,encoding,encoder_open_state:render_bundle_commands:*
// https://github.com/gfx-rs/wgpu/issues/7857
webgpu:api,validation,encoding,encoder_open_state:compute_pass_commands:*
webgpu:api,validation,encoding,beginComputePass:*
webgpu:api,validation,encoding,beginRenderPass:*

View File

@ -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");
}

View File

@ -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();
@ -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()
.unwrap();
assert!(output.status.success())
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();
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")
}

View File

@ -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)
})