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 [Pref="dom.webgpu.enabled",
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 maxDynamicUniformBuffersPerPipelineLayout;
27 readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
28 readonly attribute unsigned long maxSampledTexturesPerShaderStage;
29 readonly attribute unsigned long maxSamplersPerShaderStage;
30 readonly attribute unsigned long maxStorageBuffersPerShaderStage;
31 readonly attribute unsigned long maxStorageTexturesPerShaderStage;
32 readonly attribute unsigned long maxUniformBuffersPerShaderStage;
33 readonly attribute unsigned long maxUniformBufferBindingSize;
34 readonly attribute unsigned long maxStorageBufferBindingSize;
35 readonly attribute unsigned long minUniformBufferOffsetAlignment;
36 readonly attribute unsigned long minStorageBufferOffsetAlignment;
37 readonly attribute unsigned long maxVertexBuffers;
38 readonly attribute unsigned long maxVertexAttributes;
39 readonly attribute unsigned long maxVertexBufferArrayStride;
40 readonly attribute unsigned long maxInterStageShaderComponents;
41 readonly attribute unsigned long maxComputeWorkgroupStorageSize;
42 readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
43 readonly attribute unsigned long maxComputeWorkgroupSizeX;
44 readonly attribute unsigned long maxComputeWorkgroupSizeY;
45 readonly attribute unsigned long maxComputeWorkgroupSizeZ;
46 readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
49 [Pref="dom.webgpu.enabled",
50 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
51 interface GPUSupportedFeatures {
52 readonly setlike<DOMString>;
55 // ****************************************************************************
57 // ****************************************************************************
60 Pref="dom.webgpu.enabled",
61 Exposed=(Window /* ,DedicatedWorker */), SecureContext
64 // May reject with DOMException
66 Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
67 GPUTextureFormat getPreferredCanvasFormat();
70 // Add a "webgpu" member to Navigator/Worker that contains the global instance of a "WebGPU"
71 interface mixin GPUProvider {
72 [SameObject, Replaceable, Pref="dom.webgpu.enabled", Exposed=(Window /* ,DedicatedWorker */), SecureContext] readonly attribute GPU gpu;
75 dictionary GPURequestAdapterOptions {
76 GPUPowerPreference powerPreference;
77 boolean forceFallbackAdapter = false;
80 enum GPUPowerPreference {
85 [Pref="dom.webgpu.enabled",
86 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
87 interface GPUAdapterInfo {
88 readonly attribute DOMString vendor;
89 readonly attribute DOMString architecture;
90 readonly attribute DOMString device;
91 readonly attribute DOMString description;
94 [Pref="dom.webgpu.enabled",
95 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
96 interface GPUAdapter {
97 [SameObject] readonly attribute GPUSupportedFeatures features;
98 [SameObject] readonly attribute GPUSupportedLimits limits;
99 readonly attribute boolean isFallbackAdapter;
102 Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
104 Promise<GPUAdapterInfo> requestAdapterInfo(optional sequence<DOMString> unmaskHints = []);
107 dictionary GPUDeviceDescriptor {
108 sequence<GPUFeatureName> requiredFeatures = [];
109 record<DOMString, GPUSize64> requiredLimits;
112 enum GPUFeatureName {
113 "depth-clip-control",
114 "depth24unorm-stencil8",
115 "depth32float-stencil8",
116 "pipeline-statistics-query",
117 "texture-compression-bc",
118 "texture-compression-etc2",
119 "texture-compression-astc",
121 "indirect-first-instance",
125 [Pref="dom.webgpu.enabled",
126 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
127 interface GPUDevice: EventTarget {
128 [SameObject] readonly attribute GPUSupportedFeatures features;
129 [SameObject] readonly attribute GPUSupportedLimits limits;
131 // Overriding the name to avoid collision with `class Queue` in gcc
132 [SameObject, BinaryName="getQueue"] readonly attribute GPUQueue queue;
137 GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
139 GPUTexture createTexture(GPUTextureDescriptor descriptor);
141 GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
143 GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
144 GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor);
145 GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor);
147 GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
148 GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
149 GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
152 Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor);
154 Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor);
157 GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
159 GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
161 //GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
163 GPUDevice includes GPUObjectBase;
166 [Pref="dom.webgpu.enabled",
167 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
168 interface GPUBuffer {
170 Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
172 ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
178 GPUBuffer includes GPUObjectBase;
180 dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
181 required GPUSize64 size;
182 required GPUBufferUsageFlags usage;
183 boolean mappedAtCreation = false;
186 typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
187 [Pref="dom.webgpu.enabled",
188 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
189 interface GPUBufferUsage {
190 const GPUBufferUsageFlags MAP_READ = 0x0001;
191 const GPUBufferUsageFlags MAP_WRITE = 0x0002;
192 const GPUBufferUsageFlags COPY_SRC = 0x0004;
193 const GPUBufferUsageFlags COPY_DST = 0x0008;
194 const GPUBufferUsageFlags INDEX = 0x0010;
195 const GPUBufferUsageFlags VERTEX = 0x0020;
196 const GPUBufferUsageFlags UNIFORM = 0x0040;
197 const GPUBufferUsageFlags STORAGE = 0x0080;
198 const GPUBufferUsageFlags INDIRECT = 0x0100;
199 const GPUBufferUsageFlags QUERY_RESOLVE = 0x0200;
202 typedef [EnforceRange] unsigned long GPUMapModeFlags;
204 [Pref="dom.webgpu.enabled",
205 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
208 const GPUMapModeFlags READ = 0x0001;
209 const GPUMapModeFlags WRITE = 0x0002;
212 typedef sequence<any> GPUMappedBuffer;
216 [Pref="dom.webgpu.enabled",
217 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
218 interface GPUTexture {
220 GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
224 GPUTexture includes GPUObjectBase;
226 dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
227 required GPUExtent3D size;
228 GPUIntegerCoordinate mipLevelCount = 1;
229 GPUSize32 sampleCount = 1;
230 GPUTextureDimension dimension = "2d";
231 required GPUTextureFormat format;
232 required GPUTextureUsageFlags usage;
235 enum GPUTextureDimension {
241 typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
242 [Pref="dom.webgpu.enabled",
243 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
244 interface GPUTextureUsage {
245 const GPUTextureUsageFlags COPY_SRC = 0x01;
246 const GPUTextureUsageFlags COPY_DST = 0x02;
247 const GPUTextureUsageFlags TEXTURE_BINDING = 0x04;
248 const GPUTextureUsageFlags STORAGE_BINDING = 0x08;
249 const GPUTextureUsageFlags RENDER_ATTACHMENT = 0x10;
252 enum GPUTextureComponentType {
260 [Pref="dom.webgpu.enabled",
261 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
262 interface GPUTextureView {
264 GPUTextureView includes GPUObjectBase;
266 dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase {
267 GPUTextureFormat format;
268 GPUTextureViewDimension dimension;
269 GPUTextureAspect aspect = "all";
270 GPUIntegerCoordinate baseMipLevel = 0;
271 GPUIntegerCoordinate mipLevelCount;
272 GPUIntegerCoordinate baseArrayLayer = 0;
273 GPUIntegerCoordinate arrayLayerCount;
276 enum GPUTextureViewDimension {
285 enum GPUTextureAspect {
291 enum GPUTextureFormat {
321 // Packed 32-bit formats
338 // Depth and stencil formats
342 "depth24plus-stencil8",
345 // BC compressed formats usable if "texture-compression-bc" is both
346 // supported by the device/user agent and enabled in requestDevice.
348 "bc1-rgba-unorm-srgb",
350 "bc2-rgba-unorm-srgb",
352 "bc3-rgba-unorm-srgb",
360 "bc7-rgba-unorm-srgb",
362 // "depth24unorm-stencil8" feature
363 //"depth24unorm-stencil8",
365 // "depth32float-stencil8" feature
366 //"depth32float-stencil8",
369 [Pref="dom.webgpu.enabled",
370 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
371 interface GPUSampler {
373 GPUSampler includes GPUObjectBase;
375 dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
376 GPUAddressMode addressModeU = "clamp-to-edge";
377 GPUAddressMode addressModeV = "clamp-to-edge";
378 GPUAddressMode addressModeW = "clamp-to-edge";
379 GPUFilterMode magFilter = "nearest";
380 GPUFilterMode minFilter = "nearest";
381 GPUFilterMode mipmapFilter = "nearest";
382 float lodMinClamp = 0;
383 float lodMaxClamp = 1000.0; // TODO: What should this be?
384 GPUCompareFunction compare;
385 [Clamp] unsigned short maxAnisotropy = 1;
389 enum GPUAddressMode {
400 enum GPUCompareFunction {
411 [Pref="dom.webgpu.enabled",
412 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
413 interface GPUBindGroupLayout {
415 GPUBindGroupLayout includes GPUObjectBase;
417 dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
418 required sequence<GPUBindGroupLayoutEntry> entries;
421 dictionary GPUBindGroupLayoutEntry {
422 required GPUIndex32 binding;
423 required GPUShaderStageFlags visibility;
424 GPUBufferBindingLayout buffer;
425 GPUSamplerBindingLayout sampler;
426 GPUTextureBindingLayout texture;
427 GPUStorageTextureBindingLayout storageTexture;
430 typedef [EnforceRange] unsigned long GPUShaderStageFlags;
431 [Pref="dom.webgpu.enabled",
432 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
433 interface GPUShaderStage {
434 const GPUShaderStageFlags VERTEX = 1;
435 const GPUShaderStageFlags FRAGMENT = 2;
436 const GPUShaderStageFlags COMPUTE = 4;
439 enum GPUBufferBindingType {
445 dictionary GPUBufferBindingLayout {
446 GPUBufferBindingType type = "uniform";
447 boolean hasDynamicOffset = false;
448 GPUSize64 minBindingSize = 0;
451 enum GPUSamplerBindingType {
457 dictionary GPUSamplerBindingLayout {
458 GPUSamplerBindingType type = "filtering";
461 enum GPUTextureSampleType {
463 "unfilterable-float",
469 dictionary GPUTextureBindingLayout {
470 GPUTextureSampleType sampleType = "float";
471 GPUTextureViewDimension viewDimension = "2d";
472 boolean multisampled = false;
475 enum GPUStorageTextureAccess {
479 dictionary GPUStorageTextureBindingLayout {
480 GPUStorageTextureAccess access = "write-only";
481 required GPUTextureFormat format;
482 GPUTextureViewDimension viewDimension = "2d";
485 [Pref="dom.webgpu.enabled",
486 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
487 interface GPUBindGroup {
489 GPUBindGroup includes GPUObjectBase;
491 dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
492 required GPUBindGroupLayout layout;
493 required sequence<GPUBindGroupEntry> entries;
496 typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
498 dictionary GPUBindGroupEntry {
499 required GPUIndex32 binding;
500 required GPUBindingResource resource;
503 dictionary GPUBufferBinding {
504 required GPUBuffer buffer;
505 GPUSize64 offset = 0;
510 [Pref="dom.webgpu.enabled",
511 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
512 interface GPUPipelineLayout {
514 GPUPipelineLayout includes GPUObjectBase;
516 dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
517 required sequence<GPUBindGroupLayout> bindGroupLayouts;
521 [Pref="dom.webgpu.enabled",
522 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
523 interface GPUShaderModule {
525 Promise<GPUCompilationInfo> compilationInfo();
527 GPUShaderModule includes GPUObjectBase;
529 dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
530 // UTF8String is not observably different from USVString
531 required UTF8String code;
535 enum GPUCompilationMessageType {
541 [Pref="dom.webgpu.enabled",
542 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
543 interface GPUCompilationMessage {
544 readonly attribute DOMString message;
545 readonly attribute GPUCompilationMessageType type;
546 readonly attribute unsigned long long lineNum;
547 readonly attribute unsigned long long linePos;
548 readonly attribute unsigned long long offset;
549 readonly attribute unsigned long long length;
552 [Pref="dom.webgpu.enabled",
553 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
554 interface GPUCompilationInfo {
555 [Cached, Frozen, Pure]
556 readonly attribute sequence<GPUCompilationMessage> messages;
559 // Common stuff for ComputePipeline and RenderPipeline
560 dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
561 GPUPipelineLayout layout;
564 interface mixin GPUPipelineBase {
565 GPUBindGroupLayout getBindGroupLayout(unsigned long index);
568 dictionary GPUProgrammableStage {
569 required GPUShaderModule module;
570 required USVString entryPoint;
574 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
575 [Pref="dom.webgpu.enabled",
576 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
577 interface GPUComputePipeline {
579 GPUComputePipeline includes GPUObjectBase;
580 GPUComputePipeline includes GPUPipelineBase;
583 dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
584 required GPUProgrammableStage compute;
588 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696219
589 [Pref="dom.webgpu.enabled",
590 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
591 interface GPURenderPipeline {
593 GPURenderPipeline includes GPUObjectBase;
594 GPURenderPipeline includes GPUPipelineBase;
596 dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
597 required GPUVertexState vertex;
598 GPUPrimitiveState primitive = {};
599 GPUDepthStencilState depthStencil;
600 GPUMultisampleState multisample = {};
601 GPUFragmentState fragment;
604 dictionary GPUPrimitiveState {
605 GPUPrimitiveTopology topology = "triangle-list";
606 GPUIndexFormat stripIndexFormat;
607 GPUFrontFace frontFace = "ccw";
608 GPUCullMode cullMode = "none";
609 // Enable depth clamping (requires "depth-clamping" feature)
610 boolean clampDepth = false;
613 enum GPUPrimitiveTopology {
632 dictionary GPUMultisampleState {
634 GPUSampleMask mask = 0xFFFFFFFF;
635 boolean alphaToCoverageEnabled = false;
638 dictionary GPUFragmentState: GPUProgrammableStage {
639 required sequence<GPUColorTargetState> targets;
642 dictionary GPUColorTargetState {
643 required GPUTextureFormat format;
645 GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL
648 dictionary GPUBlendState {
649 required GPUBlendComponent color;
650 required GPUBlendComponent alpha;
653 typedef [EnforceRange] unsigned long GPUColorWriteFlags;
654 [Pref="dom.webgpu.enabled",
655 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
656 interface GPUColorWrite {
657 const GPUColorWriteFlags RED = 0x1;
658 const GPUColorWriteFlags GREEN = 0x2;
659 const GPUColorWriteFlags BLUE = 0x4;
660 const GPUColorWriteFlags ALPHA = 0x8;
661 const GPUColorWriteFlags ALL = 0xF;
664 dictionary GPUBlendComponent {
665 GPUBlendFactor srcFactor = "one";
666 GPUBlendFactor dstFactor = "zero";
667 GPUBlendOperation operation = "add";
670 enum GPUBlendFactor {
676 "one-minus-src-alpha",
680 "one-minus-dst-alpha",
681 "src-alpha-saturated",
683 "one-minus-constant",
686 enum GPUBlendOperation {
694 dictionary GPUDepthStencilState {
695 required GPUTextureFormat format;
697 boolean depthWriteEnabled = false;
698 GPUCompareFunction depthCompare = "always";
700 GPUStencilFaceState stencilFront = {};
701 GPUStencilFaceState stencilBack = {};
703 GPUStencilValue stencilReadMask = 0xFFFFFFFF;
704 GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
706 GPUDepthBias depthBias = 0;
707 float depthBiasSlopeScale = 0;
708 float depthBiasClamp = 0;
711 dictionary GPUStencilFaceState {
712 GPUCompareFunction compare = "always";
713 GPUStencilOperation failOp = "keep";
714 GPUStencilOperation depthFailOp = "keep";
715 GPUStencilOperation passOp = "keep";
718 enum GPUStencilOperation {
729 enum GPUIndexFormat {
734 enum GPUVertexFormat {
767 enum GPUVertexStepMode {
772 dictionary GPUVertexState: GPUProgrammableStage {
773 sequence<GPUVertexBufferLayout?> buffers = [];
776 dictionary GPUVertexBufferLayout {
777 required GPUSize64 arrayStride;
778 GPUVertexStepMode stepMode = "vertex";
779 required sequence<GPUVertexAttribute> attributes;
782 dictionary GPUVertexAttribute {
783 required GPUVertexFormat format;
784 required GPUSize64 offset;
785 required GPUIndex32 shaderLocation;
788 dictionary GPUImageDataLayout {
789 GPUSize64 offset = 0;
790 required GPUSize32 bytesPerRow;
791 GPUSize32 rowsPerImage = 0;
794 dictionary GPUImageCopyBuffer : GPUImageDataLayout {
795 required GPUBuffer buffer;
798 dictionary GPUImageCopyExternalImage {
799 required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
800 GPUOrigin2D origin = {};
801 boolean flipY = false;
804 dictionary GPUImageCopyTexture {
805 required GPUTexture texture;
806 GPUIntegerCoordinate mipLevel = 0;
808 GPUTextureAspect aspect = "all";
811 dictionary GPUImageCopyTextureTagged : GPUImageCopyTexture {
812 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
813 boolean premultipliedAlpha = false;
816 dictionary GPUImageBitmapCopyView {
817 //required ImageBitmap imageBitmap; //TODO
821 [Pref="dom.webgpu.enabled",
822 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
823 interface GPUCommandBuffer {
825 GPUCommandBuffer includes GPUObjectBase;
828 dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
831 [Pref="dom.webgpu.enabled",
832 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
833 interface GPUCommandEncoder {
835 GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
837 GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
839 undefined copyBufferToBuffer(
841 GPUSize64 sourceOffset,
842 GPUBuffer destination,
843 GPUSize64 destinationOffset,
846 undefined copyBufferToTexture(
847 GPUImageCopyBuffer source,
848 GPUImageCopyTexture destination,
849 GPUExtent3D copySize);
851 undefined copyTextureToBuffer(
852 GPUImageCopyTexture source,
853 GPUImageCopyBuffer destination,
854 GPUExtent3D copySize);
856 undefined copyTextureToTexture(
857 GPUImageCopyTexture source,
858 GPUImageCopyTexture destination,
859 GPUExtent3D copySize);
862 undefined copyImageBitmapToTexture(
863 GPUImageBitmapCopyView source,
864 GPUImageCopyTexture destination,
865 GPUExtent3D copySize);
868 undefined pushDebugGroup(USVString groupLabel);
869 undefined popDebugGroup();
870 undefined insertDebugMarker(USVString markerLabel);
873 GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
875 GPUCommandEncoder includes GPUObjectBase;
877 dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
880 interface mixin GPUProgrammablePassEncoder {
881 undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
882 optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
884 undefined pushDebugGroup(USVString groupLabel);
885 undefined popDebugGroup();
886 undefined insertDebugMarker(USVString markerLabel);
889 [Pref="dom.webgpu.enabled",
890 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
891 interface GPUComputePassEncoder {
892 undefined setPipeline(GPUComputePipeline pipeline);
893 undefined dispatchWorkgroups(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
894 [Pref="dom.webgpu.indirect-dispatch.enabled"]
895 undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
900 GPUComputePassEncoder includes GPUObjectBase;
901 GPUComputePassEncoder includes GPUProgrammablePassEncoder;
903 dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
906 interface mixin GPURenderEncoderBase {
907 undefined setPipeline(GPURenderPipeline pipeline);
909 undefined setIndexBuffer(GPUBuffer buffer, GPUIndexFormat indexFormat, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
910 undefined setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
912 undefined draw(GPUSize32 vertexCount,
913 optional GPUSize32 instanceCount = 1,
914 optional GPUSize32 firstVertex = 0,
915 optional GPUSize32 firstInstance = 0);
916 undefined drawIndexed(GPUSize32 indexCount,
917 optional GPUSize32 instanceCount = 1,
918 optional GPUSize32 firstIndex = 0,
919 optional GPUSignedOffset32 baseVertex = 0,
920 optional GPUSize32 firstInstance = 0);
922 [Pref="dom.webgpu.indirect-dispatch.enabled"]
923 undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
924 [Pref="dom.webgpu.indirect-dispatch.enabled"]
925 undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
928 [Pref="dom.webgpu.enabled",
929 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
930 interface GPURenderPassEncoder {
931 undefined setViewport(float x, float y,
932 float width, float height,
933 float minDepth, float maxDepth);
935 undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
936 GPUIntegerCoordinate width, GPUIntegerCoordinate height);
938 undefined setBlendConstant(GPUColor color);
939 undefined setStencilReference(GPUStencilValue reference);
941 //undefined beginOcclusionQuery(GPUSize32 queryIndex);
942 //undefined endOcclusionQuery();
944 //undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
945 //undefined endPipelineStatisticsQuery();
947 //undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
949 undefined executeBundles(sequence<GPURenderBundle> bundles);
954 GPURenderPassEncoder includes GPUObjectBase;
955 GPURenderPassEncoder includes GPUProgrammablePassEncoder;
956 GPURenderPassEncoder includes GPURenderEncoderBase;
958 dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
959 required sequence<GPURenderPassColorAttachment> colorAttachments;
960 GPURenderPassDepthStencilAttachment depthStencilAttachment;
961 GPUQuerySet occlusionQuerySet;
964 dictionary GPURenderPassColorAttachment {
965 required GPUTextureView view;
966 GPUTextureView resolveTarget;
968 required (GPULoadOp or GPUColor) loadValue;
969 required GPUStoreOp storeOp;
972 dictionary GPURenderPassDepthStencilAttachment {
973 required GPUTextureView view;
975 required (GPULoadOp or float) depthLoadValue;
976 required GPUStoreOp depthStoreOp;
978 required (GPULoadOp or GPUStencilValue) stencilLoadValue;
979 required GPUStoreOp stencilStoreOp;
991 dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
992 required sequence<GPUTextureFormat> colorFormats;
993 GPUTextureFormat depthStencilFormat;
994 GPUSize32 sampleCount = 1;
997 [Pref="dom.webgpu.enabled",
998 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
999 interface GPURenderBundle {
1001 GPURenderBundle includes GPUObjectBase;
1003 dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
1006 [Pref="dom.webgpu.enabled",
1007 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1008 interface GPURenderBundleEncoder {
1009 GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
1011 GPURenderBundleEncoder includes GPUObjectBase;
1012 GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
1013 GPURenderBundleEncoder includes GPURenderEncoderBase;
1015 dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
1016 boolean depthReadOnly = false;
1017 boolean stencilReadOnly = false;
1020 //TODO: use [AllowShared] on BufferSource
1021 // https://bugzilla.mozilla.org/show_bug.cgi?id=1696216
1022 // https://github.com/heycam/webidl/issues/961
1024 [Pref="dom.webgpu.enabled",
1025 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1026 interface GPUQueue {
1027 undefined submit(sequence<GPUCommandBuffer> buffers);
1030 //Promise<undefined> onSubmittedWorkDone();
1033 undefined writeBuffer(
1035 GPUSize64 bufferOffset,
1037 optional GPUSize64 dataOffset = 0,
1038 optional GPUSize64 size);
1041 undefined writeTexture(
1042 GPUImageCopyTexture destination,
1044 GPUImageDataLayout dataLayout,
1048 undefined copyExternalImageToTexture(
1049 GPUImageCopyExternalImage source,
1050 GPUImageCopyTextureTagged destination,
1051 GPUExtent3D copySize);
1053 GPUQueue includes GPUObjectBase;
1055 [Pref="dom.webgpu.enabled",
1056 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1057 interface GPUQuerySet {
1058 undefined destroy();
1060 GPUQuerySet includes GPUObjectBase;
1062 dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase {
1063 required GPUQueryType type;
1064 required GPUSize32 count;
1065 sequence<GPUPipelineStatisticName> pipelineStatistics = [];
1068 enum GPUPipelineStatisticName {
1069 "vertex-shader-invocations",
1070 "clipper-invocations",
1071 "clipper-primitives-out",
1072 "fragment-shader-invocations",
1073 "compute-shader-invocations"
1078 "pipeline-statistics",
1082 [Pref="dom.webgpu.enabled",
1083 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1084 interface GPUCanvasContext {
1085 // Calling configure() a second time invalidates the previous one,
1086 // and all of the textures it's produced.
1087 undefined configure(GPUCanvasConfiguration descriptor);
1088 undefined unconfigure();
1091 GPUTexture getCurrentTexture();
1094 enum GPUCanvasCompositingAlphaMode {
1099 dictionary GPUCanvasConfiguration {
1100 required GPUDevice device;
1101 required GPUTextureFormat format;
1102 GPUTextureUsageFlags usage = 0x10; //GPUTextureUsage.OUTPUT_ATTACHMENT
1103 //GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
1104 GPUCanvasCompositingAlphaMode compositingAlphaMode = "opaque";
1107 enum GPUDeviceLostReason {
1111 [Pref="dom.webgpu.enabled",
1112 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1113 interface GPUDeviceLostInfo {
1114 readonly attribute any reason; // GPUDeviceLostReason or undefined
1115 readonly attribute DOMString message;
1118 partial interface GPUDevice {
1120 readonly attribute Promise<GPUDeviceLostInfo> lost;
1121 undefined pushErrorScope(GPUErrorFilter filter);
1123 Promise<GPUError?> popErrorScope();
1124 [Exposed=(Window /* ,DedicatedWorker */)]
1125 attribute EventHandler onuncapturederror;
1128 [Pref="dom.webgpu.enabled",
1129 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1130 interface GPUOutOfMemoryError {
1134 [Pref="dom.webgpu.enabled",
1135 Exposed=(Window /* ,DedicatedWorker */), SecureContext]
1136 interface GPUValidationError {
1138 constructor(DOMString message);
1139 readonly attribute DOMString message;
1142 typedef (GPUOutOfMemoryError or GPUValidationError) GPUError;
1144 enum GPUErrorFilter {
1149 typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
1150 typedef [EnforceRange] unsigned long GPUStencilValue;
1151 typedef [EnforceRange] unsigned long GPUSampleMask;
1152 typedef [EnforceRange] long GPUDepthBias;
1154 typedef [EnforceRange] unsigned long long GPUSize64;
1155 typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
1156 typedef [EnforceRange] unsigned long GPUIndex32;
1157 typedef [EnforceRange] unsigned long GPUSize32;
1158 typedef [EnforceRange] long GPUSignedOffset32;
1160 dictionary GPUColorDict {
1166 typedef (sequence<double> or GPUColorDict) GPUColor;
1168 dictionary GPUOrigin2DDict {
1169 GPUIntegerCoordinate x = 0;
1170 GPUIntegerCoordinate y = 0;
1172 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
1174 dictionary GPUOrigin3DDict {
1175 GPUIntegerCoordinate x = 0;
1176 GPUIntegerCoordinate y = 0;
1177 GPUIntegerCoordinate z = 0;
1179 typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
1181 dictionary GPUExtent3DDict {
1182 required GPUIntegerCoordinate width;
1183 GPUIntegerCoordinate height = 1;
1184 GPUIntegerCoordinate depthOrArrayLayers = 1;
1186 typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;