summaryrefslogtreecommitdiff
path: root/extensions/webgpu/webgpu.idl
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/webgpu/webgpu.idl')
-rw-r--r--extensions/webgpu/webgpu.idl234
1 files changed, 144 insertions, 90 deletions
diff --git a/extensions/webgpu/webgpu.idl b/extensions/webgpu/webgpu.idl
index 598df7efb..023dcda96 100644
--- a/extensions/webgpu/webgpu.idl
+++ b/extensions/webgpu/webgpu.idl
@@ -6,39 +6,37 @@ dictionary GPUObjectDescriptorBase {
USVString label;
};
+[Exposed=Window]
interface GPUAdapterLimits {
- readonly attribute GPUSize32 maxTextureDimension1D;
- readonly attribute GPUSize32 maxTextureDimension2D;
- readonly attribute GPUSize32 maxTextureDimension3D;
- readonly attribute GPUSize32 maxTextureArrayLayers;
- readonly attribute GPUSize32 maxBindGroups;
- readonly attribute GPUSize32 maxDynamicUniformBuffersPerPipelineLayout;
- readonly attribute GPUSize32 maxDynamicStorageBuffersPerPipelineLayout;
- readonly attribute GPUSize32 maxSampledTexturesPerShaderStage;
- readonly attribute GPUSize32 maxSamplersPerShaderStage;
- readonly attribute GPUSize32 maxStorageBuffersPerShaderStage;
- readonly attribute GPUSize32 maxStorageTexturesPerShaderStage;
- readonly attribute GPUSize32 maxUniformBuffersPerShaderStage;
- readonly attribute GPUSize32 maxUniformBufferBindingSize;
- readonly attribute GPUSize32 maxStorageBufferBindingSize;
- readonly attribute GPUSize32 maxVertexBuffers;
- readonly attribute GPUSize32 maxVertexAttributes;
- readonly attribute GPUSize32 maxVertexBufferArrayStride;
-};
-
-interface GPUAdapterFeatures {
- readonly setlike<GPUFeatureName>;
+ 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 maxVertexBuffers;
+ readonly attribute unsigned long maxVertexAttributes;
+ readonly attribute unsigned long maxVertexBufferArrayStride;
};
[Exposed=Window]
-partial interface Navigator {
- [SameObject] readonly attribute GPU gpu;
+interface GPUSupportedFeatures {
+ readonly setlike<DOMString>;
};
-[Exposed=DedicatedWorker]
-partial interface WorkerNavigator {
+interface mixin NavigatorGPU {
[SameObject] readonly attribute GPU gpu;
};
+Navigator includes NavigatorGPU;
+WorkerNavigator includes NavigatorGPU;
[Exposed=(Window, DedicatedWorker)]
interface GPU {
@@ -54,12 +52,13 @@ enum GPUPowerPreference {
"high-performance"
};
+[Exposed=Window]
interface GPUAdapter {
readonly attribute DOMString name;
- [SameObject] readonly attribute GPUAdapterFeatures features;
+ [SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUAdapterLimits limits;
- Promise<GPUDevice?> requestDevice(optional GPUDeviceDescriptor descriptor = {});
+ Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
};
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
@@ -78,8 +77,7 @@ enum GPUFeatureName {
[Exposed=(Window, DedicatedWorker), Serializable]
interface GPUDevice : EventTarget {
- [SameObject] readonly attribute GPUAdapter adapter;
- readonly attribute FrozenArray<GPUFeatureName> features;
+ [SameObject] readonly attribute GPUSupportedFeatures features;
readonly attribute object limits;
[SameObject] readonly attribute GPUQueue queue;
@@ -107,7 +105,7 @@ interface GPUDevice : EventTarget {
};
GPUDevice includes GPUObjectBase;
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUBuffer {
Promise<undefined> mapAsync(GPUMapModeFlags mode, optional GPUSize64 offset = 0, optional GPUSize64 size);
ArrayBuffer getMappedRange(optional GPUSize64 offset = 0, optional GPUSize64 size);
@@ -124,6 +122,7 @@ dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
+[Exposed=Window]
interface GPUBufferUsage {
const GPUFlagsConstant MAP_READ = 0x0001;
const GPUFlagsConstant MAP_WRITE = 0x0002;
@@ -138,12 +137,13 @@ interface GPUBufferUsage {
};
typedef [EnforceRange] unsigned long GPUMapModeFlags;
+[Exposed=Window]
interface GPUMapMode {
const GPUFlagsConstant READ = 0x0001;
const GPUFlagsConstant WRITE = 0x0002;
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUTexture {
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
@@ -167,6 +167,7 @@ enum GPUTextureDimension {
};
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
+[Exposed=Window]
interface GPUTextureUsage {
const GPUFlagsConstant COPY_SRC = 0x01;
const GPUFlagsConstant COPY_DST = 0x02;
@@ -175,6 +176,7 @@ interface GPUTextureUsage {
const GPUFlagsConstant RENDER_ATTACHMENT = 0x10;
};
+[Exposed=Window]
interface GPUTextureView {
};
GPUTextureView includes GPUObjectBase;
@@ -283,6 +285,7 @@ enum GPUTextureFormat {
"depth32float-stencil8",
};
+[Exposed=Window]
interface GPUSampler {
};
GPUSampler includes GPUObjectBase;
@@ -322,7 +325,7 @@ enum GPUCompareFunction {
"always"
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUBindGroupLayout {
};
GPUBindGroupLayout includes GPUObjectBase;
@@ -332,6 +335,7 @@ dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
};
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
+[Exposed=Window]
interface GPUShaderStage {
const GPUFlagsConstant VERTEX = 0x1;
const GPUFlagsConstant FRAGMENT = 0x2;
@@ -395,6 +399,7 @@ dictionary GPUStorageTextureBindingLayout {
GPUTextureViewDimension viewDimension = "2d";
};
+[Exposed=Window]
interface GPUBindGroup {
};
GPUBindGroup includes GPUObjectBase;
@@ -417,7 +422,7 @@ dictionary GPUBufferBinding {
GPUSize64 size;
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUPipelineLayout {
};
GPUPipelineLayout includes GPUObjectBase;
@@ -426,36 +431,38 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
required sequence<GPUBindGroupLayout> bindGroupLayouts;
};
+[Exposed=Window, Serializable]
+interface GPUShaderModule {
+ Promise<GPUCompilationInfo> compilationInfo();
+};
+GPUShaderModule includes GPUObjectBase;
+
+dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
+ required USVString code;
+ object sourceMap;
+};
+
enum GPUCompilationMessageType {
"error",
"warning",
"info"
};
-[Serializable]
+[Exposed=Window, Serializable]
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;
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUCompilationInfo {
readonly attribute FrozenArray<GPUCompilationMessage> messages;
};
-[Serializable]
-interface GPUShaderModule {
- Promise<GPUCompilationInfo> compilationInfo();
-};
-GPUShaderModule includes GPUObjectBase;
-
-dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
- required USVString code;
- object sourceMap;
-};
-
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
GPUPipelineLayout layout;
};
@@ -469,7 +476,7 @@ dictionary GPUProgrammableStage {
required USVString entryPoint;
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPUComputePipeline {
};
GPUComputePipeline includes GPUObjectBase;
@@ -479,7 +486,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
required GPUProgrammableStage compute;
};
-[Serializable]
+[Exposed=Window, Serializable]
interface GPURenderPipeline {
};
GPURenderPipeline includes GPUObjectBase;
@@ -506,6 +513,9 @@ dictionary GPUPrimitiveState {
GPUIndexFormat stripIndexFormat;
GPUFrontFace frontFace = "ccw";
GPUCullMode cullMode = "none";
+
+ // Enable depth clamping (requires "depth-clamping" feature)
+ boolean clampDepth = false;
};
enum GPUFrontFace {
@@ -542,6 +552,7 @@ dictionary GPUBlendState {
};
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
+[Exposed=Window]
interface GPUColorWrite {
const GPUFlagsConstant RED = 0x1;
const GPUFlagsConstant GREEN = 0x2;
@@ -559,17 +570,17 @@ dictionary GPUBlendComponent {
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 {
@@ -595,9 +606,6 @@ dictionary GPUDepthStencilState {
GPUDepthBias depthBias = 0;
float depthBiasSlopeScale = 0;
float depthBiasClamp = 0;
-
- // Enable depth clamping (requires "depth-clamping" feature)
- boolean clampDepth = false;
};
dictionary GPUStencilFaceState {
@@ -624,36 +632,36 @@ enum GPUIndexFormat {
};
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 {
@@ -678,6 +686,7 @@ dictionary GPUVertexAttribute {
required GPUIndex32 shaderLocation;
};
+[Exposed=Window]
interface GPUCommandBuffer {
readonly attribute Promise<double> executionTime;
};
@@ -686,6 +695,7 @@ GPUCommandBuffer includes GPUObjectBase;
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
};
+[Exposed=Window]
interface GPUCommandEncoder {
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
@@ -752,6 +762,11 @@ dictionary GPUImageCopyTexture {
GPUTextureAspect aspect = "all";
};
+dictionary GPUImageCopyExternalImage {
+ required (ImageBitmap or HTMLCanvasElement or OffscreenCanvas) source;
+ GPUOrigin2D origin = {};
+};
+
interface mixin GPUProgrammablePassEncoder {
undefined setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
@@ -766,6 +781,7 @@ interface mixin GPUProgrammablePassEncoder {
undefined insertDebugMarker(USVString markerLabel);
};
+[Exposed=Window]
interface GPUComputePassEncoder {
undefined setPipeline(GPUComputePipeline pipeline);
undefined dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
@@ -801,6 +817,7 @@ interface mixin GPURenderEncoderBase {
undefined drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
};
+[Exposed=Window]
interface GPURenderPassEncoder {
undefined setViewport(float x, float y,
float width, float height,
@@ -809,7 +826,7 @@ interface GPURenderPassEncoder {
undefined setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
- undefined setBlendColor(GPUColor color);
+ undefined setBlendConstant(GPUColor color);
undefined setStencilReference(GPUStencilValue reference);
undefined beginOcclusionQuery(GPUSize32 queryIndex);
@@ -838,7 +855,7 @@ dictionary GPURenderPassColorAttachment {
GPUTextureView resolveTarget;
required (GPULoadOp or GPUColor) loadValue;
- GPUStoreOp storeOp = "store";
+ required GPUStoreOp storeOp;
};
dictionary GPURenderPassDepthStencilAttachment {
@@ -862,6 +879,7 @@ enum GPUStoreOp {
"clear"
};
+[Exposed=Window]
interface GPURenderBundle {
};
GPURenderBundle includes GPUObjectBase;
@@ -869,6 +887,7 @@ GPURenderBundle includes GPUObjectBase;
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
};
+[Exposed=Window]
interface GPURenderBundleEncoder {
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
};
@@ -882,6 +901,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
GPUSize32 sampleCount = 1;
};
+[Exposed=Window]
interface GPUQueue {
undefined submit(sequence<GPUCommandBuffer> commandBuffers);
@@ -899,9 +919,15 @@ interface GPUQueue {
[AllowShared] BufferSource data,
GPUImageDataLayout dataLayout,
GPUExtent3D size);
+
+ undefined copyExternalImageToTexture(
+ GPUImageCopyExternalImage source,
+ GPUImageCopyTexture destination,
+ GPUExtent3D copySize);
};
GPUQueue includes GPUObjectBase;
+[Exposed=Window]
interface GPUQuerySet {
undefined destroy();
};
@@ -927,10 +953,36 @@ enum GPUPipelineStatisticName {
"compute-shader-invocations"
};
+[Exposed=Window]
+interface GPUCanvasContext {
+ GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
+
+ GPUTextureFormat getSwapChainPreferredFormat(GPUAdapter adapter);
+};
+
+enum GPUCanvasCompositingAlphaMode {
+ "opaque",
+ "premultiplied",
+};
+
+dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
+ required GPUDevice device;
+ required GPUTextureFormat format;
+ GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.RENDER_ATTACHMENT
+ GPUCanvasCompositingAlphaMode compositingAlphaMode = "opaque";
+};
+
+[Exposed=Window]
+interface GPUSwapChain {
+ GPUTexture getCurrentTexture();
+};
+GPUSwapChain includes GPUObjectBase;
+
enum GPUDeviceLostReason {
"destroyed",
};
+[Exposed=Window]
interface GPUDeviceLostInfo {
readonly attribute (GPUDeviceLostReason or undefined) reason;
readonly attribute DOMString message;
@@ -945,10 +997,12 @@ enum GPUErrorFilter {
"validation"
};
+[Exposed=Window]
interface GPUOutOfMemoryError {
constructor();
};
+[Exposed=Window]
interface GPUValidationError {
constructor(DOMString message);
readonly attribute DOMString message;
@@ -1016,7 +1070,7 @@ dictionary GPUOrigin3DDict {
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
dictionary GPUExtent3DDict {
- GPUIntegerCoordinate width = 1;
+ required GPUIntegerCoordinate width;
GPUIntegerCoordinate height = 1;
GPUIntegerCoordinate depthOrArrayLayers = 1;
};