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:
@@ -6,6 +6,8 @@
|
||||
#include "Instance.h"
|
||||
|
||||
#include "Adapter.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "ipc/WebGPUChild.h"
|
||||
#include "ipc/WebGPUTypes.h"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include "mozilla/gfx/CanvasManagerChild.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#ifdef RELEASE_OR_BETA
|
||||
# include "mozilla/dom/WorkerPrivate.h"
|
||||
@@ -51,7 +54,23 @@ already_AddRefed<Instance> Instance::Create(nsIGlobalObject* aOwner) {
|
||||
}
|
||||
|
||||
Instance::Instance(nsIGlobalObject* aOwner)
|
||||
: mOwner(aOwner), mWgslLanguageFeatures(new WGSLLanguageFeatures(this)) {}
|
||||
: mOwner(aOwner), mWgslLanguageFeatures(new WGSLLanguageFeatures(this)) {
|
||||
// Populate `mWgslLanguageFeatures`.
|
||||
IgnoredErrorResult rv;
|
||||
nsCString wgslFeature;
|
||||
for (size_t i = 0;; ++i) {
|
||||
wgslFeature.Truncate(0);
|
||||
ffi::wgpu_client_instance_get_wgsl_language_feature(&wgslFeature, i);
|
||||
if (wgslFeature.IsEmpty()) {
|
||||
break;
|
||||
}
|
||||
NS_ConvertASCIItoUTF16 feature{wgslFeature};
|
||||
this->mWgslLanguageFeatures->Add(feature, rv);
|
||||
if (rv.Failed()) {
|
||||
MOZ_CRASH("failed to append WGSL language feature");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Instance::~Instance() { Cleanup(); }
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ class WGSLLanguageFeatures final : public nsWrapperCache,
|
||||
public:
|
||||
explicit WGSLLanguageFeatures(Instance* const aParent) : ChildOf(aParent) {}
|
||||
|
||||
void Add(const nsAString& feature, ErrorResult& aRv) {
|
||||
dom::WGSLLanguageFeatures_Binding::SetlikeHelpers::Add(this, feature, aRv);
|
||||
}
|
||||
|
||||
private:
|
||||
void Cleanup() {}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -582,6 +582,8 @@
|
||||
[:inputSource="storage_rw";vectorize=4;scalarType="u32";derefType="pointer"]
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -592,6 +594,8 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f16";derefType="address_of_identifier"]
|
||||
|
||||
@@ -602,6 +606,8 @@
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f16";derefType="pointer"]
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -612,8 +618,12 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -624,8 +634,12 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -636,6 +650,8 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize=2;scalarType="bool";derefType="address_of_identifier"]
|
||||
|
||||
@@ -1082,6 +1098,8 @@
|
||||
[:inputSource="storage_rw";vectorize=4;scalarType="u32";derefType="pointer"]
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -1092,6 +1110,8 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="bool";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f16";derefType="address_of_identifier"]
|
||||
|
||||
@@ -1102,6 +1122,8 @@
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f16";derefType="pointer"]
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -1112,8 +1134,12 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="f32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -1124,8 +1150,12 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="i32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="address_of_identifier"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="deref_address_of_identifier"]
|
||||
expected:
|
||||
@@ -1136,6 +1166,8 @@
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize="_undef_";scalarType="u32";derefType="pointer"]
|
||||
expected:
|
||||
if os == "mac": FAIL
|
||||
|
||||
[:inputSource="uniform";vectorize=2;scalarType="bool";derefType="address_of_identifier"]
|
||||
|
||||
|
||||
@@ -243,165 +243,122 @@
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="array";storageType="bool"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="array";storageType="f16"]
|
||||
|
||||
[:addressSpace="private";compositeType="array";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="array";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="array";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="mat";storageType="f16"]
|
||||
|
||||
[:addressSpace="private";compositeType="mat";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="struct";storageType="bool"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="struct";storageType="f16"]
|
||||
|
||||
[:addressSpace="private";compositeType="struct";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="struct";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="struct";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="vec";storageType="bool"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="vec";storageType="f16"]
|
||||
|
||||
[:addressSpace="private";compositeType="vec";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="vec";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="private";compositeType="vec";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="array";storageType="f16"]
|
||||
|
||||
[:addressSpace="storage";compositeType="array";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="array";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="array";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="mat";storageType="f16"]
|
||||
|
||||
[:addressSpace="storage";compositeType="mat";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="struct";storageType="f16"]
|
||||
|
||||
[:addressSpace="storage";compositeType="struct";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="struct";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="struct";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="vec";storageType="f16"]
|
||||
|
||||
[:addressSpace="storage";compositeType="vec";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="vec";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="storage";compositeType="vec";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="array";storageType="f16"]
|
||||
|
||||
[:addressSpace="uniform";compositeType="array";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="array";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="array";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="mat";storageType="f16"]
|
||||
|
||||
[:addressSpace="uniform";compositeType="mat";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="struct";storageType="f16"]
|
||||
|
||||
[:addressSpace="uniform";compositeType="struct";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="struct";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="struct";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="vec";storageType="f16"]
|
||||
|
||||
[:addressSpace="uniform";compositeType="vec";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="vec";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="uniform";compositeType="vec";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="array";storageType="f16"]
|
||||
|
||||
[:addressSpace="workgroup";compositeType="array";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="array";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="array";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="mat";storageType="f16"]
|
||||
|
||||
[:addressSpace="workgroup";compositeType="mat";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="struct";storageType="f16"]
|
||||
|
||||
[:addressSpace="workgroup";compositeType="struct";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="struct";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="struct";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="vec";storageType="f16"]
|
||||
|
||||
[:addressSpace="workgroup";compositeType="vec";storageType="f32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="vec";storageType="i32"]
|
||||
expected: FAIL
|
||||
|
||||
[:addressSpace="workgroup";compositeType="vec";storageType="u32"]
|
||||
expected: FAIL
|
||||
|
||||
|
||||
[cts.https.html?q=webgpu:shader,validation,expression,unary,address_of_and_indirection:invalid:*]
|
||||
|
||||
@@ -29,45 +29,30 @@
|
||||
|
||||
|
||||
[cts.https.html?q=webgpu:shader,validation,extension,pointer_composite_access:pointer:*]
|
||||
implementation-status: backlog
|
||||
[:case="array_index_access_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="array_index_access_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="builtin_struct_frexp_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="builtin_struct_frexp_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="builtin_struct_modf_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="builtin_struct_modf_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="matrix_index_access_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="matrix_index_access_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="struct_member_access_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="struct_member_access_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="vector_index_access_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="vector_index_access_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="vector_member_access_via_identifier"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="vector_member_access_via_pointer"]
|
||||
expected: FAIL
|
||||
|
||||
@@ -31,11 +31,9 @@
|
||||
|
||||
|
||||
[cts.https.html?q=webgpu:shader,validation,parse,requires:wgsl_matches_api:*]
|
||||
implementation-status: backlog
|
||||
[:feature="packed_4x8_integer_dot_product"]
|
||||
|
||||
[:feature="pointer_composite_access"]
|
||||
expected: FAIL
|
||||
|
||||
[:feature="readonly_and_readwrite_storage_textures"]
|
||||
|
||||
|
||||
@@ -980,20 +980,26 @@
|
||||
[:case="contents_lhs_pointer_deref2"]
|
||||
|
||||
[:case="contents_lhs_pointer_deref2a"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref3"]
|
||||
|
||||
[:case="contents_lhs_pointer_deref3a"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref4"]
|
||||
|
||||
[:case="contents_lhs_pointer_deref4a"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref4b"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref4c"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref4d"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_lhs_pointer_deref4e"]
|
||||
|
||||
@@ -1033,12 +1039,16 @@
|
||||
[:case="contents_rhs_pointer_deref1"]
|
||||
|
||||
[:case="contents_rhs_pointer_deref1a"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_rhs_pointer_deref2"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_rhs_pointer_swizzle_non_uniform"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_rhs_pointer_swizzle_uniform"]
|
||||
expected: FAIL
|
||||
|
||||
[:case="contents_scalar_alias_nonuniform1"]
|
||||
expected: FAIL
|
||||
|
||||
Reference in New Issue
Block a user