Upgrade whole webgpu stack (#29795)

* Allow noidl files in script/dom/webidls

* Upgrade wgpu to 0.16 and refresh whole webgpu implementation

* Update WebGPU test expectations

* misc

* MutNullableDom -> DomRefCell<Option<Dom for GPUTexture

* Direct use of GPUTextureDescriptor

* Remove config from GPUCanvasContext

* misc

* finally blue color

* gpubuffer "handle" error

* GPU object have non-null label

* gpu limits and info

* use buffer_size

* fix warnings

* Cleanup

* device destroy

* fallback adapter

* mach update-webgpu write webgpu commit hash in file

* Mising deps in CI for webgpu tests

* Updated expectations

* Fixups

* early reject

* DomRefCell<Option<Dom -> MutNullableDom for GPUTexture
This commit is contained in:
Samson 2023-08-21 01:16:46 +02:00 committed by GitHub
parent fed3491f23
commit 71e0372ac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 15612 additions and 4023 deletions

View file

@ -5,15 +5,16 @@
// https://gpuweb.github.io/gpuweb/#gpu-interface
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPU {
[NewObject]
Promise<GPUAdapter?> requestAdapter(optional GPURequestAdapterOptions options = {});
GPUTextureFormat getPreferredCanvasFormat();
};
// https://gpuweb.github.io/gpuweb/#dictdef-gpurequestadapteroptions
dictionary GPURequestAdapterOptions {
GPUPowerPreference powerPreference;
boolean forceFallbackAdapter = false;
};
// https://gpuweb.github.io/gpuweb/#enumdef-gpupowerpreference
enum GPUPowerPreference {
"low-power",
"high-performance"

View file

@ -5,35 +5,29 @@
// https://gpuweb.github.io/gpuweb/#gpuadapter
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUAdapter {
readonly attribute DOMString name;
readonly attribute object extensions;
//readonly attribute GPULimits limits; Dont expose higher limits for now.
//[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
readonly attribute boolean isFallbackAdapter;
Promise<GPUDevice?> requestDevice(optional GPUDeviceDescriptor descriptor = {});
[NewObject]
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
[NewObject]
Promise<GPUAdapterInfo> requestAdapterInfo(optional sequence<DOMString> unmaskHints = []);
};
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
sequence<GPUExtensionName> extensions = [];
GPULimits limits = {};
dictionary GPUDeviceDescriptor {
sequence<GPUFeatureName> requiredFeatures = [];
record<DOMString, GPUSize64> requiredLimits;
};
enum GPUExtensionName {
"depth-clamping",
enum GPUFeatureName {
"depth-clip-control",
"depth24unorm-stencil8",
"depth32float-stencil8",
"pipeline-statistics-query",
"texture-compression-bc",
"texture-compression-etc2",
"texture-compression-astc",
"timestamp-query",
};
dictionary GPULimits {
GPUSize32 maxBindGroups = 4;
GPUSize32 maxDynamicUniformBuffersPerPipelineLayout = 8;
GPUSize32 maxDynamicStorageBuffersPerPipelineLayout = 4;
GPUSize32 maxSampledTexturesPerShaderStage = 16;
GPUSize32 maxSamplersPerShaderStage = 16;
GPUSize32 maxStorageBuffersPerShaderStage = 4;
GPUSize32 maxStorageTexturesPerShaderStage = 4;
GPUSize32 maxUniformBuffersPerShaderStage = 12;
GPUSize32 maxUniformBufferBindingSize = 16384;
"indirect-first-instance",
};

View file

@ -0,0 +1,12 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpuadapterinfo
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUAdapterInfo {
readonly attribute DOMString vendor;
readonly attribute DOMString architecture;
readonly attribute DOMString device;
readonly attribute DOMString description;
};

View file

@ -13,16 +13,14 @@ dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupEntry> entries;
};
typedef (GPUSampler or GPUTextureView or GPUBufferBindings) GPUBindingResource;
typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
dictionary GPUBindGroupEntry {
required GPUIndex32 binding;
required GPUBindingResource resource;
};
// Note: Servo codegen doesn't like the name `GPUBufferBinding` because it's already occupied
// dictionary GPUBufferBinding {
dictionary GPUBufferBindings {
dictionary GPUBufferBinding {
required GPUBuffer buffer;
GPUSize64 offset = 0;
GPUSize64 size;

View file

@ -15,22 +15,54 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
dictionary GPUBindGroupLayoutEntry {
required GPUIndex32 binding;
required GPUShaderStageFlags visibility;
required GPUBindingType type;
boolean hasDynamicOffset;
GPUSize64 minBufferBindingSize;
GPUTextureViewDimension viewDimension;
GPUTextureComponentType textureComponentType;
GPUTextureFormat storageTextureFormat;
GPUBufferBindingLayout buffer;
GPUSamplerBindingLayout sampler;
GPUTextureBindingLayout texture;
GPUStorageTextureBindingLayout storageTexture;
};
enum GPUBindingType {
"uniform-buffer",
"storage-buffer",
"readonly-storage-buffer",
"sampler",
"comparison-sampler",
"sampled-texture",
"multisampled-texture",
"readonly-storage-texture",
"writeonly-storage-texture"
enum GPUBufferBindingType {
"uniform",
"storage",
"read-only-storage",
};
dictionary GPUBufferBindingLayout {
GPUBufferBindingType type = "uniform";
boolean hasDynamicOffset = false;
GPUSize64 minBindingSize = 0;
};
enum GPUSamplerBindingType {
"filtering",
"non-filtering",
"comparison",
};
dictionary GPUSamplerBindingLayout {
GPUSamplerBindingType type = "filtering";
};
enum GPUTextureSampleType {
"float",
"unfilterable-float",
"depth",
"sint",
"uint",
};
dictionary GPUTextureBindingLayout {
GPUTextureSampleType sampleType = "float";
GPUTextureViewDimension viewDimension = "2d";
boolean multisampled = false;
};
enum GPUStorageTextureAccess {
"write-only",
};
dictionary GPUStorageTextureBindingLayout {
GPUStorageTextureAccess access = "write-only";
required GPUTextureFormat format;
GPUTextureViewDimension viewDimension = "2d";
};

View file

@ -5,10 +5,13 @@
// https://gpuweb.github.io/gpuweb/#gpubuffer
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUBuffer {
[NewObject]
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
[Throws] ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
[NewObject, Throws]
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
[Throws]
undefined unmap();
[Throws]
undefined destroy();
};
GPUBuffer includes GPUObjectBase;
@ -19,4 +22,4 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
boolean mappedAtCreation = false;
};
typedef unsigned long long GPUSize64;
typedef [EnforceRange] unsigned long long GPUSize64;

View file

@ -16,5 +16,4 @@ interface GPUBufferUsage {
const GPUBufferUsageFlags INDIRECT = 0x0100;
const GPUBufferUsageFlags QUERY_RESOLVE = 0x0200;
};
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;

View file

@ -5,13 +5,27 @@
// https://gpuweb.github.io/gpuweb/#gpucanvascontext
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUCanvasContext {
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;
//Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
// Calling configure() a second time invalidates the previous one,
// and all of the textures it's produced.
undefined configure(GPUCanvasConfiguration descriptor);
undefined unconfigure();
[Throws]
GPUTexture getCurrentTexture();
};
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
enum GPUCanvasAlphaMode {
"opaque",
"premultiplied",
};
dictionary GPUCanvasConfiguration {
required GPUDevice device;
required GPUTextureFormat format;
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.OUTPUT_ATTACHMENT
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
sequence<GPUTextureFormat> viewFormats = [];
// PredefinedColorSpace colorSpace = "srgb"; // TODO
GPUCanvasAlphaMode alphaMode = "opaque";
};

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpucolorwrite
// https://gpuweb.github.io/gpuweb/#namespacedef-gpucolorwrite
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUColorWrite {
const GPUColorWriteFlags RED = 0x1;

View file

@ -5,6 +5,8 @@
// https://gpuweb.github.io/gpuweb/#gpucommandbuffer
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUCommandBuffer {
//readonly attribute Promise<double> executionTime;
};
GPUCommandBuffer includes GPUObjectBase;
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};

View file

@ -5,8 +5,10 @@
// https://gpuweb.github.io/gpuweb/#gpucommandencoder
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
[NewObject]
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
[NewObject]
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
undefined copyBufferToBuffer(
GPUBuffer source,
@ -16,78 +18,117 @@ interface GPUCommandEncoder {
GPUSize64 size);
undefined copyBufferToTexture(
GPUBufferCopyView source,
GPUTextureCopyView destination,
GPUImageCopyBuffer source,
GPUImageCopyTexture destination,
GPUExtent3D copySize);
undefined copyTextureToBuffer(
GPUTextureCopyView source,
GPUBufferCopyView destination,
GPUImageCopyTexture source,
GPUImageCopyBuffer destination,
GPUExtent3D copySize);
undefined copyTextureToTexture(
GPUTextureCopyView source,
GPUTextureCopyView destination,
GPUImageCopyTexture source,
GPUImageCopyTexture destination,
GPUExtent3D copySize);
//void pushDebugGroup(USVString groupLabel);
//void popDebugGroup();
//void insertDebugMarker(USVString markerLabel);
/*
undefined copyImageBitmapToTexture(
GPUImageBitmapCopyView source,
GPUImageCopyTexture destination,
GPUExtent3D copySize);
*/
//void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
//void resolveQuerySet(
// GPUQuerySet querySet,
// GPUSize32 firstQuery,
// GPUSize32 queryCount,
// GPUBuffer destination,
// GPUSize64 destinationOffset);
//undefined pushDebugGroup(USVString groupLabel);
//undefined popDebugGroup();
//undefined insertDebugMarker(USVString markerLabel);
[NewObject]
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
};
GPUCommandEncoder includes GPUObjectBase;
dictionary GPUImageDataLayout {
GPUSize64 offset = 0;
GPUSize32 bytesPerRow;
GPUSize32 rowsPerImage;
};
dictionary GPUImageCopyBuffer : GPUImageDataLayout {
required GPUBuffer buffer;
};
dictionary GPUImageCopyExternalImage {
required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
GPUOrigin2D origin = {};
boolean flipY = false;
};
dictionary GPUImageCopyTexture {
required GPUTexture texture;
GPUIntegerCoordinate mipLevel = 0;
GPUOrigin3D origin;
GPUTextureAspect aspect = "all";
};
dictionary GPUImageCopyTextureTagged : GPUImageCopyTexture {
//GPUPredefinedColorSpace colorSpace = "srgb"; //TODO
boolean premultipliedAlpha = false;
};
dictionary GPUImageBitmapCopyView {
//required ImageBitmap imageBitmap; //TODO
GPUOrigin2D origin;
};
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
};
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};
//
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
//GPUQuerySet occlusionQuerySet;
required sequence<GPURenderPassColorAttachment> colorAttachments;
GPURenderPassDepthStencilAttachment depthStencilAttachment;
GPUQuerySet occlusionQuerySet;
};
dictionary GPURenderPassColorAttachmentDescriptor {
required GPUTextureView attachment;
dictionary GPURenderPassColorAttachment {
required GPUTextureView view;
GPUTextureView resolveTarget;
required (GPULoadOp or GPUColor) loadValue;
GPUStoreOp storeOp = "store";
GPUColor clearValue;
required GPULoadOp loadOp;
required GPUStoreOp storeOp;
};
dictionary GPURenderPassDepthStencilAttachmentDescriptor {
required GPUTextureView attachment;
dictionary GPURenderPassDepthStencilAttachment {
required GPUTextureView view;
required (GPULoadOp or float) depthLoadValue;
required GPUStoreOp depthStoreOp;
float depthClearValue;
GPULoadOp depthLoadOp;
GPUStoreOp depthStoreOp;
boolean depthReadOnly = false;
required GPUStencilLoadValue stencilLoadValue;
required GPUStoreOp stencilStoreOp;
GPUStencilValue stencilClearValue = 0;
GPULoadOp stencilLoadOp;
GPUStoreOp stencilStoreOp;
boolean stencilReadOnly = false;
};
typedef (GPULoadOp or GPUStencilValue) GPUStencilLoadValue;
enum GPULoadOp {
"load"
"load",
"clear"
};
enum GPUStoreOp {
"store",
"clear"
"discard"
};
dictionary GPURenderPassLayout: GPUObjectDescriptorBase {
// TODO: We don't support nullable enumerated arguments yet
required sequence<GPUTextureFormat> colorFormats;
GPUTextureFormat depthStencilFormat;
GPUSize32 sampleCount = 1;
};
dictionary GPUColorDict {
@ -98,21 +139,11 @@ dictionary GPUColorDict {
};
typedef (sequence<double> or GPUColorDict) GPUColor;
dictionary GPUTextureDataLayout {
GPUSize64 offset = 0;
required GPUSize32 bytesPerRow;
GPUSize32 rowsPerImage = 0;
};
dictionary GPUBufferCopyView : GPUTextureDataLayout {
required GPUBuffer buffer;
};
dictionary GPUTextureCopyView {
required GPUTexture texture;
GPUIntegerCoordinate mipLevel = 0;
GPUOrigin3D origin = {};
dictionary GPUOrigin2DDict {
GPUIntegerCoordinate x = 0;
GPUIntegerCoordinate y = 0;
};
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
dictionary GPUOrigin3DDict {
GPUIntegerCoordinate x = 0;

View file

@ -0,0 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpucompilationinfo
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUCompilationInfo {
// codegen hates it
//[Cached, Frozen, Pure]
readonly attribute /*sequence<GPUCompilationMessage>*/ any messages;
};

View file

@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpucompilationmessage
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUCompilationMessage {
readonly attribute DOMString message;
readonly attribute GPUCompilationMessageType type;
readonly attribute unsigned long long lineNum;
readonly attribute unsigned long long linePos;
readonly attribute unsigned long long offset;
readonly attribute unsigned long long length;
};
enum GPUCompilationMessageType {
"error",
"warning",
"info"
};

View file

@ -6,15 +6,12 @@
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
undefined dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
undefined dispatchWorkgroups(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
//[Pref="dom.webgpu.indirect-dispatch.enabled"]
undefined dispatchWorkgroupsIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
//void beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
//void endPipelineStatisticsQuery();
//void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
undefined endPass();
[Throws]
undefined end();
};
GPUComputePassEncoder includes GPUObjectBase;
GPUComputePassEncoder includes GPUProgrammablePassEncoder;

View file

@ -9,19 +9,23 @@ interface GPUComputePipeline {
GPUComputePipeline includes GPUObjectBase;
GPUComputePipeline includes GPUPipelineBase;
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
GPUPipelineLayout layout;
enum GPUAutoLayoutMode {
"auto"
};
dictionary GPUProgrammableStageDescriptor {
required GPUShaderModule module;
required DOMString entryPoint;
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
required (GPUPipelineLayout or GPUAutoLayoutMode) layout;
};
dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStageDescriptor computeStage;
required GPUProgrammableStage compute;
};
interface mixin GPUPipelineBase {
[Throws] GPUBindGroupLayout getBindGroupLayout(unsigned long index);
};
dictionary GPUProgrammableStage {
required GPUShaderModule module;
required USVString entryPoint;
};

View file

@ -4,15 +4,20 @@
// https://gpuweb.github.io/gpuweb/#gpudevice
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom.webgpu.enabled"]
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUAdapter adapter;
readonly attribute object extensions;
readonly attribute object limits;
interface GPUDevice: EventTarget {
//[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
[SameObject] readonly attribute GPUQueue defaultQueue;
// Overriding the name to avoid collision with `class Queue` in gcc
[SameObject, BinaryName="getQueue"] readonly attribute GPUQueue queue;
undefined destroy();
[NewObject, Throws]
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
[NewObject]
GPUTexture createTexture(GPUTextureDescriptor descriptor);
[NewObject]
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
@ -22,16 +27,22 @@ interface GPUDevice : EventTarget {
GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
//Promise<GPUComputePipeline> createReadyComputePipeline(GPUComputePipelineDescriptor descriptor);
//Promise<GPURenderPipeline> createReadyRenderPipeline(GPURenderPipelineDescriptor descriptor);
[NewObject]
Promise<GPUComputePipeline> createComputePipelineAsync(GPUComputePipelineDescriptor descriptor);
[NewObject]
Promise<GPURenderPipeline> createRenderPipelineAsync(GPURenderPipelineDescriptor descriptor);
[NewObject]
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
[NewObject]
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
//[NewObject]
//GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
};
GPUDevice includes GPUObjectBase;
//TODO
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
boolean measureExecutionTime = false;
};

View file

@ -5,9 +5,16 @@
// https://gpuweb.github.io/gpuweb/#gpudevicelostinfo
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUDeviceLostInfo {
readonly attribute GPUDeviceLostReason reason;
readonly attribute DOMString message;
};
enum GPUDeviceLostReason {
"unknown",
"destroyed",
};
partial interface GPUDevice {
[Throws]
readonly attribute Promise<GPUDeviceLostInfo> lost;
};

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpumapmode
// https://gpuweb.github.io/gpuweb/#namespacedef-gpumapmode
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUMapMode {
const GPUMapModeFlags READ = 0x0001;

View file

@ -5,7 +5,7 @@
// https://gpuweb.github.io/gpuweb/#gpuobjectbase
[Exposed=(Window)]
interface mixin GPUObjectBase {
attribute USVString? label;
attribute USVString label;
};
dictionary GPUObjectDescriptorBase {

View file

@ -6,16 +6,11 @@
[Exposed=(Window, DedicatedWorker)]
interface mixin GPUProgrammablePassEncoder {
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
// void setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
// Uint32Array dynamicOffsetsData,
// GPUSize64 dynamicOffsetsDataStart,
// GPUSize64 dynamicOffsetsDataLength);
// void pushDebugGroup(DOMString groupLabel);
// void popDebugGroup();
// void insertDebugMarker(DOMString markerLabel);
//undefined pushDebugGroup(USVString groupLabel);
//undefined popDebugGroup();
//undefined insertDebugMarker(USVString markerLabel);
};
typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;

View file

@ -0,0 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpuqueryset
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUQuerySet {
undefined destroy();
};
GPUQuerySet includes GPUObjectBase;
dictionary GPUQuerySetDescriptor : GPUObjectDescriptorBase {
required GPUQueryType type;
required GPUSize32 count;
sequence<GPUPipelineStatisticName> pipelineStatistics = [];
};
enum GPUPipelineStatisticName {
"vertex-shader-invocations",
"clipper-invocations",
"clipper-primitives-out",
"fragment-shader-invocations",
"compute-shader-invocations"
};
enum GPUQueryType {
"occlusion",
"pipeline-statistics",
"timestamp"
};

View file

@ -5,27 +5,30 @@
// https://gpuweb.github.io/gpuweb/#gpuqueue
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
undefined submit(sequence<GPUCommandBuffer> buffers);
//GPUFence createFence(optional GPUFenceDescriptor descriptor = {});
//void signal(GPUFence fence, GPUFenceValue signalValue);
//TODO:
//Promise<undefined> onSubmittedWorkDone();
[Throws] undefined writeBuffer(
[Throws]
undefined writeBuffer(
GPUBuffer buffer,
GPUSize64 bufferOffset,
/*[AllowShared]*/ BufferSource data,
BufferSource data,
optional GPUSize64 dataOffset = 0,
optional GPUSize64 size);
[Throws] undefined writeTexture(
GPUTextureCopyView destination,
/*[AllowShared]*/ BufferSource data,
GPUTextureDataLayout dataLayout,
[Throws]
undefined writeTexture(
GPUImageCopyTexture destination,
BufferSource data,
GPUImageDataLayout dataLayout,
GPUExtent3D size);
//void copyImageBitmapToTexture(
// GPUImageBitmapCopyView source,
// GPUTextureCopyView destination,
// GPUExtent3D copySize);
//[Throws]
//undefined copyExternalImageToTexture(
// GPUImageCopyExternalImage source,
// GPUImageCopyTextureTagged destination,
// GPUExtent3D copySize);
};
GPUQueue includes GPUObjectBase;

View file

@ -11,8 +11,7 @@ GPURenderBundleEncoder includes GPUObjectBase;
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
GPURenderBundleEncoder includes GPURenderEncoderBase;
dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
required sequence<GPUTextureFormat> colorFormats;
GPUTextureFormat depthStencilFormat;
GPUSize32 sampleCount = 1;
dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
boolean depthReadOnly = false;
boolean stencilReadOnly = false;
};

View file

@ -2,27 +2,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpurenderencoderbase
// https://gpuweb.github.io/gpuweb/#gpurendercommandsmixin
[Exposed=(Window, DedicatedWorker)]
interface mixin GPURenderEncoderBase {
undefined setPipeline(GPURenderPipeline pipeline);
undefined setIndexBuffer(GPUBuffer buffer, optional GPUSize64 offset = 0, optional GPUSize64 size = 0);
undefined setVertexBuffer(
GPUIndex32 slot,
GPUBuffer buffer,
optional GPUSize64 offset = 0,
optional GPUSize64 size = 0
);
undefined setIndexBuffer(GPUBuffer buffer,
GPUIndexFormat indexFormat,
optional GPUSize64 offset = 0,
optional GPUSize64 size = 0);
undefined setVertexBuffer(GPUIndex32 slot,
GPUBuffer buffer,
optional GPUSize64 offset = 0,
optional GPUSize64 size = 0);
undefined draw(GPUSize32 vertexCount, optional GPUSize32 instanceCount = 1,
optional GPUSize32 firstVertex = 0, optional GPUSize32 firstInstance = 0);
undefined drawIndexed(GPUSize32 indexCount, optional GPUSize32 instanceCount = 1,
optional GPUSize32 firstIndex = 0,
optional GPUSignedOffset32 baseVertex = 0,
optional GPUSize32 firstInstance = 0);
undefined draw(GPUSize32 vertexCount,
optional GPUSize32 instanceCount = 1,
optional GPUSize32 firstVertex = 0,
optional GPUSize32 firstInstance = 0);
undefined drawIndexed(GPUSize32 indexCount,
optional GPUSize32 instanceCount = 1,
optional GPUSize32 firstIndex = 0,
optional GPUSignedOffset32 baseVertex = 0,
optional GPUSize32 firstInstance = 0);
//[Pref="dom.webgpu.indirect-dispatch.enabled"]
undefined drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
//[Pref="dom.webgpu.indirect-dispatch.enabled"]
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};

View file

@ -6,25 +6,27 @@
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
float minDepth, float maxDepth);
float width, float height,
float minDepth, float maxDepth);
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
undefined setBlendColor(GPUColor color);
undefined setBlendConstant(GPUColor color);
undefined setStencilReference(GPUStencilValue reference);
//void beginOcclusionQuery(GPUSize32 queryIndex);
//void endOcclusionQuery();
//undefined beginOcclusionQuery(GPUSize32 queryIndex);
//undefined endOcclusionQuery();
//void beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
//void endPipelineStatisticsQuery();
//undefined beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
//undefined endPipelineStatisticsQuery();
//void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
//undefined writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
undefined executeBundles(sequence<GPURenderBundle> bundles);
undefined endPass();
[Throws]
undefined end();
};
GPURenderPassEncoder includes GPUObjectBase;
GPURenderPassEncoder includes GPUProgrammablePassEncoder;

View file

@ -10,21 +10,21 @@ GPURenderPipeline includes GPUObjectBase;
GPURenderPipeline includes GPUPipelineBase;
dictionary GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStageDescriptor vertexStage;
GPUProgrammableStageDescriptor fragmentStage;
required GPUPrimitiveTopology primitiveTopology;
GPURasterizationStateDescriptor rasterizationState = {};
required sequence<GPUColorStateDescriptor> colorStates;
GPUDepthStencilStateDescriptor depthStencilState;
GPUVertexStateDescriptor vertexState = {};
GPUSize32 sampleCount = 1;
GPUSampleMask sampleMask = 0xFFFFFFFF;
boolean alphaToCoverageEnabled = false;
required GPUVertexState vertex;
GPUPrimitiveState primitive = {};
GPUDepthStencilState depthStencil;
GPUMultisampleState multisample = {};
GPUFragmentState fragment;
};
typedef [EnforceRange] unsigned long GPUSampleMask;
dictionary GPUPrimitiveState {
GPUPrimitiveTopology topology = "triangle-list";
GPUIndexFormat stripIndexFormat;
GPUFrontFace frontFace = "ccw";
GPUCullMode cullMode = "none";
// Enable depth clamping (requires "depth-clamping" feature)
boolean clampDepth = false;
};
enum GPUPrimitiveTopology {
"point-list",
@ -34,19 +34,6 @@ enum GPUPrimitiveTopology {
"triangle-strip"
};
typedef [EnforceRange] long GPUDepthBias;
dictionary GPURasterizationStateDescriptor {
GPUFrontFace frontFace = "ccw";
GPUCullMode cullMode = "none";
// Enable depth clamping (requires "depth-clamping" extension)
boolean clampDepth = false;
GPUDepthBias depthBias = 0;
float depthBiasSlopeScale = 0;
float depthBiasClamp = 0;
};
enum GPUFrontFace {
"ccw",
"cw"
@ -58,15 +45,31 @@ enum GPUCullMode {
"back"
};
dictionary GPUColorStateDescriptor {
required GPUTextureFormat format;
dictionary GPUMultisampleState {
GPUSize32 count = 1;
GPUSampleMask mask = 0xFFFFFFFF;
boolean alphaToCoverageEnabled = false;
};
GPUBlendDescriptor alphaBlend = {};
GPUBlendDescriptor colorBlend = {};
dictionary GPUFragmentState: GPUProgrammableStage {
required sequence<GPUColorTargetState> targets;
};
dictionary GPUColorTargetState {
required GPUTextureFormat format;
GPUBlendState blend;
GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL
};
dictionary GPUBlendDescriptor {
dictionary GPUBlendState {
required GPUBlendComponent color;
required GPUBlendComponent alpha;
};
typedef [EnforceRange] unsigned long GPUSampleMask;
typedef [EnforceRange] long GPUDepthBias;
dictionary GPUBlendComponent {
GPUBlendFactor srcFactor = "one";
GPUBlendFactor dstFactor = "zero";
GPUBlendOperation operation = "add";
@ -75,17 +78,17 @@ dictionary GPUBlendDescriptor {
enum GPUBlendFactor {
"zero",
"one",
"src-color",
"one-minus-src-color",
"src",
"one-minus-src",
"src-alpha",
"one-minus-src-alpha",
"dst-color",
"one-minus-dst-color",
"dst",
"one-minus-dst",
"dst-alpha",
"one-minus-dst-alpha",
"src-alpha-saturated",
"blend-color",
"one-minus-blend-color"
"constant",
"one-minus-constant",
};
enum GPUBlendOperation {
@ -96,6 +99,30 @@ enum GPUBlendOperation {
"max"
};
dictionary GPUDepthStencilState {
required GPUTextureFormat format;
boolean depthWriteEnabled = false;
GPUCompareFunction depthCompare = "always";
GPUStencilFaceState stencilFront = {};
GPUStencilFaceState stencilBack = {};
GPUStencilValue stencilReadMask = 0xFFFFFFFF;
GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
GPUDepthBias depthBias = 0;
float depthBiasSlopeScale = 0;
float depthBiasClamp = 0;
};
dictionary GPUStencilFaceState {
GPUCompareFunction compare = "always";
GPUStencilOperation failOp = "keep";
GPUStencilOperation depthFailOp = "keep";
GPUStencilOperation passOp = "keep";
};
enum GPUStencilOperation {
"keep",
"zero",
@ -107,85 +134,63 @@ enum GPUStencilOperation {
"decrement-wrap"
};
typedef [EnforceRange] unsigned long GPUStencilValue;
dictionary GPUDepthStencilStateDescriptor {
required GPUTextureFormat format;
boolean depthWriteEnabled = false;
GPUCompareFunction depthCompare = "always";
GPUStencilStateFaceDescriptor stencilFront = {};
GPUStencilStateFaceDescriptor stencilBack = {};
GPUStencilValue stencilReadMask = 0xFFFFFFFF;
GPUStencilValue stencilWriteMask = 0xFFFFFFFF;
};
dictionary GPUStencilStateFaceDescriptor {
GPUCompareFunction compare = "always";
GPUStencilOperation failOp = "keep";
GPUStencilOperation depthFailOp = "keep";
GPUStencilOperation passOp = "keep";
};
enum GPUIndexFormat {
"uint16",
"uint32"
"uint32",
};
typedef [EnforceRange] unsigned long GPUStencilValue;
enum GPUVertexFormat {
"uchar2",
"uchar4",
"char2",
"char4",
"uchar2norm",
"uchar4norm",
"char2norm",
"char4norm",
"ushort2",
"ushort4",
"short2",
"short4",
"ushort2norm",
"ushort4norm",
"short2norm",
"short4norm",
"half2",
"half4",
"float",
"float2",
"float3",
"float4",
"uint",
"uint2",
"uint3",
"uint4",
"int",
"int2",
"int3",
"int4"
"uint8x2",
"uint8x4",
"sint8x2",
"sint8x4",
"unorm8x2",
"unorm8x4",
"snorm8x2",
"snorm8x4",
"uint16x2",
"uint16x4",
"sint16x2",
"sint16x4",
"unorm16x2",
"unorm16x4",
"snorm16x2",
"snorm16x4",
"float16x2",
"float16x4",
"float32",
"float32x2",
"float32x3",
"float32x4",
"uint32",
"uint32x2",
"uint32x3",
"uint32x4",
"sint32",
"sint32x2",
"sint32x3",
"sint32x4",
};
enum GPUInputStepMode {
enum GPUVertexStepMode {
"vertex",
"instance"
"instance",
};
dictionary GPUVertexStateDescriptor {
GPUIndexFormat indexFormat = "uint32";
sequence<GPUVertexBufferLayoutDescriptor?> vertexBuffers = [];
dictionary GPUVertexState: GPUProgrammableStage {
sequence<GPUVertexBufferLayout?> buffers = [];
};
dictionary GPUVertexBufferLayoutDescriptor {
dictionary GPUVertexBufferLayout {
required GPUSize64 arrayStride;
GPUInputStepMode stepMode = "vertex";
required sequence<GPUVertexAttributeDescriptor> attributes;
GPUVertexStepMode stepMode = "vertex";
required sequence<GPUVertexAttribute> attributes;
};
dictionary GPUVertexAttributeDescriptor {
dictionary GPUVertexAttribute {
required GPUVertexFormat format;
required GPUSize64 offset;
required GPUIndex32 shaderLocation;
};

View file

@ -16,9 +16,9 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
GPUFilterMode minFilter = "nearest";
GPUFilterMode mipmapFilter = "nearest";
float lodMinClamp = 0;
float lodMaxClamp = 0xfffff; // TODO: What should this be? Was Number.MAX_VALUE.
float lodMaxClamp = 1000.0; // TODO: What should this be?
GPUCompareFunction compare;
unsigned short maxAnisotropy = 1;
[Clamp] unsigned short maxAnisotropy = 1;
};
enum GPUAddressMode {
@ -29,7 +29,7 @@ enum GPUAddressMode {
enum GPUFilterMode {
"nearest",
"linear"
"linear",
};
enum GPUCompareFunction {

View file

@ -5,11 +5,13 @@
// https://gpuweb.github.io/gpuweb/#gpushadermodule
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUShaderModule {
[Throws]
Promise<GPUCompilationInfo> compilationInfo();
};
GPUShaderModule includes GPUObjectBase;
typedef (Uint32Array or DOMString) GPUShaderCode;
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
required GPUShaderCode code;
// UTF8String is not observably different from USVString
required USVString code;
object sourceMap;
};

View file

@ -5,9 +5,9 @@
// https://gpuweb.github.io/gpuweb/#typedefdef-gpushaderstageflags
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUShaderStage {
const GPUShaderStageFlags VERTEX = 0x1;
const GPUShaderStageFlags FRAGMENT = 0x2;
const GPUShaderStageFlags COMPUTE = 0x4;
const GPUShaderStageFlags VERTEX = 1;
const GPUShaderStageFlags FRAGMENT = 2;
const GPUShaderStageFlags COMPUTE = 4;
};
typedef unsigned long GPUShaderStageFlags;
typedef [EnforceRange] unsigned long GPUShaderStageFlags;

View file

@ -2,9 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpuswapchain
// https://gpuweb.github.io/gpuweb/#gpusupportedfeatures
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUSwapChain {
GPUTexture getCurrentTexture();
interface GPUSupportedFeatures {
readonly setlike<DOMString>;
};
GPUSwapChain includes GPUObjectBase;

View file

@ -0,0 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gpusupportedlimits
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUSupportedLimits {
readonly attribute unsigned long maxTextureDimension1D;
readonly attribute unsigned long maxTextureDimension2D;
readonly attribute unsigned long maxTextureDimension3D;
readonly attribute unsigned long maxTextureArrayLayers;
readonly attribute unsigned long maxBindGroups;
readonly attribute unsigned long maxDynamicUniformBuffersPerPipelineLayout;
readonly attribute unsigned long maxDynamicStorageBuffersPerPipelineLayout;
readonly attribute unsigned long maxSampledTexturesPerShaderStage;
readonly attribute unsigned long maxSamplersPerShaderStage;
readonly attribute unsigned long maxStorageBuffersPerShaderStage;
readonly attribute unsigned long maxStorageTexturesPerShaderStage;
readonly attribute unsigned long maxUniformBuffersPerShaderStage;
readonly attribute unsigned long maxUniformBufferBindingSize;
readonly attribute unsigned long maxStorageBufferBindingSize;
readonly attribute unsigned long minUniformBufferOffsetAlignment;
readonly attribute unsigned long minStorageBufferOffsetAlignment;
readonly attribute unsigned long maxVertexBuffers;
readonly attribute unsigned long maxVertexAttributes;
readonly attribute unsigned long maxVertexBufferArrayStride;
readonly attribute unsigned long maxInterStageShaderComponents;
readonly attribute unsigned long maxComputeWorkgroupStorageSize;
readonly attribute unsigned long maxComputeInvocationsPerWorkgroup;
readonly attribute unsigned long maxComputeWorkgroupSizeX;
readonly attribute unsigned long maxComputeWorkgroupSizeY;
readonly attribute unsigned long maxComputeWorkgroupSizeZ;
readonly attribute unsigned long maxComputeWorkgroupsPerDimension;
};

View file

@ -5,6 +5,7 @@
// https://gpuweb.github.io/gpuweb/#gputexture
[Exposed=(Window, DedicatedWorker), Serializable , Pref="dom.webgpu.enabled"]
interface GPUTexture {
[NewObject]
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
undefined destroy();
@ -18,12 +19,13 @@ dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
GPUTextureDimension dimension = "2d";
required GPUTextureFormat format;
required GPUTextureUsageFlags usage;
sequence<GPUTextureFormat> viewFormats = [];
};
enum GPUTextureDimension {
"1d",
"2d",
"3d"
"3d",
};
enum GPUTextureFormat {
@ -57,9 +59,8 @@ enum GPUTextureFormat {
"bgra8unorm",
"bgra8unorm-srgb",
// Packed 32-bit formats
//"rgb9e5ufloat",
"rgb10a2unorm",
//"rg11b10ufloat",
"rg11b10float",
// 64-bit formats
"rg32uint",
@ -75,7 +76,7 @@ enum GPUTextureFormat {
"rgba32float",
// Depth and stencil formats
//"stencil8",
//"stencil8", //TODO
//"depth16unorm",
"depth24plus",
"depth24plus-stencil8",
@ -94,29 +95,22 @@ enum GPUTextureFormat {
"bc5-rg-unorm",
"bc5-rg-snorm",
"bc6h-rgb-ufloat",
//"bc6h-rgb-float",
"bc6h-rgb-float",
"bc7-rgba-unorm",
"bc7-rgba-unorm-srgb",
// "depth24unorm-stencil8" extension
// "depth24unorm-stencil8" feature
//"depth24unorm-stencil8",
// "depth32float-stencil8" extension
// "depth32float-stencil8" feature
//"depth32float-stencil8",
};
enum GPUTextureComponentType {
"float",
"sint",
"uint",
// Texture is used with comparison sampling only.
"depth-comparison"
};
typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
dictionary GPUExtent3DDict {
required GPUIntegerCoordinate width;
required GPUIntegerCoordinate height;
required GPUIntegerCoordinate depth;
GPUIntegerCoordinate height = 1;
GPUIntegerCoordinate depthOrArrayLayers = 1;
};
typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;

View file

@ -2,14 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// https://gpuweb.github.io/gpuweb/#gputextureusage
// https://gpuweb.github.io/gpuweb/#typedefdef-gputextureusageflags
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUTextureUsage {
const GPUTextureUsageFlags COPY_SRC = 0x01;
const GPUTextureUsageFlags COPY_DST = 0x02;
const GPUTextureUsageFlags SAMPLED = 0x04;
const GPUTextureUsageFlags STORAGE = 0x08;
const GPUTextureUsageFlags OUTPUT_ATTACHMENT = 0x10;
const GPUTextureUsageFlags TEXTURE_BINDING = 0x04;
const GPUTextureUsageFlags STORAGE_BINDING = 0x08;
const GPUTextureUsageFlags RENDER_ATTACHMENT = 0x10;
};
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;

View file

@ -5,6 +5,7 @@
// https://gpuweb.github.io/gpuweb/#gpuvalidationerror
[Exposed=(Window, DedicatedWorker), Pref="dom.webgpu.enabled"]
interface GPUValidationError {
[Throws]
constructor(DOMString message);
readonly attribute DOMString message;
};
@ -18,5 +19,6 @@ enum GPUErrorFilter {
partial interface GPUDevice {
undefined pushErrorScope(GPUErrorFilter filter);
[NewObject]
Promise<GPUError?> popErrorScope();
};