diff options
author | Samson <16504129+sagudev@users.noreply.github.com> | 2023-09-30 14:30:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-30 12:30:12 +0000 |
commit | ddc47aa56b2c59911b7fec018d7ae89bf2a77bee (patch) | |
tree | 754019c50c36ec2a59dcf861036d6c624490fb32 /components/script/dom | |
parent | ebd41d41017ee9727eb8417a0a01237b75f3e9c4 (diff) | |
download | servo-ddc47aa56b2c59911b7fec018d7ae89bf2a77bee.tar.gz servo-ddc47aa56b2c59911b7fec018d7ae89bf2a77bee.zip |
Codegen support multiple interfaces in single webidl file & WebGPU single webidl (#30448)
* Codegen support multiple interfaces in single webidl file
* Merge GPU*.webidl into WebGPU.webidl
* Update gpu files to use WebGPUBinding module file
Diffstat (limited to 'components/script/dom')
73 files changed, 1267 insertions, 1428 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index ad53b2268b4..eff03384447 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -76,6 +76,13 @@ def toBindingModuleFile(arg): return re.sub("((_workers)?$)", "Binding\\1", MakeNativeName(arg)) +def toBindingModuleFileFromDescriptor(desc): + if desc.maybeGetSuperModule() is not None: + return toBindingModuleFile(desc.maybeGetSuperModule()) + else: + return toBindingModuleFile(desc.name) + + def stripTrailingWhitespace(text): tail = '\n' if text.endswith('\n') else '' lines = text.splitlines() @@ -8068,8 +8075,8 @@ class GlobalGenRoots(): def InterfaceObjectMapData(config): pairs = [] for d in config.getDescriptors(hasInterfaceObject=True, isInline=False): + binding_mod = toBindingModuleFileFromDescriptor(d) binding_ns = toBindingNamespace(d.name) - binding_mod = toBindingModuleFile(d.name) pairs.append((d.name, binding_mod, binding_ns)) for alias in d.interface.legacyWindowAliases: pairs.append((alias, binding_mod, binding_ns)) @@ -8142,7 +8149,7 @@ class GlobalGenRoots(): return getModuleFromObject(d).split('::')[-1] descriptors = config.getDescriptors(register=True, isIteratorInterface=False) - descriptors = (set(toBindingModuleFile(d.name) for d in descriptors) + descriptors = (set(toBindingModuleFile(d.name) for d in descriptors if d.maybeGetSuperModule() is None) | set(leafModule(d) for d in config.callbacks) | set(leafModule(d) for d in config.getDictionaries())) curr = CGList([CGGeneric("pub mod %s;\n" % name) for name in sorted(descriptors)]) diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py index f15b003ac58..0b113c73bd4 100644 --- a/components/script/dom/bindings/codegen/Configuration.py +++ b/components/script/dom/bindings/codegen/Configuration.py @@ -364,6 +364,17 @@ class Descriptor(DescriptorProvider): config.maxProtoChainLength = max(config.maxProtoChainLength, len(self.prototypeChain)) + def maybeGetSuperModule(self): + """ + Returns name of super module if self is part of it + """ + filename = getIdlFileName(self.interface) + # if interface name is not same as webidl file + # webidl is super module for interface + if filename.lower() != self.interface.identifier.name.lower() and not self.interface.isIteratorInterface(): + return filename + return None + def binaryNameFor(self, name): return self._binaryNames.get(name, name) @@ -459,9 +470,12 @@ def MakeNativeName(name): return name[0].upper() + name[1:] +def getIdlFileName(object): + return os.path.basename(object.location.filename()).split('.webidl')[0] + + def getModuleFromObject(object): - return ('crate::dom::bindings::codegen::Bindings::' - + os.path.basename(object.location.filename()).split('.webidl')[0] + 'Binding') + return ('crate::dom::bindings::codegen::Bindings::' + getIdlFileName(object) + 'Binding') def getTypesFromDescriptor(descriptor): diff --git a/components/script/dom/gpu.rs b/components/script/dom/gpu.rs index 3ecd09ce088..def7c4c3883 100644 --- a/components/script/dom/gpu.rs +++ b/components/script/dom/gpu.rs @@ -12,8 +12,8 @@ use script_traits::ScriptMsg; use webgpu::wgt::PowerPreference; use webgpu::{wgpu, WebGPUResponse, WebGPUResponseResult}; -use super::bindings::codegen::Bindings::GPUTextureBinding::GPUTextureFormat; -use crate::dom::bindings::codegen::Bindings::GPUBinding::{ +use super::bindings::codegen::Bindings::WebGPUBinding::GPUTextureFormat; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ GPUMethods, GPUPowerPreference, GPURequestAdapterOptions, }; use crate::dom::bindings::error::Error; diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs index 6eca90793c7..dd5b31e1be2 100644 --- a/components/script/dom/gpuadapter.rs +++ b/components/script/dom/gpuadapter.rs @@ -11,7 +11,7 @@ use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse, WebGPURe use super::gpusupportedfeatures::GPUSupportedFeatures; use super::types::{GPUAdapterInfo, GPUSupportedLimits}; -use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::{ +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ GPUAdapterMethods, GPUDeviceDescriptor, }; use crate::dom::bindings::error::Error; diff --git a/components/script/dom/gpuadapterinfo.rs b/components/script/dom/gpuadapterinfo.rs index 01f878cc66a..e475fd7b859 100644 --- a/components/script/dom/gpuadapterinfo.rs +++ b/components/script/dom/gpuadapterinfo.rs @@ -5,7 +5,7 @@ use dom_struct::dom_struct; use webgpu::wgt::AdapterInfo; -use super::bindings::codegen::Bindings::GPUAdapterInfoBinding::GPUAdapterInfoMethods; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUAdapterInfoMethods; use super::bindings::reflector::reflect_dom_object; use super::bindings::root::DomRoot; use crate::dom::bindings::reflector::Reflector; diff --git a/components/script/dom/gpubindgroup.rs b/components/script/dom/gpubindgroup.rs index 4b835c86049..5aa7b14473e 100644 --- a/components/script/dom/gpubindgroup.rs +++ b/components/script/dom/gpubindgroup.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPUBindGroup, WebGPUDevice}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::GPUBindGroupMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpubindgrouplayout.rs b/components/script/dom/gpubindgrouplayout.rs index b9bc483450d..b08181b40b6 100644 --- a/components/script/dom/gpubindgrouplayout.rs +++ b/components/script/dom/gpubindgrouplayout.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::WebGPUBindGroupLayout; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::GPUBindGroupLayoutMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUBindGroupLayoutMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs index f57faac9ab6..8f2b9b0f988 100644 --- a/components/script/dom/gpubuffer.rs +++ b/components/script/dom/gpubuffer.rs @@ -17,8 +17,9 @@ use webgpu::wgpu::device::HostMap; use webgpu::{WebGPU, WebGPUBuffer, WebGPURequest, WebGPUResponse, WebGPUResponseResult}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::{GPUBufferMethods, GPUSize64}; -use crate::dom::bindings::codegen::Bindings::GPUMapModeBinding::GPUMapModeConstants; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUBufferMethods, GPUMapModeConstants, GPUSize64, +}; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs index 5bc6f706860..6e0a06f0232 100644 --- a/components/script/dom/gpucanvascontext.rs +++ b/components/script/dom/gpucanvascontext.rs @@ -16,20 +16,17 @@ use webrender_api::{ ImageDescriptorFlags, ImageFormat, ImageKey, }; -use super::bindings::codegen::Bindings::GPUTextureUsageBinding::GPUTextureUsageConstants; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUTextureUsageConstants; use super::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas; use super::bindings::error::{Error, Fallible}; use super::bindings::root::MutNullableDom; use super::gputexture::GPUTexture; -use crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::{ - GPUCanvasConfiguration, GPUCanvasContextMethods, -}; -use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::GPUDevice_Binding::GPUDeviceMethods; -use crate::dom::bindings::codegen::Bindings::GPUObjectBaseBinding::GPUObjectDescriptorBase; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ - GPUExtent3D, GPUExtent3DDict, GPUTextureDescriptor, GPUTextureDimension, GPUTextureFormat, -}; use crate::dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElement_Binding::HTMLCanvasElementMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUCanvasConfiguration, GPUCanvasContextMethods, GPUDeviceMethods, GPUExtent3D, + GPUExtent3DDict, GPUObjectDescriptorBase, GPUTextureDescriptor, GPUTextureDimension, + GPUTextureFormat, +}; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{DomRoot, LayoutDom}; diff --git a/components/script/dom/gpucommandbuffer.rs b/components/script/dom/gpucommandbuffer.rs index 32bc4fee487..b0269fa4d40 100644 --- a/components/script/dom/gpucommandbuffer.rs +++ b/components/script/dom/gpucommandbuffer.rs @@ -9,7 +9,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPU, WebGPUCommandBuffer, WebGPURequest}; use crate::dom::bindings::cell::{DomRefCell, Ref}; -use crate::dom::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCommandBufferMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs index be8dbe73803..e3946a9a812 100644 --- a/components/script/dom/gpucommandencoder.rs +++ b/components/script/dom/gpucommandencoder.rs @@ -10,19 +10,16 @@ use dom_struct::dom_struct; use webgpu::wgpu::command as wgpu_com; use webgpu::{self, wgt, WebGPU, WebGPURequest}; -use super::bindings::codegen::Bindings::GPUCommandBufferBinding::GPUCommandBufferDescriptor; -use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, GPULoadOp, +use super::bindings::codegen::Bindings::WebGPUBinding::{ + GPUCommandBufferDescriptor, GPUImageCopyBuffer, GPUImageCopyTexture, GPUImageDataLayout, + GPULoadOp, GPUTextureAspect, }; -use super::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureAspect; use super::bindings::codegen::UnionTypes::DoubleSequenceOrGPUColorDict; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUSize64; -use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - GPUCommandEncoderMethods, GPUComputePassDescriptor, GPUOrigin3D, GPURenderPassDescriptor, - GPUStoreOp, +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUCommandEncoderMethods, GPUComputePassDescriptor, GPUExtent3D, GPUOrigin3D, + GPURenderPassDescriptor, GPUSize64, GPUStoreOp, }; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::GPUExtent3D; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gpucompilationinfo.rs b/components/script/dom/gpucompilationinfo.rs index 9e8d69df9c2..d964f4ea325 100644 --- a/components/script/dom/gpucompilationinfo.rs +++ b/components/script/dom/gpucompilationinfo.rs @@ -5,7 +5,7 @@ use dom_struct::dom_struct; use js::jsval::JSVal; -use super::bindings::codegen::Bindings::GPUCompilationInfoBinding::GPUCompilationInfoMethods; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUCompilationInfoMethods; use super::bindings::root::Dom; use super::types::GPUCompilationMessage; use crate::dom::bindings::reflector::Reflector; diff --git a/components/script/dom/gpucompilationmessage.rs b/components/script/dom/gpucompilationmessage.rs index 5dab738439f..26b8dafe0dd 100644 --- a/components/script/dom/gpucompilationmessage.rs +++ b/components/script/dom/gpucompilationmessage.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; -use super::bindings::codegen::Bindings::GPUCompilationMessageBinding::{ +use super::bindings::codegen::Bindings::WebGPUBinding::{ GPUCompilationMessageMethods, GPUCompilationMessageType, }; use super::bindings::root::DomRoot; diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs index e58193bcf40..0d43e152403 100644 --- a/components/script/dom/gpucomputepassencoder.rs +++ b/components/script/dom/gpucomputepassencoder.rs @@ -8,7 +8,7 @@ use webgpu::{WebGPU, WebGPURequest}; use super::bindings::error::Fallible; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUComputePassEncoderBinding::GPUComputePassEncoderMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUComputePassEncoderMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpucomputepipeline.rs b/components/script/dom/gpucomputepipeline.rs index 2795e6fa253..ef568e04df6 100644 --- a/components/script/dom/gpucomputepipeline.rs +++ b/components/script/dom/gpucomputepipeline.rs @@ -8,7 +8,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPUBindGroupLayout, WebGPUComputePipeline}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUComputePipelineMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs index e4016551c2c..804f326701a 100644 --- a/components/script/dom/gpudevice.rs +++ b/components/script/dom/gpudevice.rs @@ -19,12 +19,9 @@ use webgpu::wgpu::{ }; use webgpu::{self, wgt, ErrorScopeId, WebGPU, WebGPURequest}; -use super::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::{ - GPUBufferBindingType, GPUSamplerBindingType, GPUStorageTextureAccess, GPUTextureSampleType, -}; -use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::{ - GPUBlendComponent, GPUPrimitiveState, GPUVertexStepMode, +use super::bindings::codegen::Bindings::WebGPUBinding::{ + GPUBlendComponent, GPUBufferBindingType, GPUDeviceLostReason, GPUPrimitiveState, + GPUSamplerBindingType, GPUStorageTextureAccess, GPUTextureSampleType, GPUVertexStepMode, }; use super::bindings::codegen::UnionTypes::GPUPipelineLayoutOrGPUAutoLayoutMode; use super::bindings::error::Fallible; @@ -33,34 +30,16 @@ use super::gpusupportedlimits::GPUSupportedLimits; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::EventBinding::EventInit; use crate::dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods; -use crate::dom::bindings::codegen::Bindings::GPUBindGroupBinding::{ - GPUBindGroupDescriptor, GPUBindingResource, -}; -use crate::dom::bindings::codegen::Bindings::GPUBindGroupLayoutBinding::GPUBindGroupLayoutDescriptor; -use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUBufferDescriptor; -use crate::dom::bindings::codegen::Bindings::GPUComputePipelineBinding::GPUComputePipelineDescriptor; -use crate::dom::bindings::codegen::Bindings::GPUDeviceBinding::{ - GPUCommandEncoderDescriptor, GPUDeviceMethods, -}; -use crate::dom::bindings::codegen::Bindings::GPUObjectBaseBinding::GPUObjectDescriptorBase; -use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutDescriptor; -use crate::dom::bindings::codegen::Bindings::GPURenderBundleEncoderBinding::GPURenderBundleEncoderDescriptor; -use crate::dom::bindings::codegen::Bindings::GPURenderPipelineBinding::{ - GPUBlendFactor, GPUBlendOperation, GPUCullMode, GPUFrontFace, GPUIndexFormat, - GPUPrimitiveTopology, GPURenderPipelineDescriptor, GPUStencilOperation, GPUVertexFormat, -}; -use crate::dom::bindings::codegen::Bindings::GPUSamplerBinding::{ - GPUAddressMode, GPUCompareFunction, GPUFilterMode, GPUSamplerDescriptor, -}; -use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleDescriptor; -use crate::dom::bindings::codegen::Bindings::GPUSupportedLimitsBinding::GPUSupportedLimits_Binding::GPUSupportedLimitsMethods; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ - GPUExtent3D, GPUExtent3DDict, GPUTextureDescriptor, GPUTextureDimension, GPUTextureFormat, -}; -use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewDimension; -use crate::dom::bindings::codegen::Bindings::GPUUncapturedErrorEventBinding::GPUUncapturedErrorEventInit; -use crate::dom::bindings::codegen::Bindings::GPUValidationErrorBinding::{ - GPUError, GPUErrorFilter, +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUAddressMode, GPUBindGroupDescriptor, GPUBindGroupLayoutDescriptor, GPUBindingResource, + GPUBlendFactor, GPUBlendOperation, GPUBufferDescriptor, GPUCommandEncoderDescriptor, + GPUCompareFunction, GPUComputePipelineDescriptor, GPUCullMode, GPUDeviceMethods, GPUError, + GPUErrorFilter, GPUExtent3D, GPUExtent3DDict, GPUFilterMode, GPUFrontFace, GPUIndexFormat, + GPUObjectDescriptorBase, GPUPipelineLayoutDescriptor, GPUPrimitiveTopology, + GPURenderBundleEncoderDescriptor, GPURenderPipelineDescriptor, GPUSamplerDescriptor, + GPUShaderModuleDescriptor, GPUStencilOperation, GPUSupportedLimitsMethods, + GPUTextureDescriptor, GPUTextureDimension, GPUTextureFormat, GPUTextureViewDimension, + GPUUncapturedErrorEventInit, GPUVertexFormat, }; use crate::dom::bindings::error::Error; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject}; diff --git a/components/script/dom/gpudevicelostinfo.rs b/components/script/dom/gpudevicelostinfo.rs index 98dcc85d62f..420f4d28c1a 100644 --- a/components/script/dom/gpudevicelostinfo.rs +++ b/components/script/dom/gpudevicelostinfo.rs @@ -6,8 +6,8 @@ use dom_struct::dom_struct; -use super::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostReason; -use crate::dom::bindings::codegen::Bindings::GPUDeviceLostInfoBinding::GPUDeviceLostInfoMethods; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUDeviceLostReason; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUDeviceLostInfoMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; diff --git a/components/script/dom/gpupipelinelayout.rs b/components/script/dom/gpupipelinelayout.rs index 88ef939f931..e01ef489743 100644 --- a/components/script/dom/gpupipelinelayout.rs +++ b/components/script/dom/gpupipelinelayout.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPUBindGroupLayout, WebGPUPipelineLayout}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUPipelineLayoutBinding::GPUPipelineLayoutMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUPipelineLayoutMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpuqueryset.rs b/components/script/dom/gpuqueryset.rs index e62d0ca4dcb..69599b4490a 100644 --- a/components/script/dom/gpuqueryset.rs +++ b/components/script/dom/gpuqueryset.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; -use super::bindings::codegen::Bindings::GPUQuerySetBinding::GPUQuerySetMethods; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUQuerySetMethods; use super::bindings::str::USVString; use crate::dom::bindings::reflector::Reflector; diff --git a/components/script/dom/gpuqueue.rs b/components/script/dom/gpuqueue.rs index 3061211f20f..a9a850e825f 100644 --- a/components/script/dom/gpuqueue.rs +++ b/components/script/dom/gpuqueue.rs @@ -7,13 +7,11 @@ use ipc_channel::ipc::IpcSharedMemory; use webgpu::identity::WebGPUOpResult; use webgpu::{wgt, WebGPU, WebGPUQueue, WebGPURequest}; -use super::bindings::codegen::Bindings::GPUCommandEncoderBinding::{ - GPUImageCopyTexture, GPUImageDataLayout, -}; +use super::bindings::codegen::Bindings::WebGPUBinding::{GPUImageCopyTexture, GPUImageDataLayout}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUBufferBinding::GPUSize64; -use crate::dom::bindings::codegen::Bindings::GPUQueueBinding::GPUQueueMethods; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::GPUExtent3D; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUExtent3D, GPUQueueMethods, GPUSize64, +}; use crate::dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer as BufferSource; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; diff --git a/components/script/dom/gpurenderbundle.rs b/components/script/dom/gpurenderbundle.rs index 17f72d41dd8..5a746a4f0dd 100644 --- a/components/script/dom/gpurenderbundle.rs +++ b/components/script/dom/gpurenderbundle.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPU, WebGPUDevice, WebGPURenderBundle}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPURenderBundleBinding::GPURenderBundleMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderBundleMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpurenderbundleencoder.rs b/components/script/dom/gpurenderbundleencoder.rs index ab6f8aae3a4..df78a4055ba 100644 --- a/components/script/dom/gpurenderbundleencoder.rs +++ b/components/script/dom/gpurenderbundleencoder.rs @@ -6,10 +6,11 @@ use dom_struct::dom_struct; use webgpu::wgpu::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder}; use webgpu::{wgt, WebGPU, WebGPURenderBundle, WebGPURequest}; -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPURenderBundleBinding::GPURenderBundleDescriptor; -use crate::dom::bindings::codegen::Bindings::GPURenderBundleEncoderBinding::GPURenderBundleEncoderMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPURenderBundleDescriptor, GPURenderBundleEncoderMethods, +}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpurenderpassencoder.rs b/components/script/dom/gpurenderpassencoder.rs index 7827e090c10..a970eff4e2b 100644 --- a/components/script/dom/gpurenderpassencoder.rs +++ b/components/script/dom/gpurenderpassencoder.rs @@ -6,11 +6,12 @@ use dom_struct::dom_struct; use webgpu::wgpu::command::{render_ffi as wgpu_render, RenderPass}; use webgpu::{wgt, WebGPU, WebGPURequest}; -use super::bindings::codegen::Bindings::GPURenderPipelineBinding::GPUIndexFormat; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUIndexFormat; use super::bindings::error::Fallible; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUCommandEncoderBinding::GPUColor; -use crate::dom::bindings::codegen::Bindings::GPURenderPassEncoderBinding::GPURenderPassEncoderMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUColor, GPURenderPassEncoderMethods, +}; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs index 7cd11632707..a1cef99c7e8 100644 --- a/components/script/dom/gpurenderpipeline.rs +++ b/components/script/dom/gpurenderpipeline.rs @@ -8,7 +8,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPUBindGroupLayout, WebGPURenderPipeline}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPURenderPipelineBinding::GPURenderPipelineMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods; use crate::dom::bindings::error::{Error, Fallible}; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gpusampler.rs b/components/script/dom/gpusampler.rs index 670d3fec896..6a3b5462ff1 100644 --- a/components/script/dom/gpusampler.rs +++ b/components/script/dom/gpusampler.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::{WebGPUDevice, WebGPUSampler}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUSamplerBinding::GPUSamplerMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUSamplerMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpushadermodule.rs b/components/script/dom/gpushadermodule.rs index 28a0a885506..5fe770a3e45 100644 --- a/components/script/dom/gpushadermodule.rs +++ b/components/script/dom/gpushadermodule.rs @@ -10,7 +10,7 @@ use webgpu::WebGPUShaderModule; use super::bindings::error::Fallible; use super::promise::Promise; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUShaderModuleBinding::GPUShaderModuleMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUShaderModuleMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpusupportedfeatures.rs b/components/script/dom/gpusupportedfeatures.rs index bf6e5e8011a..9cdde31c45e 100644 --- a/components/script/dom/gpusupportedfeatures.rs +++ b/components/script/dom/gpusupportedfeatures.rs @@ -13,9 +13,10 @@ use webgpu::wgt; use super::bindings::like::Setlike; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::GPUFeatureName; -use crate::dom::bindings::codegen::Bindings::GPUAdapterBinding::GPUFeatureNameValues::pairs; -use crate::dom::bindings::codegen::Bindings::GPUSupportedFeaturesBinding::GPUSupportedFeaturesMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUFeatureNameValues::pairs; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUFeatureName, GPUSupportedFeaturesMethods, +}; use crate::dom::bindings::error::Fallible; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; diff --git a/components/script/dom/gpusupportedlimits.rs b/components/script/dom/gpusupportedlimits.rs index 70d361594d2..d4fc0f1a0d0 100644 --- a/components/script/dom/gpusupportedlimits.rs +++ b/components/script/dom/gpusupportedlimits.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::wgt::Limits; use GPUSupportedLimits_Binding::GPUSupportedLimitsMethods; -use super::bindings::codegen::Bindings::GPUSupportedLimitsBinding::GPUSupportedLimits_Binding; +use super::bindings::codegen::Bindings::WebGPUBinding::GPUSupportedLimits_Binding; use super::bindings::reflector::reflect_dom_object; use super::bindings::root::DomRoot; use crate::dom::bindings::reflector::Reflector; diff --git a/components/script/dom/gputexture.rs b/components/script/dom/gputexture.rs index 5b420276d47..b10f79915d3 100644 --- a/components/script/dom/gputexture.rs +++ b/components/script/dom/gputexture.rs @@ -11,11 +11,9 @@ use webgpu::wgpu::resource; use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView}; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{ - GPUExtent3DDict, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods, -}; -use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::{ - GPUTextureAspect, GPUTextureViewDescriptor, +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUExtent3DDict, GPUTextureAspect, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods, + GPUTextureViewDescriptor, }; use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/dom/gputextureview.rs b/components/script/dom/gputextureview.rs index b18130f01d9..af207c076f9 100644 --- a/components/script/dom/gputextureview.rs +++ b/components/script/dom/gputextureview.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use webgpu::WebGPUTextureView; use crate::dom::bindings::cell::DomRefCell; -use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::GPUTextureViewMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUTextureViewMethods; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{Dom, DomRoot}; use crate::dom::bindings::str::USVString; diff --git a/components/script/dom/gpuuncapturederrorevent.rs b/components/script/dom/gpuuncapturederrorevent.rs index 2a8b68541df..d6d9bdbd45a 100644 --- a/components/script/dom/gpuuncapturederrorevent.rs +++ b/components/script/dom/gpuuncapturederrorevent.rs @@ -7,10 +7,9 @@ use js::rust::HandleObject; use servo_atoms::Atom; use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods; -use crate::dom::bindings::codegen::Bindings::GPUUncapturedErrorEventBinding::{ - GPUUncapturedErrorEventInit, GPUUncapturedErrorEventMethods, +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{ + GPUError, GPUUncapturedErrorEventInit, GPUUncapturedErrorEventMethods, }; -use crate::dom::bindings::codegen::Bindings::GPUValidationErrorBinding::GPUError; use crate::dom::bindings::reflector::reflect_dom_object_with_proto; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; diff --git a/components/script/dom/gpuvalidationerror.rs b/components/script/dom/gpuvalidationerror.rs index 0153399f449..044502bfa32 100644 --- a/components/script/dom/gpuvalidationerror.rs +++ b/components/script/dom/gpuvalidationerror.rs @@ -6,7 +6,7 @@ use dom_struct::dom_struct; use js::rust::HandleObject; use super::bindings::error::Fallible; -use crate::dom::bindings::codegen::Bindings::GPUValidationErrorBinding::GPUValidationErrorMethods; +use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUValidationErrorMethods; use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, Reflector}; use crate::dom::bindings::root::DomRoot; use crate::dom::bindings::str::DOMString; diff --git a/components/script/dom/webidls/GPU.webidl b/components/script/dom/webidls/GPU.webidl deleted file mode 100644 index f35966f4b3d..00000000000 --- a/components/script/dom/webidls/GPU.webidl +++ /dev/null @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpu-interface -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPU { - [NewObject] - Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {}); - GPUTextureFormat getPreferredCanvasFormat(); -}; - -dictionary GPURequestAdapterOptions { - GPUPowerPreference powerPreference; - boolean forceFallbackAdapter = false; -}; - -enum GPUPowerPreference { - "low-power", - "high-performance" -}; diff --git a/components/script/dom/webidls/GPUAdapter.webidl b/components/script/dom/webidls/GPUAdapter.webidl deleted file mode 100644 index bd7f9c2a6ab..00000000000 --- a/components/script/dom/webidls/GPUAdapter.webidl +++ /dev/null @@ -1,33 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuadapter -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUAdapter { - [SameObject] readonly attribute GPUSupportedFeatures features; - [SameObject] readonly attribute GPUSupportedLimits limits; - readonly attribute boolean isFallbackAdapter; - - [NewObject] - Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {}); - [NewObject] - Promise<GPUAdapterInfo> requestAdapterInfo(optional sequence<DOMString> unmaskHints = []); -}; - -dictionary GPUDeviceDescriptor { - sequence<GPUFeatureName> requiredFeatures = []; - record<DOMString, GPUSize64> requiredLimits; -}; - -enum GPUFeatureName { - "depth-clip-control", - "depth24unorm-stencil8", - "depth32float-stencil8", - "pipeline-statistics-query", - "texture-compression-bc", - "texture-compression-etc2", - "texture-compression-astc", - "timestamp-query", - "indirect-first-instance", -}; diff --git a/components/script/dom/webidls/GPUAdapterInfo.webidl b/components/script/dom/webidls/GPUAdapterInfo.webidl deleted file mode 100644 index 7ddc34866e0..00000000000 --- a/components/script/dom/webidls/GPUAdapterInfo.webidl +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuadapterinfo -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUAdapterInfo { - readonly attribute DOMString vendor; - readonly attribute DOMString architecture; - readonly attribute DOMString device; - readonly attribute DOMString description; -}; diff --git a/components/script/dom/webidls/GPUBindGroup.webidl b/components/script/dom/webidls/GPUBindGroup.webidl deleted file mode 100644 index 4c83e6460ed..00000000000 --- a/components/script/dom/webidls/GPUBindGroup.webidl +++ /dev/null @@ -1,27 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpubindgrouplayout -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUBindGroup { -}; -GPUBindGroup includes GPUObjectBase; - -dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase { - required GPUBindGroupLayout layout; - required sequence<GPUBindGroupEntry> entries; -}; - -typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource; - -dictionary GPUBindGroupEntry { - required GPUIndex32 binding; - required GPUBindingResource resource; -}; - -dictionary GPUBufferBinding { - required GPUBuffer buffer; - GPUSize64 offset = 0; - GPUSize64 size; -}; diff --git a/components/script/dom/webidls/GPUBindGroupLayout.webidl b/components/script/dom/webidls/GPUBindGroupLayout.webidl deleted file mode 100644 index 91ce4702417..00000000000 --- a/components/script/dom/webidls/GPUBindGroupLayout.webidl +++ /dev/null @@ -1,68 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpubindgrouplayout -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUBindGroupLayout { -}; -GPUBindGroupLayout includes GPUObjectBase; - -dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase { - required sequence<GPUBindGroupLayoutEntry> entries; -}; - -dictionary GPUBindGroupLayoutEntry { - required GPUIndex32 binding; - required GPUShaderStageFlags visibility; - GPUBufferBindingLayout buffer; - GPUSamplerBindingLayout sampler; - GPUTextureBindingLayout texture; - GPUStorageTextureBindingLayout storageTexture; -}; - -enum GPUBufferBindingType { - "uniform", - "storage", - "read-only-storage", -}; - -dictionary GPUBufferBindingLayout { - GPUBufferBindingType type = "uniform"; - boolean hasDynamicOffset = false; - GPUSize64 minBindingSize = 0; -}; - -enum GPUSamplerBindingType { - "filtering", - "non-filtering", - "comparison", -}; - -dictionary GPUSamplerBindingLayout { - GPUSamplerBindingType type = "filtering"; -}; - -enum GPUTextureSampleType { - "float", - "unfilterable-float", - "depth", - "sint", - "uint", -}; - -dictionary GPUTextureBindingLayout { - GPUTextureSampleType sampleType = "float"; - GPUTextureViewDimension viewDimension = "2d"; - boolean multisampled = false; -}; - -enum GPUStorageTextureAccess { - "write-only", -}; - -dictionary GPUStorageTextureBindingLayout { - GPUStorageTextureAccess access = "write-only"; - required GPUTextureFormat format; - GPUTextureViewDimension viewDimension = "2d"; -}; diff --git a/components/script/dom/webidls/GPUBuffer.webidl b/components/script/dom/webidls/GPUBuffer.webidl deleted file mode 100644 index 8cc7f652e80..00000000000 --- a/components/script/dom/webidls/GPUBuffer.webidl +++ /dev/null @@ -1,25 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpubuffer -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUBuffer { - [NewObject] - Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); - [NewObject, Throws] - ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size); - [Throws] - undefined unmap(); - [Throws] - undefined destroy(); -}; -GPUBuffer includes GPUObjectBase; - -dictionary GPUBufferDescriptor : GPUObjectDescriptorBase { - required GPUSize64 size; - required GPUBufferUsageFlags usage; - boolean mappedAtCreation = false; -}; - -typedef [EnforceRange] unsigned long long GPUSize64; diff --git a/components/script/dom/webidls/GPUBufferUsage.webidl b/components/script/dom/webidls/GPUBufferUsage.webidl deleted file mode 100644 index 78330c9bf17..00000000000 --- a/components/script/dom/webidls/GPUBufferUsage.webidl +++ /dev/null @@ -1,19 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#buffer-usage -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUBufferUsage { - const GPUBufferUsageFlags MAP_READ = 0x0001; - const GPUBufferUsageFlags MAP_WRITE = 0x0002; - const GPUBufferUsageFlags COPY_SRC = 0x0004; - const GPUBufferUsageFlags COPY_DST = 0x0008; - const GPUBufferUsageFlags INDEX = 0x0010; - const GPUBufferUsageFlags VERTEX = 0x0020; - const GPUBufferUsageFlags UNIFORM = 0x0040; - const GPUBufferUsageFlags STORAGE = 0x0080; - const GPUBufferUsageFlags INDIRECT = 0x0100; - const GPUBufferUsageFlags QUERY_RESOLVE = 0x0200; -}; -typedef [EnforceRange] unsigned long GPUBufferUsageFlags; diff --git a/components/script/dom/webidls/GPUCanvasContext.webidl b/components/script/dom/webidls/GPUCanvasContext.webidl deleted file mode 100644 index 4395f176c9e..00000000000 --- a/components/script/dom/webidls/GPUCanvasContext.webidl +++ /dev/null @@ -1,31 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucanvascontext -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUCanvasContext { - readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; - - // Calling configure() a second time invalidates the previous one, - // and all of the textures it's produced. - undefined configure(GPUCanvasConfiguration descriptor); - undefined unconfigure(); - - [Throws] - GPUTexture getCurrentTexture(); -}; - -enum GPUCanvasAlphaMode { - "opaque", - "premultiplied", -}; - -dictionary GPUCanvasConfiguration { - required GPUDevice device; - required GPUTextureFormat format; - GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT - sequence<GPUTextureFormat> viewFormats = []; - // PredefinedColorSpace colorSpace = "srgb"; // TODO - GPUCanvasAlphaMode alphaMode = "opaque"; -}; diff --git a/components/script/dom/webidls/GPUColorWrite.webidl b/components/script/dom/webidls/GPUColorWrite.webidl deleted file mode 100644 index d667580fbf3..00000000000 --- a/components/script/dom/webidls/GPUColorWrite.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#namespacedef-gpucolorwrite -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUColorWrite { - const GPUColorWriteFlags RED = 0x1; - const GPUColorWriteFlags GREEN = 0x2; - const GPUColorWriteFlags BLUE = 0x4; - const GPUColorWriteFlags ALPHA = 0x8; - const GPUColorWriteFlags ALL = 0xF; -}; - -typedef [EnforceRange] unsigned long GPUColorWriteFlags; diff --git a/components/script/dom/webidls/GPUCommandBuffer.webidl b/components/script/dom/webidls/GPUCommandBuffer.webidl deleted file mode 100644 index 38186438afb..00000000000 --- a/components/script/dom/webidls/GPUCommandBuffer.webidl +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucommandbuffer -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUCommandBuffer { -}; -GPUCommandBuffer includes GPUObjectBase; - -dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase { -}; diff --git a/components/script/dom/webidls/GPUCommandEncoder.webidl b/components/script/dom/webidls/GPUCommandEncoder.webidl deleted file mode 100644 index 2e63fced636..00000000000 --- a/components/script/dom/webidls/GPUCommandEncoder.webidl +++ /dev/null @@ -1,153 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucommandencoder -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUCommandEncoder { - [NewObject] - GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); - [NewObject] - GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); - - undefined copyBufferToBuffer( - GPUBuffer source, - GPUSize64 sourceOffset, - GPUBuffer destination, - GPUSize64 destinationOffset, - GPUSize64 size); - - undefined copyBufferToTexture( - GPUImageCopyBuffer source, - GPUImageCopyTexture destination, - GPUExtent3D copySize); - - undefined copyTextureToBuffer( - GPUImageCopyTexture source, - GPUImageCopyBuffer destination, - GPUExtent3D copySize); - - undefined copyTextureToTexture( - GPUImageCopyTexture source, - GPUImageCopyTexture destination, - GPUExtent3D copySize); - - /* - undefined copyImageBitmapToTexture( - GPUImageBitmapCopyView source, - GPUImageCopyTexture destination, - GPUExtent3D copySize); - */ - - //undefined pushDebugGroup(USVString groupLabel); - //undefined popDebugGroup(); - //undefined insertDebugMarker(USVString markerLabel); - - [NewObject] - GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); -}; -GPUCommandEncoder includes GPUObjectBase; - -dictionary GPUImageDataLayout { - GPUSize64 offset = 0; - GPUSize32 bytesPerRow; - GPUSize32 rowsPerImage; -}; - -dictionary GPUImageCopyBuffer : GPUImageDataLayout { - required GPUBuffer buffer; -}; - -dictionary GPUImageCopyExternalImage { - required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source; - GPUOrigin2D origin = {}; - boolean flipY = false; -}; - -dictionary GPUImageCopyTexture { - required GPUTexture texture; - GPUIntegerCoordinate mipLevel = 0; - GPUOrigin3D origin; - GPUTextureAspect aspect = "all"; -}; - -dictionary GPUImageCopyTextureTagged : GPUImageCopyTexture { - //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO - boolean premultipliedAlpha = false; -}; - -dictionary GPUImageBitmapCopyView { - //required ImageBitmap imageBitmap; //TODO - GPUOrigin2D origin; -}; - -dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase { -}; - -// -dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase { - required sequence<GPURenderPassColorAttachment> colorAttachments; - GPURenderPassDepthStencilAttachment depthStencilAttachment; - GPUQuerySet occlusionQuerySet; -}; - -dictionary GPURenderPassColorAttachment { - required GPUTextureView view; - GPUTextureView resolveTarget; - - GPUColor clearValue; - required GPULoadOp loadOp; - required GPUStoreOp storeOp; -}; - -dictionary GPURenderPassDepthStencilAttachment { - required GPUTextureView view; - - float depthClearValue; - GPULoadOp depthLoadOp; - GPUStoreOp depthStoreOp; - boolean depthReadOnly = false; - - GPUStencilValue stencilClearValue = 0; - GPULoadOp stencilLoadOp; - GPUStoreOp stencilStoreOp; - boolean stencilReadOnly = false; -}; - -enum GPULoadOp { - "load", - "clear" -}; - -enum GPUStoreOp { - "store", - "discard" -}; - -dictionary GPURenderPassLayout: GPUObjectDescriptorBase { - // TODO: We don't support nullable enumerated arguments yet - required sequence<GPUTextureFormat> colorFormats; - GPUTextureFormat depthStencilFormat; - GPUSize32 sampleCount = 1; -}; - -dictionary GPUColorDict { - required double r; - required double g; - required double b; - required double a; -}; -typedef (sequence<double> or GPUColorDict) GPUColor; - -dictionary GPUOrigin2DDict { - GPUIntegerCoordinate x = 0; - GPUIntegerCoordinate y = 0; -}; -typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D; - -dictionary GPUOrigin3DDict { - GPUIntegerCoordinate x = 0; - GPUIntegerCoordinate y = 0; - GPUIntegerCoordinate z = 0; -}; -typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D; diff --git a/components/script/dom/webidls/GPUCompilationInfo.webidl b/components/script/dom/webidls/GPUCompilationInfo.webidl deleted file mode 100644 index c5451db6f52..00000000000 --- a/components/script/dom/webidls/GPUCompilationInfo.webidl +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucompilationinfo -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUCompilationInfo { - // codegen hates it - //[Cached, Frozen, Pure] - readonly attribute /*sequence<GPUCompilationMessage>*/ any messages; -}; diff --git a/components/script/dom/webidls/GPUCompilationMessage.webidl b/components/script/dom/webidls/GPUCompilationMessage.webidl deleted file mode 100644 index 29d55da1aad..00000000000 --- a/components/script/dom/webidls/GPUCompilationMessage.webidl +++ /dev/null @@ -1,20 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucompilationmessage -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUCompilationMessage { - readonly attribute DOMString message; - readonly attribute GPUCompilationMessageType type; - readonly attribute unsigned long long lineNum; - readonly attribute unsigned long long linePos; - readonly attribute unsigned long long offset; - readonly attribute unsigned long long length; -}; - -enum GPUCompilationMessageType { - "error", - "warning", - "info" -}; diff --git a/components/script/dom/webidls/GPUComputePassEncoder.webidl b/components/script/dom/webidls/GPUComputePassEncoder.webidl deleted file mode 100644 index 41aea0a2371..00000000000 --- a/components/script/dom/webidls/GPUComputePassEncoder.webidl +++ /dev/null @@ -1,19 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucomputepassencoder -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUComputePassEncoder { - undefined setPipeline(GPUComputePipeline pipeline); - undefined dispatchWorkgroups(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1); - //[Pref="dom.webgpu.indirect-dispatch.enabled"] - undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); - - [Throws] - undefined end(); -}; -GPUComputePassEncoder includes GPUObjectBase; -GPUComputePassEncoder includes GPUProgrammablePassEncoder; - -typedef [EnforceRange] unsigned long GPUSize32; diff --git a/components/script/dom/webidls/GPUComputePipeline.webidl b/components/script/dom/webidls/GPUComputePipeline.webidl deleted file mode 100644 index 7e6f5da1b12..00000000000 --- a/components/script/dom/webidls/GPUComputePipeline.webidl +++ /dev/null @@ -1,31 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpucomputepipeline -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUComputePipeline { -}; -GPUComputePipeline includes GPUObjectBase; -GPUComputePipeline includes GPUPipelineBase; - -enum GPUAutoLayoutMode { - "auto" -}; - -dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase { - required (GPUPipelineLayout or GPUAutoLayoutMode) layout; -}; - -dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase { - required GPUProgrammableStage compute; -}; - -interface mixin GPUPipelineBase { - [Throws] GPUBindGroupLayout getBindGroupLayout(unsigned long index); -}; - -dictionary GPUProgrammableStage { - required GPUShaderModule module; - required USVString entryPoint; -}; diff --git a/components/script/dom/webidls/GPUDevice.webidl b/components/script/dom/webidls/GPUDevice.webidl deleted file mode 100644 index e00b3825c4f..00000000000 --- a/components/script/dom/webidls/GPUDevice.webidl +++ /dev/null @@ -1,48 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpudevice -[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom.webgpu.enabled"] -interface GPUDevice: EventTarget { - [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; - - undefined destroy(); - - [NewObject, Throws] - GPUBuffer createBuffer(GPUBufferDescriptor descriptor); - [NewObject] - GPUTexture createTexture(GPUTextureDescriptor descriptor); - [NewObject] - GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {}); - - GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); - GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor); - GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor); - - GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); - GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); - GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor); - - [NewObject] - Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor); - [NewObject] - Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor); - - [NewObject] - GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); - [NewObject] - GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); - //[NewObject] - //GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor); -}; -GPUDevice includes GPUObjectBase; - -//TODO -dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase { - boolean measureExecutionTime = false; -}; diff --git a/components/script/dom/webidls/GPUDeviceLostInfo.webidl b/components/script/dom/webidls/GPUDeviceLostInfo.webidl deleted file mode 100644 index de011768889..00000000000 --- a/components/script/dom/webidls/GPUDeviceLostInfo.webidl +++ /dev/null @@ -1,20 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpudevicelostinfo -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUDeviceLostInfo { - readonly attribute GPUDeviceLostReason reason; - readonly attribute DOMString message; -}; - -enum GPUDeviceLostReason { - "unknown", - "destroyed", -}; - -partial interface GPUDevice { - [Throws] - readonly attribute Promise<GPUDeviceLostInfo> lost; -}; diff --git a/components/script/dom/webidls/GPUMapMode.webidl b/components/script/dom/webidls/GPUMapMode.webidl deleted file mode 100644 index e99bde35237..00000000000 --- a/components/script/dom/webidls/GPUMapMode.webidl +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#namespacedef-gpumapmode -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUMapMode { - const GPUMapModeFlags READ = 0x0001; - const GPUMapModeFlags WRITE = 0x0002; -}; - -typedef [EnforceRange] unsigned long GPUMapModeFlags; diff --git a/components/script/dom/webidls/GPUObjectBase.webidl b/components/script/dom/webidls/GPUObjectBase.webidl deleted file mode 100644 index d977999f64f..00000000000 --- a/components/script/dom/webidls/GPUObjectBase.webidl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuobjectbase -[Exposed=(Window)] -interface mixin GPUObjectBase { - attribute USVString label; -}; - -dictionary GPUObjectDescriptorBase { - USVString label; -}; diff --git a/components/script/dom/webidls/GPUOutOfMemoryError.webidl b/components/script/dom/webidls/GPUOutOfMemoryError.webidl deleted file mode 100644 index 470684edaab..00000000000 --- a/components/script/dom/webidls/GPUOutOfMemoryError.webidl +++ /dev/null @@ -1,9 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuoutofmemoryerror -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUOutOfMemoryError { - constructor(); -}; diff --git a/components/script/dom/webidls/GPUPipelineLayout.webidl b/components/script/dom/webidls/GPUPipelineLayout.webidl deleted file mode 100644 index a50c2c60f40..00000000000 --- a/components/script/dom/webidls/GPUPipelineLayout.webidl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#pipeline-layout -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUPipelineLayout { -}; -GPUPipelineLayout includes GPUObjectBase; - -dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase { - required sequence<GPUBindGroupLayout> bindGroupLayouts; -}; diff --git a/components/script/dom/webidls/GPUProgrammablePassEncoder.webidl b/components/script/dom/webidls/GPUProgrammablePassEncoder.webidl deleted file mode 100644 index a7293fca7e8..00000000000 --- a/components/script/dom/webidls/GPUProgrammablePassEncoder.webidl +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuprogrammablepassencoder -[Exposed=(Window, DedicatedWorker)] -interface mixin GPUProgrammablePassEncoder { - undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup, - optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []); - - //undefined pushDebugGroup(USVString groupLabel); - //undefined popDebugGroup(); - //undefined insertDebugMarker(USVString markerLabel); -}; - -typedef [EnforceRange] unsigned long GPUBufferDynamicOffset; -typedef [EnforceRange] unsigned long GPUIndex32; diff --git a/components/script/dom/webidls/GPUQuerySet.webidl b/components/script/dom/webidls/GPUQuerySet.webidl deleted file mode 100644 index 12275263c02..00000000000 --- a/components/script/dom/webidls/GPUQuerySet.webidl +++ /dev/null @@ -1,30 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuqueryset -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUQuerySet { - undefined destroy(); -}; -GPUQuerySet includes GPUObjectBase; - -dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase { - required GPUQueryType type; - required GPUSize32 count; - sequence<GPUPipelineStatisticName> pipelineStatistics = []; -}; - -enum GPUPipelineStatisticName { - "vertex-shader-invocations", - "clipper-invocations", - "clipper-primitives-out", - "fragment-shader-invocations", - "compute-shader-invocations" -}; - -enum GPUQueryType { - "occlusion", - "pipeline-statistics", - "timestamp" -}; diff --git a/components/script/dom/webidls/GPUQueue.webidl b/components/script/dom/webidls/GPUQueue.webidl deleted file mode 100644 index 1fa33cab309..00000000000 --- a/components/script/dom/webidls/GPUQueue.webidl +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuqueue -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUQueue { - undefined submit(sequence<GPUCommandBuffer> buffers); - - //TODO: - //Promise<undefined> onSubmittedWorkDone(); - - [Throws] - undefined writeBuffer( - GPUBuffer buffer, - GPUSize64 bufferOffset, - BufferSource data, - optional GPUSize64 dataOffset = 0, - optional GPUSize64 size); - - [Throws] - undefined writeTexture( - GPUImageCopyTexture destination, - BufferSource data, - GPUImageDataLayout dataLayout, - GPUExtent3D size); - - //[Throws] - //undefined copyExternalImageToTexture( - // GPUImageCopyExternalImage source, - // GPUImageCopyTextureTagged destination, - // GPUExtent3D copySize); -}; -GPUQueue includes GPUObjectBase; diff --git a/components/script/dom/webidls/GPURenderBundle.webidl b/components/script/dom/webidls/GPURenderBundle.webidl deleted file mode 100644 index 52a8e5b0bc8..00000000000 --- a/components/script/dom/webidls/GPURenderBundle.webidl +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpurenderbundle -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPURenderBundle { -}; -GPURenderBundle includes GPUObjectBase; - -dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase { -}; diff --git a/components/script/dom/webidls/GPURenderBundleEncoder.webidl b/components/script/dom/webidls/GPURenderBundleEncoder.webidl deleted file mode 100644 index cc65f37b818..00000000000 --- a/components/script/dom/webidls/GPURenderBundleEncoder.webidl +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpurenderbundleencoder -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPURenderBundleEncoder { - GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {}); -}; -GPURenderBundleEncoder includes GPUObjectBase; -GPURenderBundleEncoder includes GPUProgrammablePassEncoder; -GPURenderBundleEncoder includes GPURenderEncoderBase; - -dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout { - boolean depthReadOnly = false; - boolean stencilReadOnly = false; -}; diff --git a/components/script/dom/webidls/GPURenderEncoderBase.webidl b/components/script/dom/webidls/GPURenderEncoderBase.webidl deleted file mode 100644 index f4bdc5609e5..00000000000 --- a/components/script/dom/webidls/GPURenderEncoderBase.webidl +++ /dev/null @@ -1,35 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpurendercommandsmixin -[Exposed=(Window, DedicatedWorker)] -interface mixin GPURenderEncoderBase { - undefined setPipeline(GPURenderPipeline pipeline); - - undefined setIndexBuffer(GPUBuffer buffer, - GPUIndexFormat indexFormat, - optional GPUSize64 offset = 0, - optional GPUSize64 size = 0); - undefined setVertexBuffer(GPUIndex32 slot, - GPUBuffer buffer, - optional GPUSize64 offset = 0, - optional GPUSize64 size = 0); - - undefined draw(GPUSize32 vertexCount, - optional GPUSize32 instanceCount = 1, - optional GPUSize32 firstVertex = 0, - optional GPUSize32 firstInstance = 0); - undefined drawIndexed(GPUSize32 indexCount, - optional GPUSize32 instanceCount = 1, - optional GPUSize32 firstIndex = 0, - optional GPUSignedOffset32 baseVertex = 0, - optional GPUSize32 firstInstance = 0); - - //[Pref="dom.webgpu.indirect-dispatch.enabled"] - undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); - //[Pref="dom.webgpu.indirect-dispatch.enabled"] - undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); -}; - -typedef [EnforceRange] long GPUSignedOffset32; diff --git a/components/script/dom/webidls/GPURenderPassEncoder.webidl b/components/script/dom/webidls/GPURenderPassEncoder.webidl deleted file mode 100644 index 27764df5624..00000000000 --- a/components/script/dom/webidls/GPURenderPassEncoder.webidl +++ /dev/null @@ -1,33 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpurenderpassencoder -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPURenderPassEncoder { - undefined setViewport(float x, float y, - float width, float height, - float minDepth, float maxDepth); - - undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, - GPUIntegerCoordinate width, GPUIntegerCoordinate height); - - undefined setBlendConstant(GPUColor color); - undefined setStencilReference(GPUStencilValue reference); - - //undefined beginOcclusionQuery(GPUSize32 queryIndex); - //undefined endOcclusionQuery(); - - //undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); - //undefined endPipelineStatisticsQuery(); - - //undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); - - undefined executeBundles(sequence<GPURenderBundle> bundles); - - [Throws] - undefined end(); -}; -GPURenderPassEncoder includes GPUObjectBase; -GPURenderPassEncoder includes GPUProgrammablePassEncoder; -GPURenderPassEncoder includes GPURenderEncoderBase; diff --git a/components/script/dom/webidls/GPURenderPipeline.webidl b/components/script/dom/webidls/GPURenderPipeline.webidl deleted file mode 100644 index 1d654a4814e..00000000000 --- a/components/script/dom/webidls/GPURenderPipeline.webidl +++ /dev/null @@ -1,196 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpurenderpipeline -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPURenderPipeline { -}; -GPURenderPipeline includes GPUObjectBase; -GPURenderPipeline includes GPUPipelineBase; - -dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase { - required GPUVertexState vertex; - GPUPrimitiveState primitive = {}; - GPUDepthStencilState depthStencil; - GPUMultisampleState multisample = {}; - GPUFragmentState fragment; -}; - -dictionary GPUPrimitiveState { - GPUPrimitiveTopology topology = "triangle-list"; - GPUIndexFormat stripIndexFormat; - GPUFrontFace frontFace = "ccw"; - GPUCullMode cullMode = "none"; - // Enable depth clamping (requires "depth-clamping" feature) - boolean clampDepth = false; -}; - -enum GPUPrimitiveTopology { - "point-list", - "line-list", - "line-strip", - "triangle-list", - "triangle-strip" -}; - -enum GPUFrontFace { - "ccw", - "cw" -}; - -enum GPUCullMode { - "none", - "front", - "back" -}; - -dictionary GPUMultisampleState { - GPUSize32 count = 1; - GPUSampleMask mask = 0xFFFFFFFF; - boolean alphaToCoverageEnabled = false; -}; - -dictionary GPUFragmentState: GPUProgrammableStage { - required sequence<GPUColorTargetState> targets; -}; - -dictionary GPUColorTargetState { - required GPUTextureFormat format; - GPUBlendState blend; - GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL -}; - -dictionary GPUBlendState { - required GPUBlendComponent color; - required GPUBlendComponent alpha; -}; - -typedef [EnforceRange] unsigned long GPUSampleMask; -typedef [EnforceRange] long GPUDepthBias; - -dictionary GPUBlendComponent { - GPUBlendFactor srcFactor = "one"; - GPUBlendFactor dstFactor = "zero"; - GPUBlendOperation operation = "add"; -}; - -enum GPUBlendFactor { - "zero", - "one", - "src", - "one-minus-src", - "src-alpha", - "one-minus-src-alpha", - "dst", - "one-minus-dst", - "dst-alpha", - "one-minus-dst-alpha", - "src-alpha-saturated", - "constant", - "one-minus-constant", -}; - -enum GPUBlendOperation { - "add", - "subtract", - "reverse-subtract", - "min", - "max" -}; - -dictionary GPUDepthStencilState { - required GPUTextureFormat format; - - boolean depthWriteEnabled = false; - GPUCompareFunction depthCompare = "always"; - - GPUStencilFaceState stencilFront = {}; - GPUStencilFaceState stencilBack = {}; - - GPUStencilValue stencilReadMask = 0xFFFFFFFF; - GPUStencilValue stencilWriteMask = 0xFFFFFFFF; - - GPUDepthBias depthBias = 0; - float depthBiasSlopeScale = 0; - float depthBiasClamp = 0; -}; - -dictionary GPUStencilFaceState { - GPUCompareFunction compare = "always"; - GPUStencilOperation failOp = "keep"; - GPUStencilOperation depthFailOp = "keep"; - GPUStencilOperation passOp = "keep"; -}; - -enum GPUStencilOperation { - "keep", - "zero", - "replace", - "invert", - "increment-clamp", - "decrement-clamp", - "increment-wrap", - "decrement-wrap" -}; - -enum GPUIndexFormat { - "uint16", - "uint32", -}; - -typedef [EnforceRange] unsigned long GPUStencilValue; - -enum GPUVertexFormat { - "uint8x2", - "uint8x4", - "sint8x2", - "sint8x4", - "unorm8x2", - "unorm8x4", - "snorm8x2", - "snorm8x4", - "uint16x2", - "uint16x4", - "sint16x2", - "sint16x4", - "unorm16x2", - "unorm16x4", - "snorm16x2", - "snorm16x4", - "float16x2", - "float16x4", - "float32", - "float32x2", - "float32x3", - "float32x4", - "uint32", - "uint32x2", - "uint32x3", - "uint32x4", - "sint32", - "sint32x2", - "sint32x3", - "sint32x4", -}; - -enum GPUVertexStepMode { - "vertex", - "instance", -}; - -dictionary GPUVertexState: GPUProgrammableStage { - sequence<GPUVertexBufferLayout?> buffers = []; -}; - -dictionary GPUVertexBufferLayout { - required GPUSize64 arrayStride; - GPUVertexStepMode stepMode = "vertex"; - required sequence<GPUVertexAttribute> attributes; -}; - -dictionary GPUVertexAttribute { - required GPUVertexFormat format; - required GPUSize64 offset; - required GPUIndex32 shaderLocation; -}; diff --git a/components/script/dom/webidls/GPUSampler.webidl b/components/script/dom/webidls/GPUSampler.webidl deleted file mode 100644 index 5220acc1f76..00000000000 --- a/components/script/dom/webidls/GPUSampler.webidl +++ /dev/null @@ -1,44 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpusampler -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUSampler { -}; -GPUSampler includes GPUObjectBase; - -dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase { - GPUAddressMode addressModeU = "clamp-to-edge"; - GPUAddressMode addressModeV = "clamp-to-edge"; - GPUAddressMode addressModeW = "clamp-to-edge"; - GPUFilterMode magFilter = "nearest"; - GPUFilterMode minFilter = "nearest"; - GPUFilterMode mipmapFilter = "nearest"; - float lodMinClamp = 0; - float lodMaxClamp = 1000.0; // TODO: What should this be? - GPUCompareFunction compare; - [Clamp] unsigned short maxAnisotropy = 1; -}; - -enum GPUAddressMode { - "clamp-to-edge", - "repeat", - "mirror-repeat" -}; - -enum GPUFilterMode { - "nearest", - "linear", -}; - -enum GPUCompareFunction { - "never", - "less", - "equal", - "less-equal", - "greater", - "not-equal", - "greater-equal", - "always" -}; diff --git a/components/script/dom/webidls/GPUShaderModule.webidl b/components/script/dom/webidls/GPUShaderModule.webidl deleted file mode 100644 index 8ce90180463..00000000000 --- a/components/script/dom/webidls/GPUShaderModule.webidl +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpushadermodule -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUShaderModule { - [Throws] - Promise<GPUCompilationInfo> compilationInfo(); -}; -GPUShaderModule includes GPUObjectBase; - -dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { - // UTF8String is not observably different from USVString - required USVString code; - object sourceMap; -}; diff --git a/components/script/dom/webidls/GPUShaderStage.webidl b/components/script/dom/webidls/GPUShaderStage.webidl deleted file mode 100644 index 8ba66ef10bc..00000000000 --- a/components/script/dom/webidls/GPUShaderStage.webidl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#typedefdef-gpushaderstageflags -[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] -interface GPUShaderStage { - const GPUShaderStageFlags VERTEX = 1; - const GPUShaderStageFlags FRAGMENT = 2; - const GPUShaderStageFlags COMPUTE = 4; -}; - -typedef [EnforceRange] unsigned long GPUShaderStageFlags; diff --git a/components/script/dom/webidls/GPUSupportedFeatures.webidl b/components/script/dom/webidls/GPUSupportedFeatures.webidl deleted file mode 100644 index e0adcc047af..00000000000 --- a/components/script/dom/webidls/GPUSupportedFeatures.webidl +++ /dev/null @@ -1,9 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpusupportedfeatures -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUSupportedFeatures { - readonly setlike<DOMString>; -}; diff --git a/components/script/dom/webidls/GPUSupportedLimits.webidl b/components/script/dom/webidls/GPUSupportedLimits.webidl deleted file mode 100644 index 2394f40eca0..00000000000 --- a/components/script/dom/webidls/GPUSupportedLimits.webidl +++ /dev/null @@ -1,40 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpusupportedlimits -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUSupportedLimits { - readonly attribute unsigned long maxTextureDimension1D; - readonly attribute unsigned long maxTextureDimension2D; - readonly attribute unsigned long maxTextureDimension3D; - readonly attribute unsigned long maxTextureArrayLayers; - readonly attribute unsigned long maxBindGroups; - //readonly attribute unsigned long maxBindGroupsPlusVertexBuffers; - readonly attribute unsigned long maxBindingsPerBindGroup; - readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout; - readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout; - readonly attribute unsigned long maxSampledTexturesPerShaderStage; - readonly attribute unsigned long maxSamplersPerShaderStage; - readonly attribute unsigned long maxStorageBuffersPerShaderStage; - readonly attribute unsigned long maxStorageTexturesPerShaderStage; - readonly attribute unsigned long maxUniformBuffersPerShaderStage; - readonly attribute unsigned long long maxUniformBufferBindingSize; - readonly attribute unsigned long long maxStorageBufferBindingSize; - readonly attribute unsigned long minUniformBufferOffsetAlignment; - readonly attribute unsigned long minStorageBufferOffsetAlignment; - readonly attribute unsigned long maxVertexBuffers; - readonly attribute unsigned long long maxBufferSize; - readonly attribute unsigned long maxVertexAttributes; - readonly attribute unsigned long maxVertexBufferArrayStride; - readonly attribute unsigned long maxInterStageShaderComponents; - //readonly attribute unsigned long maxInterStageShaderVariables; - //readonly attribute unsigned long maxColorAttachments; - //readonly attribute unsigned long maxColorAttachmentBytesPerSample; - readonly attribute unsigned long maxComputeWorkgroupStorageSize; - readonly attribute unsigned long maxComputeInvocationsPerWorkgroup; - readonly attribute unsigned long maxComputeWorkgroupSizeX; - readonly attribute unsigned long maxComputeWorkgroupSizeY; - readonly attribute unsigned long maxComputeWorkgroupSizeZ; - readonly attribute unsigned long maxComputeWorkgroupsPerDimension; -}; diff --git a/components/script/dom/webidls/GPUTexture.webidl b/components/script/dom/webidls/GPUTexture.webidl deleted file mode 100644 index 0448bbdb096..00000000000 --- a/components/script/dom/webidls/GPUTexture.webidl +++ /dev/null @@ -1,116 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gputexture -[Exposed=(Window, DedicatedWorker), Serializable , Pref="dom.webgpu.enabled"] -interface GPUTexture { - [NewObject] - GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {}); - - undefined destroy(); -}; -GPUTexture includes GPUObjectBase; - -dictionary GPUTextureDescriptor : GPUObjectDescriptorBase { - required GPUExtent3D size; - GPUIntegerCoordinate mipLevelCount = 1; - GPUSize32 sampleCount = 1; - GPUTextureDimension dimension = "2d"; - required GPUTextureFormat format; - required GPUTextureUsageFlags usage; - sequence<GPUTextureFormat> viewFormats = []; -}; - -enum GPUTextureDimension { - "1d", - "2d", - "3d", -}; - -enum GPUTextureFormat { - // 8-bit formats - "r8unorm", - "r8snorm", - "r8uint", - "r8sint", - - // 16-bit formats - "r16uint", - "r16sint", - "r16float", - "rg8unorm", - "rg8snorm", - "rg8uint", - "rg8sint", - - // 32-bit formats - "r32uint", - "r32sint", - "r32float", - "rg16uint", - "rg16sint", - "rg16float", - "rgba8unorm", - "rgba8unorm-srgb", - "rgba8snorm", - "rgba8uint", - "rgba8sint", - "bgra8unorm", - "bgra8unorm-srgb", - // Packed 32-bit formats - "rgb10a2unorm", - "rg11b10float", - - // 64-bit formats - "rg32uint", - "rg32sint", - "rg32float", - "rgba16uint", - "rgba16sint", - "rgba16float", - - // 128-bit formats - "rgba32uint", - "rgba32sint", - "rgba32float", - - // Depth and stencil formats - //"stencil8", //TODO - //"depth16unorm", - "depth24plus", - "depth24plus-stencil8", - "depth32float", - - // BC compressed formats usable if "texture-compression-bc" is both - // supported by the device/user agent and enabled in requestDevice. - "bc1-rgba-unorm", - "bc1-rgba-unorm-srgb", - "bc2-rgba-unorm", - "bc2-rgba-unorm-srgb", - "bc3-rgba-unorm", - "bc3-rgba-unorm-srgb", - "bc4-r-unorm", - "bc4-r-snorm", - "bc5-rg-unorm", - "bc5-rg-snorm", - "bc6h-rgb-ufloat", - "bc6h-rgb-float", - "bc7-rgba-unorm", - "bc7-rgba-unorm-srgb", - - // "depth24unorm-stencil8" feature - //"depth24unorm-stencil8", - - // "depth32float-stencil8" feature - //"depth32float-stencil8", -}; - -typedef [EnforceRange] unsigned long GPUIntegerCoordinate; - -dictionary GPUExtent3DDict { - required GPUIntegerCoordinate width; - GPUIntegerCoordinate height = 1; - GPUIntegerCoordinate depthOrArrayLayers = 1; -}; -typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D; diff --git a/components/script/dom/webidls/GPUTextureUsage.webidl b/components/script/dom/webidls/GPUTextureUsage.webidl deleted file mode 100644 index 9ff666dff41..00000000000 --- a/components/script/dom/webidls/GPUTextureUsage.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#typedefdef-gputextureusageflags -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUTextureUsage { - const GPUTextureUsageFlags COPY_SRC = 0x01; - const GPUTextureUsageFlags COPY_DST = 0x02; - const GPUTextureUsageFlags TEXTURE_BINDING = 0x04; - const GPUTextureUsageFlags STORAGE_BINDING = 0x08; - const GPUTextureUsageFlags RENDER_ATTACHMENT = 0x10; -}; - -typedef [EnforceRange] unsigned long GPUTextureUsageFlags; diff --git a/components/script/dom/webidls/GPUTextureView.webidl b/components/script/dom/webidls/GPUTextureView.webidl deleted file mode 100644 index f6b8b7d1317..00000000000 --- a/components/script/dom/webidls/GPUTextureView.webidl +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gputextureview -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUTextureView { -}; -GPUTextureView includes GPUObjectBase; - -dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase { - GPUTextureFormat format; - GPUTextureViewDimension dimension; - GPUTextureAspect aspect = "all"; - GPUIntegerCoordinate baseMipLevel = 0; - GPUIntegerCoordinate mipLevelCount; - GPUIntegerCoordinate baseArrayLayer = 0; - GPUIntegerCoordinate arrayLayerCount; -}; - -enum GPUTextureViewDimension { - "1d", - "2d", - "2d-array", - "cube", - "cube-array", - "3d" -}; - -enum GPUTextureAspect { - "all", - "stencil-only", - "depth-only" -}; diff --git a/components/script/dom/webidls/GPUUncapturedErrorEvent.webidl b/components/script/dom/webidls/GPUUncapturedErrorEvent.webidl deleted file mode 100644 index 565c72ef9be..00000000000 --- a/components/script/dom/webidls/GPUUncapturedErrorEvent.webidl +++ /dev/null @@ -1,22 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuuncapturederrorevent -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUUncapturedErrorEvent : Event { - constructor( - DOMString type, - GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict - ); - /*[SameObject]*/ readonly attribute GPUError error; -}; - -dictionary GPUUncapturedErrorEventInit : EventInit { - required GPUError error; -}; - -partial interface GPUDevice { - [Exposed=(Window, DedicatedWorker)] - attribute EventHandler onuncapturederror; -}; diff --git a/components/script/dom/webidls/GPUValidationError.webidl b/components/script/dom/webidls/GPUValidationError.webidl deleted file mode 100644 index e4c1249e311..00000000000 --- a/components/script/dom/webidls/GPUValidationError.webidl +++ /dev/null @@ -1,24 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// https://gpuweb.github.io/gpuweb/#gpuvalidationerror -[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] -interface GPUValidationError { - [Throws] - constructor(DOMString message); - readonly attribute DOMString message; -}; - -typedef (GPUOutOfMemoryError or GPUValidationError) GPUError; - -enum GPUErrorFilter { - "out-of-memory", - "validation" -}; - -partial interface GPUDevice { - undefined pushErrorScope(GPUErrorFilter filter); - [NewObject] - Promise<GPUError?> popErrorScope(); -}; diff --git a/components/script/dom/webidls/Navigator.webidl b/components/script/dom/webidls/Navigator.webidl index 4ebb5ad20be..bb9a0e77564 100644 --- a/components/script/dom/webidls/Navigator.webidl +++ b/components/script/dom/webidls/Navigator.webidl @@ -14,6 +14,7 @@ Navigator includes NavigatorLanguage; //Navigator includes NavigatorStorageUtils; Navigator includes NavigatorPlugins; Navigator includes NavigatorCookies; +Navigator includes NavigatorGPU; // https://html.spec.whatwg.org/multipage/#navigatorid [Exposed=(Window,Worker)] @@ -69,8 +70,3 @@ partial interface Navigator { partial interface Navigator { [Pref="dom.gamepad.enabled"] GamepadList getGamepads(); }; - -[Exposed=Window] -partial interface Navigator { - [SameObject, Pref="dom.webgpu.enabled"] readonly attribute GPU gpu; -}; diff --git a/components/script/dom/webidls/WebGPU.webidl b/components/script/dom/webidls/WebGPU.webidl new file mode 100644 index 00000000000..78cf829ef04 --- /dev/null +++ b/components/script/dom/webidls/WebGPU.webidl @@ -0,0 +1,1170 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +// Source: WebGPU (https://gpuweb.github.io/gpuweb/) +// Direct source: https://github.com/w3c/webref/blob/curated/ed/idl/webgpu.idl + +[Exposed=(Window)] +interface mixin GPUObjectBase { + attribute USVString label; +}; + +dictionary GPUObjectDescriptorBase { + USVString label; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUSupportedLimits { + readonly attribute unsigned long maxTextureDimension1D; + readonly attribute unsigned long maxTextureDimension2D; + readonly attribute unsigned long maxTextureDimension3D; + readonly attribute unsigned long maxTextureArrayLayers; + readonly attribute unsigned long maxBindGroups; + //readonly attribute unsigned long maxBindGroupsPlusVertexBuffers; + readonly attribute unsigned long maxBindingsPerBindGroup; + readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout; + readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout; + readonly attribute unsigned long maxSampledTexturesPerShaderStage; + readonly attribute unsigned long maxSamplersPerShaderStage; + readonly attribute unsigned long maxStorageBuffersPerShaderStage; + readonly attribute unsigned long maxStorageTexturesPerShaderStage; + readonly attribute unsigned long maxUniformBuffersPerShaderStage; + readonly attribute unsigned long long maxUniformBufferBindingSize; + readonly attribute unsigned long long maxStorageBufferBindingSize; + readonly attribute unsigned long minUniformBufferOffsetAlignment; + readonly attribute unsigned long minStorageBufferOffsetAlignment; + readonly attribute unsigned long maxVertexBuffers; + readonly attribute unsigned long long maxBufferSize; + readonly attribute unsigned long maxVertexAttributes; + readonly attribute unsigned long maxVertexBufferArrayStride; + readonly attribute unsigned long maxInterStageShaderComponents; + //readonly attribute unsigned long maxInterStageShaderVariables; + //readonly attribute unsigned long maxColorAttachments; + //readonly attribute unsigned long maxColorAttachmentBytesPerSample; + readonly attribute unsigned long maxComputeWorkgroupStorageSize; + readonly attribute unsigned long maxComputeInvocationsPerWorkgroup; + readonly attribute unsigned long maxComputeWorkgroupSizeX; + readonly attribute unsigned long maxComputeWorkgroupSizeY; + readonly attribute unsigned long maxComputeWorkgroupSizeZ; + readonly attribute unsigned long maxComputeWorkgroupsPerDimension; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUSupportedFeatures { + readonly setlike<DOMString>; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUAdapterInfo { + readonly attribute DOMString vendor; + readonly attribute DOMString architecture; + readonly attribute DOMString device; + readonly attribute DOMString description; +}; + +interface mixin NavigatorGPU { + [SameObject, Pref="dom.webgpu.enabled", Exposed=(Window /* ,DedicatedWorker */)] readonly attribute GPU gpu; +}; +// NOTE: see `Navigator.webidl` +// Navigator includes NavigatorGPU; +// NOTE: see `WorkerNavigator.webidl` +// WorkerNavigator includes NavigatorGPU; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPU { + [NewObject] + Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {}); + GPUTextureFormat getPreferredCanvasFormat(); +}; + +dictionary GPURequestAdapterOptions { + GPUPowerPreference powerPreference; + boolean forceFallbackAdapter = false; +}; + +enum GPUPowerPreference { + "low-power", + "high-performance" +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUAdapter { + [SameObject] readonly attribute GPUSupportedFeatures features; + [SameObject] readonly attribute GPUSupportedLimits limits; + readonly attribute boolean isFallbackAdapter; + + [NewObject] + Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {}); + [NewObject] + Promise<GPUAdapterInfo> requestAdapterInfo(optional sequence<DOMString> unmaskHints = []); +}; + +dictionary GPUDeviceDescriptor { + sequence<GPUFeatureName> requiredFeatures = []; + record<DOMString, GPUSize64> requiredLimits; +}; + +enum GPUFeatureName { + "depth-clip-control", + "depth24unorm-stencil8", + "depth32float-stencil8", + "pipeline-statistics-query", + "texture-compression-bc", + "texture-compression-etc2", + "texture-compression-astc", + "timestamp-query", + "indirect-first-instance", +}; + +[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom.webgpu.enabled"] +interface GPUDevice: EventTarget { + [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; + + undefined destroy(); + + [NewObject, Throws] + GPUBuffer createBuffer(GPUBufferDescriptor descriptor); + [NewObject] + GPUTexture createTexture(GPUTextureDescriptor descriptor); + [NewObject] + GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {}); + + GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); + GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor); + GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor); + + GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor); + GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); + GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor); + + [NewObject] + Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor); + [NewObject] + Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor); + + [NewObject] + GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); + [NewObject] + GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); + //[NewObject] + //GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor); +}; +GPUDevice includes GPUObjectBase; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUBuffer { + [NewObject] + Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size); + [NewObject, Throws] + ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size); + [Throws] + undefined unmap(); + [Throws] + undefined destroy(); +}; +GPUBuffer includes GPUObjectBase; + +dictionary GPUBufferDescriptor : GPUObjectDescriptorBase { + required GPUSize64 size; + required GPUBufferUsageFlags usage; + boolean mappedAtCreation = false; +}; + +typedef [EnforceRange] unsigned long GPUBufferUsageFlags; +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUBufferUsage { + const GPUBufferUsageFlags MAP_READ = 0x0001; + const GPUBufferUsageFlags MAP_WRITE = 0x0002; + const GPUBufferUsageFlags COPY_SRC = 0x0004; + const GPUBufferUsageFlags COPY_DST = 0x0008; + const GPUBufferUsageFlags INDEX = 0x0010; + const GPUBufferUsageFlags VERTEX = 0x0020; + const GPUBufferUsageFlags UNIFORM = 0x0040; + const GPUBufferUsageFlags STORAGE = 0x0080; + const GPUBufferUsageFlags INDIRECT = 0x0100; + const GPUBufferUsageFlags QUERY_RESOLVE = 0x0200; +}; + +typedef [EnforceRange] unsigned long GPUMapModeFlags; +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUMapMode { + const GPUMapModeFlags READ = 0x0001; + const GPUMapModeFlags WRITE = 0x0002; +}; + +[Exposed=(Window, DedicatedWorker), Serializable , Pref="dom.webgpu.enabled"] +interface GPUTexture { + [NewObject] + GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {}); + + undefined destroy(); +}; +GPUTexture includes GPUObjectBase; + +dictionary GPUTextureDescriptor : GPUObjectDescriptorBase { + required GPUExtent3D size; + GPUIntegerCoordinate mipLevelCount = 1; + GPUSize32 sampleCount = 1; + GPUTextureDimension dimension = "2d"; + required GPUTextureFormat format; + required GPUTextureUsageFlags usage; + sequence<GPUTextureFormat> viewFormats = []; +}; + +enum GPUTextureDimension { + "1d", + "2d", + "3d", +}; + +typedef [EnforceRange] unsigned long GPUTextureUsageFlags; +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUTextureUsage { + const GPUTextureUsageFlags COPY_SRC = 0x01; + const GPUTextureUsageFlags COPY_DST = 0x02; + const GPUTextureUsageFlags TEXTURE_BINDING = 0x04; + const GPUTextureUsageFlags STORAGE_BINDING = 0x08; + const GPUTextureUsageFlags RENDER_ATTACHMENT = 0x10; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUTextureView { +}; +GPUTextureView includes GPUObjectBase; + +dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase { + GPUTextureFormat format; + GPUTextureViewDimension dimension; + GPUTextureAspect aspect = "all"; + GPUIntegerCoordinate baseMipLevel = 0; + GPUIntegerCoordinate mipLevelCount; + GPUIntegerCoordinate baseArrayLayer = 0; + GPUIntegerCoordinate arrayLayerCount; +}; + +enum GPUTextureViewDimension { + "1d", + "2d", + "2d-array", + "cube", + "cube-array", + "3d" +}; + +enum GPUTextureAspect { + "all", + "stencil-only", + "depth-only" +}; + +enum GPUTextureFormat { + // 8-bit formats + "r8unorm", + "r8snorm", + "r8uint", + "r8sint", + + // 16-bit formats + "r16uint", + "r16sint", + "r16float", + "rg8unorm", + "rg8snorm", + "rg8uint", + "rg8sint", + + // 32-bit formats + "r32uint", + "r32sint", + "r32float", + "rg16uint", + "rg16sint", + "rg16float", + "rgba8unorm", + "rgba8unorm-srgb", + "rgba8snorm", + "rgba8uint", + "rgba8sint", + "bgra8unorm", + "bgra8unorm-srgb", + // Packed 32-bit formats + "rgb10a2unorm", + "rg11b10float", + + // 64-bit formats + "rg32uint", + "rg32sint", + "rg32float", + "rgba16uint", + "rgba16sint", + "rgba16float", + + // 128-bit formats + "rgba32uint", + "rgba32sint", + "rgba32float", + + // Depth and stencil formats + //"stencil8", //TODO + //"depth16unorm", + "depth24plus", + "depth24plus-stencil8", + "depth32float", + + // BC compressed formats usable if "texture-compression-bc" is both + // supported by the device/user agent and enabled in requestDevice. + "bc1-rgba-unorm", + "bc1-rgba-unorm-srgb", + "bc2-rgba-unorm", + "bc2-rgba-unorm-srgb", + "bc3-rgba-unorm", + "bc3-rgba-unorm-srgb", + "bc4-r-unorm", + "bc4-r-snorm", + "bc5-rg-unorm", + "bc5-rg-snorm", + "bc6h-rgb-ufloat", + "bc6h-rgb-float", + "bc7-rgba-unorm", + "bc7-rgba-unorm-srgb", + + // "depth24unorm-stencil8" feature + //"depth24unorm-stencil8", + + // "depth32float-stencil8" feature + //"depth32float-stencil8", +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUSampler { +}; +GPUSampler includes GPUObjectBase; + +dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase { + GPUAddressMode addressModeU = "clamp-to-edge"; + GPUAddressMode addressModeV = "clamp-to-edge"; + GPUAddressMode addressModeW = "clamp-to-edge"; + GPUFilterMode magFilter = "nearest"; + GPUFilterMode minFilter = "nearest"; + GPUFilterMode mipmapFilter = "nearest"; + float lodMinClamp = 0; + float lodMaxClamp = 1000.0; // TODO: What should this be? + GPUCompareFunction compare; + [Clamp] unsigned short maxAnisotropy = 1; +}; + +enum GPUAddressMode { + "clamp-to-edge", + "repeat", + "mirror-repeat" +}; + +enum GPUFilterMode { + "nearest", + "linear", +}; + +enum GPUCompareFunction { + "never", + "less", + "equal", + "less-equal", + "greater", + "not-equal", + "greater-equal", + "always" +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUBindGroupLayout { +}; +GPUBindGroupLayout includes GPUObjectBase; + +dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase { + required sequence<GPUBindGroupLayoutEntry> entries; +}; + +dictionary GPUBindGroupLayoutEntry { + required GPUIndex32 binding; + required GPUShaderStageFlags visibility; + GPUBufferBindingLayout buffer; + GPUSamplerBindingLayout sampler; + GPUTextureBindingLayout texture; + GPUStorageTextureBindingLayout storageTexture; +}; + +typedef [EnforceRange] unsigned long GPUShaderStageFlags; +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUShaderStage { + const GPUShaderStageFlags VERTEX = 1; + const GPUShaderStageFlags FRAGMENT = 2; + const GPUShaderStageFlags COMPUTE = 4; +}; + +enum GPUBufferBindingType { + "uniform", + "storage", + "read-only-storage", +}; + +dictionary GPUBufferBindingLayout { + GPUBufferBindingType type = "uniform"; + boolean hasDynamicOffset = false; + GPUSize64 minBindingSize = 0; +}; + +enum GPUSamplerBindingType { + "filtering", + "non-filtering", + "comparison", +}; + +dictionary GPUSamplerBindingLayout { + GPUSamplerBindingType type = "filtering"; +}; + +enum GPUTextureSampleType { + "float", + "unfilterable-float", + "depth", + "sint", + "uint", +}; + +dictionary GPUTextureBindingLayout { + GPUTextureSampleType sampleType = "float"; + GPUTextureViewDimension viewDimension = "2d"; + boolean multisampled = false; +}; + +enum GPUStorageTextureAccess { + "write-only", +}; + +dictionary GPUStorageTextureBindingLayout { + GPUStorageTextureAccess access = "write-only"; + required GPUTextureFormat format; + GPUTextureViewDimension viewDimension = "2d"; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUBindGroup { +}; +GPUBindGroup includes GPUObjectBase; + +dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase { + required GPUBindGroupLayout layout; + required sequence<GPUBindGroupEntry> entries; +}; + +typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource; + +dictionary GPUBindGroupEntry { + required GPUIndex32 binding; + required GPUBindingResource resource; +}; + +dictionary GPUBufferBinding { + required GPUBuffer buffer; + GPUSize64 offset = 0; + GPUSize64 size; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUPipelineLayout { +}; +GPUPipelineLayout includes GPUObjectBase; + +dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase { + required sequence<GPUBindGroupLayout> bindGroupLayouts; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUShaderModule { + [Throws] + Promise<GPUCompilationInfo> compilationInfo(); +}; +GPUShaderModule includes GPUObjectBase; + +dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase { + // UTF8String is not observably different from USVString + required USVString code; + object sourceMap; +}; + +enum GPUCompilationMessageType { + "error", + "warning", + "info" +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUCompilationMessage { + readonly attribute DOMString message; + readonly attribute GPUCompilationMessageType type; + readonly attribute unsigned long long lineNum; + readonly attribute unsigned long long linePos; + readonly attribute unsigned long long offset; + readonly attribute unsigned long long length; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUCompilationInfo { + // codegen hates it + //[Cached, Frozen, Pure] + readonly attribute /*sequence<GPUCompilationMessage>*/ any messages; +}; + +enum GPUAutoLayoutMode { + "auto" +}; + +dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase { + required (GPUPipelineLayout or GPUAutoLayoutMode) layout; +}; + +interface mixin GPUPipelineBase { + [Throws] GPUBindGroupLayout getBindGroupLayout(unsigned long index); +}; + +dictionary GPUProgrammableStage { + required GPUShaderModule module; + required USVString entryPoint; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUComputePipeline { +}; +GPUComputePipeline includes GPUObjectBase; +GPUComputePipeline includes GPUPipelineBase; + +dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase { + required GPUProgrammableStage compute; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPURenderPipeline { +}; +GPURenderPipeline includes GPUObjectBase; +GPURenderPipeline includes GPUPipelineBase; + +dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase { + required GPUVertexState vertex; + GPUPrimitiveState primitive = {}; + GPUDepthStencilState depthStencil; + GPUMultisampleState multisample = {}; + GPUFragmentState fragment; +}; + +dictionary GPUPrimitiveState { + GPUPrimitiveTopology topology = "triangle-list"; + GPUIndexFormat stripIndexFormat; + GPUFrontFace frontFace = "ccw"; + GPUCullMode cullMode = "none"; + // Enable depth clamping (requires "depth-clamping" feature) + boolean clampDepth = false; +}; + +enum GPUPrimitiveTopology { + "point-list", + "line-list", + "line-strip", + "triangle-list", + "triangle-strip" +}; + +enum GPUFrontFace { + "ccw", + "cw" +}; + +enum GPUCullMode { + "none", + "front", + "back" +}; + +dictionary GPUMultisampleState { + GPUSize32 count = 1; + GPUSampleMask mask = 0xFFFFFFFF; + boolean alphaToCoverageEnabled = false; +}; + +dictionary GPUFragmentState: GPUProgrammableStage { + required sequence<GPUColorTargetState> targets; +}; + +dictionary GPUColorTargetState { + required GPUTextureFormat format; + GPUBlendState blend; + GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL +}; + +dictionary GPUBlendState { + required GPUBlendComponent color; + required GPUBlendComponent alpha; +}; + +typedef [EnforceRange] unsigned long GPUColorWriteFlags; +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUColorWrite { + const GPUColorWriteFlags RED = 0x1; + const GPUColorWriteFlags GREEN = 0x2; + const GPUColorWriteFlags BLUE = 0x4; + const GPUColorWriteFlags ALPHA = 0x8; + const GPUColorWriteFlags ALL = 0xF; +}; + +dictionary GPUBlendComponent { + GPUBlendFactor srcFactor = "one"; + GPUBlendFactor dstFactor = "zero"; + GPUBlendOperation operation = "add"; +}; + +enum GPUBlendFactor { + "zero", + "one", + "src", + "one-minus-src", + "src-alpha", + "one-minus-src-alpha", + "dst", + "one-minus-dst", + "dst-alpha", + "one-minus-dst-alpha", + "src-alpha-saturated", + "constant", + "one-minus-constant", +}; + +enum GPUBlendOperation { + "add", + "subtract", + "reverse-subtract", + "min", + "max" +}; + +dictionary GPUDepthStencilState { + required GPUTextureFormat format; + + boolean depthWriteEnabled = false; + GPUCompareFunction depthCompare = "always"; + + GPUStencilFaceState stencilFront = {}; + GPUStencilFaceState stencilBack = {}; + + GPUStencilValue stencilReadMask = 0xFFFFFFFF; + GPUStencilValue stencilWriteMask = 0xFFFFFFFF; + + GPUDepthBias depthBias = 0; + float depthBiasSlopeScale = 0; + float depthBiasClamp = 0; +}; + +dictionary GPUStencilFaceState { + GPUCompareFunction compare = "always"; + GPUStencilOperation failOp = "keep"; + GPUStencilOperation depthFailOp = "keep"; + GPUStencilOperation passOp = "keep"; +}; + +enum GPUStencilOperation { + "keep", + "zero", + "replace", + "invert", + "increment-clamp", + "decrement-clamp", + "increment-wrap", + "decrement-wrap" +}; + +enum GPUIndexFormat { + "uint16", + "uint32", +}; + +enum GPUVertexFormat { + "uint8x2", + "uint8x4", + "sint8x2", + "sint8x4", + "unorm8x2", + "unorm8x4", + "snorm8x2", + "snorm8x4", + "uint16x2", + "uint16x4", + "sint16x2", + "sint16x4", + "unorm16x2", + "unorm16x4", + "snorm16x2", + "snorm16x4", + "float16x2", + "float16x4", + "float32", + "float32x2", + "float32x3", + "float32x4", + "uint32", + "uint32x2", + "uint32x3", + "uint32x4", + "sint32", + "sint32x2", + "sint32x3", + "sint32x4", +}; + +enum GPUVertexStepMode { + "vertex", + "instance", +}; + +dictionary GPUVertexState: GPUProgrammableStage { + sequence<GPUVertexBufferLayout?> buffers = []; +}; + +dictionary GPUVertexBufferLayout { + required GPUSize64 arrayStride; + GPUVertexStepMode stepMode = "vertex"; + required sequence<GPUVertexAttribute> attributes; +}; + +dictionary GPUVertexAttribute { + required GPUVertexFormat format; + required GPUSize64 offset; + required GPUIndex32 shaderLocation; +}; + +dictionary GPUImageDataLayout { + GPUSize64 offset = 0; + GPUSize32 bytesPerRow; + GPUSize32 rowsPerImage; +}; + +dictionary GPUImageCopyBuffer : GPUImageDataLayout { + required GPUBuffer buffer; +}; + +dictionary GPUImageCopyTexture { + required GPUTexture texture; + GPUIntegerCoordinate mipLevel = 0; + GPUOrigin3D origin; + GPUTextureAspect aspect = "all"; +}; + +dictionary GPUImageCopyTextureTagged : GPUImageCopyTexture { + //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO + boolean premultipliedAlpha = false; +}; + +dictionary GPUImageCopyExternalImage { + required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source; + GPUOrigin2D origin = {}; + boolean flipY = false; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUCommandBuffer { +}; +GPUCommandBuffer includes GPUObjectBase; + +dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase { +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUCommandEncoder { + [NewObject] + GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); + [NewObject] + GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); + + undefined copyBufferToBuffer( + GPUBuffer source, + GPUSize64 sourceOffset, + GPUBuffer destination, + GPUSize64 destinationOffset, + GPUSize64 size); + + undefined copyBufferToTexture( + GPUImageCopyBuffer source, + GPUImageCopyTexture destination, + GPUExtent3D copySize); + + undefined copyTextureToBuffer( + GPUImageCopyTexture source, + GPUImageCopyBuffer destination, + GPUExtent3D copySize); + + undefined copyTextureToTexture( + GPUImageCopyTexture source, + GPUImageCopyTexture destination, + GPUExtent3D copySize); + + /* + undefined copyImageBitmapToTexture( + GPUImageBitmapCopyView source, + GPUImageCopyTexture destination, + GPUExtent3D copySize); + */ + + //undefined pushDebugGroup(USVString groupLabel); + //undefined popDebugGroup(); + //undefined insertDebugMarker(USVString markerLabel); + + [NewObject] + GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {}); +}; +GPUCommandEncoder includes GPUObjectBase; + +dictionary GPUImageBitmapCopyView { + //required ImageBitmap imageBitmap; //TODO + GPUOrigin2D origin; +}; + +//TODO +dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase { + boolean measureExecutionTime = false; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUComputePassEncoder { + undefined setPipeline(GPUComputePipeline pipeline); + undefined dispatchWorkgroups(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1); + //[Pref="dom.webgpu.indirect-dispatch.enabled"] + undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); + + [Throws] + undefined end(); +}; +GPUComputePassEncoder includes GPUObjectBase; +GPUComputePassEncoder includes GPUProgrammablePassEncoder; + +dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase { +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPURenderPassEncoder { + undefined setViewport(float x, float y, + float width, float height, + float minDepth, float maxDepth); + + undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y, + GPUIntegerCoordinate width, GPUIntegerCoordinate height); + + undefined setBlendConstant(GPUColor color); + undefined setStencilReference(GPUStencilValue reference); + + //undefined beginOcclusionQuery(GPUSize32 queryIndex); + //undefined endOcclusionQuery(); + + //undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex); + //undefined endPipelineStatisticsQuery(); + + //undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex); + + undefined executeBundles(sequence<GPURenderBundle> bundles); + + [Throws] + undefined end(); +}; +GPURenderPassEncoder includes GPUObjectBase; +GPURenderPassEncoder includes GPUProgrammablePassEncoder; +GPURenderPassEncoder includes GPURenderEncoderBase; + +[Exposed=(Window, DedicatedWorker)] +interface mixin GPUProgrammablePassEncoder { + undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup, + optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []); + + //undefined pushDebugGroup(USVString groupLabel); + //undefined popDebugGroup(); + //undefined insertDebugMarker(USVString markerLabel); +}; + +dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase { + required sequence<GPURenderPassColorAttachment> colorAttachments; + GPURenderPassDepthStencilAttachment depthStencilAttachment; + GPUQuerySet occlusionQuerySet; +}; + +dictionary GPURenderPassColorAttachment { + required GPUTextureView view; + GPUTextureView resolveTarget; + + GPUColor clearValue; + required GPULoadOp loadOp; + required GPUStoreOp storeOp; +}; + +dictionary GPURenderPassDepthStencilAttachment { + required GPUTextureView view; + + float depthClearValue; + GPULoadOp depthLoadOp; + GPUStoreOp depthStoreOp; + boolean depthReadOnly = false; + + GPUStencilValue stencilClearValue = 0; + GPULoadOp stencilLoadOp; + GPUStoreOp stencilStoreOp; + boolean stencilReadOnly = false; +}; + +enum GPULoadOp { + "load", + "clear" +}; + +enum GPUStoreOp { + "store", + "discard" +}; + +dictionary GPURenderPassLayout: GPUObjectDescriptorBase { + // TODO: We don't support nullable enumerated arguments yet + required sequence<GPUTextureFormat> colorFormats; + GPUTextureFormat depthStencilFormat; + GPUSize32 sampleCount = 1; +}; + +// https://gpuweb.github.io/gpuweb/#gpurendercommandsmixin +[Exposed=(Window, DedicatedWorker)] +interface mixin GPURenderEncoderBase { + undefined setPipeline(GPURenderPipeline pipeline); + + undefined setIndexBuffer(GPUBuffer buffer, + GPUIndexFormat indexFormat, + optional GPUSize64 offset = 0, + optional GPUSize64 size = 0); + undefined setVertexBuffer(GPUIndex32 slot, + GPUBuffer buffer, + optional GPUSize64 offset = 0, + optional GPUSize64 size = 0); + + undefined draw(GPUSize32 vertexCount, + optional GPUSize32 instanceCount = 1, + optional GPUSize32 firstVertex = 0, + optional GPUSize32 firstInstance = 0); + undefined drawIndexed(GPUSize32 indexCount, + optional GPUSize32 instanceCount = 1, + optional GPUSize32 firstIndex = 0, + optional GPUSignedOffset32 baseVertex = 0, + optional GPUSize32 firstInstance = 0); + + //[Pref="dom.webgpu.indirect-dispatch.enabled"] + undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); + //[Pref="dom.webgpu.indirect-dispatch.enabled"] + undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset); +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPURenderBundle { +}; +GPURenderBundle includes GPUObjectBase; + +dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase { +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPURenderBundleEncoder { + GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {}); +}; +GPURenderBundleEncoder includes GPUObjectBase; +GPURenderBundleEncoder includes GPUProgrammablePassEncoder; +GPURenderBundleEncoder includes GPURenderEncoderBase; + +dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout { + boolean depthReadOnly = false; + boolean stencilReadOnly = false; +}; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUQueue { + undefined submit(sequence<GPUCommandBuffer> buffers); + + //TODO: + //Promise<undefined> onSubmittedWorkDone(); + + [Throws] + undefined writeBuffer( + GPUBuffer buffer, + GPUSize64 bufferOffset, + BufferSource data, + optional GPUSize64 dataOffset = 0, + optional GPUSize64 size); + + [Throws] + undefined writeTexture( + GPUImageCopyTexture destination, + BufferSource data, + GPUImageDataLayout dataLayout, + GPUExtent3D size); + + //[Throws] + //undefined copyExternalImageToTexture( + // GPUImageCopyExternalImage source, + // GPUImageCopyTextureTagged destination, + // GPUExtent3D copySize); +}; +GPUQueue includes GPUObjectBase; + +[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"] +interface GPUQuerySet { + undefined destroy(); +}; +GPUQuerySet includes GPUObjectBase; + +dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase { + required GPUQueryType type; + required GPUSize32 count; + sequence<GPUPipelineStatisticName> pipelineStatistics = []; +}; + +enum GPUPipelineStatisticName { + "vertex-shader-invocations", + "clipper-invocations", + "clipper-primitives-out", + "fragment-shader-invocations", + "compute-shader-invocations" +}; + +enum GPUQueryType { + "occlusion", + "pipeline-statistics", + "timestamp" +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUCanvasContext { + readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; + + // Calling configure() a second time invalidates the previous one, + // and all of the textures it's produced. + undefined configure(GPUCanvasConfiguration descriptor); + undefined unconfigure(); + + [Throws] + GPUTexture getCurrentTexture(); +}; + +enum GPUCanvasAlphaMode { + "opaque", + "premultiplied", +}; + +dictionary GPUCanvasConfiguration { + required GPUDevice device; + required GPUTextureFormat format; + GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT + sequence<GPUTextureFormat> viewFormats = []; + // PredefinedColorSpace colorSpace = "srgb"; // TODO + GPUCanvasAlphaMode alphaMode = "opaque"; +}; + +enum GPUDeviceLostReason { + "unknown", + "destroyed", +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUDeviceLostInfo { + readonly attribute GPUDeviceLostReason reason; + readonly attribute DOMString message; +}; + +partial interface GPUDevice { + [Throws] + readonly attribute Promise<GPUDeviceLostInfo> lost; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUValidationError { + [Throws] + constructor(DOMString message); + readonly attribute DOMString message; +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUOutOfMemoryError { + constructor(); +}; + +typedef (GPUOutOfMemoryError or GPUValidationError) GPUError; + +enum GPUErrorFilter { + "out-of-memory", + "validation" +}; + +partial interface GPUDevice { + undefined pushErrorScope(GPUErrorFilter filter); + [NewObject] + Promise<GPUError?> popErrorScope(); +}; + +[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"] +interface GPUUncapturedErrorEvent : Event { + constructor( + DOMString type, + GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict + ); + /*[SameObject]*/ readonly attribute GPUError error; +}; + +dictionary GPUUncapturedErrorEventInit : EventInit { + required GPUError error; +}; + +partial interface GPUDevice { + [Exposed=(Window, DedicatedWorker)] + attribute EventHandler onuncapturederror; +}; + +typedef [EnforceRange] unsigned long GPUBufferDynamicOffset; +typedef [EnforceRange] unsigned long GPUStencilValue; +typedef [EnforceRange] unsigned long GPUSampleMask; +typedef [EnforceRange] long GPUDepthBias; + +typedef [EnforceRange] unsigned long long GPUSize64; +typedef [EnforceRange] unsigned long GPUIntegerCoordinate; +typedef [EnforceRange] unsigned long GPUIndex32; +typedef [EnforceRange] unsigned long GPUSize32; +typedef [EnforceRange] long GPUSignedOffset32; + +dictionary GPUColorDict { + required double r; + required double g; + required double b; + required double a; +}; +typedef (sequence<double> or GPUColorDict) GPUColor; + +dictionary GPUOrigin2DDict { + GPUIntegerCoordinate x = 0; + GPUIntegerCoordinate y = 0; +}; +typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D; + +dictionary GPUOrigin3DDict { + GPUIntegerCoordinate x = 0; + GPUIntegerCoordinate y = 0; + GPUIntegerCoordinate z = 0; +}; +typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D; + +dictionary GPUExtent3DDict { + required GPUIntegerCoordinate width; + GPUIntegerCoordinate height = 1; + GPUIntegerCoordinate depthOrArrayLayers = 1; +}; + +typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D; |