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);
160 GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
161 GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
162 GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
164 Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor);
166 Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor);
168 GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
169 GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
171 //GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
173 GPUDevice includes GPUObjectBase;
175 [Func="mozilla::webgpu::Instance::PrefEnabled",
176 Exposed=(Window, DedicatedWorker), SecureContext]
177 interface GPUBuffer {
178 readonly attribute GPUSize64Out size;
179 readonly attribute GPUFlagsConstant usage;
181 readonly attribute GPUBufferMapState mapState;
184 Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
186 ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
193 GPUBuffer includes GPUObjectBase;
195 enum GPUBufferMapState {
201 dictionary GPUBufferDescriptor
202 : GPUObjectDescriptorBase {
203 required GPUSize64 size;
204 required GPUBufferUsageFlags usage;
205 boolean mappedAtCreation = false;
208 typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
209 [Func="mozilla::webgpu::Instance::PrefEnabled",
210 Exposed=(Window, DedicatedWorker), SecureContext]
211 interface GPUBufferUsage {
212 const GPUFlagsConstant MAP_READ = 0x0001;
213 const GPUFlagsConstant MAP_WRITE = 0x0002;
214 const GPUFlagsConstant COPY_SRC = 0x0004;
215 const GPUFlagsConstant COPY_DST = 0x0008;
216 const GPUFlagsConstant INDEX = 0x0010;
217 const GPUFlagsConstant VERTEX = 0x0020;
218 const GPUFlagsConstant UNIFORM = 0x0040;
219 const GPUFlagsConstant STORAGE = 0x0080;
220 const GPUFlagsConstant INDIRECT = 0x0100;
221 const GPUFlagsConstant QUERY_RESOLVE = 0x0200;
224 typedef [EnforceRange] unsigned long GPUMapModeFlags;
225 [Func="mozilla::webgpu::Instance::PrefEnabled",
226 Exposed=(Window, DedicatedWorker), SecureContext]
227 interface GPUMapMode {
228 const GPUFlagsConstant READ = 0x0001;
229 const GPUFlagsConstant WRITE = 0x0002;
232 [Func="mozilla::webgpu::Instance::PrefEnabled",
233 Exposed=(Window, DedicatedWorker), SecureContext]
234 interface GPUTexture {
235 GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
239 readonly attribute GPUIntegerCoordinateOut width;
240 readonly attribute GPUIntegerCoordinateOut height;
241 readonly attribute GPUIntegerCoordinateOut depthOrArrayLayers;
242 readonly attribute GPUIntegerCoordinateOut mipLevelCount;
243 readonly attribute GPUSize32Out sampleCount;
244 readonly attribute GPUTextureDimension dimension;
245 readonly attribute GPUTextureFormat format;
246 readonly attribute GPUFlagsConstant usage;
248 GPUTexture includes GPUObjectBase;
250 dictionary GPUTextureDescriptor
251 : GPUObjectDescriptorBase {
252 required GPUExtent3D size;
253 GPUIntegerCoordinate mipLevelCount = 1;
254 GPUSize32 sampleCount = 1;
255 GPUTextureDimension dimension = "2d";
256 required GPUTextureFormat format;
257 required GPUTextureUsageFlags usage;
258 sequence<GPUTextureFormat> viewFormats = [];
261 enum GPUTextureDimension {
267 typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
268 [Func="mozilla::webgpu::Instance::PrefEnabled",
269 Exposed=(Window, DedicatedWorker), SecureContext]
270 interface GPUTextureUsage {
271 const GPUFlagsConstant COPY_SRC = 0x01;
272 const GPUFlagsConstant COPY_DST = 0x02;
273 const GPUFlagsConstant TEXTURE_BINDING = 0x04;
274 const GPUFlagsConstant STORAGE_BINDING = 0x08;
275 const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
278 [Func="mozilla::webgpu::Instance::PrefEnabled",
279 Exposed=(Window, DedicatedWorker), SecureContext]
280 interface GPUTextureView {
282 GPUTextureView includes GPUObjectBase;
284 dictionary GPUTextureViewDescriptor
285 : GPUObjectDescriptorBase {
286 GPUTextureFormat format;
287 GPUTextureViewDimension dimension;
288 GPUTextureAspect aspect = "all";
289 GPUIntegerCoordinate baseMipLevel = 0;
290 GPUIntegerCoordinate mipLevelCount;
291 GPUIntegerCoordinate baseArrayLayer = 0;
292 GPUIntegerCoordinate arrayLayerCount;
295 enum GPUTextureViewDimension {
304 enum GPUTextureAspect {
310 enum GPUTextureFormat {
340 // Packed 32-bit formats
358 // Depth/stencil formats
362 "depth24plus-stencil8",
365 // "depth32float-stencil8" feature
366 "depth32float-stencil8",
368 // BC compressed formats usable if "texture-compression-bc" is both
369 // supported by the device/user agent and enabled in requestDevice.
371 "bc1-rgba-unorm-srgb",
373 "bc2-rgba-unorm-srgb",
375 "bc3-rgba-unorm-srgb",
383 "bc7-rgba-unorm-srgb",
386 [Func="mozilla::webgpu::Instance::PrefEnabled",
387 Exposed=(Window, DedicatedWorker), SecureContext]
388 interface GPUSampler {
390 GPUSampler includes GPUObjectBase;
392 dictionary GPUSamplerDescriptor
393 : GPUObjectDescriptorBase {
394 GPUAddressMode addressModeU = "clamp-to-edge";
395 GPUAddressMode addressModeV = "clamp-to-edge";
396 GPUAddressMode addressModeW = "clamp-to-edge";
397 GPUFilterMode magFilter = "nearest";
398 GPUFilterMode minFilter = "nearest";
399 GPUMipmapFilterMode mipmapFilter = "nearest";
400 float lodMinClamp = 0;
401 float lodMaxClamp = 1000.0; // TODO: What should this be?
402 GPUCompareFunction compare;
403 [Clamp] unsigned short maxAnisotropy = 1;
406 enum GPUAddressMode {
417 enum GPUMipmapFilterMode {
422 enum GPUCompareFunction {
433 [Func="mozilla::webgpu::Instance::PrefEnabled",
434 Exposed=(Window, DedicatedWorker), SecureContext]
435 interface GPUBindGroupLayout {
437 GPUBindGroupLayout includes GPUObjectBase;
439 dictionary GPUBindGroupLayoutDescriptor
440 : GPUObjectDescriptorBase {
441 required sequence<GPUBindGroupLayoutEntry> entries;
444 dictionary GPUBindGroupLayoutEntry {
445 required GPUIndex32 binding;
446 required GPUShaderStageFlags visibility;
448 GPUBufferBindingLayout buffer;
449 GPUSamplerBindingLayout sampler;
450 GPUTextureBindingLayout texture;
451 GPUStorageTextureBindingLayout storageTexture;
454 typedef [EnforceRange] unsigned long GPUShaderStageFlags;
455 [Func="mozilla::webgpu::Instance::PrefEnabled",
456 Exposed=(Window, DedicatedWorker), SecureContext]
457 interface GPUShaderStage {
458 const GPUFlagsConstant VERTEX = 0x1;
459 const GPUFlagsConstant FRAGMENT = 0x2;
460 const GPUFlagsConstant COMPUTE = 0x4;
463 enum GPUBufferBindingType {
469 dictionary GPUBufferBindingLayout {
470 GPUBufferBindingType type = "uniform";
471 boolean hasDynamicOffset = false;
472 GPUSize64 minBindingSize = 0;
475 enum GPUSamplerBindingType {
481 dictionary GPUSamplerBindingLayout {
482 GPUSamplerBindingType type = "filtering";
485 enum GPUTextureSampleType {
487 "unfilterable-float",
493 dictionary GPUTextureBindingLayout {
494 GPUTextureSampleType sampleType = "float";
495 GPUTextureViewDimension viewDimension = "2d";
496 boolean multisampled = false;
499 enum GPUStorageTextureAccess {
503 dictionary GPUStorageTextureBindingLayout {
504 GPUStorageTextureAccess access = "write-only";
505 required GPUTextureFormat format;
506 GPUTextureViewDimension viewDimension = "2d";
509 [Func="mozilla::webgpu::Instance::PrefEnabled",
510 Exposed=(Window, DedicatedWorker), SecureContext]
511 interface GPUBindGroup {
513 GPUBindGroup includes GPUObjectBase;
515 dictionary GPUBindGroupDescriptor
516 : GPUObjectDescriptorBase {
517 required GPUBindGroupLayout layout;
518 required sequence<GPUBindGroupEntry> entries;
521 typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
523 dictionary GPUBindGroupEntry {
524 required GPUIndex32 binding;
525 required GPUBindingResource resource;
528 dictionary GPUBufferBinding {
529 required GPUBuffer buffer;
530 GPUSize64 offset = 0;
534 [Func="mozilla::webgpu::Instance::PrefEnabled",
535 Exposed=(Window, DedicatedWorker), SecureContext]
536 interface GPUPipelineLayout {
538 GPUPipelineLayout includes GPUObjectBase;
540 dictionary GPUPipelineLayoutDescriptor
541 : GPUObjectDescriptorBase {
542 required sequence<GPUBindGroupLayout> bindGroupLayouts;
545 [Func="mozilla::webgpu::Instance::PrefEnabled",
546 Exposed=(Window, DedicatedWorker), SecureContext]
547 interface GPUShaderModule {
549 Promise<GPUCompilationInfo> compilationInfo(); // To be removed with <https://bugzilla.mozilla.org/show_bug.cgi?id=1846892>
551 Promise<GPUCompilationInfo> getCompilationInfo();
553 GPUShaderModule includes GPUObjectBase;
555 dictionary GPUShaderModuleDescriptor
556 : GPUObjectDescriptorBase {
557 // UTF8String is not observably different from USVString
558 required UTF8String code;
562 enum GPUCompilationMessageType {
568 [Func="mozilla::webgpu::Instance::PrefEnabled",
569 Exposed=(Window, DedicatedWorker), SecureContext]
570 interface GPUCompilationMessage {
571 readonly attribute DOMString message;
572 readonly attribute GPUCompilationMessageType type;
573 readonly attribute unsigned long long lineNum;
574 readonly attribute unsigned long long linePos;
575 readonly attribute unsigned long long offset;
576 readonly attribute unsigned long long length;
579 [Func="mozilla::webgpu::Instance::PrefEnabled",
580 Exposed=(Window, DedicatedWorker), SecureContext]
581 interface GPUCompilationInfo {
582 [Cached, Frozen, Pure]
583 readonly attribute sequence<GPUCompilationMessage> messages;
586 enum GPUAutoLayoutMode {
590 dictionary GPUPipelineDescriptorBase
591 : GPUObjectDescriptorBase {
592 required (GPUPipelineLayout or GPUAutoLayoutMode) layout;
595 interface mixin GPUPipelineBase {
596 GPUBindGroupLayout getBindGroupLayout(unsigned long index);
599 dictionary GPUProgrammableStage {
600 required GPUShaderModule module;
601 required USVString entryPoint;
605 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
606 [Func="mozilla::webgpu::Instance::PrefEnabled",
607 Exposed=(Window, DedicatedWorker), SecureContext]
608 interface GPUComputePipeline {
610 GPUComputePipeline includes GPUObjectBase;
611 GPUComputePipeline includes GPUPipelineBase;
613 dictionary GPUComputePipelineDescriptor
614 : GPUPipelineDescriptorBase {
615 required GPUProgrammableStage compute;
619 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
620 [Func="mozilla::webgpu::Instance::PrefEnabled",
621 Exposed=(Window, DedicatedWorker), SecureContext]
622 interface GPURenderPipeline {
624 GPURenderPipeline includes GPUObjectBase;
625 GPURenderPipeline includes GPUPipelineBase;
627 dictionary GPURenderPipelineDescriptor
628 : GPUPipelineDescriptorBase {
629 required GPUVertexState vertex;
630 GPUPrimitiveState primitive = {};
631 GPUDepthStencilState depthStencil;
632 GPUMultisampleState multisample = {};
633 GPUFragmentState fragment;
636 dictionary GPUPrimitiveState {
637 GPUPrimitiveTopology topology = "triangle-list";
638 GPUIndexFormat stripIndexFormat;
639 GPUFrontFace frontFace = "ccw";
640 GPUCullMode cullMode = "none";
642 // Requires "depth-clip-control" feature.
643 boolean unclippedDepth = false;
646 enum GPUPrimitiveTopology {
665 dictionary GPUMultisampleState {
667 GPUSampleMask mask = 0xFFFFFFFF;
668 boolean alphaToCoverageEnabled = false;
671 dictionary GPUFragmentState
672 : GPUProgrammableStage {
673 required sequence<GPUColorTargetState> targets;
676 dictionary GPUColorTargetState {
677 required GPUTextureFormat format;
680 GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL
683 dictionary GPUBlendState {
684 required GPUBlendComponent color;
685 required GPUBlendComponent alpha;
688 typedef [EnforceRange] unsigned long GPUColorWriteFlags;
689 [Func="mozilla::webgpu::Instance::PrefEnabled",
690 Exposed=(Window, DedicatedWorker), SecureContext]
691 interface GPUColorWrite {
692 const GPUFlagsConstant RED = 0x1;
693 const GPUFlagsConstant GREEN = 0x2;
694 const GPUFlagsConstant BLUE = 0x4;
695 const GPUFlagsConstant ALPHA = 0x8;
696 const GPUFlagsConstant ALL = 0xF;
699 dictionary GPUBlendComponent {
700 GPUBlendOperation operation = "add";
701 GPUBlendFactor srcFactor = "one";
702 GPUBlendFactor dstFactor = "zero";
705 enum GPUBlendFactor {
711 "one-minus-src-alpha",
715 "one-minus-dst-alpha",
716 "src-alpha-saturated",
718 "one-minus-constant",
721 enum GPUBlendOperation {
729 dictionary GPUDepthStencilState {
730 required GPUTextureFormat format;
732 boolean depthWriteEnabled = false;
733 GPUCompareFunction depthCompare = "always";
735 GPUStencilFaceState stencilFront = {};
736 GPUStencilFaceState stencilBack = {};
738 GPUStencilValue stencilReadMask = 0xFFFFFFFF;
739 GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
741 GPUDepthBias depthBias = 0;
742 float depthBiasSlopeScale = 0;
743 float depthBiasClamp = 0;
746 dictionary GPUStencilFaceState {
747 GPUCompareFunction compare = "always";
748 GPUStencilOperation failOp = "keep";
749 GPUStencilOperation depthFailOp = "keep";
750 GPUStencilOperation passOp = "keep";
753 enum GPUStencilOperation {
764 enum GPUIndexFormat {
769 enum GPUVertexFormat {
802 enum GPUVertexStepMode {
807 dictionary GPUVertexState
808 : GPUProgrammableStage {
809 sequence<GPUVertexBufferLayout?> buffers = [];
812 dictionary GPUVertexBufferLayout {
813 required GPUSize64 arrayStride;
814 GPUVertexStepMode stepMode = "vertex";
815 required sequence<GPUVertexAttribute> attributes;
818 dictionary GPUVertexAttribute {
819 required GPUVertexFormat format;
820 required GPUSize64 offset;
822 required GPUIndex32 shaderLocation;
825 dictionary GPUImageDataLayout {
826 GPUSize64 offset = 0;
827 GPUSize32 bytesPerRow;
828 GPUSize32 rowsPerImage;
831 dictionary GPUImageCopyBuffer
832 : GPUImageDataLayout {
833 required GPUBuffer buffer;
836 dictionary GPUImageCopyTexture {
837 required GPUTexture texture;
838 GPUIntegerCoordinate mipLevel = 0;
840 GPUTextureAspect aspect = "all";
843 dictionary GPUImageCopyTextureTagged
844 : GPUImageCopyTexture {
845 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
846 boolean premultipliedAlpha = false;
849 dictionary GPUImageCopyExternalImage {
850 required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
851 GPUOrigin2D origin = {};
852 boolean flipY = false;
855 [Func="mozilla::webgpu::Instance::PrefEnabled",
856 Exposed=(Window, DedicatedWorker), SecureContext]
857 interface GPUCommandBuffer {
859 GPUCommandBuffer includes GPUObjectBase;
861 dictionary GPUCommandBufferDescriptor
862 : GPUObjectDescriptorBase {
865 interface mixin GPUCommandsMixin {
868 [Func="mozilla::webgpu::Instance::PrefEnabled",
869 Exposed=(Window, DedicatedWorker), SecureContext]
870 interface GPUCommandEncoder {
871 GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
872 GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
874 undefined copyBufferToBuffer(
876 GPUSize64 sourceOffset,
877 GPUBuffer destination,
878 GPUSize64 destinationOffset,
881 undefined copyBufferToTexture(
882 GPUImageCopyBuffer source,
883 GPUImageCopyTexture destination,
884 GPUExtent3D copySize);
886 undefined copyTextureToBuffer(
887 GPUImageCopyTexture source,
888 GPUImageCopyBuffer destination,
889 GPUExtent3D copySize);
891 undefined copyTextureToTexture(
892 GPUImageCopyTexture source,
893 GPUImageCopyTexture destination,
894 GPUExtent3D copySize);
896 GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
898 GPUCommandEncoder includes GPUObjectBase;
899 GPUCommandEncoder includes GPUCommandsMixin;
900 GPUCommandEncoder includes GPUDebugCommandsMixin;
902 dictionary GPUCommandEncoderDescriptor
903 : GPUObjectDescriptorBase {
906 interface mixin GPUBindingCommandsMixin {
907 undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
908 optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
911 interface mixin GPUDebugCommandsMixin {
912 undefined pushDebugGroup(USVString groupLabel);
913 undefined popDebugGroup();
914 undefined insertDebugMarker(USVString markerLabel);
917 [Func="mozilla::webgpu::Instance::PrefEnabled",
918 Exposed=(Window, DedicatedWorker), SecureContext]
919 interface GPUComputePassEncoder {
920 undefined setPipeline(GPUComputePipeline pipeline);
921 undefined dispatchWorkgroups(GPUSize32 workgroupCountX, optional GPUSize32 workgroupCountY = 1, optional GPUSize32 workgroupCountZ = 1);
922 [Pref="dom.webgpu.indirect-dispatch.enabled"]
923 undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
928 GPUComputePassEncoder includes GPUObjectBase;
929 GPUComputePassEncoder includes GPUCommandsMixin;
930 GPUComputePassEncoder includes GPUDebugCommandsMixin;
931 GPUComputePassEncoder includes GPUBindingCommandsMixin;
933 dictionary GPUComputePassDescriptor
934 : GPUObjectDescriptorBase {
937 [Func="mozilla::webgpu::Instance::PrefEnabled",
938 Exposed=(Window, DedicatedWorker), SecureContext]
939 interface GPURenderPassEncoder {
940 undefined setViewport(float x, float y,
941 float width, float height,
942 float minDepth, float maxDepth);
944 undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
945 GPUIntegerCoordinate width, GPUIntegerCoordinate height);
947 undefined setBlendConstant(GPUColor color);
948 undefined setStencilReference(GPUStencilValue reference);
950 //undefined beginOcclusionQuery(GPUSize32 queryIndex);
951 //undefined endOcclusionQuery();
953 undefined executeBundles(sequence<GPURenderBundle> bundles);
957 GPURenderPassEncoder includes GPUObjectBase;
958 GPURenderPassEncoder includes GPUCommandsMixin;
959 GPURenderPassEncoder includes GPUDebugCommandsMixin;
960 GPURenderPassEncoder includes GPUBindingCommandsMixin;
961 GPURenderPassEncoder includes GPURenderCommandsMixin;
963 dictionary GPURenderPassDescriptor
964 : GPUObjectDescriptorBase {
965 required sequence<GPURenderPassColorAttachment> colorAttachments;
966 GPURenderPassDepthStencilAttachment depthStencilAttachment;
967 GPUQuerySet occlusionQuerySet;
970 dictionary GPURenderPassColorAttachment {
971 required GPUTextureView view;
972 GPUTextureView resolveTarget;
975 required GPULoadOp loadOp;
976 required GPUStoreOp storeOp;
979 dictionary GPURenderPassDepthStencilAttachment {
980 required GPUTextureView view;
982 float depthClearValue;
983 GPULoadOp depthLoadOp;
984 GPUStoreOp depthStoreOp;
985 boolean depthReadOnly = false;
987 GPUStencilValue stencilClearValue = 0;
988 GPULoadOp stencilLoadOp;
989 GPUStoreOp stencilStoreOp;
990 boolean stencilReadOnly = false;
1003 dictionary GPURenderPassLayout
1004 : GPUObjectDescriptorBase {
1005 required sequence<GPUTextureFormat> colorFormats;
1006 GPUTextureFormat depthStencilFormat;
1007 GPUSize32 sampleCount = 1;
1010 interface mixin GPURenderCommandsMixin {
1011 undefined setPipeline(GPURenderPipeline pipeline);
1013 undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
1014 undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
1016 undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1,
1017 optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0);
1018 undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1,
1019 optional GPUSize32 firstIndex = 0,
1020 optional GPUSignedOffset32 baseVertex = 0,
1021 optional GPUSize32 firstInstance = 0);
1023 [Pref="dom.webgpu.indirect-dispatch.enabled"]
1024 undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
1025 [Pref="dom.webgpu.indirect-dispatch.enabled"]
1026 undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
1029 [Func="mozilla::webgpu::Instance::PrefEnabled",
1030 Exposed=(Window, DedicatedWorker), SecureContext]
1031 interface GPURenderBundle {
1033 GPURenderBundle includes GPUObjectBase;
1035 dictionary GPURenderBundleDescriptor
1036 : GPUObjectDescriptorBase {
1039 [Func="mozilla::webgpu::Instance::PrefEnabled",
1040 Exposed=(Window, DedicatedWorker), SecureContext]
1041 interface GPURenderBundleEncoder {
1042 GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
1044 GPURenderBundleEncoder includes GPUObjectBase;
1045 GPURenderBundleEncoder includes GPUCommandsMixin;
1046 GPURenderBundleEncoder includes GPUDebugCommandsMixin;
1047 GPURenderBundleEncoder includes GPUBindingCommandsMixin;
1048 GPURenderBundleEncoder includes GPURenderCommandsMixin;
1050 dictionary GPURenderBundleEncoderDescriptor
1051 : GPURenderPassLayout {
1052 boolean depthReadOnly = false;
1053 boolean stencilReadOnly = false;
1056 dictionary GPUQueueDescriptor
1057 : GPUObjectDescriptorBase {
1060 //TODO: use [AllowShared] on BufferSource
1061 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696216
1062 // https://github.com/heycam/webidl/issues/961
1064 [Func="mozilla::webgpu::Instance::PrefEnabled",
1065 Exposed=(Window, DedicatedWorker), SecureContext]
1066 interface GPUQueue {
1067 undefined submit(sequence<GPUCommandBuffer> buffers);
1070 Promise<undefined> onSubmittedWorkDone();
1073 undefined writeBuffer(
1075 GPUSize64 bufferOffset,
1077 optional GPUSize64 dataOffset = 0,
1078 optional GPUSize64 size);
1081 undefined writeTexture(
1082 GPUImageCopyTexture destination,
1084 GPUImageDataLayout dataLayout,
1088 undefined copyExternalImageToTexture(
1089 GPUImageCopyExternalImage source,
1090 GPUImageCopyTextureTagged destination,
1091 GPUExtent3D copySize);
1093 GPUQueue includes GPUObjectBase;
1095 [Func="mozilla::webgpu::Instance::PrefEnabled",
1096 Exposed=(Window, DedicatedWorker), SecureContext]
1097 interface GPUQuerySet {
1098 undefined destroy();
1100 GPUQuerySet includes GPUObjectBase;
1102 dictionary GPUQuerySetDescriptor
1103 : GPUObjectDescriptorBase {
1104 required GPUQueryType type;
1105 required GPUSize32 count;
1106 sequence<GPUPipelineStatisticName> pipelineStatistics = [];
1109 enum GPUPipelineStatisticName {
1110 "vertex-shader-invocations",
1111 "clipper-invocations",
1112 "clipper-primitives-out",
1113 "fragment-shader-invocations",
1114 "compute-shader-invocations"
1119 "pipeline-statistics",
1123 [Func="mozilla::webgpu::Instance::PrefEnabled",
1124 Exposed=(Window, DedicatedWorker), SecureContext]
1125 interface GPUCanvasContext {
1126 readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
1128 undefined configure(GPUCanvasConfiguration configuration);
1129 undefined unconfigure();
1132 GPUTexture getCurrentTexture();
1135 enum GPUCanvasAlphaMode {
1140 dictionary GPUCanvasConfiguration {
1141 required GPUDevice device;
1142 required GPUTextureFormat format;
1143 GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
1144 sequence<GPUTextureFormat> viewFormats = [];
1145 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
1146 GPUCanvasAlphaMode alphaMode = "opaque";
1149 enum GPUDeviceLostReason {
1153 [Func="mozilla::webgpu::Instance::PrefEnabled",
1154 Exposed=(Window, DedicatedWorker), SecureContext]
1155 interface GPUDeviceLostInfo {
1156 readonly attribute any reason; // GPUDeviceLostReason or undefined
1157 readonly attribute DOMString message;
1160 partial interface GPUDevice {
1162 readonly attribute Promise<GPUDeviceLostInfo> lost;
1165 [Func="mozilla::webgpu::Instance::PrefEnabled",
1166 Exposed=(Window, DedicatedWorker), SecureContext]
1167 interface GPUError {
1168 readonly attribute DOMString message;
1171 [Func="mozilla::webgpu::Instance::PrefEnabled",
1172 Exposed=(Window, DedicatedWorker), SecureContext]
1173 interface GPUValidationError
1176 constructor(DOMString message);
1179 [Func="mozilla::webgpu::Instance::PrefEnabled",
1180 Exposed=(Window, DedicatedWorker), SecureContext]
1181 interface GPUOutOfMemoryError
1184 constructor(DOMString message);
1187 [Func="mozilla::webgpu::Instance::PrefEnabled",
1188 Exposed=(Window, DedicatedWorker), SecureContext]
1189 interface GPUInternalError
1192 constructor(DOMString message);
1195 enum GPUErrorFilter {
1201 partial interface GPUDevice {
1202 undefined pushErrorScope(GPUErrorFilter filter);
1204 Promise<GPUError?> popErrorScope();
1207 partial interface GPUDevice {
1208 [Exposed=(Window, DedicatedWorker)]
1209 attribute EventHandler onuncapturederror;
1212 typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
1213 typedef [EnforceRange] unsigned long GPUStencilValue;
1214 typedef [EnforceRange] unsigned long GPUSampleMask;
1215 typedef [EnforceRange] long GPUDepthBias;
1217 typedef [EnforceRange] unsigned long long GPUSize64;
1218 typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
1219 typedef [EnforceRange] unsigned long GPUIndex32;
1220 typedef [EnforceRange] unsigned long GPUSize32;
1221 typedef [EnforceRange] long GPUSignedOffset32;
1223 typedef unsigned long long GPUSize64Out;
1224 typedef unsigned long GPUIntegerCoordinateOut;
1225 typedef unsigned long GPUSize32Out;
1227 typedef unsigned long GPUFlagsConstant;
1229 dictionary GPUColorDict {
1235 typedef (sequence<double> or GPUColorDict) GPUColor;
1237 dictionary GPUOrigin2DDict {
1238 GPUIntegerCoordinate x = 0;
1239 GPUIntegerCoordinate y = 0;
1241 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
1243 dictionary GPUOrigin3DDict {
1244 GPUIntegerCoordinate x = 0;
1245 GPUIntegerCoordinate y = 0;
1246 GPUIntegerCoordinate z = 0;
1248 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
1250 dictionary GPUExtent3DDict {
1251 required GPUIntegerCoordinate width;
1252 GPUIntegerCoordinate height = 1;
1253 GPUIntegerCoordinate depthOrArrayLayers = 1;
1255 typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;