tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WebGPU.webidl (40119B)


      1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/.
      5 *
      6 * The origin of this IDL file is
      7 * https://gpuweb.github.io/gpuweb/
      8 */
      9 
     10 interface mixin GPUObjectBase {
     11    attribute USVString label;
     12 };
     13 
     14 dictionary GPUObjectDescriptorBase {
     15    USVString label = "";
     16 };
     17 
     18 [Func="mozilla::webgpu::Instance::PrefEnabled",
     19 Exposed=(Window, Worker), SecureContext]
     20 interface GPUSupportedLimits {
     21    readonly attribute unsigned long maxTextureDimension1D;
     22    readonly attribute unsigned long maxTextureDimension2D;
     23    readonly attribute unsigned long maxTextureDimension3D;
     24    readonly attribute unsigned long maxTextureArrayLayers;
     25    readonly attribute unsigned long maxBindGroups;
     26    readonly attribute unsigned long maxBindGroupsPlusVertexBuffers;
     27    readonly attribute unsigned long maxBindingsPerBindGroup;
     28    readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout;
     29    readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
     30    readonly attribute unsigned long maxSampledTexturesPerShaderStage;
     31    readonly attribute unsigned long maxSamplersPerShaderStage;
     32    readonly attribute unsigned long maxStorageBuffersPerShaderStage;
     33    readonly attribute unsigned long maxStorageTexturesPerShaderStage;
     34    readonly attribute unsigned long maxUniformBuffersPerShaderStage;
     35    readonly attribute unsigned long long maxUniformBufferBindingSize;
     36    readonly attribute unsigned long long maxStorageBufferBindingSize;
     37    readonly attribute unsigned long minUniformBufferOffsetAlignment;
     38    readonly attribute unsigned long minStorageBufferOffsetAlignment;
     39    readonly attribute unsigned long maxVertexBuffers;
     40    readonly attribute unsigned long long maxBufferSize;
     41    readonly attribute unsigned long maxVertexAttributes;
     42    readonly attribute unsigned long maxVertexBufferArrayStride;
     43    readonly attribute unsigned long maxInterStageShaderVariables;
     44    readonly attribute unsigned long maxColorAttachments;
     45    readonly attribute unsigned long maxColorAttachmentBytesPerSample;
     46    readonly attribute unsigned long maxComputeWorkgroupStorageSize;
     47    readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
     48    readonly attribute unsigned long maxComputeWorkgroupSizeX;
     49    readonly attribute unsigned long maxComputeWorkgroupSizeY;
     50    readonly attribute unsigned long maxComputeWorkgroupSizeZ;
     51    readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
     52 };
     53 
     54 [Func="mozilla::webgpu::Instance::PrefEnabled",
     55 Exposed=(Window, Worker), SecureContext]
     56 interface GPUSupportedFeatures {
     57    readonly setlike<DOMString>;
     58 };
     59 
     60 [Func="mozilla::webgpu::Instance::PrefEnabled",
     61 Exposed=(Window, Worker), SecureContext]
     62 interface WGSLLanguageFeatures {
     63    readonly setlike<DOMString>;
     64 };
     65 
     66 [Func="mozilla::webgpu::Instance::PrefEnabled",
     67 Exposed=(Window, Worker), SecureContext]
     68 interface GPUAdapterInfo {
     69    readonly attribute DOMString vendor;
     70    readonly attribute DOMString architecture;
     71    readonly attribute DOMString device;
     72    readonly attribute DOMString description;
     73    readonly attribute unsigned long subgroupMinSize;
     74    readonly attribute unsigned long subgroupMaxSize;
     75    readonly attribute boolean isFallbackAdapter;
     76 
     77    // Non-standard; see <https://bugzilla.mozilla.org/show_bug.cgi?id=1831994>.
     78    [ChromeOnly] readonly attribute DOMString wgpuName;
     79    [ChromeOnly] readonly attribute unsigned long wgpuVendor;
     80    [ChromeOnly] readonly attribute unsigned long wgpuDevice;
     81    [ChromeOnly] readonly attribute DOMString wgpuDeviceType;
     82    [ChromeOnly] readonly attribute DOMString wgpuDriver;
     83    [ChromeOnly] readonly attribute DOMString wgpuDriverInfo;
     84    [ChromeOnly] readonly attribute DOMString wgpuBackend;
     85 };
     86 
     87 interface mixin NavigatorGPU {
     88    [SameObject, Func="mozilla::webgpu::Instance::PrefEnabled", SecureContext] readonly attribute GPU gpu;
     89 };
     90 // NOTE: see `dom/webidl/Navigator.webidl`
     91 // Navigator includes NavigatorGPU;
     92 // NOTE: see `dom/webidl/WorkerNavigator.webidl`
     93 // WorkerNavigator includes NavigatorGPU;
     94 
     95 [
     96    Func="mozilla::webgpu::Instance::PrefEnabled",
     97    Exposed=(Window, Worker), SecureContext
     98 ]
     99 interface GPU {
    100    [Throws]
    101    Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
    102    GPUTextureFormat getPreferredCanvasFormat();
    103    [SameObject] readonly attribute WGSLLanguageFeatures wgslLanguageFeatures;
    104 };
    105 
    106 dictionary GPURequestAdapterOptions {
    107    DOMString featureLevel = "core";
    108    GPUPowerPreference powerPreference;
    109    boolean forceFallbackAdapter = false;
    110    boolean xrCompatible = false;
    111 };
    112 
    113 enum GPUPowerPreference {
    114    "low-power",
    115    "high-performance",
    116 };
    117 
    118 [Func="mozilla::webgpu::Instance::PrefEnabled",
    119 Exposed=(Window, Worker), SecureContext]
    120 interface GPUAdapter {
    121    [SameObject] readonly attribute GPUSupportedFeatures features;
    122    [SameObject] readonly attribute GPUSupportedLimits limits;
    123    [SameObject] readonly attribute GPUAdapterInfo info;
    124 
    125    [Throws]
    126    Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
    127 
    128    [Func="nsRFPService::IsSystemPrincipalOrAboutFingerprintingProtection"]
    129    readonly attribute unsigned long long missingFeatures;
    130 };
    131 
    132 dictionary GPUDeviceDescriptor
    133         : GPUObjectDescriptorBase {
    134    sequence<GPUFeatureName> requiredFeatures = [];
    135    record<DOMString, GPUSize64> requiredLimits;
    136    GPUQueueDescriptor defaultQueue = {};
    137 };
    138 
    139 enum GPUFeatureName {
    140    "core-features-and-limits",
    141    "depth-clip-control",
    142    "depth32float-stencil8",
    143    "texture-compression-bc",
    144    "texture-compression-bc-sliced-3d",
    145    "texture-compression-etc2",
    146    "texture-compression-astc",
    147    "texture-compression-astc-sliced-3d",
    148    "timestamp-query",
    149    "indirect-first-instance",
    150    "shader-f16",
    151    "rg11b10ufloat-renderable",
    152    "bgra8unorm-storage",
    153    "float32-filterable",
    154    "float32-blendable",
    155    "clip-distances",
    156    "dual-source-blending",
    157    "subgroups",
    158    "primitive-index",
    159 };
    160 
    161 [Func="mozilla::webgpu::Instance::PrefEnabled",
    162 Exposed=(Window, Worker), SecureContext]
    163 interface GPUDevice : EventTarget {
    164    [SameObject] readonly attribute GPUSupportedFeatures features;
    165    [SameObject] readonly attribute GPUSupportedLimits limits;
    166    [SameObject, BinaryName="GetAdapterInfo"] readonly attribute GPUAdapterInfo adapterInfo;
    167 
    168    [SameObject, BinaryName="getQueue"] readonly attribute GPUQueue queue;
    169 
    170    undefined destroy();
    171 
    172    [Throws]
    173    GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
    174    GPUTexture createTexture(GPUTextureDescriptor descriptor);
    175    [Throws, Func="mozilla::webgpu::Instance::ExternalTexturePrefEnabled"]
    176    GPUExternalTexture importExternalTexture(GPUExternalTextureDescriptor descriptor);
    177    GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
    178 
    179    GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
    180    GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor);
    181    GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor);
    182 
    183    [Throws]
    184    GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
    185    GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
    186    GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
    187    [Throws]
    188    Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor);
    189    [Throws]
    190    Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor);
    191 
    192    GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
    193    GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
    194 
    195    [Throws]
    196    GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
    197 };
    198 GPUDevice includes GPUObjectBase;
    199 
    200 [Func="mozilla::webgpu::Instance::PrefEnabled",
    201 Exposed=(Window, Worker), SecureContext]
    202 interface GPUBuffer {
    203    readonly attribute GPUSize64Out size;
    204    readonly attribute GPUFlagsConstant usage;
    205 
    206    readonly attribute GPUBufferMapState mapState;
    207 
    208    [Throws]
    209    Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
    210    [Throws]
    211    ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
    212    [Throws]
    213    undefined unmap();
    214 
    215    [Throws]
    216    undefined destroy();
    217 };
    218 GPUBuffer includes GPUObjectBase;
    219 
    220 enum GPUBufferMapState {
    221    "unmapped",
    222    "pending",
    223    "mapped",
    224 };
    225 
    226 dictionary GPUBufferDescriptor
    227         : GPUObjectDescriptorBase {
    228    required GPUSize64 size;
    229    required GPUBufferUsageFlags usage;
    230    boolean mappedAtCreation = false;
    231 };
    232 
    233 typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
    234 [Func="mozilla::webgpu::Instance::PrefEnabled",
    235 Exposed=(Window, Worker), SecureContext]
    236 namespace GPUBufferUsage {
    237    const GPUFlagsConstant MAP_READ      = 0x0001;
    238    const GPUFlagsConstant MAP_WRITE     = 0x0002;
    239    const GPUFlagsConstant COPY_SRC      = 0x0004;
    240    const GPUFlagsConstant COPY_DST      = 0x0008;
    241    const GPUFlagsConstant INDEX         = 0x0010;
    242    const GPUFlagsConstant VERTEX        = 0x0020;
    243    const GPUFlagsConstant UNIFORM       = 0x0040;
    244    const GPUFlagsConstant STORAGE       = 0x0080;
    245    const GPUFlagsConstant INDIRECT      = 0x0100;
    246    const GPUFlagsConstant QUERY_RESOLVE = 0x0200;
    247 };
    248 
    249 typedef [EnforceRange] unsigned long GPUMapModeFlags;
    250 [Func="mozilla::webgpu::Instance::PrefEnabled",
    251 Exposed=(Window, Worker), SecureContext]
    252 namespace GPUMapMode {
    253    const GPUFlagsConstant READ  = 0x0001;
    254    const GPUFlagsConstant WRITE = 0x0002;
    255 };
    256 
    257 [Func="mozilla::webgpu::Instance::PrefEnabled",
    258 Exposed=(Window, Worker), SecureContext]
    259 interface GPUTexture {
    260    GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
    261 
    262    undefined destroy();
    263 
    264    readonly attribute GPUIntegerCoordinateOut width;
    265    readonly attribute GPUIntegerCoordinateOut height;
    266    readonly attribute GPUIntegerCoordinateOut depthOrArrayLayers;
    267    readonly attribute GPUIntegerCoordinateOut mipLevelCount;
    268    readonly attribute GPUSize32Out sampleCount;
    269    readonly attribute GPUTextureDimension dimension;
    270    readonly attribute GPUTextureFormat format;
    271    readonly attribute GPUFlagsConstant usage;
    272 };
    273 GPUTexture includes GPUObjectBase;
    274 
    275 dictionary GPUTextureDescriptor
    276         : GPUObjectDescriptorBase {
    277    required GPUExtent3D size;
    278    GPUIntegerCoordinate mipLevelCount = 1;
    279    GPUSize32 sampleCount = 1;
    280    GPUTextureDimension dimension = "2d";
    281    required GPUTextureFormat format;
    282    required GPUTextureUsageFlags usage;
    283    sequence<GPUTextureFormat> viewFormats = [];
    284 };
    285 
    286 enum GPUTextureDimension {
    287    "1d",
    288    "2d",
    289    "3d",
    290 };
    291 
    292 typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
    293 [Func="mozilla::webgpu::Instance::PrefEnabled",
    294 Exposed=(Window, Worker), SecureContext]
    295 namespace GPUTextureUsage {
    296    const GPUFlagsConstant COPY_SRC          = 0x01;
    297    const GPUFlagsConstant COPY_DST          = 0x02;
    298    const GPUFlagsConstant TEXTURE_BINDING   = 0x04;
    299    const GPUFlagsConstant STORAGE_BINDING   = 0x08;
    300    const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
    301 };
    302 
    303 [Func="mozilla::webgpu::Instance::PrefEnabled",
    304 Exposed=(Window, Worker), SecureContext]
    305 interface GPUTextureView {
    306 };
    307 GPUTextureView includes GPUObjectBase;
    308 
    309 dictionary GPUTextureViewDescriptor
    310         : GPUObjectDescriptorBase {
    311    GPUTextureFormat format;
    312    GPUTextureViewDimension dimension;
    313    GPUTextureAspect aspect = "all";
    314    GPUIntegerCoordinate baseMipLevel = 0;
    315    GPUIntegerCoordinate mipLevelCount;
    316    GPUIntegerCoordinate baseArrayLayer = 0;
    317    GPUIntegerCoordinate arrayLayerCount;
    318 };
    319 
    320 enum GPUTextureViewDimension {
    321    "1d",
    322    "2d",
    323    "2d-array",
    324    "cube",
    325    "cube-array",
    326    "3d",
    327 };
    328 
    329 enum GPUTextureAspect {
    330    "all",
    331    "stencil-only",
    332    "depth-only",
    333 };
    334 
    335 enum GPUTextureFormat {
    336    // 8-bit formats
    337    "r8unorm",
    338    "r8snorm",
    339    "r8uint",
    340    "r8sint",
    341 
    342    // 16-bit formats
    343    "r16uint",
    344    "r16sint",
    345    "r16float",
    346    "rg8unorm",
    347    "rg8snorm",
    348    "rg8uint",
    349    "rg8sint",
    350 
    351    // 32-bit formats
    352    "r32uint",
    353    "r32sint",
    354    "r32float",
    355    "rg16uint",
    356    "rg16sint",
    357    "rg16float",
    358    "rgba8unorm",
    359    "rgba8unorm-srgb",
    360    "rgba8snorm",
    361    "rgba8uint",
    362    "rgba8sint",
    363    "bgra8unorm",
    364    "bgra8unorm-srgb",
    365    // Packed 32-bit formats
    366    "rgb9e5ufloat",
    367    "rgb10a2uint",
    368    "rgb10a2unorm",
    369    "rg11b10ufloat",
    370 
    371    // 64-bit formats
    372    "rg32uint",
    373    "rg32sint",
    374    "rg32float",
    375    "rgba16uint",
    376    "rgba16sint",
    377    "rgba16float",
    378 
    379    // 128-bit formats
    380    "rgba32uint",
    381    "rgba32sint",
    382    "rgba32float",
    383 
    384    // Depth/stencil formats
    385    "stencil8",
    386    "depth16unorm",
    387    "depth24plus",
    388    "depth24plus-stencil8",
    389    "depth32float",
    390 
    391    // "depth32float-stencil8" feature
    392    "depth32float-stencil8",
    393 
    394    // BC compressed formats usable if "texture-compression-bc" is both
    395    // supported by the device/user agent and enabled in requestDevice.
    396    "bc1-rgba-unorm",
    397    "bc1-rgba-unorm-srgb",
    398    "bc2-rgba-unorm",
    399    "bc2-rgba-unorm-srgb",
    400    "bc3-rgba-unorm",
    401    "bc3-rgba-unorm-srgb",
    402    "bc4-r-unorm",
    403    "bc4-r-snorm",
    404    "bc5-rg-unorm",
    405    "bc5-rg-snorm",
    406    "bc6h-rgb-ufloat",
    407    "bc6h-rgb-float",
    408    "bc7-rgba-unorm",
    409    "bc7-rgba-unorm-srgb",
    410 
    411    // ETC2 compressed formats usable if "texture-compression-etc2" is both
    412    // supported by the device/user agent and enabled in requestDevice.
    413    "etc2-rgb8unorm",
    414    "etc2-rgb8unorm-srgb",
    415    "etc2-rgb8a1unorm",
    416    "etc2-rgb8a1unorm-srgb",
    417    "etc2-rgba8unorm",
    418    "etc2-rgba8unorm-srgb",
    419    "eac-r11unorm",
    420    "eac-r11snorm",
    421    "eac-rg11unorm",
    422    "eac-rg11snorm",
    423 
    424    // ASTC compressed formats usable if "texture-compression-astc" is both
    425    // supported by the device/user agent and enabled in requestDevice.
    426    "astc-4x4-unorm",
    427    "astc-4x4-unorm-srgb",
    428    "astc-5x4-unorm",
    429    "astc-5x4-unorm-srgb",
    430    "astc-5x5-unorm",
    431    "astc-5x5-unorm-srgb",
    432    "astc-6x5-unorm",
    433    "astc-6x5-unorm-srgb",
    434    "astc-6x6-unorm",
    435    "astc-6x6-unorm-srgb",
    436    "astc-8x5-unorm",
    437    "astc-8x5-unorm-srgb",
    438    "astc-8x6-unorm",
    439    "astc-8x6-unorm-srgb",
    440    "astc-8x8-unorm",
    441    "astc-8x8-unorm-srgb",
    442    "astc-10x5-unorm",
    443    "astc-10x5-unorm-srgb",
    444    "astc-10x6-unorm",
    445    "astc-10x6-unorm-srgb",
    446    "astc-10x8-unorm",
    447    "astc-10x8-unorm-srgb",
    448    "astc-10x10-unorm",
    449    "astc-10x10-unorm-srgb",
    450    "astc-12x10-unorm",
    451    "astc-12x10-unorm-srgb",
    452    "astc-12x12-unorm",
    453    "astc-12x12-unorm-srgb",
    454 };
    455 
    456 [Func="mozilla::webgpu::Instance::PrefEnabled",
    457 Exposed=(Window, Worker), SecureContext]
    458 interface GPUExternalTexture {
    459 };
    460 GPUExternalTexture includes GPUObjectBase;
    461 
    462 dictionary GPUExternalTextureDescriptor
    463         : GPUObjectDescriptorBase {
    464    required (HTMLVideoElement or VideoFrame) source;
    465    PredefinedColorSpace colorSpace = "srgb";
    466 };
    467 
    468 [Func="mozilla::webgpu::Instance::PrefEnabled",
    469 Exposed=(Window, Worker), SecureContext]
    470 interface GPUSampler {
    471 };
    472 GPUSampler includes GPUObjectBase;
    473 
    474 dictionary GPUSamplerDescriptor
    475         : GPUObjectDescriptorBase {
    476    GPUAddressMode addressModeU = "clamp-to-edge";
    477    GPUAddressMode addressModeV = "clamp-to-edge";
    478    GPUAddressMode addressModeW = "clamp-to-edge";
    479    GPUFilterMode magFilter = "nearest";
    480    GPUFilterMode minFilter = "nearest";
    481    GPUMipmapFilterMode mipmapFilter = "nearest";
    482    float lodMinClamp = 0;
    483    float lodMaxClamp = 32;
    484    GPUCompareFunction compare;
    485    [Clamp] unsigned short maxAnisotropy = 1;
    486 };
    487 
    488 enum GPUAddressMode {
    489    "clamp-to-edge",
    490    "repeat",
    491    "mirror-repeat",
    492 };
    493 
    494 enum GPUFilterMode {
    495    "nearest",
    496    "linear",
    497 };
    498 
    499 enum GPUMipmapFilterMode {
    500    "nearest",
    501    "linear",
    502 };
    503 
    504 enum GPUCompareFunction {
    505    "never",
    506    "less",
    507    "equal",
    508    "less-equal",
    509    "greater",
    510    "not-equal",
    511    "greater-equal",
    512    "always",
    513 };
    514 
    515 [Func="mozilla::webgpu::Instance::PrefEnabled",
    516 Exposed=(Window, Worker), SecureContext]
    517 interface GPUBindGroupLayout {
    518 };
    519 GPUBindGroupLayout includes GPUObjectBase;
    520 
    521 dictionary GPUBindGroupLayoutDescriptor
    522         : GPUObjectDescriptorBase {
    523    required sequence<GPUBindGroupLayoutEntry> entries;
    524 };
    525 
    526 dictionary GPUBindGroupLayoutEntry {
    527    required GPUIndex32 binding;
    528    required GPUShaderStageFlags visibility;
    529 
    530    GPUBufferBindingLayout buffer;
    531    GPUSamplerBindingLayout sampler;
    532    GPUTextureBindingLayout texture;
    533    GPUStorageTextureBindingLayout storageTexture;
    534    GPUExternalTextureBindingLayout externalTexture;
    535 };
    536 
    537 typedef [EnforceRange] unsigned long GPUShaderStageFlags;
    538 [Func="mozilla::webgpu::Instance::PrefEnabled",
    539 Exposed=(Window, Worker), SecureContext]
    540 namespace GPUShaderStage {
    541    const GPUFlagsConstant VERTEX   = 0x1;
    542    const GPUFlagsConstant FRAGMENT = 0x2;
    543    const GPUFlagsConstant COMPUTE  = 0x4;
    544 };
    545 
    546 enum GPUBufferBindingType {
    547    "uniform",
    548    "storage",
    549    "read-only-storage",
    550 };
    551 
    552 dictionary GPUBufferBindingLayout {
    553    GPUBufferBindingType type = "uniform";
    554    boolean hasDynamicOffset = false;
    555    GPUSize64 minBindingSize = 0;
    556 };
    557 
    558 enum GPUSamplerBindingType {
    559    "filtering",
    560    "non-filtering",
    561    "comparison",
    562 };
    563 
    564 dictionary GPUSamplerBindingLayout {
    565    GPUSamplerBindingType type = "filtering";
    566 };
    567 
    568 enum GPUTextureSampleType {
    569    "float",
    570    "unfilterable-float",
    571    "depth",
    572    "sint",
    573    "uint",
    574 };
    575 
    576 dictionary GPUTextureBindingLayout {
    577    GPUTextureSampleType sampleType = "float";
    578    GPUTextureViewDimension viewDimension = "2d";
    579    boolean multisampled = false;
    580 };
    581 
    582 enum GPUStorageTextureAccess {
    583    "write-only",
    584    "read-only",
    585    "read-write",
    586 };
    587 
    588 dictionary GPUStorageTextureBindingLayout {
    589    GPUStorageTextureAccess access = "write-only";
    590    required GPUTextureFormat format;
    591    GPUTextureViewDimension viewDimension = "2d";
    592 };
    593 
    594 dictionary GPUExternalTextureBindingLayout {
    595 };
    596 
    597 [Func="mozilla::webgpu::Instance::PrefEnabled",
    598 Exposed=(Window, Worker), SecureContext]
    599 interface GPUBindGroup {
    600 };
    601 GPUBindGroup includes GPUObjectBase;
    602 
    603 dictionary GPUBindGroupDescriptor
    604         : GPUObjectDescriptorBase {
    605    required GPUBindGroupLayout layout;
    606    required sequence<GPUBindGroupEntry> entries;
    607 };
    608 
    609 typedef (GPUSampler or
    610         GPUTexture or
    611         GPUTextureView or
    612         GPUBuffer or
    613         GPUBufferBinding or
    614         GPUExternalTexture) GPUBindingResource;
    615 
    616 dictionary GPUBindGroupEntry {
    617    required GPUIndex32 binding;
    618    required GPUBindingResource resource;
    619 };
    620 
    621 dictionary GPUBufferBinding {
    622    required GPUBuffer buffer;
    623    GPUSize64 offset = 0;
    624    GPUSize64 size;
    625 };
    626 
    627 [Func="mozilla::webgpu::Instance::PrefEnabled",
    628 Exposed=(Window, Worker), SecureContext]
    629 interface GPUPipelineLayout {
    630 };
    631 GPUPipelineLayout includes GPUObjectBase;
    632 
    633 dictionary GPUPipelineLayoutDescriptor
    634         : GPUObjectDescriptorBase {
    635    required sequence<GPUBindGroupLayout> bindGroupLayouts;
    636 };
    637 
    638 [Func="mozilla::webgpu::Instance::PrefEnabled",
    639 Exposed=(Window, Worker), SecureContext]
    640 interface GPUShaderModule {
    641    [Throws]
    642    Promise<GPUCompilationInfo> getCompilationInfo();
    643 };
    644 GPUShaderModule includes GPUObjectBase;
    645 
    646 dictionary GPUShaderModuleDescriptor
    647         : GPUObjectDescriptorBase {
    648    // UTF8String is not observably different from USVString
    649    required UTF8String code;
    650    sequence<GPUShaderModuleCompilationHint> compilationHints = [];
    651 };
    652 
    653 dictionary GPUShaderModuleCompilationHint {
    654    required USVString entryPoint;
    655    (GPUPipelineLayout or GPUAutoLayoutMode) layout;
    656 };
    657 
    658 enum GPUCompilationMessageType {
    659    "error",
    660    "warning",
    661    "info",
    662 };
    663 
    664 [Func="mozilla::webgpu::Instance::PrefEnabled",
    665 Exposed=(Window, Worker), SecureContext]
    666 interface GPUCompilationMessage {
    667    readonly attribute DOMString message;
    668    readonly attribute GPUCompilationMessageType type;
    669    readonly attribute unsigned long long lineNum;
    670    readonly attribute unsigned long long linePos;
    671    readonly attribute unsigned long long offset;
    672    readonly attribute unsigned long long length;
    673 };
    674 
    675 [Func="mozilla::webgpu::Instance::PrefEnabled",
    676 Exposed=(Window, Worker), SecureContext]
    677 interface GPUCompilationInfo {
    678    [Cached, Frozen, Pure]
    679    readonly attribute sequence<GPUCompilationMessage> messages;
    680 };
    681 
    682 [Func="mozilla::webgpu::Instance::PrefEnabled",
    683 Exposed=(Window, Worker), SecureContext]
    684 interface GPUPipelineError : DOMException {
    685    constructor(optional DOMString message = "", GPUPipelineErrorInit options);
    686    readonly attribute GPUPipelineErrorReason reason;
    687 };
    688 
    689 dictionary GPUPipelineErrorInit {
    690    required GPUPipelineErrorReason reason;
    691 };
    692 
    693 enum GPUPipelineErrorReason {
    694    "validation",
    695    "internal",
    696 };
    697 
    698 enum GPUAutoLayoutMode {
    699    "auto",
    700 };
    701 
    702 dictionary GPUPipelineDescriptorBase
    703         : GPUObjectDescriptorBase {
    704    required (GPUPipelineLayout or GPUAutoLayoutMode) layout;
    705 };
    706 
    707 interface mixin GPUPipelineBase {
    708    GPUBindGroupLayout getBindGroupLayout(unsigned long index);
    709 };
    710 
    711 dictionary GPUProgrammableStage {
    712    required GPUShaderModule module;
    713    USVString entryPoint;
    714    record<USVString, GPUPipelineConstantValue> constants;
    715 };
    716 
    717 typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled.
    718 
    719 //TODO: Serializable
    720 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
    721 [Func="mozilla::webgpu::Instance::PrefEnabled",
    722 Exposed=(Window, Worker), SecureContext]
    723 interface GPUComputePipeline {
    724 };
    725 GPUComputePipeline includes GPUObjectBase;
    726 GPUComputePipeline includes GPUPipelineBase;
    727 
    728 dictionary GPUComputePipelineDescriptor
    729         : GPUPipelineDescriptorBase {
    730    required GPUProgrammableStage compute;
    731 };
    732 
    733 //TODO: Serializable
    734 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
    735 [Func="mozilla::webgpu::Instance::PrefEnabled",
    736 Exposed=(Window, Worker), SecureContext]
    737 interface GPURenderPipeline {
    738 };
    739 GPURenderPipeline includes GPUObjectBase;
    740 GPURenderPipeline includes GPUPipelineBase;
    741 
    742 dictionary GPURenderPipelineDescriptor
    743         : GPUPipelineDescriptorBase {
    744    required GPUVertexState vertex;
    745    GPUPrimitiveState primitive = {};
    746    GPUDepthStencilState depthStencil;
    747    GPUMultisampleState multisample = {};
    748    GPUFragmentState fragment;
    749 };
    750 
    751 dictionary GPUPrimitiveState {
    752    GPUPrimitiveTopology topology = "triangle-list";
    753    GPUIndexFormat stripIndexFormat;
    754    GPUFrontFace frontFace = "ccw";
    755    GPUCullMode cullMode = "none";
    756 
    757    // Requires "depth-clip-control" feature.
    758    boolean unclippedDepth = false;
    759 };
    760 
    761 enum GPUPrimitiveTopology {
    762    "point-list",
    763    "line-list",
    764    "line-strip",
    765    "triangle-list",
    766    "triangle-strip",
    767 };
    768 
    769 enum GPUFrontFace {
    770    "ccw",
    771    "cw",
    772 };
    773 
    774 enum GPUCullMode {
    775    "none",
    776    "front",
    777    "back",
    778 };
    779 
    780 dictionary GPUMultisampleState {
    781    GPUSize32 count = 1;
    782    GPUSampleMask mask = 0xFFFFFFFF;
    783    boolean alphaToCoverageEnabled = false;
    784 };
    785 
    786 dictionary GPUFragmentState
    787         : GPUProgrammableStage {
    788    required sequence<GPUColorTargetState> targets;
    789 };
    790 
    791 dictionary GPUColorTargetState {
    792    required GPUTextureFormat format;
    793 
    794    GPUBlendState blend;
    795    GPUColorWriteFlags writeMask = 0xF;  // GPUColorWrite.ALL
    796 };
    797 
    798 dictionary GPUBlendState {
    799    required GPUBlendComponent color;
    800    required GPUBlendComponent alpha;
    801 };
    802 
    803 typedef [EnforceRange] unsigned long GPUColorWriteFlags;
    804 [Func="mozilla::webgpu::Instance::PrefEnabled",
    805 Exposed=(Window, Worker), SecureContext]
    806 namespace GPUColorWrite {
    807    const GPUFlagsConstant RED   = 0x1;
    808    const GPUFlagsConstant GREEN = 0x2;
    809    const GPUFlagsConstant BLUE  = 0x4;
    810    const GPUFlagsConstant ALPHA = 0x8;
    811    const GPUFlagsConstant ALL   = 0xF;
    812 };
    813 
    814 dictionary GPUBlendComponent {
    815    GPUBlendOperation operation = "add";
    816    GPUBlendFactor srcFactor = "one";
    817    GPUBlendFactor dstFactor = "zero";
    818 };
    819 
    820 enum GPUBlendFactor {
    821    "zero",
    822    "one",
    823    "src",
    824    "one-minus-src",
    825    "src-alpha",
    826    "one-minus-src-alpha",
    827    "dst",
    828    "one-minus-dst",
    829    "dst-alpha",
    830    "one-minus-dst-alpha",
    831    "src-alpha-saturated",
    832    "constant",
    833    "one-minus-constant",
    834 };
    835 
    836 enum GPUBlendOperation {
    837    "add",
    838    "subtract",
    839    "reverse-subtract",
    840    "min",
    841    "max",
    842 };
    843 
    844 dictionary GPUDepthStencilState {
    845    required GPUTextureFormat format;
    846 
    847    boolean depthWriteEnabled = false;
    848    GPUCompareFunction depthCompare = "always";
    849 
    850    GPUStencilFaceState stencilFront = {};
    851    GPUStencilFaceState stencilBack = {};
    852 
    853    GPUStencilValue stencilReadMask = 0xFFFFFFFF;
    854    GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
    855 
    856    GPUDepthBias depthBias = 0;
    857    float depthBiasSlopeScale = 0;
    858    float depthBiasClamp = 0;
    859 };
    860 
    861 dictionary GPUStencilFaceState {
    862    GPUCompareFunction compare = "always";
    863    GPUStencilOperation failOp = "keep";
    864    GPUStencilOperation depthFailOp = "keep";
    865    GPUStencilOperation passOp = "keep";
    866 };
    867 
    868 enum GPUStencilOperation {
    869    "keep",
    870    "zero",
    871    "replace",
    872    "invert",
    873    "increment-clamp",
    874    "decrement-clamp",
    875    "increment-wrap",
    876    "decrement-wrap",
    877 };
    878 
    879 enum GPUIndexFormat {
    880    "uint16",
    881    "uint32",
    882 };
    883 
    884 enum GPUVertexFormat {
    885    "uint8",
    886    "uint8x2",
    887    "uint8x4",
    888    "sint8",
    889    "sint8x2",
    890    "sint8x4",
    891    "unorm8",
    892    "unorm8x2",
    893    "unorm8x4",
    894    "snorm8",
    895    "snorm8x2",
    896    "snorm8x4",
    897    "uint16",
    898    "uint16x2",
    899    "uint16x4",
    900    "sint16",
    901    "sint16x2",
    902    "sint16x4",
    903    "unorm16",
    904    "unorm16x2",
    905    "unorm16x4",
    906    "snorm16",
    907    "snorm16x2",
    908    "snorm16x4",
    909    "float16",
    910    "float16x2",
    911    "float16x4",
    912    "float32",
    913    "float32x2",
    914    "float32x3",
    915    "float32x4",
    916    "uint32",
    917    "uint32x2",
    918    "uint32x3",
    919    "uint32x4",
    920    "sint32",
    921    "sint32x2",
    922    "sint32x3",
    923    "sint32x4",
    924    "unorm10-10-10-2",
    925    "unorm8x4-bgra",
    926 };
    927 
    928 enum GPUVertexStepMode {
    929    "vertex",
    930    "instance",
    931 };
    932 
    933 dictionary GPUVertexState
    934         : GPUProgrammableStage {
    935    sequence<GPUVertexBufferLayout?> buffers = [];
    936 };
    937 
    938 dictionary GPUVertexBufferLayout {
    939    required GPUSize64 arrayStride;
    940    GPUVertexStepMode stepMode = "vertex";
    941    required sequence<GPUVertexAttribute> attributes;
    942 };
    943 
    944 dictionary GPUVertexAttribute {
    945    required GPUVertexFormat format;
    946    required GPUSize64 offset;
    947 
    948    required GPUIndex32 shaderLocation;
    949 };
    950 
    951 dictionary GPUTexelCopyBufferLayout {
    952    GPUSize64 offset = 0;
    953    GPUSize32 bytesPerRow;
    954    GPUSize32 rowsPerImage;
    955 };
    956 
    957 dictionary GPUTexelCopyBufferInfo
    958         : GPUTexelCopyBufferLayout {
    959    required GPUBuffer buffer;
    960 };
    961 
    962 dictionary GPUTexelCopyTextureInfo {
    963    required GPUTexture texture;
    964    GPUIntegerCoordinate mipLevel = 0;
    965    GPUOrigin3D origin = {};
    966    GPUTextureAspect aspect = "all";
    967 };
    968 
    969 dictionary GPUCopyExternalImageDestInfo
    970         : GPUTexelCopyTextureInfo {
    971    //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
    972    boolean premultipliedAlpha = false;
    973 };
    974 
    975 typedef (ImageBitmap or
    976         HTMLImageElement or
    977         HTMLCanvasElement or
    978         OffscreenCanvas) GPUCopyExternalImageSource;
    979 
    980 dictionary GPUCopyExternalImageSourceInfo {
    981    required GPUCopyExternalImageSource source;
    982    GPUOrigin2D origin = {};
    983    boolean flipY = false;
    984 };
    985 
    986 [Func="mozilla::webgpu::Instance::PrefEnabled",
    987 Exposed=(Window, Worker), SecureContext]
    988 interface GPUCommandBuffer {
    989 };
    990 GPUCommandBuffer includes GPUObjectBase;
    991 
    992 dictionary GPUCommandBufferDescriptor
    993         : GPUObjectDescriptorBase {
    994 };
    995 
    996 interface mixin GPUCommandsMixin {
    997 };
    998 
    999 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1000 Exposed=(Window, Worker), SecureContext]
   1001 interface GPUCommandEncoder {
   1002    GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
   1003    GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
   1004 
   1005    undefined copyBufferToBuffer(
   1006        GPUBuffer source,
   1007        GPUBuffer destination,
   1008        optional GPUSize64 size);
   1009    undefined copyBufferToBuffer(
   1010        GPUBuffer source,
   1011        GPUSize64 sourceOffset,
   1012        GPUBuffer destination,
   1013        GPUSize64 destinationOffset,
   1014        optional GPUSize64 size);
   1015 
   1016    undefined copyBufferToTexture(
   1017        GPUTexelCopyBufferInfo source,
   1018        GPUTexelCopyTextureInfo destination,
   1019        GPUExtent3D copySize);
   1020 
   1021    undefined copyTextureToBuffer(
   1022        GPUTexelCopyTextureInfo source,
   1023        GPUTexelCopyBufferInfo destination,
   1024        GPUExtent3D copySize);
   1025 
   1026    undefined copyTextureToTexture(
   1027        GPUTexelCopyTextureInfo source,
   1028        GPUTexelCopyTextureInfo destination,
   1029        GPUExtent3D copySize);
   1030 
   1031    undefined clearBuffer(
   1032        GPUBuffer buffer,
   1033        optional GPUSize64 offset = 0,
   1034        optional GPUSize64 size);
   1035 
   1036    undefined resolveQuerySet(
   1037        GPUQuerySet querySet,
   1038        GPUSize32 firstQuery,
   1039        GPUSize32 queryCount,
   1040        GPUBuffer destination,
   1041        GPUSize64 destinationOffset);
   1042 
   1043    GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
   1044 };
   1045 GPUCommandEncoder includes GPUObjectBase;
   1046 GPUCommandEncoder includes GPUCommandsMixin;
   1047 GPUCommandEncoder includes GPUDebugCommandsMixin;
   1048 
   1049 dictionary GPUCommandEncoderDescriptor
   1050         : GPUObjectDescriptorBase {
   1051 };
   1052 
   1053 interface mixin GPUBindingCommandsMixin {
   1054    [Throws]
   1055    undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup,
   1056        optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
   1057    [Throws]
   1058    undefined setBindGroup(GPUIndex32 index, GPUBindGroup? bindGroup,
   1059        [AllowShared] Uint32Array dynamicOffsetsData,
   1060        GPUSize64 dynamicOffsetsDataStart,
   1061        GPUSize32 dynamicOffsetsDataLength);
   1062 };
   1063 
   1064 interface mixin GPUDebugCommandsMixin {
   1065    undefined pushDebugGroup(USVString groupLabel);
   1066    undefined popDebugGroup();
   1067    undefined insertDebugMarker(USVString markerLabel);
   1068 };
   1069 
   1070 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1071 Exposed=(Window, Worker), SecureContext]
   1072 interface GPUComputePassEncoder {
   1073    undefined setPipeline(GPUComputePipeline pipeline);
   1074    undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
   1075    undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
   1076 
   1077    undefined end();
   1078 };
   1079 GPUComputePassEncoder includes GPUObjectBase;
   1080 GPUComputePassEncoder includes GPUCommandsMixin;
   1081 GPUComputePassEncoder includes GPUDebugCommandsMixin;
   1082 GPUComputePassEncoder includes GPUBindingCommandsMixin;
   1083 
   1084 dictionary GPUComputePassTimestampWrites {
   1085    required GPUQuerySet querySet;
   1086    GPUSize32 beginningOfPassWriteIndex;
   1087    GPUSize32 endOfPassWriteIndex;
   1088 };
   1089 
   1090 dictionary GPUComputePassDescriptor
   1091         : GPUObjectDescriptorBase {
   1092    GPUComputePassTimestampWrites timestampWrites;
   1093 };
   1094 
   1095 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1096 Exposed=(Window, Worker), SecureContext]
   1097 interface GPURenderPassEncoder {
   1098    undefined setViewport(float x, float y,
   1099        float width, float height,
   1100        float minDepth, float maxDepth);
   1101 
   1102    undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
   1103                        GPUIntegerCoordinate width, GPUIntegerCoordinate height);
   1104 
   1105    undefined setBlendConstant(GPUColor color);
   1106    undefined setStencilReference(GPUStencilValue reference);
   1107 
   1108    undefined beginOcclusionQuery(GPUSize32 queryIndex);
   1109    undefined endOcclusionQuery();
   1110 
   1111    undefined executeBundles(sequence<GPURenderBundle> bundles);
   1112    undefined end();
   1113 };
   1114 GPURenderPassEncoder includes GPUObjectBase;
   1115 GPURenderPassEncoder includes GPUCommandsMixin;
   1116 GPURenderPassEncoder includes GPUDebugCommandsMixin;
   1117 GPURenderPassEncoder includes GPUBindingCommandsMixin;
   1118 GPURenderPassEncoder includes GPURenderCommandsMixin;
   1119 
   1120 dictionary GPURenderPassTimestampWrites {
   1121    required GPUQuerySet querySet;
   1122    GPUSize32 beginningOfPassWriteIndex;
   1123    GPUSize32 endOfPassWriteIndex;
   1124 };
   1125 
   1126 dictionary GPURenderPassDescriptor
   1127         : GPUObjectDescriptorBase {
   1128    required sequence<GPURenderPassColorAttachment> colorAttachments;
   1129    GPURenderPassDepthStencilAttachment depthStencilAttachment;
   1130    GPUQuerySet occlusionQuerySet;
   1131    GPURenderPassTimestampWrites timestampWrites;
   1132 };
   1133 
   1134 dictionary GPURenderPassColorAttachment {
   1135    required (GPUTexture or GPUTextureView) view;
   1136    GPUIntegerCoordinate depthSlice;
   1137    (GPUTexture or GPUTextureView) resolveTarget;
   1138 
   1139    GPUColor clearValue;
   1140    required GPULoadOp loadOp;
   1141    required GPUStoreOp storeOp;
   1142 };
   1143 
   1144 dictionary GPURenderPassDepthStencilAttachment {
   1145    required (GPUTexture or GPUTextureView) view;
   1146 
   1147    float depthClearValue;
   1148    GPULoadOp depthLoadOp;
   1149    GPUStoreOp depthStoreOp;
   1150    boolean depthReadOnly = false;
   1151 
   1152    GPUStencilValue stencilClearValue = 0;
   1153    GPULoadOp stencilLoadOp;
   1154    GPUStoreOp stencilStoreOp;
   1155    boolean stencilReadOnly = false;
   1156 };
   1157 
   1158 enum GPULoadOp {
   1159    "load",
   1160    "clear",
   1161 };
   1162 
   1163 enum GPUStoreOp {
   1164    "store",
   1165    "discard",
   1166 };
   1167 
   1168 dictionary GPURenderPassLayout
   1169         : GPUObjectDescriptorBase {
   1170    required sequence<GPUTextureFormat> colorFormats;
   1171    GPUTextureFormat depthStencilFormat;
   1172    GPUSize32 sampleCount = 1;
   1173 };
   1174 
   1175 interface mixin GPURenderCommandsMixin {
   1176    undefined setPipeline(GPURenderPipeline pipeline);
   1177 
   1178    undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size);
   1179    undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size);
   1180 
   1181    undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1,
   1182        optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0);
   1183    undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1,
   1184        optional GPUSize32 firstIndex = 0,
   1185        optional GPUSignedOffset32 baseVertex = 0,
   1186        optional GPUSize32 firstInstance = 0);
   1187 
   1188    undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
   1189    undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
   1190 };
   1191 
   1192 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1193 Exposed=(Window, Worker), SecureContext]
   1194 interface GPURenderBundle {
   1195 };
   1196 GPURenderBundle includes GPUObjectBase;
   1197 
   1198 dictionary GPURenderBundleDescriptor
   1199         : GPUObjectDescriptorBase {
   1200 };
   1201 
   1202 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1203 Exposed=(Window, Worker), SecureContext]
   1204 interface GPURenderBundleEncoder {
   1205    GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
   1206 };
   1207 GPURenderBundleEncoder includes GPUObjectBase;
   1208 GPURenderBundleEncoder includes GPUCommandsMixin;
   1209 GPURenderBundleEncoder includes GPUDebugCommandsMixin;
   1210 GPURenderBundleEncoder includes GPUBindingCommandsMixin;
   1211 GPURenderBundleEncoder includes GPURenderCommandsMixin;
   1212 
   1213 dictionary GPURenderBundleEncoderDescriptor
   1214         : GPURenderPassLayout {
   1215    boolean depthReadOnly = false;
   1216    boolean stencilReadOnly = false;
   1217 };
   1218 
   1219 dictionary GPUQueueDescriptor
   1220         : GPUObjectDescriptorBase {
   1221 };
   1222 
   1223 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1224 Exposed=(Window, Worker), SecureContext]
   1225 interface GPUQueue {
   1226    undefined submit(sequence<GPUCommandBuffer> buffers);
   1227 
   1228    [Throws]
   1229    Promise<undefined> onSubmittedWorkDone();
   1230 
   1231    [Throws]
   1232    undefined writeBuffer(
   1233        GPUBuffer buffer,
   1234        GPUSize64 bufferOffset,
   1235        AllowSharedBufferSource data,
   1236        optional GPUSize64 dataOffset = 0,
   1237        optional GPUSize64 size);
   1238 
   1239    [Throws]
   1240    undefined writeTexture(
   1241        GPUTexelCopyTextureInfo destination,
   1242        AllowSharedBufferSource data,
   1243        GPUTexelCopyBufferLayout dataLayout,
   1244        GPUExtent3D size);
   1245 
   1246    [Throws]
   1247    undefined copyExternalImageToTexture(
   1248        GPUCopyExternalImageSourceInfo source,
   1249        GPUCopyExternalImageDestInfo destination,
   1250        GPUExtent3D copySize);
   1251 };
   1252 GPUQueue includes GPUObjectBase;
   1253 
   1254 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1255 Exposed=(Window, Worker), SecureContext]
   1256 interface GPUQuerySet {
   1257    undefined destroy();
   1258 
   1259    readonly attribute GPUQueryType type;
   1260    readonly attribute GPUSize32Out count;
   1261 };
   1262 GPUQuerySet includes GPUObjectBase;
   1263 
   1264 dictionary GPUQuerySetDescriptor
   1265         : GPUObjectDescriptorBase {
   1266    required GPUQueryType type;
   1267    required GPUSize32 count;
   1268 };
   1269 
   1270 enum GPUQueryType {
   1271    "occlusion",
   1272    "timestamp",
   1273 };
   1274 
   1275 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1276 Exposed=(Window, Worker), SecureContext]
   1277 interface GPUCanvasContext {
   1278    readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
   1279 
   1280    [Throws]
   1281    undefined configure(GPUCanvasConfiguration configuration);
   1282    undefined unconfigure();
   1283 
   1284    GPUCanvasConfiguration? getConfiguration();
   1285    [Throws]
   1286    GPUTexture getCurrentTexture();
   1287 };
   1288 
   1289 enum GPUCanvasAlphaMode {
   1290    "opaque",
   1291    "premultiplied",
   1292 };
   1293 
   1294 dictionary GPUCanvasConfiguration {
   1295    required GPUDevice device;
   1296    required GPUTextureFormat format;
   1297    GPUTextureUsageFlags usage = 0x10;  // GPUTextureUsage.RENDER_ATTACHMENT
   1298    sequence<GPUTextureFormat> viewFormats = [];
   1299    //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO bug 1834395
   1300    //GPUCanvasToneMapping toneMapping = {}; //TODO bug 1834395
   1301    GPUCanvasAlphaMode alphaMode = "opaque";
   1302 };
   1303 
   1304 enum GPUDeviceLostReason {
   1305    "unknown",
   1306    "destroyed",
   1307 };
   1308 
   1309 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1310 Exposed=(Window, Worker), SecureContext]
   1311 interface GPUDeviceLostInfo {
   1312    readonly attribute GPUDeviceLostReason reason;
   1313    readonly attribute DOMString message;
   1314 };
   1315 
   1316 partial interface GPUDevice {
   1317    [Throws]
   1318    readonly attribute Promise<GPUDeviceLostInfo> lost;
   1319 };
   1320 
   1321 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1322 Exposed=(Window, Worker), SecureContext]
   1323 interface GPUError {
   1324    readonly attribute DOMString message;
   1325 };
   1326 
   1327 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1328 Exposed=(Window, Worker), SecureContext]
   1329 interface GPUValidationError
   1330        : GPUError {
   1331    [Throws]
   1332    constructor(DOMString message);
   1333 };
   1334 
   1335 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1336 Exposed=(Window, Worker), SecureContext]
   1337 interface GPUOutOfMemoryError
   1338        : GPUError {
   1339    [Throws]
   1340    constructor(DOMString message);
   1341 };
   1342 
   1343 [Func="mozilla::webgpu::Instance::PrefEnabled",
   1344 Exposed=(Window, Worker), SecureContext]
   1345 interface GPUInternalError
   1346        : GPUError {
   1347    [Throws]
   1348    constructor(DOMString message);
   1349 };
   1350 
   1351 enum GPUErrorFilter {
   1352    "validation",
   1353    "out-of-memory",
   1354    "internal",
   1355 };
   1356 
   1357 partial interface GPUDevice {
   1358    undefined pushErrorScope(GPUErrorFilter filter);
   1359    [Throws]
   1360    Promise<GPUError?> popErrorScope();
   1361 };
   1362 
   1363 // NOTE: `GPUUncapturedErrorEvent{,Init}` is in `GPUUncapturedErrorEvent.webidl`.
   1364 
   1365 partial interface GPUDevice {
   1366    [Exposed=(Window, Worker)]
   1367    attribute EventHandler onuncapturederror;
   1368 };
   1369 
   1370 typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
   1371 typedef [EnforceRange] unsigned long GPUStencilValue;
   1372 typedef [EnforceRange] unsigned long GPUSampleMask;
   1373 typedef [EnforceRange] long GPUDepthBias;
   1374 
   1375 typedef [EnforceRange] unsigned long long GPUSize64;
   1376 typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
   1377 typedef [EnforceRange] unsigned long GPUIndex32;
   1378 typedef [EnforceRange] unsigned long GPUSize32;
   1379 typedef [EnforceRange] long GPUSignedOffset32;
   1380 
   1381 typedef unsigned long long GPUSize64Out;
   1382 typedef unsigned long GPUIntegerCoordinateOut;
   1383 typedef unsigned long GPUSize32Out;
   1384 
   1385 typedef unsigned long GPUFlagsConstant;
   1386 
   1387 dictionary GPUColorDict {
   1388    required double r;
   1389    required double g;
   1390    required double b;
   1391    required double a;
   1392 };
   1393 typedef (sequence<double> or GPUColorDict) GPUColor;
   1394 
   1395 dictionary GPUOrigin2DDict {
   1396    GPUIntegerCoordinate x = 0;
   1397    GPUIntegerCoordinate y = 0;
   1398 };
   1399 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
   1400 
   1401 dictionary GPUOrigin3DDict {
   1402    GPUIntegerCoordinate x = 0;
   1403    GPUIntegerCoordinate y = 0;
   1404    GPUIntegerCoordinate z = 0;
   1405 };
   1406 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
   1407 
   1408 dictionary GPUExtent3DDict {
   1409    required GPUIntegerCoordinate width;
   1410    GPUIntegerCoordinate height = 1;
   1411    GPUIntegerCoordinate depthOrArrayLayers = 1;
   1412 };
   1413 typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;