mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 06:21:13 +01:00
test(cts): Enable some external texture tests (#8901)
This commit is contained in:
1 parent
96e3af8c4d
commit
835560396f
14 files changed
+128
-46
No files matched your search
Generated
+1
@@ -893,6 +893,7 @@ dependencies = [
|
||||
"deno_webgpu",
|
||||
"deno_webidl",
|
||||
"env_logger",
|
||||
"pico-args",
|
||||
"tempfile",
|
||||
"termcolor",
|
||||
"tokio",
|
||||
|
||||
@@ -20,6 +20,7 @@ deno_url.workspace = true
|
||||
deno_web.workspace = true
|
||||
deno_webidl.workspace = true
|
||||
deno_webgpu.workspace = true
|
||||
pico-args.workspace = true
|
||||
tokio = { workspace = true, features = ["full"] }
|
||||
termcolor.workspace = true
|
||||
|
||||
|
||||
@@ -189,7 +189,6 @@ webgpu:shader,validation,parse,shadow_builtins:* // 83%, function param shadowin
|
||||
webgpu:shader,validation,shader_io,align:* // 98%, https://github.com/gfx-rs/wgpu/issues/8892
|
||||
webgpu:shader,validation,shader_io,binding:* // 95%, https://github.com/gfx-rs/wgpu/issues/8892
|
||||
webgpu:shader,validation,shader_io,builtins:* // 50%, trailing comma not accepted
|
||||
webgpu:shader,validation,shader_io,group_and_binding:* // 87%, texture_external
|
||||
webgpu:shader,validation,shader_io,group:* // 95%, https://github.com/gfx-rs/wgpu/issues/8892
|
||||
webgpu:shader,validation,shader_io,id:* // 94%, https://github.com/gfx-rs/wgpu/issues/8892, @id on const
|
||||
webgpu:shader,validation,shader_io,interpolate:* // 91%, https://github.com/gfx-rs/wgpu/issues/8892
|
||||
|
||||
Vendored
+16
-1
@@ -234,8 +234,22 @@ windowOrWorkerGlobalScope.console.enumerable = false;
|
||||
// for the application.
|
||||
//
|
||||
// Note that catching an error here _does not_ result in a non-zero exit status.
|
||||
let enableExternalTexture_ = false;
|
||||
const requestDevice = webgpu.GPUAdapter.prototype.requestDevice;
|
||||
webgpu.GPUAdapter.prototype.requestDevice = function(desc) {
|
||||
if (enableExternalTexture_) {
|
||||
// Deno doesn't meaningfully support external textures, but we provide
|
||||
// an option to enable it anyways to allow running some CTS tests that
|
||||
// do pass.
|
||||
if (!desc) {
|
||||
desc = { requiredFeatures: ['external-texture'] };
|
||||
} else if (!desc.requiredFeatures) {
|
||||
desc.requiredFeatures = ['external-texture'];
|
||||
} else {
|
||||
desc.requiredFeatures.push('external-texture');
|
||||
}
|
||||
}
|
||||
|
||||
return requestDevice.call(this, desc).then((device) => {
|
||||
device.onuncapturederror = (event) => {
|
||||
core.print("cts_runner caught WebGPU error: " + event.error.message + "\n", true);
|
||||
@@ -301,12 +315,13 @@ core.registerErrorBuilder(
|
||||
|
||||
let hasBootstrapped = false;
|
||||
|
||||
function bootstrapRuntime({ args, cwd }) {
|
||||
function bootstrapRuntime({ args, cwd, enableExternalTexture = false }) {
|
||||
if (hasBootstrapped) {
|
||||
throw new Error("Runtime has already been bootstrapped.");
|
||||
}
|
||||
performance.setTimeOrigin(DateNow());
|
||||
globalThis_ = globalThis;
|
||||
enableExternalTexture_ = enableExternalTexture;
|
||||
|
||||
// Remove bootstrapping data from the global scope
|
||||
delete globalThis.__bootstrap;
|
||||
|
||||
+17
-6
@@ -23,10 +23,12 @@ use termcolor::ColorSpec;
|
||||
use termcolor::WriteColor;
|
||||
|
||||
pub async fn run() -> Result<(), AnyError> {
|
||||
let mut args_iter = env::args();
|
||||
let _ = args_iter.next();
|
||||
let url = args_iter
|
||||
.next()
|
||||
let mut args = pico_args::Arguments::from_env();
|
||||
let enable_external_texture = args.contains("--enable-external-texture");
|
||||
let url = args
|
||||
.subcommand()
|
||||
.ok()
|
||||
.flatten()
|
||||
.ok_or_else(|| anyhow!("missing specifier in first command line argument"))?;
|
||||
let specifier = resolve_url_or_path(&url, &env::current_dir()?)?;
|
||||
|
||||
@@ -43,8 +45,17 @@ pub async fn run() -> Result<(), AnyError> {
|
||||
..Default::default()
|
||||
};
|
||||
let mut js_runtime = JsRuntime::new(options);
|
||||
let args = args_iter.collect::<Vec<String>>();
|
||||
let cfg = json!({"args": args, "cwd": env::current_dir().unwrap().to_string_lossy() });
|
||||
let args = args
|
||||
.finish()
|
||||
.into_iter()
|
||||
.map(|os| os.into_string().ok())
|
||||
.collect::<Option<Vec<String>>>()
|
||||
.ok_or_else(|| anyhow!("Invalid UTF-8 in arguments"))?;
|
||||
let cfg = json!({
|
||||
"args": args,
|
||||
"cwd": env::current_dir().unwrap().to_string_lossy(),
|
||||
"enableExternalTexture": enable_external_texture,
|
||||
});
|
||||
|
||||
{
|
||||
let context = js_runtime.main_context();
|
||||
|
||||
@@ -247,6 +247,7 @@ webgpu:api,validation,render_pipeline,inter_stage:location,*
|
||||
webgpu:api,validation,render_pipeline,inter_stage:max_shader_variable_location:*
|
||||
webgpu:api,validation,render_pipeline,inter_stage:max_variables_count,*
|
||||
webgpu:api,validation,render_pipeline,misc:basic:*
|
||||
fails-if(vulkan) webgpu:api,validation,render_pipeline,misc:external_texture:*
|
||||
webgpu:api,validation,render_pipeline,misc:no_attachment:*
|
||||
webgpu:api,validation,render_pipeline,misc:pipeline_layout,device_mismatch:*
|
||||
webgpu:api,validation,render_pipeline,misc:vertex_state_only:*
|
||||
@@ -358,9 +359,13 @@ webgpu:shader,validation,expression,call,builtin,sin:*
|
||||
webgpu:shader,validation,expression,call,builtin,step:*
|
||||
webgpu:shader,validation,expression,call,builtin,tan:*
|
||||
webgpu:shader,validation,expression,call,builtin,tanh:*
|
||||
// Uses external textures
|
||||
fails-if(vulkan) webgpu:shader,validation,expression,call,builtin,textureLoad:*
|
||||
webgpu:shader,validation,expression,call,builtin,textureNumLayers:*
|
||||
webgpu:shader,validation,expression,call,builtin,textureNumLevels:*
|
||||
webgpu:shader,validation,expression,call,builtin,textureNumSamples:*
|
||||
// Uses external textures
|
||||
fails-if(vulkan) webgpu:shader,validation,expression,call,builtin,textureSampleBaseClampToEdge:*
|
||||
webgpu:shader,validation,expression,call,builtin,textureStore:*
|
||||
webgpu:shader,validation,expression,call,builtin,trunc:*
|
||||
// FAIL: others in `value_constructor` due to https://github.com/gfx-rs/wgpu/issues/4720, possibly more
|
||||
@@ -393,6 +398,8 @@ webgpu:shader,validation,parse,semicolon:*
|
||||
webgpu:shader,validation,parse,shadow_builtins:function_param:*
|
||||
webgpu:shader,validation,parse,source:*
|
||||
webgpu:shader,validation,shader_io,entry_point:*
|
||||
// Uses external texture bindings
|
||||
fails-if(vulkan) webgpu:shader,validation,shader_io,group_and_binding:*
|
||||
webgpu:shader,validation,shader_io,invariant:*
|
||||
webgpu:shader,validation,statement,break_if:*
|
||||
webgpu:shader,validation,statement,break:*
|
||||
|
||||
+12
-1
@@ -125,7 +125,18 @@ impl GPUAdapter {
|
||||
.cloned()
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
if !required_features.is_subset(&supported_features) {
|
||||
// External textures are a required part of WebGPU, and `external-texture`
|
||||
// is not a WebGPU-defined feature. `wgpu` has it behind a feature for now,
|
||||
// because support is not complete. Allow applications to request that
|
||||
// feature even though it is not reported as an adapter-supported feature.
|
||||
//
|
||||
// There is probably not anything useful that Deno applications can do with
|
||||
// external textures, but it is useful to be able to enable it in
|
||||
// `cts_runner`.
|
||||
if required_features
|
||||
.difference(&supported_features)
|
||||
.any(|feat| *feat != GPUFeatureName::ExternalTexture)
|
||||
{
|
||||
return Err(CreateDeviceError::RequiredFeaturesNotASubset);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ use deno_core::WebIDL;
|
||||
use crate::buffer::GPUBuffer;
|
||||
use crate::error::GPUGenericError;
|
||||
use crate::sampler::GPUSampler;
|
||||
use crate::texture::GPUExternalTexture;
|
||||
use crate::texture::GPUTexture;
|
||||
use crate::texture::GPUTextureView;
|
||||
use crate::Instance;
|
||||
@@ -98,6 +99,7 @@ pub(crate) enum GPUBindingResource {
|
||||
TextureView(Ptr<GPUTextureView>),
|
||||
Buffer(Ptr<GPUBuffer>),
|
||||
BufferBinding(GPUBufferBinding),
|
||||
ExternalTexture(Ptr<GPUExternalTexture>),
|
||||
}
|
||||
|
||||
impl<'a> WebIdlConverter<'a> for GPUBindingResource {
|
||||
@@ -148,6 +150,16 @@ impl<'a> WebIdlConverter<'a> for GPUBindingResource {
|
||||
)
|
||||
.map(Self::Buffer)
|
||||
})
|
||||
.or_else(|_| {
|
||||
<Ptr<GPUExternalTexture>>::convert(
|
||||
scope,
|
||||
value,
|
||||
prefix.clone(),
|
||||
context.borrowed(),
|
||||
options,
|
||||
)
|
||||
.map(Self::ExternalTexture)
|
||||
})
|
||||
.or_else(|_| {
|
||||
GPUBufferBinding::convert(scope, value, prefix, context, options)
|
||||
.map(Self::BufferBinding)
|
||||
|
||||
@@ -69,6 +69,7 @@ pub(crate) struct GPUBindGroupLayoutEntry {
|
||||
pub sampler: Option<GPUSamplerBindingLayout>,
|
||||
pub texture: Option<GPUTextureBindingLayout>,
|
||||
pub storage_texture: Option<GPUStorageTextureBindingLayout>,
|
||||
pub external_texture: Option<GPUExternalTextureBindingLayout>,
|
||||
}
|
||||
|
||||
#[derive(WebIDL)]
|
||||
@@ -189,3 +190,7 @@ impl From<GPUStorageTextureAccess> for wgpu_types::StorageTextureAccess {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(WebIDL)]
|
||||
#[webidl(dictionary)]
|
||||
pub(crate) struct GPUExternalTextureBindingLayout {}
|
||||
@@ -304,6 +304,7 @@ impl GPUDevice {
|
||||
entry.sampler.is_some(),
|
||||
entry.texture.is_some(),
|
||||
entry.storage_texture.is_some(),
|
||||
entry.external_texture.is_some(),
|
||||
]
|
||||
.into_iter()
|
||||
.filter(|t| *t)
|
||||
@@ -335,6 +336,8 @@ impl GPUDevice {
|
||||
format: storage_texture.format.into(),
|
||||
view_dimension: storage_texture.view_dimension.into(),
|
||||
}
|
||||
} else if entry.external_texture.is_some() {
|
||||
BindingType::ExternalTexture
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
@@ -435,6 +438,9 @@ impl GPUDevice {
|
||||
size: buffer_binding.size,
|
||||
})
|
||||
}
|
||||
GPUBindingResource::ExternalTexture(external_texture) => {
|
||||
BindingResource::ExternalTexture(external_texture.id)
|
||||
}
|
||||
},
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -710,7 +710,9 @@ impl From<GPUTextureFormat> for TextureFormat {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GPUExternalTexture {}
|
||||
pub struct GPUExternalTexture {
|
||||
pub id: wgpu_core::id::ExternalTextureId,
|
||||
}
|
||||
|
||||
impl WebIdlInterfaceConverter for GPUExternalTexture {
|
||||
const NAME: &'static str = "GPUExternalTexture";
|
||||
|
||||
@@ -399,6 +399,11 @@ pub enum GPUFeatureName {
|
||||
#[webidl(rename = "subgroups")]
|
||||
Subgroups,
|
||||
|
||||
// standard feature, but not default yet in wgpu due to incomplete support
|
||||
// (and even if enabled in wgpu, doing so may not be appropriate in Deno)
|
||||
#[webidl(rename = "external-texture")]
|
||||
ExternalTexture,
|
||||
|
||||
// extended from spec
|
||||
#[webidl(rename = "texture-format-16-bit-norm")]
|
||||
TextureFormat16BitNorm,
|
||||
@@ -486,6 +491,7 @@ pub fn feature_names_to_features(
|
||||
GPUFeatureName::Float32Filterable => Features::FLOAT32_FILTERABLE,
|
||||
GPUFeatureName::DualSourceBlending => Features::DUAL_SOURCE_BLENDING,
|
||||
GPUFeatureName::Subgroups => Features::SUBGROUP,
|
||||
GPUFeatureName::ExternalTexture => Features::EXTERNAL_TEXTURE,
|
||||
GPUFeatureName::TextureFormat16BitNorm => Features::TEXTURE_FORMAT_16BIT_NORM,
|
||||
GPUFeatureName::TextureCompressionAstcHdr => Features::TEXTURE_COMPRESSION_ASTC_HDR,
|
||||
GPUFeatureName::TextureAdapterSpecificFormatFeatures => Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
|
||||
|
||||
+23
-23
@@ -97,6 +97,12 @@ pub fn run_cts(
|
||||
.transpose()?;
|
||||
|
||||
let running_on_backend = args.opt_value_from_str::<_, String>("--backend")?;
|
||||
let enable_external_texture = args.contains("--enable-external-texture")
|
||||
|| (!args.contains("--disable-external-texture")
|
||||
&& running_on_backend
|
||||
.as_ref()
|
||||
.is_some_and(|b| ["metal", "dx12"].contains(&b.as_str())));
|
||||
|
||||
let mut filter_pattern = args.opt_value_from_str::<_, String>("--filter")?;
|
||||
let mut filter_invert = false;
|
||||
|
||||
@@ -117,12 +123,6 @@ pub fn run_cts(
|
||||
None
|
||||
};
|
||||
|
||||
if running_on_backend.is_none() {
|
||||
log::warn!(
|
||||
"fails-if conditions are only evaluated if a backend is specified with --backend"
|
||||
);
|
||||
}
|
||||
|
||||
let mut list_files = Vec::<OsString>::new();
|
||||
while let Some(file) = args.opt_value_from_str("-f")? {
|
||||
list_files.push(file);
|
||||
@@ -137,6 +137,11 @@ pub fn run_cts(
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if running_on_backend.is_none() && (!list_files.is_empty() || tests.is_empty()) {
|
||||
log::warn!("The `--backend` option was not provided. `fails-if` conditions and external");
|
||||
log::warn!("texture support are handled correctly only when a backend is specified.");
|
||||
}
|
||||
|
||||
let mut default_output_filter = PrintOutputWhen::Always;
|
||||
|
||||
if tests.is_empty() && list_files.is_empty() {
|
||||
@@ -313,18 +318,16 @@ pub fn run_cts(
|
||||
};
|
||||
|
||||
if let Some(passthrough_args) = passthrough_args {
|
||||
let mut cmd = shell
|
||||
shell
|
||||
.cmd("cargo")
|
||||
.args(run_flags)
|
||||
.args(["--manifest-path".as_ref(), wgpu_cargo_toml.as_os_str()])
|
||||
.args(["-p", "cts_runner"])
|
||||
.args(["--bin", "cts_runner"]);
|
||||
|
||||
if release {
|
||||
cmd = cmd.arg("--release")
|
||||
}
|
||||
|
||||
cmd.args(["--", "./tools/run_deno", "--verbose"])
|
||||
.args(["--bin", "cts_runner"])
|
||||
.args(release.then_some("--release"))
|
||||
.arg("--")
|
||||
.args(enable_external_texture.then_some("--enable-external-texture"))
|
||||
.args(["./tools/run_deno", "--verbose"])
|
||||
.args(&passthrough_args)
|
||||
.run()?;
|
||||
|
||||
@@ -348,19 +351,16 @@ pub fn run_cts(
|
||||
log::info!("Running {}", test.selector.to_string_lossy());
|
||||
}
|
||||
|
||||
let mut cmd = shell
|
||||
let cmd = shell
|
||||
.cmd("cargo")
|
||||
.args(run_flags)
|
||||
.args(["--manifest-path".as_ref(), wgpu_cargo_toml.as_os_str()])
|
||||
.args(["-p", "cts_runner"])
|
||||
.args(["--bin", "cts_runner"]);
|
||||
|
||||
if release {
|
||||
cmd = cmd.arg("--release")
|
||||
}
|
||||
|
||||
cmd = cmd
|
||||
.args(["--", "./tools/run_deno", "--verbose"])
|
||||
.args(["--bin", "cts_runner"])
|
||||
.args(release.then_some("--release"))
|
||||
.arg("--")
|
||||
.args(enable_external_texture.then_some("--enable-external-texture"))
|
||||
.args(["./tools/run_deno", "--verbose"])
|
||||
.args([&test.selector]);
|
||||
|
||||
match output_filter {
|
||||
|
||||
+19
-13
@@ -26,19 +26,25 @@ Commands:
|
||||
-f cts_runner/test.lst --print-output-when=test-fails` were
|
||||
specified.
|
||||
|
||||
--skip-checkout Don't check out the pinned CTS version, use whatever
|
||||
is already checked out.
|
||||
--release Build and run in release mode
|
||||
--llvm-cov Run with LLVM code coverage
|
||||
--backend <backend> Specify the backend (metal, dx12, or vulkan). Used
|
||||
to evaluate `fails-if` conditions in the test list.
|
||||
--filter <regex> Filter tests by selector using a regex pattern.
|
||||
Prefix with '!' to invert (exclude matching tests).
|
||||
Applied after all tests are collected.
|
||||
--print-output-when One of `test-fails` or `always`. When no `test
|
||||
selector`, `test list file`, or `args` are
|
||||
specified, this defaults to `test-fails`. Otherwise,
|
||||
this defaults to `always`.
|
||||
--skip-checkout Don't check out the pinned CTS version, use whatever
|
||||
is already checked out.
|
||||
--release Build and run in release mode
|
||||
--llvm-cov Run with LLVM code coverage
|
||||
--backend <backend> Specify the backend (metal, dx12, or vulkan). Used
|
||||
to evaluate `fails-if` conditions in the test list.
|
||||
--filter <regex> Filter tests by selector using a regex pattern.
|
||||
Prefix with '!' to invert (exclude matching tests).
|
||||
Applied after all tests are collected.
|
||||
--print-output-when One of `test-fails` or `always`. When no `test
|
||||
selector`, `test list file`, or `args` are
|
||||
specified, this defaults to `test-fails`. Otherwise,
|
||||
this defaults to `always`.
|
||||
--enable-external-texture Enable the external-texture feature. By default it is
|
||||
enabled if `--backend` specifies Metal or DX12,
|
||||
otherwise disabled. External textures do not really
|
||||
work in Deno, but some CTS tests for shaders and
|
||||
pipeline layouts are able to pass.
|
||||
--disable-external-texture Disable the external-texture feature.
|
||||
|
||||
run-wasm
|
||||
Build and run web examples
|
||||
|
||||
Reference in new issue
Block a user