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/.
6 * The origin of this IDL file is
7 * https://gpuweb.github.io/gpuweb/
10 interface mixin GPUObjectBase {
11 attribute USVString? label;
14 dictionary GPUObjectDescriptorBase {
18 [Func="mozilla::webgpu::Instance::PrefEnabled",
19 Exposed=(Window, DedicatedWorker), 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 maxInterStageShaderComponents;
44 readonly attribute unsigned long maxInterStageShaderVariables;
45 readonly attribute unsigned long maxColorAttachments;
46 readonly attribute unsigned long maxColorAttachmentBytesPerSample;
47 readonly attribute unsigned long maxComputeWorkgroupStorageSize;
48 readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
49 readonly attribute unsigned long maxComputeWorkgroupSizeX;
50 readonly attribute unsigned long maxComputeWorkgroupSizeY;
51 readonly attribute unsigned long maxComputeWorkgroupSizeZ;
52 readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
55 [Func="mozilla::webgpu::Instance::PrefEnabled",
56 Exposed=(Window, DedicatedWorker), SecureContext]
57 interface GPUSupportedFeatures {
58 readonly setlike<DOMString>;
61 [Func="mozilla::webgpu::Instance::PrefEnabled",
62 Exposed=(Window, DedicatedWorker), SecureContext]
63 interface GPUAdapterInfo {
64 readonly attribute DOMString vendor;
65 readonly attribute DOMString architecture;
66 readonly attribute DOMString device;
67 readonly attribute DOMString description;
69 // Non-standard; see <https://bugzilla.mozilla.org/show_bug.cgi?id=1831994>.
70 [ChromeOnly] readonly attribute DOMString wgpuName;
71 [ChromeOnly] readonly attribute unsigned long wgpuVendor;
72 [ChromeOnly] readonly attribute unsigned long wgpuDevice;
73 [ChromeOnly] readonly attribute DOMString wgpuDeviceType;
74 [ChromeOnly] readonly attribute DOMString wgpuDriver;
75 [ChromeOnly] readonly attribute DOMString wgpuDriverInfo;
76 [ChromeOnly] readonly attribute DOMString wgpuBackend;
79 interface mixin NavigatorGPU {
80 [SameObject, Func="mozilla::webgpu::Instance::PrefEnabled", Exposed=(Window, DedicatedWorker), SecureContext] readonly attribute GPU gpu;
82 // NOTE: see `dom/webidl/Navigator.webidl`
83 // Navigator includes NavigatorGPU;
84 // NOTE: see `dom/webidl/WorkerNavigator.webidl`
85 // WorkerNavigator includes NavigatorGPU;
88 Func="mozilla::webgpu::Instance::PrefEnabled",
89 Exposed=(Window, DedicatedWorker), SecureContext
93 Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
94 GPUTextureFormat getPreferredCanvasFormat();
97 dictionary GPURequestAdapterOptions {
98 GPUPowerPreference powerPreference;
99 boolean forceFallbackAdapter = false;
102 enum GPUPowerPreference {
107 [Func="mozilla::webgpu::Instance::PrefEnabled",
108 Exposed=(Window, DedicatedWorker), SecureContext]
109 interface GPUAdapter {
110 [SameObject] readonly attribute GPUSupportedFeatures features;
111 [SameObject] readonly attribute GPUSupportedLimits limits;
112 readonly attribute boolean isFallbackAdapter;
115 Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
117 Promise<GPUAdapterInfo> requestAdapterInfo(optional sequence<DOMString> unmaskHints = []);
120 dictionary GPUDeviceDescriptor
121 : GPUObjectDescriptorBase {
122 sequence<GPUFeatureName> requiredFeatures = [];
123 record<DOMString, GPUSize64> requiredLimits;
124 GPUQueueDescriptor defaultQueue = {};
127 enum GPUFeatureName {
128 "depth-clip-control",
129 "depth32float-stencil8",
130 "texture-compression-bc",
131 "texture-compression-etc2",
132 "texture-compression-astc",
134 "indirect-first-instance",
136 "rg11b10ufloat-renderable",
137 "bgra8unorm-storage",
138 "float32-filterable",
141 [Func="mozilla::webgpu::Instance::PrefEnabled",
142 Exposed=(Window, DedicatedWorker), SecureContext]
143 interface GPUDevice : EventTarget {
144 [SameObject] readonly attribute GPUSupportedFeatures features;
145 [SameObject] readonly attribute GPUSupportedLimits limits;
147 [SameObject, BinaryName="getQueue"] readonly attribute GPUQueue queue;
152 GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
153 GPUTexture createTexture(GPUTextureDescriptor descriptor);
154 GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
156 GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
157 GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor);
158 GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor);
161 GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
162 GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
163 GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
165 Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor);
167 Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor);
169 GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
170 GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
172 //GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
174 GPUDevice includes GPUObjectBase;
176 [Func="mozilla::webgpu::Instance::PrefEnabled",
177 Exposed=(Window, DedicatedWorker), SecureContext]
178 interface GPUBuffer {
179 readonly attribute GPUSize64Out size;
180 readonly attribute GPUFlagsConstant usage;
182 readonly attribute GPUBufferMapState mapState;
185 Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
187 ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
194 GPUBuffer includes GPUObjectBase;
196 enum GPUBufferMapState {
202 dictionary GPUBufferDescriptor
203 : GPUObjectDescriptorBase {
204 required GPUSize64 size;
205 required GPUBufferUsageFlags usage;
206 boolean mappedAtCreation = false;
209 typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
210 [Func="mozilla::webgpu::Instance::PrefEnabled",
211 Exposed=(Window, DedicatedWorker), SecureContext]
212 namespace GPUBufferUsage {
213 const GPUFlagsConstant MAP_READ = 0x0001;
214 const GPUFlagsConstant MAP_WRITE = 0x0002;
215 const GPUFlagsConstant COPY_SRC = 0x0004;
216 const GPUFlagsConstant COPY_DST = 0x0008;
217 const GPUFlagsConstant INDEX = 0x0010;
218 const GPUFlagsConstant VERTEX = 0x0020;
219 const GPUFlagsConstant UNIFORM = 0x0040;
220 const GPUFlagsConstant STORAGE = 0x0080;
221 const GPUFlagsConstant INDIRECT = 0x0100;
222 const GPUFlagsConstant QUERY_RESOLVE = 0x0200;
225 typedef [EnforceRange] unsigned long GPUMapModeFlags;
226 [Func="mozilla::webgpu::Instance::PrefEnabled",
227 Exposed=(Window, DedicatedWorker), SecureContext]
228 namespace GPUMapMode {
229 const GPUFlagsConstant READ = 0x0001;
230 const GPUFlagsConstant WRITE = 0x0002;
233 [Func="mozilla::webgpu::Instance::PrefEnabled",
234 Exposed=(Window, DedicatedWorker), SecureContext]
235 interface GPUTexture {
236 GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
240 readonly attribute GPUIntegerCoordinateOut width;
241 readonly attribute GPUIntegerCoordinateOut height;
242 readonly attribute GPUIntegerCoordinateOut depthOrArrayLayers;
243 readonly attribute GPUIntegerCoordinateOut mipLevelCount;
244 readonly attribute GPUSize32Out sampleCount;
245 readonly attribute GPUTextureDimension dimension;
246 readonly attribute GPUTextureFormat format;
247 readonly attribute GPUFlagsConstant usage;
249 GPUTexture includes GPUObjectBase;
251 dictionary GPUTextureDescriptor
252 : GPUObjectDescriptorBase {
253 required GPUExtent3D size;
254 GPUIntegerCoordinate mipLevelCount = 1;
255 GPUSize32 sampleCount = 1;
256 GPUTextureDimension dimension = "2d";
257 required GPUTextureFormat format;
258 required GPUTextureUsageFlags usage;
259 sequence<GPUTextureFormat> viewFormats = [];
262 enum GPUTextureDimension {
268 typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
269 [Func="mozilla::webgpu::Instance::PrefEnabled",
270 Exposed=(Window, DedicatedWorker), SecureContext]
271 namespace GPUTextureUsage {
272 const GPUFlagsConstant COPY_SRC = 0x01;
273 const GPUFlagsConstant COPY_DST = 0x02;
274 const GPUFlagsConstant TEXTURE_BINDING = 0x04;
275 const GPUFlagsConstant STORAGE_BINDING = 0x08;
276 const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
279 [Func="mozilla::webgpu::Instance::PrefEnabled",
280 Exposed=(Window, DedicatedWorker), SecureContext]
281 interface GPUTextureView {
283 GPUTextureView includes GPUObjectBase;
285 dictionary GPUTextureViewDescriptor
286 : GPUObjectDescriptorBase {
287 GPUTextureFormat format;
288 GPUTextureViewDimension dimension;
289 GPUTextureAspect aspect = "all";
290 GPUIntegerCoordinate baseMipLevel = 0;
291 GPUIntegerCoordinate mipLevelCount;
292 GPUIntegerCoordinate baseArrayLayer = 0;
293 GPUIntegerCoordinate arrayLayerCount;
296 enum GPUTextureViewDimension {
305 enum GPUTextureAspect {
311 enum GPUTextureFormat {
341 // Packed 32-bit formats
359 // Depth/stencil formats
363 "depth24plus-stencil8",
366 // "depth32float-stencil8" feature
367 "depth32float-stencil8",
369 // BC compressed formats usable if "texture-compression-bc" is both
370 // supported by the device/user agent and enabled in requestDevice.
372 "bc1-rgba-unorm-srgb",
374 "bc2-rgba-unorm-srgb",
376 "bc3-rgba-unorm-srgb",
384 "bc7-rgba-unorm-srgb",
387 [Func="mozilla::webgpu::Instance::PrefEnabled",
388 Exposed=(Window, DedicatedWorker), SecureContext]
389 interface GPUSampler {
391 GPUSampler includes GPUObjectBase;
393 dictionary GPUSamplerDescriptor
394 : GPUObjectDescriptorBase {
395 GPUAddressMode addressModeU = "clamp-to-edge";
396 GPUAddressMode addressModeV = "clamp-to-edge";
397 GPUAddressMode addressModeW = "clamp-to-edge";
398 GPUFilterMode magFilter = "nearest";
399 GPUFilterMode minFilter = "nearest";
400 GPUMipmapFilterMode mipmapFilter = "nearest";
401 float lodMinClamp = 0;
402 float lodMaxClamp = 1000.0; // TODO: What should this be?
403 GPUCompareFunction compare;
404 [Clamp] unsigned short maxAnisotropy = 1;
407 enum GPUAddressMode {
418 enum GPUMipmapFilterMode {
423 enum GPUCompareFunction {
434 [Func="mozilla::webgpu::Instance::PrefEnabled",
435 Exposed=(Window, DedicatedWorker), SecureContext]
436 interface GPUBindGroupLayout {
438 GPUBindGroupLayout includes GPUObjectBase;
440 dictionary GPUBindGroupLayoutDescriptor
441 : GPUObjectDescriptorBase {
442 required sequence<GPUBindGroupLayoutEntry> entries;
445 dictionary GPUBindGroupLayoutEntry {
446 required GPUIndex32 binding;
447 required GPUShaderStageFlags visibility;
449 GPUBufferBindingLayout buffer;
450 GPUSamplerBindingLayout sampler;
451 GPUTextureBindingLayout texture;
452 GPUStorageTextureBindingLayout storageTexture;
455 typedef [EnforceRange] unsigned long GPUShaderStageFlags;
456 [Func="mozilla::webgpu::Instance::PrefEnabled",
457 Exposed=(Window, DedicatedWorker), SecureContext]
458 namespace GPUShaderStage {
459 const GPUFlagsConstant VERTEX = 0x1;
460 const GPUFlagsConstant FRAGMENT = 0x2;
461 const GPUFlagsConstant COMPUTE = 0x4;
464 enum GPUBufferBindingType {
470 dictionary GPUBufferBindingLayout {
471 GPUBufferBindingType type = "uniform";
472 boolean hasDynamicOffset = false;
473 GPUSize64 minBindingSize = 0;
476 enum GPUSamplerBindingType {
482 dictionary GPUSamplerBindingLayout {
483 GPUSamplerBindingType type = "filtering";
486 enum GPUTextureSampleType {
488 "unfilterable-float",
494 dictionary GPUTextureBindingLayout {
495 GPUTextureSampleType sampleType = "float";
496 GPUTextureViewDimension viewDimension = "2d";
497 boolean multisampled = false;
500 enum GPUStorageTextureAccess {
506 dictionary GPUStorageTextureBindingLayout {
507 GPUStorageTextureAccess access = "write-only";
508 required GPUTextureFormat format;
509 GPUTextureViewDimension viewDimension = "2d";
512 [Func="mozilla::webgpu::Instance::PrefEnabled",
513 Exposed=(Window, DedicatedWorker), SecureContext]
514 interface GPUBindGroup {
516 GPUBindGroup includes GPUObjectBase;
518 dictionary GPUBindGroupDescriptor
519 : GPUObjectDescriptorBase {
520 required GPUBindGroupLayout layout;
521 required sequence<GPUBindGroupEntry> entries;
524 typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
526 dictionary GPUBindGroupEntry {
527 required GPUIndex32 binding;
528 required GPUBindingResource resource;
531 dictionary GPUBufferBinding {
532 required GPUBuffer buffer;
533 GPUSize64 offset = 0;
537 [Func="mozilla::webgpu::Instance::PrefEnabled",
538 Exposed=(Window, DedicatedWorker), SecureContext]
539 interface GPUPipelineLayout {
541 GPUPipelineLayout includes GPUObjectBase;
543 dictionary GPUPipelineLayoutDescriptor
544 : GPUObjectDescriptorBase {
545 required sequence<GPUBindGroupLayout> bindGroupLayouts;
548 [Func="mozilla::webgpu::Instance::PrefEnabled",
549 Exposed=(Window, DedicatedWorker), SecureContext]
550 interface GPUShaderModule {
552 Promise<GPUCompilationInfo> getCompilationInfo();
554 GPUShaderModule includes GPUObjectBase;
556 dictionary GPUShaderModuleDescriptor
557 : GPUObjectDescriptorBase {
558 // UTF8String is not observably different from USVString
559 required UTF8String code;
563 enum GPUCompilationMessageType {
569 [Func="mozilla::webgpu::Instance::PrefEnabled",
570 Exposed=(Window, DedicatedWorker), SecureContext]
571 interface GPUCompilationMessage {
572 readonly attribute DOMString message;
573 readonly attribute GPUCompilationMessageType type;
574 readonly attribute unsigned long long lineNum;
575 readonly attribute unsigned long long linePos;
576 readonly attribute unsigned long long offset;
577 readonly attribute unsigned long long length;
580 [Func="mozilla::webgpu::Instance::PrefEnabled",
581 Exposed=(Window, DedicatedWorker), SecureContext]
582 interface GPUCompilationInfo {
583 [Cached, Frozen, Pure]
584 readonly attribute sequence<GPUCompilationMessage> messages;
587 enum GPUAutoLayoutMode {
591 dictionary GPUPipelineDescriptorBase
592 : GPUObjectDescriptorBase {
593 required (GPUPipelineLayout or GPUAutoLayoutMode) layout;
596 interface mixin GPUPipelineBase {
597 GPUBindGroupLayout getBindGroupLayout(unsigned long index);
600 dictionary GPUProgrammableStage {
601 required GPUShaderModule module;
602 USVString entryPoint;
603 record<USVString, GPUPipelineConstantValue> constants;
606 typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled.
609 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
610 [Func="mozilla::webgpu::Instance::PrefEnabled",
611 Exposed=(Window, DedicatedWorker), SecureContext]
612 interface GPUComputePipeline {
614 GPUComputePipeline includes GPUObjectBase;
615 GPUComputePipeline includes GPUPipelineBase;
617 dictionary GPUComputePipelineDescriptor
618 : GPUPipelineDescriptorBase {
619 required GPUProgrammableStage compute;
623 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
624 [Func="mozilla::webgpu::Instance::PrefEnabled",
625 Exposed=(Window, DedicatedWorker), SecureContext]
626 interface GPURenderPipeline {
628 GPURenderPipeline includes GPUObjectBase;
629 GPURenderPipeline includes GPUPipelineBase;
631 dictionary GPURenderPipelineDescriptor
632 : GPUPipelineDescriptorBase {
633 required GPUVertexState vertex;
634 GPUPrimitiveState primitive = {};
635 GPUDepthStencilState depthStencil;
636 GPUMultisampleState multisample = {};
637 GPUFragmentState fragment;
640 dictionary GPUPrimitiveState {
641 GPUPrimitiveTopology topology = "triangle-list";
642 GPUIndexFormat stripIndexFormat;
643 GPUFrontFace frontFace = "ccw";
644 GPUCullMode cullMode = "none";
646 // Requires "depth-clip-control" feature.
647 boolean unclippedDepth = false;
650 enum GPUPrimitiveTopology {
669 dictionary GPUMultisampleState {
671 GPUSampleMask mask = 0xFFFFFFFF;
672 boolean alphaToCoverageEnabled = false;
675 dictionary GPUFragmentState
676 : GPUProgrammableStage {
677 required sequence<GPUColorTargetState> targets;
680 dictionary GPUColorTargetState {
681 required GPUTextureFormat format;
684 GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL
687 dictionary GPUBlendState {
688 required GPUBlendComponent color;
689 required GPUBlendComponent alpha;
692 typedef [EnforceRange] unsigned long GPUColorWriteFlags;
693 [Func="mozilla::webgpu::Instance::PrefEnabled",
694 Exposed=(Window, DedicatedWorker), SecureContext]
695 namespace GPUColorWrite {
696 const GPUFlagsConstant RED = 0x1;
697 const GPUFlagsConstant GREEN = 0x2;
698 const GPUFlagsConstant BLUE = 0x4;
699 const GPUFlagsConstant ALPHA = 0x8;
700 const GPUFlagsConstant ALL = 0xF;
703 dictionary GPUBlendComponent {
704 GPUBlendOperation operation = "add";
705 GPUBlendFactor srcFactor = "one";
706 GPUBlendFactor dstFactor = "zero";
709 enum GPUBlendFactor {
715 "one-minus-src-alpha",
719 "one-minus-dst-alpha",
720 "src-alpha-saturated",
722 "one-minus-constant",
725 enum GPUBlendOperation {
733 dictionary GPUDepthStencilState {
734 required GPUTextureFormat format;
736 boolean depthWriteEnabled = false;
737 GPUCompareFunction depthCompare = "always";
739 GPUStencilFaceState stencilFront = {};
740 GPUStencilFaceState stencilBack = {};
742 GPUStencilValue stencilReadMask = 0xFFFFFFFF;
743 GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
745 GPUDepthBias depthBias = 0;
746 float depthBiasSlopeScale = 0;
747 float depthBiasClamp = 0;
750 dictionary GPUStencilFaceState {
751 GPUCompareFunction compare = "always";
752 GPUStencilOperation failOp = "keep";
753 GPUStencilOperation depthFailOp = "keep";
754 GPUStencilOperation passOp = "keep";
757 enum GPUStencilOperation {
768 enum GPUIndexFormat {
773 enum GPUVertexFormat {
806 enum GPUVertexStepMode {
811 dictionary GPUVertexState
812 : GPUProgrammableStage {
813 sequence<GPUVertexBufferLayout?> buffers = [];
816 dictionary GPUVertexBufferLayout {
817 required GPUSize64 arrayStride;
818 GPUVertexStepMode stepMode = "vertex";
819 required sequence<GPUVertexAttribute> attributes;
822 dictionary GPUVertexAttribute {
823 required GPUVertexFormat format;
824 required GPUSize64 offset;
826 required GPUIndex32 shaderLocation;
829 dictionary GPUImageDataLayout {
830 GPUSize64 offset = 0;
831 GPUSize32 bytesPerRow;
832 GPUSize32 rowsPerImage;
835 dictionary GPUImageCopyBuffer
836 : GPUImageDataLayout {
837 required GPUBuffer buffer;
840 dictionary GPUImageCopyTexture {
841 required GPUTexture texture;
842 GPUIntegerCoordinate mipLevel = 0;
844 GPUTextureAspect aspect = "all";
847 dictionary GPUImageCopyTextureTagged
848 : GPUImageCopyTexture {
849 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
850 boolean premultipliedAlpha = false;
853 dictionary GPUImageCopyExternalImage {
854 required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
855 GPUOrigin2D origin = {};
856 boolean flipY = false;
859 [Func="mozilla::webgpu::Instance::PrefEnabled",
860 Exposed=(Window, DedicatedWorker), SecureContext]
861 interface GPUCommandBuffer {
863 GPUCommandBuffer includes GPUObjectBase;
865 dictionary GPUCommandBufferDescriptor
866 : GPUObjectDescriptorBase {
869 interface mixin GPUCommandsMixin {
872 [Func="mozilla::webgpu::Instance::PrefEnabled",
873 Exposed=(Window, DedicatedWorker), SecureContext]
874 interface GPUCommandEncoder {
875 GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
876 GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
878 undefined copyBufferToBuffer(
880 GPUSize64 sourceOffset,
881 GPUBuffer destination,
882 GPUSize64 destinationOffset,
885 undefined copyBufferToTexture(
886 GPUImageCopyBuffer source,
887 GPUImageCopyTexture destination,
888 GPUExtent3D copySize);
890 undefined copyTextureToBuffer(
891 GPUImageCopyTexture source,
892 GPUImageCopyBuffer destination,
893 GPUExtent3D copySize);
895 undefined copyTextureToTexture(
896 GPUImageCopyTexture source,
897 GPUImageCopyTexture destination,
898 GPUExtent3D copySize);
900 undefined clearBuffer(
902 optional GPUSize64 offset = 0,
903 optional GPUSize64 size);
905 GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
907 GPUCommandEncoder includes GPUObjectBase;
908 GPUCommandEncoder includes GPUCommandsMixin;
909 GPUCommandEncoder includes GPUDebugCommandsMixin;
911 dictionary GPUCommandEncoderDescriptor
912 : GPUObjectDescriptorBase {
915 interface mixin GPUBindingCommandsMixin {
916 undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
917 optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
920 interface mixin GPUDebugCommandsMixin {
921 undefined pushDebugGroup(USVString groupLabel);
922 undefined popDebugGroup();
923 undefined insertDebugMarker(USVString markerLabel);
926 [Func="mozilla::webgpu::Instance::PrefEnabled",
927 Exposed=(Window, DedicatedWorker), SecureContext]
928 interface GPUComputePassEncoder {
929 undefined setPipeline(GPUComputePipeline pipeline);
930 undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
931 [Pref="dom.webgpu.indirect-dispatch.enabled"]
932 undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
936 GPUComputePassEncoder includes GPUObjectBase;
937 GPUComputePassEncoder includes GPUCommandsMixin;
938 GPUComputePassEncoder includes GPUDebugCommandsMixin;
939 GPUComputePassEncoder includes GPUBindingCommandsMixin;
941 dictionary GPUComputePassDescriptor
942 : GPUObjectDescriptorBase {
945 [Func="mozilla::webgpu::Instance::PrefEnabled",
946 Exposed=(Window, DedicatedWorker), SecureContext]
947 interface GPURenderPassEncoder {
948 undefined setViewport(float x, float y,
949 float width, float height,
950 float minDepth, float maxDepth);
952 undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
953 GPUIntegerCoordinate width, GPUIntegerCoordinate height);
955 undefined setBlendConstant(GPUColor color);
956 undefined setStencilReference(GPUStencilValue reference);
958 //undefined beginOcclusionQuery(GPUSize32 queryIndex);
959 //undefined endOcclusionQuery();
961 undefined executeBundles(sequence<GPURenderBundle> bundles);
964 GPURenderPassEncoder includes GPUObjectBase;
965 GPURenderPassEncoder includes GPUCommandsMixin;
966 GPURenderPassEncoder includes GPUDebugCommandsMixin;
967 GPURenderPassEncoder includes GPUBindingCommandsMixin;
968 GPURenderPassEncoder includes GPURenderCommandsMixin;
970 dictionary GPURenderPassDescriptor
971 : GPUObjectDescriptorBase {
972 required sequence<GPURenderPassColorAttachment> colorAttachments;
973 GPURenderPassDepthStencilAttachment depthStencilAttachment;
974 GPUQuerySet occlusionQuerySet;
977 dictionary GPURenderPassColorAttachment {
978 required GPUTextureView view;
979 GPUTextureView resolveTarget;
982 required GPULoadOp loadOp;
983 required GPUStoreOp storeOp;
986 dictionary GPURenderPassDepthStencilAttachment {
987 required GPUTextureView view;
989 float depthClearValue;
990 GPULoadOp depthLoadOp;
991 GPUStoreOp depthStoreOp;
992 boolean depthReadOnly = false;
994 GPUStencilValue stencilClearValue = 0;
995 GPULoadOp stencilLoadOp;
996 GPUStoreOp stencilStoreOp;
997 boolean stencilReadOnly = false;
1010 dictionary GPURenderPassLayout
1011 : GPUObjectDescriptorBase {
1012 required sequence<GPUTextureFormat> colorFormats;
1013 GPUTextureFormat depthStencilFormat;
1014 GPUSize32 sampleCount = 1;
1017 interface mixin GPURenderCommandsMixin {
1018 undefined setPipeline(GPURenderPipeline pipeline);
1020 undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
1021 undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
1023 undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1,
1024 optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0);
1025 undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1,
1026 optional GPUSize32 firstIndex = 0,
1027 optional GPUSignedOffset32 baseVertex = 0,
1028 optional GPUSize32 firstInstance = 0);
1030 [Pref="dom.webgpu.indirect-dispatch.enabled"]
1031 undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
1032 [Pref="dom.webgpu.indirect-dispatch.enabled"]
1033 undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
1036 [Func="mozilla::webgpu::Instance::PrefEnabled",
1037 Exposed=(Window, DedicatedWorker), SecureContext]
1038 interface GPURenderBundle {
1040 GPURenderBundle includes GPUObjectBase;
1042 dictionary GPURenderBundleDescriptor
1043 : GPUObjectDescriptorBase {
1046 [Func="mozilla::webgpu::Instance::PrefEnabled",
1047 Exposed=(Window, DedicatedWorker), SecureContext]
1048 interface GPURenderBundleEncoder {
1049 GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
1051 GPURenderBundleEncoder includes GPUObjectBase;
1052 GPURenderBundleEncoder includes GPUCommandsMixin;
1053 GPURenderBundleEncoder includes GPUDebugCommandsMixin;
1054 GPURenderBundleEncoder includes GPUBindingCommandsMixin;
1055 GPURenderBundleEncoder includes GPURenderCommandsMixin;
1057 dictionary GPURenderBundleEncoderDescriptor
1058 : GPURenderPassLayout {
1059 boolean depthReadOnly = false;
1060 boolean stencilReadOnly = false;
1063 dictionary GPUQueueDescriptor
1064 : GPUObjectDescriptorBase {
1067 //TODO: use [AllowShared] on BufferSource
1068 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696216
1069 // https://github.com/heycam/webidl/issues/961
1071 [Func="mozilla::webgpu::Instance::PrefEnabled",
1072 Exposed=(Window, DedicatedWorker), SecureContext]
1073 interface GPUQueue {
1074 undefined submit(sequence<GPUCommandBuffer> buffers);
1077 Promise<undefined> onSubmittedWorkDone();
1080 undefined writeBuffer(
1082 GPUSize64 bufferOffset,
1084 optional GPUSize64 dataOffset = 0,
1085 optional GPUSize64 size);
1088 undefined writeTexture(
1089 GPUImageCopyTexture destination,
1091 GPUImageDataLayout dataLayout,
1095 undefined copyExternalImageToTexture(
1096 GPUImageCopyExternalImage source,
1097 GPUImageCopyTextureTagged destination,
1098 GPUExtent3D copySize);
1100 GPUQueue includes GPUObjectBase;
1102 [Func="mozilla::webgpu::Instance::PrefEnabled",
1103 Exposed=(Window, DedicatedWorker), SecureContext]
1104 interface GPUQuerySet {
1105 undefined destroy();
1107 GPUQuerySet includes GPUObjectBase;
1109 dictionary GPUQuerySetDescriptor
1110 : GPUObjectDescriptorBase {
1111 required GPUQueryType type;
1112 required GPUSize32 count;
1113 sequence<GPUPipelineStatisticName> pipelineStatistics = [];
1116 enum GPUPipelineStatisticName {
1117 "vertex-shader-invocations",
1118 "clipper-invocations",
1119 "clipper-primitives-out",
1120 "fragment-shader-invocations",
1121 "compute-shader-invocations"
1126 "pipeline-statistics",
1130 [Func="mozilla::webgpu::Instance::PrefEnabled",
1131 Exposed=(Window, DedicatedWorker), SecureContext]
1132 interface GPUCanvasContext {
1133 readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
1135 undefined configure(GPUCanvasConfiguration configuration);
1136 undefined unconfigure();
1139 GPUTexture getCurrentTexture();
1142 enum GPUCanvasAlphaMode {
1147 dictionary GPUCanvasConfiguration {
1148 required GPUDevice device;
1149 required GPUTextureFormat format;
1150 GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
1151 sequence<GPUTextureFormat> viewFormats = [];
1152 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
1153 GPUCanvasAlphaMode alphaMode = "opaque";
1156 enum GPUDeviceLostReason {
1160 [Func="mozilla::webgpu::Instance::PrefEnabled",
1161 Exposed=(Window, DedicatedWorker), SecureContext]
1162 interface GPUDeviceLostInfo {
1163 readonly attribute any reason; // GPUDeviceLostReason or undefined
1164 readonly attribute DOMString message;
1167 partial interface GPUDevice {
1169 readonly attribute Promise<GPUDeviceLostInfo> lost;
1172 [Func="mozilla::webgpu::Instance::PrefEnabled",
1173 Exposed=(Window, DedicatedWorker), SecureContext]
1174 interface GPUError {
1175 readonly attribute DOMString message;
1178 [Func="mozilla::webgpu::Instance::PrefEnabled",
1179 Exposed=(Window, DedicatedWorker), SecureContext]
1180 interface GPUValidationError
1183 constructor(DOMString message);
1186 [Func="mozilla::webgpu::Instance::PrefEnabled",
1187 Exposed=(Window, DedicatedWorker), SecureContext]
1188 interface GPUOutOfMemoryError
1191 constructor(DOMString message);
1194 [Func="mozilla::webgpu::Instance::PrefEnabled",
1195 Exposed=(Window, DedicatedWorker), SecureContext]
1196 interface GPUInternalError
1199 constructor(DOMString message);
1202 enum GPUErrorFilter {
1208 partial interface GPUDevice {
1209 undefined pushErrorScope(GPUErrorFilter filter);
1211 Promise<GPUError?> popErrorScope();
1214 partial interface GPUDevice {
1215 [Exposed=(Window, DedicatedWorker)]
1216 attribute EventHandler onuncapturederror;
1219 typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
1220 typedef [EnforceRange] unsigned long GPUStencilValue;
1221 typedef [EnforceRange] unsigned long GPUSampleMask;
1222 typedef [EnforceRange] long GPUDepthBias;
1224 typedef [EnforceRange] unsigned long long GPUSize64;
1225 typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
1226 typedef [EnforceRange] unsigned long GPUIndex32;
1227 typedef [EnforceRange] unsigned long GPUSize32;
1228 typedef [EnforceRange] long GPUSignedOffset32;
1230 typedef unsigned long long GPUSize64Out;
1231 typedef unsigned long GPUIntegerCoordinateOut;
1232 typedef unsigned long GPUSize32Out;
1234 typedef unsigned long GPUFlagsConstant;
1236 dictionary GPUColorDict {
1242 typedef (sequence<double> or GPUColorDict) GPUColor;
1244 dictionary GPUOrigin2DDict {
1245 GPUIntegerCoordinate x = 0;
1246 GPUIntegerCoordinate y = 0;
1248 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
1250 dictionary GPUOrigin3DDict {
1251 GPUIntegerCoordinate x = 0;
1252 GPUIntegerCoordinate y = 0;
1253 GPUIntegerCoordinate z = 0;
1255 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
1257 dictionary GPUExtent3DDict {
1258 required GPUIntegerCoordinate width;
1259 GPUIntegerCoordinate height = 1;
1260 GPUIntegerCoordinate depthOrArrayLayers = 1;
1262 typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;