Skip to content
Draft
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
2 changes: 0 additions & 2 deletions cts_runner/fail.lst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ webgpu:api,validation,render_pipeline,fragment_state:pipeline_output_targets:* /
webgpu:api,validation,render_pipeline,fragment_state:targets_blend:* // 0%
webgpu:api,validation,render_pipeline,fragment_state:targets_write_mask:* // 50%
webgpu:api,validation,render_pipeline,inter_stage:* // 63%
webgpu:api,validation,render_pipeline,misc:external_texture:* // 0%
webgpu:api,validation,render_pipeline,misc:storage_texture,format:* // 8%
webgpu:api,validation,render_pipeline,multisample_state:* // 60%, https://github.com/gfx-rs/wgpu/issues/8779
webgpu:api,validation,render_pipeline,overrides:* // 83%
Expand Down Expand Up @@ -194,7 +193,6 @@ webgpu:shader,validation,parse,shadow_builtins:* // 60%
webgpu:shader,validation,shader_io,align:* // 98%
webgpu:shader,validation,shader_io,binding:* // 95%
webgpu:shader,validation,shader_io,builtins:* // 50%
webgpu:shader,validation,shader_io,group_and_binding:* // 87%
webgpu:shader,validation,shader_io,group:* // 95%
webgpu:shader,validation,shader_io,id:* // 94%
webgpu:shader,validation,shader_io,interpolate:* // 91%
Expand Down
1 change: 1 addition & 0 deletions cts_runner/skip.lst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
webgpu:api,validation,encoding,queries,begin_end:nesting:*
webgpu:api,validation,gpu_external_texture_expiration:*
webgpu:api,validation,queue,copyToTexture,CopyExternalImageToTexture:*
webgpu:api,validation,render_pipeline,misc:external_texture:*

webgpu:shader,validation,expression,call,builtin,quadBroadcast:* // https://github.com/gfx-rs/wgpu/issues/8722
webgpu:shader,validation,expression,call,builtin,quadSwap:* // ibid.
Expand Down
10 changes: 10 additions & 0 deletions cts_runner/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ windowOrWorkerGlobalScope.console.enumerable = false;
// Note that catching an error here _does not_ result in a non-zero exit status.
const requestDevice = webgpu.GPUAdapter.prototype.requestDevice;
webgpu.GPUAdapter.prototype.requestDevice = function(desc) {
// Deno doesn't meaningfully support external textures, but we enable it
// here 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, true);
Expand Down
2 changes: 2 additions & 0 deletions cts_runner/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:no_atomics
webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:only_in_compute:*
webgpu:shader,validation,expression,call,builtin,workgroupUniformLoad:param_constructible_only:*
webgpu:shader,validation,extension,dual_source_blending:blend_src_syntax_validation:*
// Fails on Linux because no external texture support
fails-if(vulkan) webgpu:shader,validation,shader_io,group_and_binding:*
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break_if"
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="break"
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="continue"
Expand Down
13 changes: 12 additions & 1 deletion deno_webgpu/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,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);
}

Expand Down
12 changes: 12 additions & 0 deletions deno_webgpu/bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions deno_webgpu/bind_group_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -189,3 +190,7 @@ impl From<GPUStorageTextureAccess> for wgpu_types::StorageTextureAccess {
}
}
}

#[derive(WebIDL)]
#[webidl(dictionary)]
pub(crate) struct GPUExternalTextureBindingLayout {}
6 changes: 6 additions & 0 deletions deno_webgpu/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,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)
Expand Down Expand Up @@ -334,6 +335,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!()
};
Expand Down Expand Up @@ -434,6 +437,9 @@ impl GPUDevice {
size: buffer_binding.size,
})
}
GPUBindingResource::ExternalTexture(external_texture) => {
BindingResource::ExternalTexture(external_texture.id)
}
},
})
.collect::<Vec<_>>();
Expand Down
4 changes: 3 additions & 1 deletion deno_webgpu/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 6 additions & 0 deletions deno_webgpu/webidl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading