From 0b48a2d1e1c647708029518db768f4fb1c7d4205 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 10 Dec 2021 01:09:04 +0000 Subject: [PATCH] Bug 1743667 - Hook up WebGPU device limits and features r=jgilbert,webidl,smaug Differential Revision: https://phabricator.services.mozilla.com/D133280 --- dom/bindings/Bindings.conf | 6 +- dom/webgpu/Adapter.cpp | 62 +++++++++++-- dom/webgpu/Adapter.h | 12 ++- dom/webgpu/Device.cpp | 13 ++- dom/webgpu/Device.h | 16 +++- dom/webgpu/Instance.cpp | 4 +- ...pterFeatures.cpp => SupportedFeatures.cpp} | 9 +- ...{AdapterFeatures.h => SupportedFeatures.h} | 16 ++-- dom/webgpu/SupportedLimits.cpp | 4 +- dom/webgpu/SupportedLimits.h | 2 +- dom/webgpu/ipc/WebGPUChild.cpp | 90 +++++++++++++++---- dom/webgpu/ipc/WebGPUChild.h | 4 +- dom/webgpu/moz.build | 2 +- dom/webidl/WebGPU.webidl | 18 ++-- 14 files changed, 194 insertions(+), 64 deletions(-) rename dom/webgpu/{AdapterFeatures.cpp => SupportedFeatures.cpp} (67%) rename dom/webgpu/{AdapterFeatures.h => SupportedFeatures.h} (57%) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index f3f1bdff30a1..931319612b76 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1366,9 +1366,6 @@ DOMInterfaces = { 'GPUAdapter': { 'nativeType': 'mozilla::webgpu::Adapter', }, -'GPUAdapterFeatures': { - 'nativeType': 'mozilla::webgpu::AdapterFeatures', -}, 'GPUBindGroup': { 'nativeType': 'mozilla::webgpu::BindGroup', }, @@ -1436,6 +1433,9 @@ DOMInterfaces = { 'GPUShaderModule': { 'nativeType': 'mozilla::webgpu::ShaderModule', }, +'GPUSupportedFeatures': { + 'nativeType': 'mozilla::webgpu::SupportedFeatures', +}, 'GPUSupportedLimits': { 'nativeType': 'mozilla::webgpu::SupportedLimits', }, diff --git a/dom/webgpu/Adapter.cpp b/dom/webgpu/Adapter.cpp index 6a3653fb0caa..edb690778c0c 100644 --- a/dom/webgpu/Adapter.cpp +++ b/dom/webgpu/Adapter.cpp @@ -6,12 +6,13 @@ #include "mozilla/dom/WebGPUBinding.h" #include "Adapter.h" -#include "AdapterFeatures.h" #include "Device.h" #include "Instance.h" +#include "SupportedFeatures.h" #include "SupportedLimits.h" #include "ipc/WebGPUChild.h" #include "mozilla/dom/Promise.h" +#include "mozilla/webgpu/ffi/wgpu.h" namespace mozilla { namespace webgpu { @@ -19,14 +20,51 @@ namespace webgpu { GPU_IMPL_CYCLE_COLLECTION(Adapter, mParent, mBridge, mFeatures, mLimits) GPU_IMPL_JS_WRAP(Adapter) +Maybe Adapter::MakeFeatureBits( + const dom::Sequence& aFeatures) { + uint32_t bits = 0; + for (const auto& feature : aFeatures) { + if (feature == dom::GPUFeatureName::Depth_clip_control) { + bits |= WGPUFeatures_DEPTH_CLIP_CONTROL; + } else if (feature == dom::GPUFeatureName::Texture_compression_bc) { + bits |= WGPUFeatures_TEXTURE_COMPRESSION_BC; + } else if (feature == dom::GPUFeatureName::Indirect_first_instance) { + bits |= WGPUFeatures_INDIRECT_FIRST_INSTANCE; + } else { + NS_WARNING( + nsPrintfCString("Requested feature bit '%d' is not recognized.", + static_cast(feature)) + .get()); + return Nothing(); + } + } + return Some(bits); +} + Adapter::Adapter(Instance* const aParent, const ffi::WGPUAdapterInformation& aInfo) : ChildOf(aParent), mBridge(aParent->mBridge), mId(aInfo.id), - mFeatures(new AdapterFeatures(this)), - mLimits(new SupportedLimits(this, aInfo.limits)), - mIsFallbackAdapter(aInfo.ty == ffi::WGPUDeviceType_Cpu) {} + mFeatures(new SupportedFeatures(this)), + mLimits( + new SupportedLimits(this, MakeUnique(aInfo.limits))), + mIsFallbackAdapter(aInfo.ty == ffi::WGPUDeviceType_Cpu) { + ErrorResult result; // TODO: should this come from outside + // This list needs to match `AdapterRequestDevice` + if (aInfo.features & WGPUFeatures_DEPTH_CLIP_CONTROL) { + dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add( + mFeatures, u"depth-clip-control"_ns, result); + } + if (aInfo.features & WGPUFeatures_TEXTURE_COMPRESSION_BC) { + dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add( + mFeatures, u"texture-compression-bc"_ns, result); + } + if (aInfo.features & WGPUFeatures_INDIRECT_FIRST_INSTANCE) { + dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add( + mFeatures, u"indirect-first-instance"_ns, result); + } +} Adapter::~Adapter() { Cleanup(); } @@ -37,7 +75,7 @@ void Adapter::Cleanup() { } } -const RefPtr& Adapter::Features() const { return mFeatures; } +const RefPtr& Adapter::Features() const { return mFeatures; } const RefPtr& Adapter::Limits() const { return mLimits; } already_AddRefed Adapter::RequestDevice( @@ -47,9 +85,19 @@ already_AddRefed Adapter::RequestDevice( return nullptr; } - Maybe id = mBridge->AdapterRequestDevice(mId, aDesc); + ffi::WGPULimits limits = {}; + Maybe id = mBridge->AdapterRequestDevice(mId, aDesc, &limits); if (id.isSome()) { - RefPtr device = new Device(this, id.value()); + RefPtr device = + new Device(this, id.value(), aDesc.mRequiredFeatures, + MakeUnique(limits)); + // copy over the features + for (const auto& feature : aDesc.mRequiredFeatures) { + NS_ConvertASCIItoUTF16 string( + dom::GPUFeatureNameValues::GetString(feature)); + dom::GPUSupportedFeatures_Binding::SetlikeHelpers::Add(mFeatures, string, + aRv); + } promise->MaybeResolve(device); } else { promise->MaybeRejectWithNotSupportedError("Unable to instanciate a Device"); diff --git a/dom/webgpu/Adapter.h b/dom/webgpu/Adapter.h index bcd14d79f9c2..bda6f41924fd 100644 --- a/dom/webgpu/Adapter.h +++ b/dom/webgpu/Adapter.h @@ -18,12 +18,15 @@ class Promise; struct GPUDeviceDescriptor; struct GPUExtensions; struct GPUFeatures; +enum class GPUFeatureName : uint8_t; +template +class Sequence; } // namespace dom namespace webgpu { -class AdapterFeatures; class Device; class Instance; +class SupportedFeatures; class SupportedLimits; class WebGPUChild; namespace ffi { @@ -37,6 +40,9 @@ class Adapter final : public ObjectBase, public ChildOf { RefPtr mBridge; + static Maybe MakeFeatureBits( + const dom::Sequence& aFeatures); + private: ~Adapter(); void Cleanup(); @@ -45,14 +51,14 @@ class Adapter final : public ObjectBase, public ChildOf { const nsString mName; // Cant have them as `const` right now, since we wouldn't be able // to unlink them in CC unlink. - RefPtr mFeatures; + RefPtr mFeatures; RefPtr mLimits; const bool mIsFallbackAdapter = false; public: Adapter(Instance* const aParent, const ffi::WGPUAdapterInformation& aInfo); void GetName(nsString& out) const { out = mName; } - const RefPtr& Features() const; + const RefPtr& Features() const; const RefPtr& Limits() const; bool IsFallbackAdapter() const { return mIsFallbackAdapter; } diff --git a/dom/webgpu/Device.cpp b/dom/webgpu/Device.cpp index b9f9af5e97df..31dbf1da1d95 100644 --- a/dom/webgpu/Device.cpp +++ b/dom/webgpu/Device.cpp @@ -21,6 +21,8 @@ #include "RenderBundleEncoder.h" #include "RenderPipeline.h" #include "Sampler.h" +#include "SupportedFeatures.h" +#include "SupportedLimits.h" #include "Texture.h" #include "TextureView.h" #include "ValidationError.h" @@ -51,11 +53,16 @@ JSObject* Device::CreateExternalArrayBuffer(JSContext* aCx, size_t aOffset, &mapFreeCallback, nullptr); } -Device::Device(Adapter* const aParent, RawId aId) +Device::Device(Adapter* const aParent, RawId aId, + const dom::Sequence& aRequiredFeatures, + UniquePtr aRawLimits) : DOMEventTargetHelper(aParent->GetParentObject()), mId(aId), mBridge(aParent->mBridge), - mQueue(new class Queue(this, aParent->mBridge, aId)) { + mQueue(new class Queue(this, aParent->mBridge, aId)), + // features are filled in Adapter::RequestDevice + mFeatures(new SupportedFeatures(aParent)), + mLimits(new SupportedLimits(aParent, std::move(aRawLimits))) { mBridge->RegisterDevice(mId, this); } @@ -71,8 +78,6 @@ void Device::Cleanup() { void Device::GetLabel(nsAString& aValue) const { aValue = mLabel; } void Device::SetLabel(const nsAString& aLabel) { mLabel = aLabel; } -const RefPtr& Device::GetQueue() const { return mQueue; } - already_AddRefed Device::CreateBuffer( const dom::GPUBufferDescriptor& aDesc, ErrorResult& aRv) { ipc::Shmem shmem; diff --git a/dom/webgpu/Device.h b/dom/webgpu/Device.h index 228cf763de53..dcf5b0270640 100644 --- a/dom/webgpu/Device.h +++ b/dom/webgpu/Device.h @@ -44,6 +44,7 @@ template class Sequence; class GPUBufferOrGPUTexture; enum class GPUErrorFilter : uint8_t; +enum class GPUFeatureName : uint8_t; class GPULogCallback; } // namespace dom namespace ipc { @@ -52,6 +53,9 @@ class Shmem; } // namespace ipc namespace webgpu { +namespace ffi { +struct WGPULimits; +} class Adapter; class BindGroup; class BindGroupLayout; @@ -66,6 +70,8 @@ class RenderBundleEncoder; class RenderPipeline; class Sampler; class ShaderModule; +class SupportedFeatures; +class SupportedLimits; class Texture; class WebGPUChild; @@ -79,7 +85,9 @@ class Device final : public DOMEventTargetHelper { const RawId mId; - explicit Device(Adapter* const aParent, RawId aId); + explicit Device(Adapter* const aParent, RawId aId, + const dom::Sequence& aRequiredFeatures, + UniquePtr aRawLimits); RefPtr GetBridge(); static JSObject* CreateExternalArrayBuffer(JSContext* aCx, size_t aOffset, @@ -105,12 +113,16 @@ class Device final : public DOMEventTargetHelper { nsString mLabel; RefPtr mQueue; nsTHashSet mKnownWarnings; + RefPtr mFeatures; + RefPtr mLimits; public: void GetLabel(nsAString& aValue) const; void SetLabel(const nsAString& aLabel); - const RefPtr& GetQueue() const; + const RefPtr& Features() const { return mFeatures; } + const RefPtr& Limits() const { return mLimits; } + const RefPtr& GetQueue() const { return mQueue; } already_AddRefed CreateBuffer(const dom::GPUBufferDescriptor& aDesc, ErrorResult& aRv); diff --git a/dom/webgpu/Instance.cpp b/dom/webgpu/Instance.cpp index b5550e0e25cf..6b654aa7f333 100644 --- a/dom/webgpu/Instance.cpp +++ b/dom/webgpu/Instance.cpp @@ -68,8 +68,8 @@ already_AddRefed Instance::RequestAdapter( RefPtr adapter = new Adapter(instance, info); promise->MaybeResolve(adapter); }, - [promise](const Maybe& aRv) { - if (aRv.isSome()) { + [promise](const Maybe& aResponseReason) { + if (aResponseReason.isSome()) { promise->MaybeRejectWithAbortError("Internal communication error!"); } else { promise->MaybeRejectWithInvalidStateError( diff --git a/dom/webgpu/AdapterFeatures.cpp b/dom/webgpu/SupportedFeatures.cpp similarity index 67% rename from dom/webgpu/AdapterFeatures.cpp rename to dom/webgpu/SupportedFeatures.cpp index e5ab102bd1ac..78e9abe61783 100644 --- a/dom/webgpu/AdapterFeatures.cpp +++ b/dom/webgpu/SupportedFeatures.cpp @@ -3,17 +3,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "AdapterFeatures.h" +#include "SupportedFeatures.h" #include "Adapter.h" #include "mozilla/dom/WebGPUBinding.h" namespace mozilla { namespace webgpu { -GPU_IMPL_CYCLE_COLLECTION(AdapterFeatures, mParent) -GPU_IMPL_JS_WRAP(AdapterFeatures) +GPU_IMPL_CYCLE_COLLECTION(SupportedFeatures, mParent) +GPU_IMPL_JS_WRAP(SupportedFeatures) -AdapterFeatures::AdapterFeatures(Adapter* const aParent) : ChildOf(aParent) {} +SupportedFeatures::SupportedFeatures(Adapter* const aParent) + : ChildOf(aParent) {} } // namespace webgpu } // namespace mozilla diff --git a/dom/webgpu/AdapterFeatures.h b/dom/webgpu/SupportedFeatures.h similarity index 57% rename from dom/webgpu/AdapterFeatures.h rename to dom/webgpu/SupportedFeatures.h index 6c41f2c9fa75..c40af85a350f 100644 --- a/dom/webgpu/AdapterFeatures.h +++ b/dom/webgpu/SupportedFeatures.h @@ -3,8 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef GPU_AdapterFeatures_H_ -#define GPU_AdapterFeatures_H_ +#ifndef GPU_SupportedFeatures_H_ +#define GPU_SupportedFeatures_H_ #include "nsWrapperCache.h" #include "ObjectModel.h" @@ -13,19 +13,19 @@ namespace mozilla { namespace webgpu { class Adapter; -class AdapterFeatures final : public nsWrapperCache, public ChildOf { +class SupportedFeatures final : public nsWrapperCache, public ChildOf { public: - GPU_DECL_CYCLE_COLLECTION(AdapterFeatures) - GPU_DECL_JS_WRAP(AdapterFeatures) + GPU_DECL_CYCLE_COLLECTION(SupportedFeatures) + GPU_DECL_JS_WRAP(SupportedFeatures) - explicit AdapterFeatures(Adapter* const aParent); + explicit SupportedFeatures(Adapter* const aParent); private: - ~AdapterFeatures() = default; + ~SupportedFeatures() = default; void Cleanup() {} }; } // namespace webgpu } // namespace mozilla -#endif // GPU_AdapterFeatures_H_ +#endif // GPU_SupportedFeatures_H_ diff --git a/dom/webgpu/SupportedLimits.cpp b/dom/webgpu/SupportedLimits.cpp index 5416d7e5aa7b..105bc566aa33 100644 --- a/dom/webgpu/SupportedLimits.cpp +++ b/dom/webgpu/SupportedLimits.cpp @@ -15,8 +15,8 @@ GPU_IMPL_CYCLE_COLLECTION(SupportedLimits, mParent) GPU_IMPL_JS_WRAP(SupportedLimits) SupportedLimits::SupportedLimits(Adapter* const aParent, - const ffi::WGPULimits& aLimits) - : ChildOf(aParent), mLimits(new ffi::WGPULimits(aLimits)) {} + UniquePtr&& aLimits) + : ChildOf(aParent), mLimits(std::move(aLimits)) {} SupportedLimits::~SupportedLimits() = default; diff --git a/dom/webgpu/SupportedLimits.h b/dom/webgpu/SupportedLimits.h index 1b124414076f..a768f2042d2c 100644 --- a/dom/webgpu/SupportedLimits.h +++ b/dom/webgpu/SupportedLimits.h @@ -41,7 +41,7 @@ class SupportedLimits final : public nsWrapperCache, public ChildOf { uint32_t MaxVertexAttributes() const; uint32_t MaxVertexBufferArrayStride() const; - SupportedLimits(Adapter* const aParent, const ffi::WGPULimits& aLimits); + SupportedLimits(Adapter* const aParent, UniquePtr&& aLimits); private: ~SupportedLimits(); diff --git a/dom/webgpu/ipc/WebGPUChild.cpp b/dom/webgpu/ipc/WebGPUChild.cpp index c48ea9a83966..bb82bba84bfb 100644 --- a/dom/webgpu/ipc/WebGPUChild.cpp +++ b/dom/webgpu/ipc/WebGPUChild.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/GPUUncapturedErrorEvent.h" #include "mozilla/webgpu/ValidationError.h" #include "mozilla/webgpu/ffi/wgpu.h" +#include "Adapter.h" #include "Sampler.h" namespace mozilla { @@ -202,37 +203,90 @@ RefPtr WebGPUChild::InstanceRequestAdapter( } Maybe WebGPUChild::AdapterRequestDevice( - RawId aSelfId, const dom::GPUDeviceDescriptor& aDesc) { + RawId aSelfId, const dom::GPUDeviceDescriptor& aDesc, + ffi::WGPULimits* aLimits) { RawId id = ffi::wgpu_client_make_device_id(mClient, aSelfId); ffi::WGPUDeviceDescriptor desc = {}; ffi::wgpu_client_fill_default_limits(&desc.limits); + const auto featureBits = Adapter::MakeFeatureBits(aDesc.mRequiredFeatures); + if (!featureBits) { + return {}; + } + desc.features = *featureBits; + if (aDesc.mRequiredLimits.WasPassed()) { for (const auto& entry : aDesc.mRequiredLimits.Value().Entries()) { - Unused << entry; // TODO + const uint32_t valueU32 = + entry.mValue < std::numeric_limits::max() + ? entry.mValue + : std::numeric_limits::max(); + if (entry.mKey == u"maxTextureDimension1D"_ns) { + desc.limits.max_texture_dimension_1d = valueU32; + } else if (entry.mKey == u"maxTextureDimension2D"_ns) { + desc.limits.max_texture_dimension_2d = valueU32; + } else if (entry.mKey == u"maxTextureDimension3D"_ns) { + desc.limits.max_texture_dimension_3d = valueU32; + } else if (entry.mKey == u"maxTextureArrayLayers"_ns) { + desc.limits.max_texture_array_layers = valueU32; + } else if (entry.mKey == u"maxBindGroups"_ns) { + desc.limits.max_bind_groups = valueU32; + } else if (entry.mKey == + u"maxDynamicUniformBuffersPerPipelineLayout"_ns) { + desc.limits.max_dynamic_uniform_buffers_per_pipeline_layout = valueU32; + } else if (entry.mKey == + u"maxDynamicStorageBuffersPerPipelineLayout"_ns) { + desc.limits.max_dynamic_storage_buffers_per_pipeline_layout = valueU32; + } else if (entry.mKey == u"maxSampledTexturesPerShaderStage"_ns) { + desc.limits.max_sampled_textures_per_shader_stage = valueU32; + } else if (entry.mKey == u"maxSamplersPerShaderStage"_ns) { + desc.limits.max_samplers_per_shader_stage = valueU32; + } else if (entry.mKey == u"maxStorageBuffersPerShaderStage"_ns) { + desc.limits.max_storage_buffers_per_shader_stage = valueU32; + } else if (entry.mKey == u"maxStorageTexturesPerShaderStage"_ns) { + desc.limits.max_storage_textures_per_shader_stage = valueU32; + } else if (entry.mKey == u"maxUniformBuffersPerShaderStage"_ns) { + desc.limits.max_uniform_buffers_per_shader_stage = valueU32; + } else if (entry.mKey == u"maxUniformBufferBindingSize"_ns) { + desc.limits.max_uniform_buffer_binding_size = entry.mValue; + } else if (entry.mKey == u"maxStorageBufferBindingSize"_ns) { + desc.limits.max_storage_buffer_binding_size = entry.mValue; + } else if (entry.mKey == u"minUniformBufferOffsetAlignment"_ns) { + desc.limits.min_uniform_buffer_offset_alignment = valueU32; + } else if (entry.mKey == u"minStorageBufferOffsetAlignment"_ns) { + desc.limits.min_storage_buffer_offset_alignment = valueU32; + } else if (entry.mKey == u"maxVertexBuffers"_ns) { + desc.limits.max_vertex_buffers = valueU32; + } else if (entry.mKey == u"maxVertexAttributes"_ns) { + desc.limits.max_vertex_attributes = valueU32; + } else if (entry.mKey == u"maxVertexBufferArrayStride"_ns) { + desc.limits.max_vertex_buffer_array_stride = valueU32; + } else if (entry.mKey == u"maxComputeWorkgroupSizeX"_ns) { + desc.limits.max_compute_workgroup_size_x = valueU32; + } else if (entry.mKey == u"maxComputeWorkgroupSizeY"_ns) { + desc.limits.max_compute_workgroup_size_y = valueU32; + } else if (entry.mKey == u"maxComputeWorkgroupSizeZ"_ns) { + desc.limits.max_compute_workgroup_size_z = valueU32; + } else if (entry.mKey == u"maxComputeWorkgroupsPerDimension"_ns) { + desc.limits.max_compute_workgroups_per_dimension = valueU32; + } else { + NS_WARNING(nsPrintfCString("Requested limit '%s' is not recognized.", + NS_ConvertUTF16toUTF8(entry.mKey).get()) + .get()); + return Nothing(); + } + + // TODO: maxInterStageShaderComponents + // TODO: maxComputeWorkgroupStorageSize + // TODO: maxComputeInvocationsPerWorkgroup } - /*desc.limits.max_bind_groups = lim.mMaxBindGroups; - desc.limits.max_dynamic_uniform_buffers_per_pipeline_layout = - lim.mMaxDynamicUniformBuffersPerPipelineLayout; - desc.limits.max_dynamic_storage_buffers_per_pipeline_layout = - lim.mMaxDynamicStorageBuffersPerPipelineLayout; - desc.limits.max_sampled_textures_per_shader_stage = - lim.mMaxSampledTexturesPerShaderStage; - desc.limits.max_samplers_per_shader_stage = lim.mMaxSamplersPerShaderStage; - desc.limits.max_storage_buffers_per_shader_stage = - lim.mMaxStorageBuffersPerShaderStage; - desc.limits.max_storage_textures_per_shader_stage = - lim.mMaxStorageTexturesPerShaderStage; - desc.limits.max_uniform_buffers_per_shader_stage = - lim.mMaxUniformBuffersPerShaderStage; - desc.limits.max_uniform_buffer_binding_size = - lim.mMaxUniformBufferBindingSize;*/ } ByteBuf bb; ffi::wgpu_client_serialize_device_descriptor(&desc, ToFFI(&bb)); if (SendAdapterRequestDevice(aSelfId, std::move(bb), id)) { + *aLimits = desc.limits; return Some(id); } ffi::wgpu_client_kill_device_id(mClient, id); diff --git a/dom/webgpu/ipc/WebGPUChild.h b/dom/webgpu/ipc/WebGPUChild.h index 395c8489a390..349e0e9e6e02 100644 --- a/dom/webgpu/ipc/WebGPUChild.h +++ b/dom/webgpu/ipc/WebGPUChild.h @@ -20,6 +20,7 @@ class CompositorBridgeChild; namespace webgpu { namespace ffi { struct WGPUClient; +struct WGPULimits; struct WGPUTextureViewDescriptor; } // namespace ffi @@ -43,7 +44,8 @@ class WebGPUChild final : public PWebGPUChild, public SupportsWeakPtr { RefPtr InstanceRequestAdapter( const dom::GPURequestAdapterOptions& aOptions); Maybe AdapterRequestDevice(RawId aSelfId, - const dom::GPUDeviceDescriptor& aDesc); + const dom::GPUDeviceDescriptor& aDesc, + ffi::WGPULimits* aLimtis); RawId DeviceCreateBuffer(RawId aSelfId, const dom::GPUBufferDescriptor& aDesc); RawId DeviceCreateTexture(RawId aSelfId, diff --git a/dom/webgpu/moz.build b/dom/webgpu/moz.build index 2f41ee412c34..5c2ec6fe9b7c 100644 --- a/dom/webgpu/moz.build +++ b/dom/webgpu/moz.build @@ -16,7 +16,6 @@ DIRS += [] h_and_cpp = [ "Adapter", - "AdapterFeatures", "BindGroup", "BindGroupLayout", "Buffer", @@ -41,6 +40,7 @@ h_and_cpp = [ "RenderPipeline", "Sampler", "ShaderModule", + "SupportedFeatures", "SupportedLimits", "Texture", "TextureView", diff --git a/dom/webidl/WebGPU.webidl b/dom/webidl/WebGPU.webidl index 1bb84cfbfdf8..5973466a3023 100644 --- a/dom/webidl/WebGPU.webidl +++ b/dom/webidl/WebGPU.webidl @@ -87,22 +87,25 @@ dictionary GPURequestAdapterOptions { [Pref="dom.webgpu.enabled", Exposed=Window] -interface GPUAdapterFeatures { - readonly setlike; +interface GPUSupportedFeatures { + readonly setlike; }; dictionary GPUDeviceDescriptor { sequence requiredFeatures = []; - record requiredLimits; + record requiredLimits; }; enum GPUFeatureName { - "depth-clamping", + "depth-clip-control", "depth24unorm-stencil8", "depth32float-stencil8", "pipeline-statistics-query", "texture-compression-bc", + "texture-compression-etc2", + "texture-compression-astc", "timestamp-query", + "indirect-first-instance", }; [Pref="dom.webgpu.enabled", @@ -131,7 +134,7 @@ interface GPUSupportedLimits { Exposed=Window] interface GPUAdapter { readonly attribute DOMString name; - [SameObject] readonly attribute GPUAdapterFeatures features; + [SameObject] readonly attribute GPUSupportedFeatures features; [SameObject] readonly attribute GPUSupportedLimits limits; readonly attribute boolean isFallbackAdapter; @@ -143,9 +146,8 @@ interface GPUAdapter { [Pref="dom.webgpu.enabled", Exposed=Window] interface GPUDevice: EventTarget { - //[SameObject] readonly attribute GPUAdapter adapter; - //readonly attribute FrozenArray features; - //readonly attribute object limits; + [SameObject] readonly attribute GPUSupportedFeatures features; + [SameObject] readonly attribute GPUSupportedLimits limits; // Overriding the name to avoid collision with `class Queue` in gcc [SameObject, BinaryName="getQueue"] readonly attribute GPUQueue queue;