mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
[WIP] Add support for unstable WebIDL (#1997)
* Re-enable WebGPU WebIDL as experimental * Add `web_sys_unstable_apis` attribute * Add test for unstable WebIDL * Include unstable WebIDL in docs.rs builds * Add docs and doc comment for unstable APIs * Add unstable API checks to CI
This commit is contained in:
@ -389,6 +389,105 @@ Geolocation = []
|
||||
GetNotificationOptions = []
|
||||
GetRootNodeOptions = []
|
||||
GetUserMediaRequest = []
|
||||
Gpu = []
|
||||
GpuAdapter = []
|
||||
GpuAddressMode = []
|
||||
GpuBindGroup = []
|
||||
GpuBindGroupBinding = []
|
||||
GpuBindGroupDescriptor = []
|
||||
GpuBindGroupLayout = []
|
||||
GpuBindGroupLayoutBinding = []
|
||||
GpuBindGroupLayoutDescriptor = []
|
||||
GpuBindingType = []
|
||||
GpuBlendDescriptor = []
|
||||
GpuBlendFactor = []
|
||||
GpuBlendOperation = []
|
||||
GpuBuffer = []
|
||||
GpuBufferBinding = []
|
||||
GpuBufferCopyView = []
|
||||
GpuBufferDescriptor = []
|
||||
GpuBufferUsage = []
|
||||
GpuCanvasContext = []
|
||||
GpuColorDict = []
|
||||
GpuColorStateDescriptor = []
|
||||
GpuColorWrite = []
|
||||
GpuCommandBuffer = []
|
||||
GpuCommandBufferDescriptor = []
|
||||
GpuCommandEncoder = []
|
||||
GpuCommandEncoderDescriptor = []
|
||||
GpuCompareFunction = []
|
||||
GpuComputePassDescriptor = []
|
||||
GpuComputePassEncoder = []
|
||||
GpuComputePipeline = []
|
||||
GpuComputePipelineDescriptor = []
|
||||
GpuCullMode = []
|
||||
GpuDepthStencilStateDescriptor = []
|
||||
GpuDevice = []
|
||||
GpuDeviceDescriptor = []
|
||||
GpuDeviceLostInfo = []
|
||||
GpuErrorFilter = []
|
||||
GpuExtensionName = []
|
||||
GpuExtent3dDict = []
|
||||
GpuFence = []
|
||||
GpuFenceDescriptor = []
|
||||
GpuFilterMode = []
|
||||
GpuFrontFace = []
|
||||
GpuImageBitmapCopyView = []
|
||||
GpuIndexFormat = []
|
||||
GpuInputStepMode = []
|
||||
GpuLimits = []
|
||||
GpuLoadOp = []
|
||||
GpuObjectDescriptorBase = []
|
||||
GpuOrigin2dDict = []
|
||||
GpuOrigin3dDict = []
|
||||
GpuOutOfMemoryError = []
|
||||
GpuPipelineDescriptorBase = []
|
||||
GpuPipelineLayout = []
|
||||
GpuPipelineLayoutDescriptor = []
|
||||
GpuPowerPreference = []
|
||||
GpuPrimitiveTopology = []
|
||||
GpuProgrammableStageDescriptor = []
|
||||
GpuQueue = []
|
||||
GpuRasterizationStateDescriptor = []
|
||||
GpuRenderBundle = []
|
||||
GpuRenderBundleDescriptor = []
|
||||
GpuRenderBundleEncoder = []
|
||||
GpuRenderBundleEncoderDescriptor = []
|
||||
GpuRenderPassColorAttachmentDescriptor = []
|
||||
GpuRenderPassDepthStencilAttachmentDescriptor = []
|
||||
GpuRenderPassDescriptor = []
|
||||
GpuRenderPassEncoder = []
|
||||
GpuRenderPipeline = []
|
||||
GpuRenderPipelineDescriptor = []
|
||||
GpuRequestAdapterOptions = []
|
||||
GpuSampler = []
|
||||
GpuSamplerDescriptor = []
|
||||
GpuShaderModule = []
|
||||
GpuShaderModuleDescriptor = []
|
||||
GpuShaderStage = []
|
||||
GpuStencilOperation = []
|
||||
GpuStencilStateFaceDescriptor = []
|
||||
GpuStoreOp = []
|
||||
GpuSwapChain = []
|
||||
GpuSwapChainDescriptor = []
|
||||
GpuTexture = []
|
||||
GpuTextureAspect = []
|
||||
GpuTextureComponentType = []
|
||||
GpuTextureCopyView = []
|
||||
GpuTextureDescriptor = []
|
||||
GpuTextureDimension = []
|
||||
GpuTextureFormat = []
|
||||
GpuTextureUsage = []
|
||||
GpuTextureView = []
|
||||
GpuTextureViewDescriptor = []
|
||||
GpuTextureViewDimension = []
|
||||
GpuUncapturedErrorEvent = []
|
||||
GpuUncapturedErrorEventInit = []
|
||||
GpuValidationError = []
|
||||
GpuVertexAttributeDescriptor = []
|
||||
GpuVertexBufferLayoutDescriptor = []
|
||||
GpuVertexFormat = []
|
||||
GpuVertexStateDescriptor = []
|
||||
GridDeclaration = []
|
||||
GridTrackState = []
|
||||
GroupedHistoryEventInit = []
|
||||
|
@ -7,16 +7,12 @@ use std::fs;
|
||||
use std::path::{self, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
#[cfg(feature = "env_logger")]
|
||||
env_logger::init();
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=webidls/enabled");
|
||||
|
||||
let entries = fs::read_dir("webidls/enabled").context("reading webidls/enabled directory")?;
|
||||
/// Read all WebIDL files in a directory into a single `SourceFile`
|
||||
fn read_source_from_path(dir: &str) -> Result<SourceFile> {
|
||||
let entries = fs::read_dir(dir).context("reading webidls/enabled directory")?;
|
||||
let mut source = SourceFile::default();
|
||||
for entry in entries {
|
||||
let entry = entry.context("getting webidls/enabled/*.webidl entry")?;
|
||||
let entry = entry.context(format!("getting {}/*.webidl entry", dir))?;
|
||||
let path = entry.path();
|
||||
if path.extension() != Some(OsStr::new("webidl")) {
|
||||
continue;
|
||||
@ -27,6 +23,16 @@ fn main() -> Result<()> {
|
||||
.with_context(|| format!("reading contents of file \"{}\"", path.display()))?;
|
||||
}
|
||||
|
||||
Ok(source)
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
#[cfg(feature = "env_logger")]
|
||||
env_logger::init();
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=webidls/enabled");
|
||||
println!("cargo:rerun-if-changed=webidls/unstable");
|
||||
|
||||
// Read our manifest, learn all `[feature]` directives with "toml parsing".
|
||||
// Use all these names to match against environment variables set by Cargo
|
||||
// to figure out which features are activated to we can pass that down to
|
||||
@ -63,7 +69,10 @@ fn main() -> Result<()> {
|
||||
Some(&allowed[..])
|
||||
};
|
||||
|
||||
let bindings = match wasm_bindgen_webidl::compile(&source.contents, allowed) {
|
||||
let source = read_source_from_path("webidls/enabled")?;
|
||||
let unstable_source = read_source_from_path("webidls/unstable")?;
|
||||
|
||||
let bindings = match wasm_bindgen_webidl::compile(&source.contents, &unstable_source.contents, allowed) {
|
||||
Ok(bindings) => bindings,
|
||||
Err(e) => {
|
||||
if let Some(err) = e.downcast_ref::<wasm_bindgen_webidl::WebIDLParseError>() {
|
||||
|
638
crates/web-sys/webidls/disabled/WebGPU.webidl
vendored
638
crates/web-sys/webidls/disabled/WebGPU.webidl
vendored
@ -1,638 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
|
||||
*/
|
||||
|
||||
typedef unsigned long u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
// ****************************************************************************
|
||||
// ERROR HANDLING
|
||||
// ****************************************************************************
|
||||
|
||||
enum WebGPULogEntryType {
|
||||
"device-lost",
|
||||
"validation-error",
|
||||
"recoverable-out-of-memory",
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPULogEntry {
|
||||
readonly attribute WebGPULogEntryType type;
|
||||
readonly attribute any obj;
|
||||
readonly attribute DOMString? reason;
|
||||
};
|
||||
|
||||
enum WebGPUObjectStatus {
|
||||
"valid",
|
||||
"out-of-memory",
|
||||
"invalid",
|
||||
};
|
||||
|
||||
typedef (WebGPUBuffer or WebGPUTexture) WebGPUStatusable;
|
||||
|
||||
callback WebGPULogCallback = void (WebGPULogEntry error);
|
||||
|
||||
// ****************************************************************************
|
||||
// SHADER RESOURCES (buffer, textures, texture views, samples)
|
||||
// ****************************************************************************
|
||||
|
||||
// Buffer
|
||||
typedef u32 WebGPUBufferUsageFlags;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBufferUsage {
|
||||
const u32 NONE = 0;
|
||||
const u32 MAP_READ = 1;
|
||||
const u32 MAP_WRITE = 2;
|
||||
const u32 TRANSFER_SRC = 4;
|
||||
const u32 TRANSFER_DST = 8;
|
||||
const u32 INDEX = 16;
|
||||
const u32 VERTEX = 32;
|
||||
const u32 UNIFORM = 64;
|
||||
const u32 STORAGE = 128;
|
||||
};
|
||||
|
||||
dictionary WebGPUBufferDescriptor {
|
||||
u32 size;
|
||||
WebGPUBufferUsageFlags usage;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBuffer {
|
||||
readonly attribute ArrayBuffer? mapping;
|
||||
void unmap();
|
||||
};
|
||||
|
||||
// Texture view
|
||||
dictionary WebGPUTextureViewDescriptor {
|
||||
// TODO Investigate what goes in there.
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUTextureView {
|
||||
};
|
||||
|
||||
// Texture
|
||||
typedef u32 WebGPUTextureDimensionEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUTextureDimension {
|
||||
const u32 e1D = 0;
|
||||
const u32 e2D = 1;
|
||||
const u32 e3D = 2;
|
||||
// TODO other dimensions (cube, arrays)
|
||||
};
|
||||
|
||||
typedef u32 WebGPUTextureFormatEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUTextureFormat {
|
||||
const u32 R8_G8_B8_A8_UNORM = 0;
|
||||
const u32 R8_G8_B8_A8_UINT = 1;
|
||||
const u32 B8_G8_R8_A8_UNORM = 2;
|
||||
const u32 D32_FLOAT_S8_UINT = 3;
|
||||
// TODO other formats
|
||||
};
|
||||
|
||||
typedef u32 WebGPUTextureUsageFlags;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUTextureUsage {
|
||||
const u32 NONE = 0;
|
||||
const u32 TRANSFER_SRC = 1;
|
||||
const u32 TRANSFER_DST = 2;
|
||||
const u32 SAMPLED = 4;
|
||||
const u32 STORAGE = 8;
|
||||
const u32 OUTPUT_ATTACHMENT = 16;
|
||||
const u32 PRESENT = 32;
|
||||
};
|
||||
|
||||
dictionary WebGPUTextureDescriptor {
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 depth;
|
||||
u32 arraySize;
|
||||
WebGPUTextureDimensionEnum dimension;
|
||||
WebGPUTextureFormatEnum format;
|
||||
WebGPUTextureUsageFlags usage;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUTexture {
|
||||
WebGPUTextureView createTextureView(optional WebGPUTextureViewDescriptor desc);
|
||||
};
|
||||
|
||||
// Sampler
|
||||
typedef u32 WebGPUFilterModeEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUFilterMode {
|
||||
const u32 NEAREST = 0;
|
||||
const u32 LINEAR = 1;
|
||||
};
|
||||
|
||||
dictionary WebGPUSamplerDescriptor {
|
||||
WebGPUFilterModeEnum magFilter;
|
||||
WebGPUFilterModeEnum minFilter;
|
||||
WebGPUFilterModeEnum mipmapFilter;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUSampler {
|
||||
};
|
||||
|
||||
// ****************************************************************************
|
||||
// BINDING MODEL (bindgroup layout, bindgroup)
|
||||
// ****************************************************************************
|
||||
|
||||
// BindGroupLayout
|
||||
typedef u32 WebGPUShaderStageFlags;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUShaderStageBit {
|
||||
const u32 NONE = 0;
|
||||
const u32 VERTEX = 1;
|
||||
const u32 FRAGMENT = 2;
|
||||
const u32 COMPUTE = 4;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUBindingTypeEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBindingType {
|
||||
const u32 UNIFORM_BUFFER = 0;
|
||||
const u32 SAMPLER = 1;
|
||||
const u32 SAMPLED_TEXTURE = 2;
|
||||
const u32 STORAGE_BUFFER = 3;
|
||||
// TODO other binding types (storage images, ...)
|
||||
};
|
||||
|
||||
dictionary WebGPUBindGroupBinding {
|
||||
WebGPUShaderStageFlags visibility;
|
||||
WebGPUBindingTypeEnum type;
|
||||
u32 start;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
dictionary WebGPUBindGroupLayoutDescriptor {
|
||||
sequence<WebGPUBindGroupBinding> bindingTypes;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBindGroupLayout {
|
||||
};
|
||||
|
||||
// PipelineLayout
|
||||
dictionary WebGPUPipelineLayoutDescriptor {
|
||||
sequence<WebGPUBindGroupLayout> bindGroupLayouts;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUPipelineLayout {
|
||||
};
|
||||
|
||||
// BindGroup
|
||||
/* Moved to WebGPUExtras.webidl for now.
|
||||
dictionary WebGPUBufferBinding {
|
||||
WebGPUBuffer buffer;
|
||||
u32 offset;
|
||||
u32 size;
|
||||
};
|
||||
*/
|
||||
|
||||
typedef (WebGPUSampler or WebGPUTextureView or WebGPUBufferBinding) WebGPUBindingResource;
|
||||
|
||||
dictionary WebGPUBinding {
|
||||
sequence<WebGPUBindingResource> resources;
|
||||
u32 start;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
dictionary WebGPUBindGroupDescriptor {
|
||||
WebGPUBindGroupLayout layout;
|
||||
sequence<WebGPUBinding> bindings;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBindGroup {
|
||||
};
|
||||
|
||||
// ****************************************************************************
|
||||
// PIPELINE CREATION (blend state, DS state, ..., pipelines)
|
||||
// ****************************************************************************
|
||||
|
||||
// BlendState
|
||||
typedef u32 WebGPUBlendFactorEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBlendFactor {
|
||||
const u32 ZERO = 0;
|
||||
const u32 ONE = 1;
|
||||
const u32 SRC_COLOR = 2;
|
||||
const u32 ONE_MINUS_SRC_COLOR = 3;
|
||||
const u32 SRC_ALPHA = 4;
|
||||
const u32 ONE_MINUS_SRC_ALPHA = 5;
|
||||
const u32 DST_COLOR = 6;
|
||||
const u32 ONE_MINUS_DST_COLOR = 7;
|
||||
const u32 DST_ALPHA = 8;
|
||||
const u32 ONE_MINUS_DST_ALPHA = 9;
|
||||
const u32 SRC_ALPHA_SATURATED = 10;
|
||||
const u32 BLEND_COLOR = 11;
|
||||
const u32 ONE_MINUS_BLEND_COLOR = 12;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUBlendOperationEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBlendOperation {
|
||||
const u32 ADD = 0;
|
||||
const u32 SUBTRACT = 1;
|
||||
const u32 REVERSE_SUBTRACT = 2;
|
||||
const u32 MIN = 3;
|
||||
const u32 MAX = 4;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUColorWriteFlags;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUColorWriteBits {
|
||||
const u32 NONE = 0;
|
||||
const u32 RED = 1;
|
||||
const u32 GREEN = 2;
|
||||
const u32 BLUE = 4;
|
||||
const u32 ALPHA = 8;
|
||||
const u32 ALL = 15;
|
||||
};
|
||||
|
||||
dictionary WebGPUBlendDescriptor {
|
||||
WebGPUBlendFactorEnum srcFactor;
|
||||
WebGPUBlendFactorEnum dstFactor;
|
||||
WebGPUBlendOperationEnum operation;
|
||||
};
|
||||
|
||||
dictionary WebGPUBlendStateDescriptor {
|
||||
boolean blendEnabled;
|
||||
WebGPUBlendDescriptor alpha;
|
||||
WebGPUBlendDescriptor color;
|
||||
WebGPUColorWriteFlags writeMask;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUBlendState {
|
||||
};
|
||||
|
||||
// DepthStencilState
|
||||
typedef u32 WebGPUCompareFunctionEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUCompareFunction {
|
||||
const u32 NEVER = 0;
|
||||
const u32 LESS = 1;
|
||||
const u32 LESS_EQUAL = 2;
|
||||
const u32 GREATER = 3;
|
||||
const u32 GREATER_EQUAL = 4;
|
||||
const u32 EQUAL = 5;
|
||||
const u32 NOT_EQUAL = 6;
|
||||
const u32 ALWAYS = 7;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUStencilOperationEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUStencilOperation {
|
||||
const u32 KEEP = 0;
|
||||
const u32 ZERO = 1;
|
||||
const u32 REPLACE = 2;
|
||||
const u32 INVERT = 3;
|
||||
const u32 INCREMENT_CLAMP = 4;
|
||||
const u32 DECREMENT_CLAMP = 5;
|
||||
const u32 INCREMENT_WRAP = 6;
|
||||
const u32 DECREMENT_WRAP = 7;
|
||||
};
|
||||
|
||||
dictionary WebGPUStencilStateFaceDescriptor {
|
||||
WebGPUCompareFunctionEnum compare;
|
||||
WebGPUStencilOperationEnum stencilFailOp;
|
||||
WebGPUStencilOperationEnum depthFailOp;
|
||||
WebGPUStencilOperationEnum passOp;
|
||||
};
|
||||
|
||||
dictionary WebGPUDepthStencilStateDescriptor {
|
||||
boolean depthWriteEnabled;
|
||||
WebGPUCompareFunctionEnum depthCompare;
|
||||
|
||||
WebGPUStencilStateFaceDescriptor front;
|
||||
WebGPUStencilStateFaceDescriptor back;
|
||||
|
||||
u32 stencilReadMask;
|
||||
u32 stencilWriteMask;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUDepthStencilState {
|
||||
};
|
||||
|
||||
// InputState
|
||||
typedef u32 WebGPUIndexFormatEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUIndexFormat {
|
||||
const u32 UINT16 = 0;
|
||||
const u32 UINT32 = 1;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUVertexFormatEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUVertexFormat {
|
||||
const u32 FLOAT_R32_G32_B32_A32 = 0;
|
||||
const u32 FLOAT_R32_G32_B32 = 1;
|
||||
const u32 FLOAT_R32_G32 = 2;
|
||||
const u32 FLOAT_R32 = 3;
|
||||
// TODO other vertex formats
|
||||
};
|
||||
|
||||
typedef u32 WebGPUInputStepModeEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUInputStepMode {
|
||||
const u32 VERTEX = 0;
|
||||
const u32 INSTANCE = 1;
|
||||
};
|
||||
|
||||
dictionary WebGPUVertexAttributeDescriptor {
|
||||
u32 shaderLocation;
|
||||
u32 inputSlot;
|
||||
u32 offset;
|
||||
WebGPUVertexFormatEnum format;
|
||||
};
|
||||
|
||||
dictionary WebGPUVertexInputDescriptor {
|
||||
u32 inputSlot;
|
||||
u32 stride;
|
||||
WebGPUInputStepModeEnum stepMode;
|
||||
};
|
||||
|
||||
dictionary WebGPUInputStateDescriptor {
|
||||
WebGPUIndexFormatEnum indexFormat;
|
||||
|
||||
sequence<WebGPUVertexAttributeDescriptor> attributes;
|
||||
sequence<WebGPUVertexInputDescriptor> inputs;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUInputState {
|
||||
};
|
||||
|
||||
// ShaderModule
|
||||
dictionary WebGPUShaderModuleDescriptor {
|
||||
required ArrayBuffer code;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUShaderModule {
|
||||
};
|
||||
|
||||
// AttachmentState
|
||||
dictionary WebGPUAttachmentStateDescriptor {
|
||||
sequence<WebGPUTextureFormatEnum> formats;
|
||||
// TODO other stuff like sample count etc.
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUAttachmentState {
|
||||
};
|
||||
|
||||
// Common stuff for ComputePipeline and RenderPipeline
|
||||
typedef u32 WebGPUShaderStageEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUShaderStage {
|
||||
const u32 VERTEX = 0;
|
||||
const u32 FRAGMENT = 1;
|
||||
const u32 COMPUTE = 2;
|
||||
};
|
||||
|
||||
dictionary WebGPUPipelineStageDescriptor {
|
||||
required WebGPUShaderModule shaderModule;
|
||||
required WebGPUShaderStageEnum stage;
|
||||
required DOMString entryPoint;
|
||||
// TODO other stuff like specialization constants?
|
||||
};
|
||||
|
||||
dictionary WebGPUPipelineDescriptorBase {
|
||||
required WebGPUPipelineLayout layout;
|
||||
sequence<WebGPUPipelineStageDescriptor> stages;
|
||||
};
|
||||
|
||||
// ComputePipeline
|
||||
dictionary WebGPUComputePipelineDescriptor : WebGPUPipelineDescriptorBase {
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUComputePipeline {
|
||||
};
|
||||
|
||||
// WebGPURenderPipeline
|
||||
typedef u32 WebGPUPrimitiveTopologyEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUPrimitiveTopology {
|
||||
const u32 POINT_LIST = 0;
|
||||
const u32 LINE_LIST = 1;
|
||||
const u32 LINE_STRIP = 2;
|
||||
const u32 TRIANGLE_LIST = 3;
|
||||
const u32 TRIANGLE_STRIP = 4;
|
||||
};
|
||||
|
||||
dictionary WebGPURenderPipelineDescriptor : WebGPUPipelineDescriptorBase {
|
||||
WebGPUPrimitiveTopologyEnum primitiveTopology;
|
||||
sequence<WebGPUBlendState> blendState;
|
||||
WebGPUDepthStencilState depthStencilState;
|
||||
WebGPUInputState inputState;
|
||||
WebGPUAttachmentState attachmentState;
|
||||
// TODO other properties
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPURenderPipeline {
|
||||
};
|
||||
// ****************************************************************************
|
||||
// COMMAND RECORDING (Command buffer and all relevant structures)
|
||||
// ****************************************************************************
|
||||
|
||||
typedef u32 WebGPULoadOpEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPULoadOp {
|
||||
const u32 CLEAR = 0;
|
||||
const u32 LOAD = 1;
|
||||
};
|
||||
|
||||
typedef u32 WebGPUStoreOpEnum;
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUStoreOp {
|
||||
const u32 STORE = 0;
|
||||
};
|
||||
|
||||
dictionary WebGPURenderPassAttachmentDescriptor {
|
||||
WebGPUTextureView attachment;
|
||||
WebGPULoadOpEnum loadOp;
|
||||
WebGPUStoreOpEnum storeOp;
|
||||
};
|
||||
|
||||
dictionary WebGPURenderPassDescriptor {
|
||||
sequence<WebGPURenderPassAttachmentDescriptor> colorAttachments;
|
||||
WebGPURenderPassAttachmentDescriptor depthStencilAttachment;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUCommandBuffer {
|
||||
};
|
||||
|
||||
dictionary WebGPUCommandEncoderDescriptor {
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUCommandEncoder {
|
||||
WebGPUCommandBuffer finishEncoding();
|
||||
|
||||
// Commands allowed outside of "passes"
|
||||
void copyBufferToBuffer(WebGPUBuffer src,
|
||||
u32 srcOffset,
|
||||
WebGPUBuffer dst,
|
||||
u32 dstOffset,
|
||||
u32 size);
|
||||
// TODO figure out all the arguments required for these
|
||||
void copyBufferToTexture();
|
||||
void copyTextureToBuffer();
|
||||
void copyTextureToTexture();
|
||||
void blit();
|
||||
|
||||
void transitionBuffer(WebGPUBuffer b, WebGPUBufferUsageFlags f);
|
||||
|
||||
// Allowed in both compute and render passes
|
||||
void setPushConstants(WebGPUShaderStageFlags stage,
|
||||
u32 offset,
|
||||
u32 count,
|
||||
ArrayBuffer data);
|
||||
void setBindGroup(u32 index, WebGPUBindGroup bindGroup);
|
||||
void setPipeline((WebGPUComputePipeline or WebGPURenderPipeline) pipeline);
|
||||
|
||||
// Compute pass commands
|
||||
void beginComputePass();
|
||||
void endComputePass();
|
||||
|
||||
void dispatch(u32 x, u32 y, u32 z);
|
||||
|
||||
// Render pass commands
|
||||
void beginRenderPass(optional WebGPURenderPassDescriptor descriptor);
|
||||
void endRenderPass();
|
||||
|
||||
void setBlendColor(float r, float g, float b, float a);
|
||||
void setIndexBuffer(WebGPUBuffer buffer, u32 offset);
|
||||
void setVertexBuffers(u32 startSlot, sequence<WebGPUBuffer> buffers, sequence<u32> offsets);
|
||||
|
||||
void draw(u32 vertexCount, u32 instanceCount, u32 firstVertex, u32 firstInstance);
|
||||
void drawIndexed(u32 indexCount, u32 instanceCount, u32 firstIndex, u32 firstInstance, u32 firstVertex);
|
||||
|
||||
// TODO add missing commands
|
||||
};
|
||||
|
||||
// ****************************************************************************
|
||||
// OTHER (Fence, Queue SwapChain, Device)
|
||||
// ****************************************************************************
|
||||
|
||||
// Fence
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUFence {
|
||||
boolean wait(double milliseconds);
|
||||
readonly attribute Promise<void> promise;
|
||||
};
|
||||
|
||||
// Queue
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUQueue {
|
||||
void submit(sequence<WebGPUCommandBuffer> buffers);
|
||||
WebGPUFence insertFence();
|
||||
};
|
||||
|
||||
// SwapChain / RenderingContext
|
||||
dictionary WebGPUSwapChainDescriptor {
|
||||
WebGPUTextureUsageFlags usage;
|
||||
WebGPUTextureFormatEnum format;
|
||||
u32 width;
|
||||
u32 height;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUSwapChain {
|
||||
void configure(optional WebGPUSwapChainDescriptor descriptor);
|
||||
WebGPUTexture getNextTexture();
|
||||
void present();
|
||||
};
|
||||
|
||||
//[Pref="dom.webgpu.enable"]
|
||||
//interface WebGPURenderingContext : WebGPUSwapChain {
|
||||
//};
|
||||
|
||||
// WebGPU "namespace" used for device creation
|
||||
dictionary WebGPUExtensions {
|
||||
boolean anisotropicFiltering;
|
||||
boolean logicOp; // Previously a "Feature".
|
||||
};
|
||||
|
||||
dictionary WebGPULimits {
|
||||
u32 maxBindGroups;
|
||||
};
|
||||
|
||||
// Device
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUDevice {
|
||||
readonly attribute WebGPUAdapter adapter;
|
||||
WebGPUExtensions extensions();
|
||||
WebGPULimits limits();
|
||||
|
||||
WebGPUBuffer createBuffer(optional WebGPUBufferDescriptor descriptor);
|
||||
WebGPUTexture createTexture(optional WebGPUTextureDescriptor descriptor);
|
||||
WebGPUSampler createSampler(optional WebGPUSamplerDescriptor descriptor);
|
||||
|
||||
WebGPUBindGroupLayout createBindGroupLayout(optional WebGPUBindGroupLayoutDescriptor descriptor);
|
||||
WebGPUPipelineLayout createPipelineLayout(optional WebGPUPipelineLayoutDescriptor descriptor);
|
||||
WebGPUBindGroup createBindGroup(optional WebGPUBindGroupDescriptor descriptor);
|
||||
|
||||
WebGPUBlendState createBlendState(optional WebGPUBlendStateDescriptor descriptor);
|
||||
WebGPUDepthStencilState createDepthStencilState(optional WebGPUDepthStencilStateDescriptor descriptor);
|
||||
WebGPUInputState createInputState(optional WebGPUInputStateDescriptor descriptor);
|
||||
WebGPUShaderModule createShaderModule(WebGPUShaderModuleDescriptor descriptor);
|
||||
WebGPUAttachmentState createAttachmentState(optional WebGPUAttachmentStateDescriptor descriptor);
|
||||
WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);
|
||||
WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor);
|
||||
|
||||
WebGPUCommandEncoder createCommandEncoder(optional WebGPUCommandEncoderDescriptor descriptor);
|
||||
|
||||
WebGPUQueue getQueue();
|
||||
|
||||
attribute WebGPULogCallback onLog;
|
||||
Promise<WebGPUObjectStatus> getObjectStatus(WebGPUStatusable obj);
|
||||
};
|
||||
|
||||
dictionary WebGPUDeviceDescriptor {
|
||||
WebGPUExtensions extensions;
|
||||
//WebGPULimits limits; Don't expose higher limits for now.
|
||||
|
||||
// TODO are other things configurable like queues?
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPUAdapter {
|
||||
readonly attribute DOMString name;
|
||||
WebGPUExtensions extensions();
|
||||
//WebGPULimits limits(); Don't expose higher limits for now.
|
||||
|
||||
WebGPUDevice createDevice(optional WebGPUDeviceDescriptor descriptor);
|
||||
};
|
||||
|
||||
enum WebGPUPowerPreference { "default", "low-power", "high-performance" };
|
||||
|
||||
dictionary WebGPUAdapterDescriptor {
|
||||
WebGPUPowerPreference powerPreference;
|
||||
};
|
||||
|
||||
[Pref="dom.webgpu.enable"]
|
||||
interface WebGPU {
|
||||
WebGPUAdapter getAdapter(optional WebGPUAdapterDescriptor desc);
|
||||
};
|
||||
|
||||
// Add a "webgpu" member to Window that contains the global instance of a "WebGPU"
|
||||
interface mixin WebGPUProvider {
|
||||
[SameObject, Replaceable, Pref="dom.webgpu.enable"] readonly attribute WebGPU webgpu;
|
||||
};
|
||||
//Window includes WebGPUProvider;
|
@ -1,14 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Some parts of WebGPU.webidl need to be pulled into a different file due to a codegen
|
||||
* bug/missing support.
|
||||
*/
|
||||
|
||||
dictionary WebGPUBufferBinding {
|
||||
WebGPUBuffer buffer;
|
||||
u32 offset;
|
||||
u32 size;
|
||||
};
|
2
crates/web-sys/webidls/enabled/Window.webidl
vendored
2
crates/web-sys/webidls/enabled/Window.webidl
vendored
@ -272,5 +272,3 @@ dictionary IdleRequestOptions {
|
||||
};
|
||||
|
||||
callback IdleRequestCallback = void (IdleDeadline deadline);
|
||||
|
||||
//Window includes WebGPUProvider;
|
||||
|
864
crates/web-sys/webidls/unstable/WebGPU.webidl
vendored
Normal file
864
crates/web-sys/webidls/unstable/WebGPU.webidl
vendored
Normal file
@ -0,0 +1,864 @@
|
||||
interface mixin GPUObjectBase {
|
||||
attribute DOMString? label;
|
||||
};
|
||||
|
||||
dictionary GPUObjectDescriptorBase {
|
||||
DOMString label;
|
||||
};
|
||||
|
||||
[Exposed=Window]
|
||||
partial interface Navigator {
|
||||
[SameObject] readonly attribute GPU gpu;
|
||||
};
|
||||
|
||||
[Exposed=DedicatedWorker]
|
||||
partial interface WorkerNavigator {
|
||||
[SameObject] readonly attribute GPU gpu;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker)]
|
||||
interface GPU {
|
||||
Promise<GPUAdapter> requestAdapter(optional GPURequestAdapterOptions options = {});
|
||||
};
|
||||
|
||||
dictionary GPURequestAdapterOptions {
|
||||
GPUPowerPreference powerPreference;
|
||||
};
|
||||
|
||||
enum GPUPowerPreference {
|
||||
"low-power",
|
||||
"high-performance"
|
||||
};
|
||||
|
||||
interface GPUAdapter {
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute FrozenArray<GPUExtensionName> extensions;
|
||||
//readonly attribute GPULimits limits; Don’t expose higher limits for now.
|
||||
|
||||
Promise<GPUDevice> requestDevice(optional GPUDeviceDescriptor descriptor = {});
|
||||
};
|
||||
|
||||
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
|
||||
sequence<GPUExtensionName> extensions = [];
|
||||
GPULimits limits = {};
|
||||
};
|
||||
|
||||
enum GPUExtensionName {
|
||||
"texture-compression-bc"
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable]
|
||||
interface GPUDevice : EventTarget {
|
||||
[SameObject] readonly attribute GPUAdapter adapter;
|
||||
readonly attribute FrozenArray<GPUExtensionName> extensions;
|
||||
readonly attribute object limits;
|
||||
|
||||
[SameObject] readonly attribute GPUQueue defaultQueue;
|
||||
|
||||
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
|
||||
GPUMappedBuffer createBufferMapped(GPUBufferDescriptor descriptor);
|
||||
GPUTexture createTexture(GPUTextureDescriptor descriptor);
|
||||
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
|
||||
|
||||
GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor);
|
||||
GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor);
|
||||
GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor);
|
||||
|
||||
GPUShaderModule createShaderModule(GPUShaderModuleDescriptor descriptor);
|
||||
GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor);
|
||||
GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor);
|
||||
|
||||
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
|
||||
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
|
||||
};
|
||||
GPUDevice includes GPUObjectBase;
|
||||
|
||||
[Serializable]
|
||||
interface GPUBuffer {
|
||||
Promise<ArrayBuffer> mapReadAsync();
|
||||
Promise<ArrayBuffer> mapWriteAsync();
|
||||
void unmap();
|
||||
|
||||
void destroy();
|
||||
};
|
||||
GPUBuffer includes GPUObjectBase;
|
||||
|
||||
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUSize64 size;
|
||||
required GPUBufferUsageFlags usage;
|
||||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUBufferUsageFlags;
|
||||
interface GPUBufferUsage {
|
||||
const GPUBufferUsageFlags MAP_READ = 0x0001;
|
||||
const GPUBufferUsageFlags MAP_WRITE = 0x0002;
|
||||
const GPUBufferUsageFlags COPY_SRC = 0x0004;
|
||||
const GPUBufferUsageFlags COPY_DST = 0x0008;
|
||||
const GPUBufferUsageFlags INDEX = 0x0010;
|
||||
const GPUBufferUsageFlags VERTEX = 0x0020;
|
||||
const GPUBufferUsageFlags UNIFORM = 0x0040;
|
||||
const GPUBufferUsageFlags STORAGE = 0x0080;
|
||||
const GPUBufferUsageFlags INDIRECT = 0x0100;
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
interface GPUTexture {
|
||||
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
|
||||
|
||||
void destroy();
|
||||
};
|
||||
GPUTexture includes GPUObjectBase;
|
||||
|
||||
dictionary GPUTextureDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUExtent3D size;
|
||||
GPUIntegerCoordinate arrayLayerCount = 1;
|
||||
GPUIntegerCoordinate mipLevelCount = 1;
|
||||
GPUSize32 sampleCount = 1;
|
||||
GPUTextureDimension dimension = "2d";
|
||||
required GPUTextureFormat format;
|
||||
required GPUTextureUsageFlags usage;
|
||||
};
|
||||
|
||||
enum GPUTextureDimension {
|
||||
"1d",
|
||||
"2d",
|
||||
"3d"
|
||||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUTextureUsageFlags;
|
||||
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;
|
||||
};
|
||||
|
||||
interface GPUTextureView {
|
||||
};
|
||||
GPUTextureView includes GPUObjectBase;
|
||||
|
||||
dictionary GPUTextureViewDescriptor : GPUObjectDescriptorBase {
|
||||
GPUTextureFormat format;
|
||||
GPUTextureViewDimension dimension;
|
||||
GPUTextureAspect aspect = "all";
|
||||
GPUIntegerCoordinate baseMipLevel = 0;
|
||||
GPUIntegerCoordinate mipLevelCount = 0;
|
||||
GPUIntegerCoordinate baseArrayLayer = 0;
|
||||
GPUIntegerCoordinate arrayLayerCount = 0;
|
||||
};
|
||||
|
||||
enum GPUTextureViewDimension {
|
||||
"1d",
|
||||
"2d",
|
||||
"2d-array",
|
||||
"cube",
|
||||
"cube-array",
|
||||
"3d"
|
||||
};
|
||||
|
||||
enum GPUTextureAspect {
|
||||
"all",
|
||||
"stencil-only",
|
||||
"depth-only"
|
||||
};
|
||||
|
||||
enum GPUTextureFormat {
|
||||
// 8-bit formats
|
||||
"r8unorm",
|
||||
"r8snorm",
|
||||
"r8uint",
|
||||
"r8sint",
|
||||
|
||||
// 16-bit formats
|
||||
"r16uint",
|
||||
"r16sint",
|
||||
"r16float",
|
||||
"rg8unorm",
|
||||
"rg8snorm",
|
||||
"rg8uint",
|
||||
"rg8sint",
|
||||
|
||||
// 32-bit formats
|
||||
"r32uint",
|
||||
"r32sint",
|
||||
"r32float",
|
||||
"rg16uint",
|
||||
"rg16sint",
|
||||
"rg16float",
|
||||
"rgba8unorm",
|
||||
"rgba8unorm-srgb",
|
||||
"rgba8snorm",
|
||||
"rgba8uint",
|
||||
"rgba8sint",
|
||||
"bgra8unorm",
|
||||
"bgra8unorm-srgb",
|
||||
// Packed 32-bit formats
|
||||
"rgb10a2unorm",
|
||||
"rg11b10float",
|
||||
|
||||
// 64-bit formats
|
||||
"rg32uint",
|
||||
"rg32sint",
|
||||
"rg32float",
|
||||
"rgba16uint",
|
||||
"rgba16sint",
|
||||
"rgba16float",
|
||||
|
||||
// 128-bit formats
|
||||
"rgba32uint",
|
||||
"rgba32sint",
|
||||
"rgba32float",
|
||||
|
||||
// Depth and stencil formats
|
||||
"depth32float",
|
||||
"depth24plus",
|
||||
"depth24plus-stencil8"
|
||||
};
|
||||
|
||||
enum GPUTextureComponentType {
|
||||
"float",
|
||||
"sint",
|
||||
"uint"
|
||||
};
|
||||
|
||||
interface GPUSampler {
|
||||
};
|
||||
GPUSampler includes GPUObjectBase;
|
||||
|
||||
dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
|
||||
GPUAddressMode addressModeU = "clamp-to-edge";
|
||||
GPUAddressMode addressModeV = "clamp-to-edge";
|
||||
GPUAddressMode addressModeW = "clamp-to-edge";
|
||||
GPUFilterMode magFilter = "nearest";
|
||||
GPUFilterMode minFilter = "nearest";
|
||||
GPUFilterMode mipmapFilter = "nearest";
|
||||
float lodMinClamp = 0;
|
||||
float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE.
|
||||
GPUCompareFunction compare = "never";
|
||||
};
|
||||
|
||||
enum GPUAddressMode {
|
||||
"clamp-to-edge",
|
||||
"repeat",
|
||||
"mirror-repeat"
|
||||
};
|
||||
|
||||
enum GPUFilterMode {
|
||||
"nearest",
|
||||
"linear"
|
||||
};
|
||||
|
||||
enum GPUCompareFunction {
|
||||
"never",
|
||||
"less",
|
||||
"equal",
|
||||
"less-equal",
|
||||
"greater",
|
||||
"not-equal",
|
||||
"greater-equal",
|
||||
"always"
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
interface GPUBindGroupLayout {
|
||||
};
|
||||
GPUBindGroupLayout includes GPUObjectBase;
|
||||
|
||||
dictionary GPUBindGroupLayoutDescriptor : GPUObjectDescriptorBase {
|
||||
required sequence<GPUBindGroupLayoutBinding> bindings;
|
||||
};
|
||||
|
||||
dictionary GPUBindGroupLayoutBinding {
|
||||
required GPUIndex32 binding;
|
||||
required GPUShaderStageFlags visibility;
|
||||
required GPUBindingType type;
|
||||
GPUTextureViewDimension textureDimension = "2d";
|
||||
GPUTextureComponentType textureComponentType = "float";
|
||||
boolean multisampled = false;
|
||||
boolean hasDynamicOffset = false;
|
||||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
|
||||
interface GPUShaderStage {
|
||||
const GPUShaderStageFlags VERTEX = 0x1;
|
||||
const GPUShaderStageFlags FRAGMENT = 0x2;
|
||||
const GPUShaderStageFlags COMPUTE = 0x4;
|
||||
};
|
||||
|
||||
enum GPUBindingType {
|
||||
"uniform-buffer",
|
||||
"storage-buffer",
|
||||
"readonly-storage-buffer",
|
||||
"sampler",
|
||||
"sampled-texture",
|
||||
"storage-texture"
|
||||
// TODO: other binding types
|
||||
};
|
||||
|
||||
interface GPUBindGroup {
|
||||
};
|
||||
GPUBindGroup includes GPUObjectBase;
|
||||
|
||||
dictionary GPUBindGroupDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUBindGroupLayout layout;
|
||||
required sequence<GPUBindGroupBinding> bindings;
|
||||
};
|
||||
|
||||
typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource;
|
||||
|
||||
dictionary GPUBindGroupBinding {
|
||||
required GPUIndex32 binding;
|
||||
required GPUBindingResource resource;
|
||||
};
|
||||
|
||||
dictionary GPUBufferBinding {
|
||||
required GPUBuffer buffer;
|
||||
GPUSize64 offset = 0;
|
||||
GPUSize64 size;
|
||||
};
|
||||
|
||||
interface GPUPipelineLayout {
|
||||
};
|
||||
GPUPipelineLayout includes GPUObjectBase;
|
||||
|
||||
dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
|
||||
required sequence<GPUBindGroupLayout> bindGroupLayouts;
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
interface GPUShaderModule {
|
||||
};
|
||||
GPUShaderModule includes GPUObjectBase;
|
||||
|
||||
typedef (Uint32Array or DOMString) GPUShaderCode;
|
||||
|
||||
dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUShaderCode code;
|
||||
};
|
||||
|
||||
dictionary GPUPipelineDescriptorBase : GPUObjectDescriptorBase {
|
||||
required GPUPipelineLayout layout;
|
||||
};
|
||||
|
||||
dictionary GPUProgrammableStageDescriptor {
|
||||
required GPUShaderModule module;
|
||||
required DOMString entryPoint;
|
||||
// TODO: other stuff like specialization constants?
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
interface GPUComputePipeline {
|
||||
};
|
||||
GPUComputePipeline includes GPUObjectBase;
|
||||
|
||||
dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
|
||||
required GPUProgrammableStageDescriptor computeStage;
|
||||
};
|
||||
|
||||
[Serializable]
|
||||
interface GPURenderPipeline {
|
||||
};
|
||||
GPURenderPipeline includes GPUObjectBase;
|
||||
|
||||
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;
|
||||
// TODO: other properties
|
||||
};
|
||||
|
||||
enum GPUPrimitiveTopology {
|
||||
"point-list",
|
||||
"line-list",
|
||||
"line-strip",
|
||||
"triangle-list",
|
||||
"triangle-strip"
|
||||
};
|
||||
|
||||
dictionary GPURasterizationStateDescriptor {
|
||||
GPUFrontFace frontFace = "ccw";
|
||||
GPUCullMode cullMode = "none";
|
||||
|
||||
GPUDepthBias depthBias = 0;
|
||||
float depthBiasSlopeScale = 0;
|
||||
float depthBiasClamp = 0;
|
||||
};
|
||||
|
||||
enum GPUFrontFace {
|
||||
"ccw",
|
||||
"cw"
|
||||
};
|
||||
|
||||
enum GPUCullMode {
|
||||
"none",
|
||||
"front",
|
||||
"back"
|
||||
};
|
||||
|
||||
dictionary GPUColorStateDescriptor {
|
||||
required GPUTextureFormat format;
|
||||
|
||||
GPUBlendDescriptor alphaBlend = {};
|
||||
GPUBlendDescriptor colorBlend = {};
|
||||
GPUColorWriteFlags writeMask = 0xF; // GPUColorWrite.ALL
|
||||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUColorWriteFlags;
|
||||
interface GPUColorWrite {
|
||||
const GPUColorWriteFlags RED = 0x1;
|
||||
const GPUColorWriteFlags GREEN = 0x2;
|
||||
const GPUColorWriteFlags BLUE = 0x4;
|
||||
const GPUColorWriteFlags ALPHA = 0x8;
|
||||
const GPUColorWriteFlags ALL = 0xF;
|
||||
};
|
||||
|
||||
dictionary GPUBlendDescriptor {
|
||||
GPUBlendFactor srcFactor = "one";
|
||||
GPUBlendFactor dstFactor = "zero";
|
||||
GPUBlendOperation operation = "add";
|
||||
};
|
||||
|
||||
enum GPUBlendFactor {
|
||||
"zero",
|
||||
"one",
|
||||
"src-color",
|
||||
"one-minus-src-color",
|
||||
"src-alpha",
|
||||
"one-minus-src-alpha",
|
||||
"dst-color",
|
||||
"one-minus-dst-color",
|
||||
"dst-alpha",
|
||||
"one-minus-dst-alpha",
|
||||
"src-alpha-saturated",
|
||||
"blend-color",
|
||||
"one-minus-blend-color"
|
||||
};
|
||||
|
||||
enum GPUBlendOperation {
|
||||
"add",
|
||||
"subtract",
|
||||
"reverse-subtract",
|
||||
"min",
|
||||
"max"
|
||||
};
|
||||
|
||||
enum GPUStencilOperation {
|
||||
"keep",
|
||||
"zero",
|
||||
"replace",
|
||||
"invert",
|
||||
"increment-clamp",
|
||||
"decrement-clamp",
|
||||
"increment-wrap",
|
||||
"decrement-wrap"
|
||||
};
|
||||
|
||||
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"
|
||||
};
|
||||
|
||||
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"
|
||||
};
|
||||
|
||||
enum GPUInputStepMode {
|
||||
"vertex",
|
||||
"instance"
|
||||
};
|
||||
|
||||
dictionary GPUVertexStateDescriptor {
|
||||
GPUIndexFormat indexFormat = "uint32";
|
||||
sequence<GPUVertexBufferLayoutDescriptor?> vertexBuffers = [];
|
||||
};
|
||||
|
||||
dictionary GPUVertexBufferLayoutDescriptor {
|
||||
required GPUSize64 arrayStride;
|
||||
GPUInputStepMode stepMode = "vertex";
|
||||
required sequence<GPUVertexAttributeDescriptor> attributes;
|
||||
};
|
||||
|
||||
dictionary GPUVertexAttributeDescriptor {
|
||||
required GPUVertexFormat format;
|
||||
required GPUSize64 offset;
|
||||
|
||||
required GPUIndex32 shaderLocation;
|
||||
};
|
||||
|
||||
interface GPUCommandBuffer {
|
||||
};
|
||||
GPUCommandBuffer includes GPUObjectBase;
|
||||
|
||||
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
||||
};
|
||||
|
||||
interface GPUCommandEncoder {
|
||||
GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor);
|
||||
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
|
||||
|
||||
void copyBufferToBuffer(
|
||||
GPUBuffer source,
|
||||
GPUSize64 sourceOffset,
|
||||
GPUBuffer destination,
|
||||
GPUSize64 destinationOffset,
|
||||
GPUSize64 size);
|
||||
|
||||
void copyBufferToTexture(
|
||||
GPUBufferCopyView source,
|
||||
GPUTextureCopyView destination,
|
||||
GPUExtent3D copySize);
|
||||
|
||||
void copyTextureToBuffer(
|
||||
GPUTextureCopyView source,
|
||||
GPUBufferCopyView destination,
|
||||
GPUExtent3D copySize);
|
||||
|
||||
void copyTextureToTexture(
|
||||
GPUTextureCopyView source,
|
||||
GPUTextureCopyView destination,
|
||||
GPUExtent3D copySize);
|
||||
|
||||
void pushDebugGroup(DOMString groupLabel);
|
||||
void popDebugGroup();
|
||||
void insertDebugMarker(DOMString markerLabel);
|
||||
|
||||
GPUCommandBuffer finish(optional GPUCommandBufferDescriptor descriptor = {});
|
||||
};
|
||||
GPUCommandEncoder includes GPUObjectBase;
|
||||
|
||||
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
||||
// TODO: reusability flag?
|
||||
};
|
||||
|
||||
dictionary GPUBufferCopyView {
|
||||
required GPUBuffer buffer;
|
||||
GPUSize64 offset = 0;
|
||||
required GPUSize32 rowPitch;
|
||||
required GPUSize32 imageHeight;
|
||||
};
|
||||
|
||||
dictionary GPUTextureCopyView {
|
||||
required GPUTexture texture;
|
||||
GPUIntegerCoordinate mipLevel = 0;
|
||||
GPUIntegerCoordinate arrayLayer = 0;
|
||||
GPUOrigin3D origin = {};
|
||||
};
|
||||
|
||||
dictionary GPUImageBitmapCopyView {
|
||||
required ImageBitmap imageBitmap;
|
||||
GPUOrigin2D origin = {};
|
||||
};
|
||||
|
||||
interface mixin GPUProgrammablePassEncoder {
|
||||
void setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
|
||||
optional sequence<GPUBufferDynamicOffset> dynamicOffsets = []);
|
||||
|
||||
void setBindGroup(GPUIndex32 index, GPUBindGroup bindGroup,
|
||||
Uint32Array dynamicOffsetsData,
|
||||
GPUSize64 dynamicOffsetsDataStart,
|
||||
GPUSize32 dynamicOffsetsDataLength);
|
||||
|
||||
void pushDebugGroup(DOMString groupLabel);
|
||||
void popDebugGroup();
|
||||
void insertDebugMarker(DOMString markerLabel);
|
||||
};
|
||||
|
||||
interface GPUComputePassEncoder {
|
||||
void setPipeline(GPUComputePipeline pipeline);
|
||||
void dispatch(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
|
||||
void dispatchIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
||||
|
||||
void endPass();
|
||||
};
|
||||
GPUComputePassEncoder includes GPUObjectBase;
|
||||
GPUComputePassEncoder includes GPUProgrammablePassEncoder;
|
||||
|
||||
dictionary GPUComputePassDescriptor : GPUObjectDescriptorBase {
|
||||
};
|
||||
|
||||
interface mixin GPURenderEncoderBase {
|
||||
void setPipeline(GPURenderPipeline pipeline);
|
||||
|
||||
void setIndexBuffer(GPUBuffer buffer, optional GPUSize64 offset = 0);
|
||||
void setVertexBuffer(GPUIndex32 slot, GPUBuffer buffer, optional GPUSize64 offset = 0);
|
||||
|
||||
void draw(GPUSize32 vertexCount, GPUSize32 instanceCount,
|
||||
GPUSize32 firstVertex, GPUSize32 firstInstance);
|
||||
void drawIndexed(GPUSize32 indexCount, GPUSize32 instanceCount,
|
||||
GPUSize32 firstIndex, GPUSignedOffset32 baseVertex, GPUSize32 firstInstance);
|
||||
|
||||
void drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
||||
void drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
|
||||
};
|
||||
|
||||
interface GPURenderPassEncoder {
|
||||
void setViewport(float x, float y,
|
||||
float width, float height,
|
||||
float minDepth, float maxDepth);
|
||||
|
||||
void setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
|
||||
GPUIntegerCoordinate width, GPUIntegerCoordinate height);
|
||||
|
||||
void setBlendColor(GPUColor color);
|
||||
void setStencilReference(GPUStencilValue reference);
|
||||
|
||||
void executeBundles(sequence<GPURenderBundle> bundles);
|
||||
void endPass();
|
||||
};
|
||||
GPURenderPassEncoder includes GPUObjectBase;
|
||||
GPURenderPassEncoder includes GPUProgrammablePassEncoder;
|
||||
GPURenderPassEncoder includes GPURenderEncoderBase;
|
||||
|
||||
dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
|
||||
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
|
||||
GPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
};
|
||||
|
||||
dictionary GPURenderPassColorAttachmentDescriptor {
|
||||
required GPUTextureView attachment;
|
||||
GPUTextureView resolveTarget;
|
||||
|
||||
required (GPULoadOp or GPUColor) loadValue;
|
||||
GPUStoreOp storeOp = "store";
|
||||
};
|
||||
|
||||
dictionary GPURenderPassDepthStencilAttachmentDescriptor {
|
||||
required GPUTextureView attachment;
|
||||
|
||||
required (GPULoadOp or float) depthLoadValue;
|
||||
required GPUStoreOp depthStoreOp;
|
||||
|
||||
required (GPULoadOp or GPUStencilValue) stencilLoadValue;
|
||||
required GPUStoreOp stencilStoreOp;
|
||||
};
|
||||
|
||||
enum GPULoadOp {
|
||||
"load"
|
||||
};
|
||||
|
||||
enum GPUStoreOp {
|
||||
"store",
|
||||
"clear"
|
||||
};
|
||||
|
||||
interface GPURenderBundle {
|
||||
};
|
||||
GPURenderBundle includes GPUObjectBase;
|
||||
|
||||
dictionary GPURenderBundleDescriptor : GPUObjectDescriptorBase {
|
||||
};
|
||||
|
||||
interface GPURenderBundleEncoder {
|
||||
GPURenderBundle finish(optional GPURenderBundleDescriptor descriptor = {});
|
||||
};
|
||||
GPURenderBundleEncoder includes GPUObjectBase;
|
||||
GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
|
||||
GPURenderBundleEncoder includes GPURenderEncoderBase;
|
||||
|
||||
dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
|
||||
required sequence<GPUTextureFormat> colorFormats;
|
||||
GPUTextureFormat depthStencilFormat;
|
||||
GPUSize32 sampleCount = 1;
|
||||
};
|
||||
|
||||
interface GPUQueue {
|
||||
void submit(sequence<GPUCommandBuffer> commandBuffers);
|
||||
|
||||
GPUFence createFence(optional GPUFenceDescriptor descriptor = {});
|
||||
void signal(GPUFence fence, GPUFenceValue signalValue);
|
||||
|
||||
void copyImageBitmapToTexture(
|
||||
GPUImageBitmapCopyView source,
|
||||
GPUTextureCopyView destination,
|
||||
GPUExtent3D copySize);
|
||||
};
|
||||
GPUQueue includes GPUObjectBase;
|
||||
|
||||
interface GPUFence {
|
||||
GPUFenceValue getCompletedValue();
|
||||
Promise<void> onCompletion(GPUFenceValue completionValue);
|
||||
};
|
||||
GPUFence includes GPUObjectBase;
|
||||
|
||||
dictionary GPUFenceDescriptor : GPUObjectDescriptorBase {
|
||||
GPUFenceValue initialValue = 0;
|
||||
};
|
||||
|
||||
interface GPUCanvasContext {
|
||||
GPUSwapChain configureSwapChain(GPUSwapChainDescriptor descriptor);
|
||||
|
||||
Promise<GPUTextureFormat> getSwapChainPreferredFormat(GPUDevice device);
|
||||
};
|
||||
|
||||
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
|
||||
required GPUDevice device;
|
||||
required GPUTextureFormat format;
|
||||
GPUTextureUsageFlags usage = 0x10; // GPUTextureUsage.OUTPUT_ATTACHMENT
|
||||
};
|
||||
|
||||
interface GPUSwapChain {
|
||||
GPUTexture getCurrentTexture();
|
||||
};
|
||||
GPUSwapChain includes GPUObjectBase;
|
||||
|
||||
interface GPUDeviceLostInfo {
|
||||
readonly attribute DOMString message;
|
||||
};
|
||||
|
||||
partial interface GPUDevice {
|
||||
readonly attribute Promise<GPUDeviceLostInfo> lost;
|
||||
};
|
||||
|
||||
enum GPUErrorFilter {
|
||||
"none",
|
||||
"out-of-memory",
|
||||
"validation"
|
||||
};
|
||||
|
||||
interface GPUOutOfMemoryError {
|
||||
constructor();
|
||||
};
|
||||
|
||||
interface GPUValidationError {
|
||||
constructor(DOMString message);
|
||||
readonly attribute DOMString message;
|
||||
};
|
||||
|
||||
typedef (GPUOutOfMemoryError or GPUValidationError) GPUError;
|
||||
|
||||
partial interface GPUDevice {
|
||||
void pushErrorScope(GPUErrorFilter filter);
|
||||
Promise<GPUError?> popErrorScope();
|
||||
};
|
||||
|
||||
[
|
||||
Exposed=(Window, DedicatedWorker)
|
||||
]
|
||||
interface GPUUncapturedErrorEvent : Event {
|
||||
constructor(
|
||||
DOMString type,
|
||||
GPUUncapturedErrorEventInit gpuUncapturedErrorEventInitDict
|
||||
);
|
||||
[SameObject] readonly attribute GPUError error;
|
||||
};
|
||||
|
||||
dictionary GPUUncapturedErrorEventInit : EventInit {
|
||||
required GPUError error;
|
||||
};
|
||||
|
||||
partial interface GPUDevice {
|
||||
[Exposed=(Window, DedicatedWorker)]
|
||||
attribute EventHandler onuncapturederror;
|
||||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUBufferDynamicOffset;
|
||||
typedef [EnforceRange] unsigned long long GPUFenceValue;
|
||||
typedef [EnforceRange] unsigned long GPUStencilValue;
|
||||
typedef [EnforceRange] unsigned long GPUSampleMask;
|
||||
typedef [EnforceRange] long GPUDepthBias;
|
||||
|
||||
typedef [EnforceRange] unsigned long long GPUSize64;
|
||||
typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
|
||||
typedef [EnforceRange] unsigned long GPUIndex32;
|
||||
typedef [EnforceRange] unsigned long GPUSize32;
|
||||
typedef [EnforceRange] long GPUSignedOffset32;
|
||||
|
||||
dictionary GPUColorDict {
|
||||
required double r;
|
||||
required double g;
|
||||
required double b;
|
||||
required double a;
|
||||
};
|
||||
typedef (sequence<double> or GPUColorDict) GPUColor;
|
||||
|
||||
dictionary GPUOrigin2DDict {
|
||||
GPUIntegerCoordinate x = 0;
|
||||
GPUIntegerCoordinate y = 0;
|
||||
};
|
||||
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin2DDict) GPUOrigin2D;
|
||||
|
||||
dictionary GPUOrigin3DDict {
|
||||
GPUIntegerCoordinate x = 0;
|
||||
GPUIntegerCoordinate y = 0;
|
||||
GPUIntegerCoordinate z = 0;
|
||||
};
|
||||
typedef (sequence<GPUIntegerCoordinate> or GPUOrigin3DDict) GPUOrigin3D;
|
||||
|
||||
dictionary GPUExtent3DDict {
|
||||
required GPUIntegerCoordinate width;
|
||||
required GPUIntegerCoordinate height;
|
||||
required GPUIntegerCoordinate depth;
|
||||
};
|
||||
typedef (sequence<GPUIntegerCoordinate> or GPUExtent3DDict) GPUExtent3D;
|
||||
|
||||
typedef sequence<(GPUBuffer or ArrayBuffer)> GPUMappedBuffer;
|
Reference in New Issue
Block a user