Bug 1921084 - feat(webgpu): wire up WGPU's WGSL lang. features to DOM r=webgpu-reviewers,teoxoy

Differential Revision: https://phabricator.services.mozilla.com/D237088
This commit is contained in:
Erich Gubler
2025-02-19 02:41:39 +00:00
parent e2d60a3172
commit efb4e36af4
8 changed files with 95 additions and 61 deletions

View File

@@ -10,6 +10,7 @@ use crate::{
use crate::SwapChainId;
use wgc::naga::front::wgsl::ImplementedLanguageExtension;
use wgc::{command::RenderBundleEncoder, id, identity::IdentityManager};
use wgt::{BufferAddress, BufferSize, DynamicOffset, IndexFormat, TextureFormat};
@@ -19,6 +20,7 @@ use parking_lot::Mutex;
use nsstring::{nsACString, nsString};
use std::fmt::Write;
use std::{borrow::Cow, ptr};
use self::render_pass::RenderPassDepthStencilAttachment;
@@ -419,6 +421,33 @@ pub extern "C" fn wgpu_client_fill_default_limits(limits: &mut wgt::Limits) {
*limits = wgt::Limits::default();
}
/// Writes the single `WGSLLanguageFeature` associated with `index`, appending its identifier to the
/// provided `buffer`. If `index` does not correspond to a valid feature index, then do nothing.
///
/// This function enables an FFI consumer to extract all implemented features in a loop, like so:
///
/// ```rust
/// let mut buffer = nsstring::nsCString::new();
/// for index in 0usize.. {
/// buffer.truncate();
/// wgpu_client_instance_get_wgsl_language_feature(&mut buffer, index);
/// if buffer.is_empty() {
/// break;
/// }
/// // Handle the identifier in `buffer`…
/// }
/// ```
#[no_mangle]
pub extern "C" fn wgpu_client_instance_get_wgsl_language_feature(
buffer: &mut nsstring::nsCString,
index: usize,
) {
match ImplementedLanguageExtension::all().get(index) {
Some(some) => buffer.write_str(some.to_ident()).unwrap(),
None => (),
}
}
#[no_mangle]
pub extern "C" fn wgpu_client_adapter_extract_info(
byte_buf: &ByteBuf,