Skip to content

Commit e0e8402

Browse files
authored
Add simple WebGPU interfaces (#2365)
Co-authored-by: saschanaz <[email protected]>
1 parent f9f0880 commit e0e8402

29 files changed

+4468
-51
lines changed

baselines/dom.generated.d.ts

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,10 @@ interface GPUPipelineErrorInit {
809809
reason: GPUPipelineErrorReason;
810810
}
811811

812+
interface GPUUncapturedErrorEventInit extends EventInit {
813+
error: GPUError;
814+
}
815+
812816
interface GainOptions extends AudioNodeOptions {
813817
gain?: number;
814818
}
@@ -12558,6 +12562,7 @@ interface Document extends Node, DocumentOrShadowRoot, FontFaceSource, GlobalEve
1255812562
createEvent(eventInterface: "FocusEvent"): FocusEvent;
1255912563
createEvent(eventInterface: "FontFaceSetLoadEvent"): FontFaceSetLoadEvent;
1256012564
createEvent(eventInterface: "FormDataEvent"): FormDataEvent;
12565+
createEvent(eventInterface: "GPUUncapturedErrorEvent"): GPUUncapturedErrorEvent;
1256112566
createEvent(eventInterface: "GamepadEvent"): GamepadEvent;
1256212567
createEvent(eventInterface: "HashChangeEvent"): HashChangeEvent;
1256312568
createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent;
@@ -14700,6 +14705,88 @@ declare var FragmentDirective: {
1470014705
new(): FragmentDirective;
1470114706
};
1470214707

14708+
/**
14709+
* The **`GPUBindGroup`** interface of the WebGPU API is based on a GPUBindGroupLayout and defines a set of resources to be bound together in a group and how those resources are used in shader stages.
14710+
* Available only in secure contexts.
14711+
*
14712+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBindGroup)
14713+
*/
14714+
interface GPUBindGroup extends GPUObjectBase {
14715+
}
14716+
14717+
declare var GPUBindGroup: {
14718+
prototype: GPUBindGroup;
14719+
new(): GPUBindGroup;
14720+
};
14721+
14722+
/**
14723+
* The **`GPUBindGroupLayout`** interface of the WebGPU API defines the structure and purpose of related GPU resources such as buffers that will be used in a pipeline, and is used as a template when creating GPUBindGroups.
14724+
* Available only in secure contexts.
14725+
*
14726+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBindGroupLayout)
14727+
*/
14728+
interface GPUBindGroupLayout extends GPUObjectBase {
14729+
}
14730+
14731+
declare var GPUBindGroupLayout: {
14732+
prototype: GPUBindGroupLayout;
14733+
new(): GPUBindGroupLayout;
14734+
};
14735+
14736+
/**
14737+
* The **`GPUCommandBuffer`** interface of the WebGPU API represents a pre-recorded list of GPU commands that can be submitted to a GPUQueue for execution.
14738+
* Available only in secure contexts.
14739+
*
14740+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCommandBuffer)
14741+
*/
14742+
interface GPUCommandBuffer extends GPUObjectBase {
14743+
}
14744+
14745+
declare var GPUCommandBuffer: {
14746+
prototype: GPUCommandBuffer;
14747+
new(): GPUCommandBuffer;
14748+
};
14749+
14750+
/**
14751+
* The **`GPUComputePipeline`** interface of the WebGPU API represents a pipeline that controls the compute shader stage and can be used in a GPUComputePassEncoder.
14752+
* Available only in secure contexts.
14753+
*
14754+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUComputePipeline)
14755+
*/
14756+
interface GPUComputePipeline extends GPUObjectBase, GPUPipelineBase {
14757+
}
14758+
14759+
declare var GPUComputePipeline: {
14760+
prototype: GPUComputePipeline;
14761+
new(): GPUComputePipeline;
14762+
};
14763+
14764+
/**
14765+
* The **`GPUDeviceLostInfo`** interface of the WebGPU API represents the object returned when the GPUDevice.lost Promise resolves. This provides information as to why a device has been lost.
14766+
* Available only in secure contexts.
14767+
*
14768+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDeviceLostInfo)
14769+
*/
14770+
interface GPUDeviceLostInfo {
14771+
/**
14772+
* The **`message`** read-only property of the GPUDeviceLostInfo interface provides a human-readable message that explains why the device was lost.
14773+
*
14774+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDeviceLostInfo/message)
14775+
*/
14776+
readonly message: string;
14777+
/**
14778+
* The **`reason`** read-only property of the GPUDeviceLostInfo interface defines the reason the device was lost in a machine-readable way.
14779+
*
14780+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDeviceLostInfo/reason)
14781+
*/
14782+
readonly reason: GPUDeviceLostReason;
14783+
}
14784+
14785+
declare var GPUDeviceLostInfo: {
14786+
prototype: GPUDeviceLostInfo;
14787+
new(): GPUDeviceLostInfo;
14788+
};
14789+
1470314790
/**
1470414791
* The **`GPUError`** interface of the WebGPU API is the base interface for errors surfaced by GPUDevice.popErrorScope and the uncapturederror event.
1470514792
* Available only in secure contexts.
@@ -14720,6 +14807,58 @@ declare var GPUError: {
1472014807
new(): GPUError;
1472114808
};
1472214809

14810+
/**
14811+
* The **`GPUExternalTexture`** interface of the WebGPU API represents a wrapper object containing an HTMLVideoElement snapshot that can be used as a texture in GPU rendering operations.
14812+
* Available only in secure contexts.
14813+
*
14814+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUExternalTexture)
14815+
*/
14816+
interface GPUExternalTexture extends GPUObjectBase {
14817+
}
14818+
14819+
declare var GPUExternalTexture: {
14820+
prototype: GPUExternalTexture;
14821+
new(): GPUExternalTexture;
14822+
};
14823+
14824+
/**
14825+
* The **`GPUInternalError`** interface of the WebGPU API describes an application error indicating that an operation failed for a system or implementation-specific reason, even when all validation requirements were satisfied.
14826+
* Available only in secure contexts.
14827+
*
14828+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUInternalError)
14829+
*/
14830+
interface GPUInternalError extends GPUError {
14831+
}
14832+
14833+
declare var GPUInternalError: {
14834+
prototype: GPUInternalError;
14835+
new(message: string): GPUInternalError;
14836+
};
14837+
14838+
interface GPUObjectBase {
14839+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUBindGroup/label) */
14840+
label: string;
14841+
}
14842+
14843+
/**
14844+
* The **`GPUOutOfMemoryError`** interface of the WebGPU API describes an out-of-memory (oom) error indicating that there was not enough free memory to complete the requested operation.
14845+
* Available only in secure contexts.
14846+
*
14847+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUOutOfMemoryError)
14848+
*/
14849+
interface GPUOutOfMemoryError extends GPUError {
14850+
}
14851+
14852+
declare var GPUOutOfMemoryError: {
14853+
prototype: GPUOutOfMemoryError;
14854+
new(message: string): GPUOutOfMemoryError;
14855+
};
14856+
14857+
interface GPUPipelineBase {
14858+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUComputePipeline/getBindGroupLayout) */
14859+
getBindGroupLayout(index: number): GPUBindGroupLayout;
14860+
}
14861+
1472314862
/**
1472414863
* The **`GPUPipelineError`** interface of the WebGPU API describes a pipeline failure. This is the value received when a Promise returned by a GPUDevice.createComputePipelineAsync() or GPUDevice.createRenderPipelineAsync() call rejects.
1472514864
* Available only in secure contexts.
@@ -14740,6 +14879,125 @@ declare var GPUPipelineError: {
1474014879
new(message: string, options: GPUPipelineErrorInit): GPUPipelineError;
1474114880
};
1474214881

14882+
/**
14883+
* The **`GPUPipelineLayout`** interface of the WebGPU API defines the GPUBindGroupLayouts used by a pipeline. GPUBindGroups used with the pipeline during command encoding must have compatible GPUBindGroupLayouts.
14884+
* Available only in secure contexts.
14885+
*
14886+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUPipelineLayout)
14887+
*/
14888+
interface GPUPipelineLayout extends GPUObjectBase {
14889+
}
14890+
14891+
declare var GPUPipelineLayout: {
14892+
prototype: GPUPipelineLayout;
14893+
new(): GPUPipelineLayout;
14894+
};
14895+
14896+
/**
14897+
* The **`GPURenderBundle`** interface of the WebGPU API represents a container for pre-recorded bundles of commands.
14898+
* Available only in secure contexts.
14899+
*
14900+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPURenderBundle)
14901+
*/
14902+
interface GPURenderBundle extends GPUObjectBase {
14903+
}
14904+
14905+
declare var GPURenderBundle: {
14906+
prototype: GPURenderBundle;
14907+
new(): GPURenderBundle;
14908+
};
14909+
14910+
/**
14911+
* The **`GPURenderPipeline`** interface of the WebGPU API represents a pipeline that controls the vertex and fragment shader stages and can be used in a GPURenderPassEncoder or GPURenderBundleEncoder.
14912+
* Available only in secure contexts.
14913+
*
14914+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPURenderPipeline)
14915+
*/
14916+
interface GPURenderPipeline extends GPUObjectBase, GPUPipelineBase {
14917+
}
14918+
14919+
declare var GPURenderPipeline: {
14920+
prototype: GPURenderPipeline;
14921+
new(): GPURenderPipeline;
14922+
};
14923+
14924+
/**
14925+
* The **`GPUSampler`** interface of the WebGPU API represents an object that can control how shaders transform and filter texture resource data.
14926+
* Available only in secure contexts.
14927+
*
14928+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUSampler)
14929+
*/
14930+
interface GPUSampler extends GPUObjectBase {
14931+
}
14932+
14933+
declare var GPUSampler: {
14934+
prototype: GPUSampler;
14935+
new(): GPUSampler;
14936+
};
14937+
14938+
/**
14939+
* The **`GPUSupportedFeatures`** interface of the WebGPU API is a Set-like object that describes additional functionality supported by a GPUAdapter.
14940+
* Available only in secure contexts.
14941+
*
14942+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUSupportedFeatures)
14943+
*/
14944+
interface GPUSupportedFeatures {
14945+
forEach(callbackfn: (value: string, key: string, parent: GPUSupportedFeatures) => void, thisArg?: any): void;
14946+
}
14947+
14948+
declare var GPUSupportedFeatures: {
14949+
prototype: GPUSupportedFeatures;
14950+
new(): GPUSupportedFeatures;
14951+
};
14952+
14953+
/**
14954+
* The **`GPUTextureView`** interface of the WebGPU API represents a view into a subset of the texture resources defined by a particular GPUTexture.
14955+
* Available only in secure contexts.
14956+
*
14957+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUTextureView)
14958+
*/
14959+
interface GPUTextureView extends GPUObjectBase {
14960+
}
14961+
14962+
declare var GPUTextureView: {
14963+
prototype: GPUTextureView;
14964+
new(): GPUTextureView;
14965+
};
14966+
14967+
/**
14968+
* The **`GPUUncapturedErrorEvent`** interface of the WebGPU API is the event object type for the GPUDevice uncapturederror event, used for telemetry and to report unexpected errors.
14969+
* Available only in secure contexts.
14970+
*
14971+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUUncapturedErrorEvent)
14972+
*/
14973+
interface GPUUncapturedErrorEvent extends Event {
14974+
/**
14975+
* The **`error`** read-only property of the GPUUncapturedErrorEvent interface is a GPUError object instance providing access to the details of the error.
14976+
*
14977+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUUncapturedErrorEvent/error)
14978+
*/
14979+
readonly error: GPUError;
14980+
}
14981+
14982+
declare var GPUUncapturedErrorEvent: {
14983+
prototype: GPUUncapturedErrorEvent;
14984+
new(type: string, gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit): GPUUncapturedErrorEvent;
14985+
};
14986+
14987+
/**
14988+
* The **`GPUValidationError`** interface of the WebGPU API describes an application error indicating that an operation did not pass the WebGPU API's validation constraints.
14989+
* Available only in secure contexts.
14990+
*
14991+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUValidationError)
14992+
*/
14993+
interface GPUValidationError extends GPUError {
14994+
}
14995+
14996+
declare var GPUValidationError: {
14997+
prototype: GPUValidationError;
14998+
new(message: string): GPUValidationError;
14999+
};
15000+
1474315001
/**
1474415002
* The **`GainNode`** interface represents a change in volume. It is an AudioNode audio-processing module that causes a given gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input and one output, both with the same number of channels.
1474515003
*
@@ -36820,6 +37078,21 @@ interface WEBGL_multi_draw {
3682037078
multiDrawElementsWEBGL(mode: GLenum, countsList: Int32Array<ArrayBufferLike> | GLsizei[], countsOffset: number, type: GLenum, offsetsList: Int32Array<ArrayBufferLike> | GLsizei[], offsetsOffset: number, drawcount: GLsizei): void;
3682137079
}
3682237080

37081+
/**
37082+
* The **`WGSLLanguageFeatures`** interface of the WebGPU API is a setlike object that reports the WGSL language extensions supported by the WebGPU implementation.
37083+
* Available only in secure contexts.
37084+
*
37085+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/WGSLLanguageFeatures)
37086+
*/
37087+
interface WGSLLanguageFeatures {
37088+
forEach(callbackfn: (value: string, key: string, parent: WGSLLanguageFeatures) => void, thisArg?: any): void;
37089+
}
37090+
37091+
declare var WGSLLanguageFeatures: {
37092+
prototype: WGSLLanguageFeatures;
37093+
new(): WGSLLanguageFeatures;
37094+
};
37095+
3682337096
/**
3682437097
* The **`WakeLock`** interface of the Screen Wake Lock API can be used to request a lock that prevents device screens from dimming or locking when an application needs to keep running.
3682537098
* Available only in secure contexts.
@@ -42572,6 +42845,7 @@ type FontDisplay = "auto" | "block" | "fallback" | "optional" | "swap";
4257242845
type FontFaceLoadStatus = "error" | "loaded" | "loading" | "unloaded";
4257342846
type FontFaceSetLoadStatus = "loaded" | "loading";
4257442847
type FullscreenNavigationUI = "auto" | "hide" | "show";
42848+
type GPUDeviceLostReason = "destroyed" | "unknown";
4257542849
type GPUPipelineErrorReason = "internal" | "validation";
4257642850
type GamepadHapticEffectType = "dual-rumble" | "trigger-rumble";
4257742851
type GamepadHapticsResult = "complete" | "preempted";
@@ -42856,6 +43130,9 @@ interface FormData {
4285643130
values(): FormDataIterator<FormDataEntryValue>;
4285743131
}
4285843132

43133+
interface GPUSupportedFeatures extends ReadonlySet<string> {
43134+
}
43135+
4285943136
interface HTMLAllCollection {
4286043137
[Symbol.iterator](): ArrayIterator<Element>;
4286143138
}
@@ -43161,6 +43438,9 @@ interface WEBGL_multi_draw {
4316143438
multiDrawElementsWEBGL(mode: GLenum, countsList: Int32Array<ArrayBufferLike> | GLsizei[], countsOffset: number, type: GLenum, offsetsList: Int32Array<ArrayBufferLike> | GLsizei[], offsetsOffset: number, drawcount: GLsizei): void;
4316243439
}
4316343440

43441+
interface WGSLLanguageFeatures extends ReadonlySet<string> {
43442+
}
43443+
4316443444
interface WebGL2RenderingContextBase {
4316543445
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebGL2RenderingContext/clearBuffer) */
4316643446
clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: GLfloat[], srcOffset?: number): void;

0 commit comments

Comments
 (0)