Skip to content

Commit a376819

Browse files
authored
Add GPUDevice.createRenderPipeline[Async] (#2420)
Co-authored-by: saschanaz <saschanaz@users.noreply.github.com>
1 parent 4fc34ea commit a376819

18 files changed

+1632
-15
lines changed

baselines/dom.generated.d.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,17 @@ interface GPUBindGroupEntry {
815815
resource: GPUBindingResource;
816816
}
817817

818+
interface GPUBlendComponent {
819+
dstFactor?: GPUBlendFactor;
820+
operation?: GPUBlendOperation;
821+
srcFactor?: GPUBlendFactor;
822+
}
823+
824+
interface GPUBlendState {
825+
alpha: GPUBlendComponent;
826+
color: GPUBlendComponent;
827+
}
828+
818829
interface GPUBufferBinding {
819830
buffer: GPUBuffer;
820831
offset?: GPUSize64;
@@ -848,6 +859,12 @@ interface GPUColorDict {
848859
r: number;
849860
}
850861

862+
interface GPUColorTargetState {
863+
blend?: GPUBlendState;
864+
format: GPUTextureFormat;
865+
writeMask?: GPUColorWriteFlags;
866+
}
867+
851868
interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {
852869
}
853870

@@ -879,6 +896,19 @@ interface GPUCopyExternalImageSourceInfo {
879896
source: GPUCopyExternalImageSource;
880897
}
881898

899+
interface GPUDepthStencilState {
900+
depthBias?: GPUDepthBias;
901+
depthBiasClamp?: number;
902+
depthBiasSlopeScale?: number;
903+
depthCompare?: GPUCompareFunction;
904+
depthWriteEnabled?: boolean;
905+
format: GPUTextureFormat;
906+
stencilBack?: GPUStencilFaceState;
907+
stencilFront?: GPUStencilFaceState;
908+
stencilReadMask?: GPUStencilValue;
909+
stencilWriteMask?: GPUStencilValue;
910+
}
911+
882912
interface GPUExtent3DDict {
883913
depthOrArrayLayers?: GPUIntegerCoordinate;
884914
height?: GPUIntegerCoordinate;
@@ -890,6 +920,16 @@ interface GPUExternalTextureDescriptor extends GPUObjectDescriptorBase {
890920
source: HTMLVideoElement | VideoFrame;
891921
}
892922

923+
interface GPUFragmentState extends GPUProgrammableStage {
924+
targets: (GPUColorTargetState | null)[];
925+
}
926+
927+
interface GPUMultisampleState {
928+
alphaToCoverageEnabled?: boolean;
929+
count?: GPUSize32;
930+
mask?: GPUSampleMask;
931+
}
932+
893933
interface GPUObjectDescriptorBase {
894934
label?: string;
895935
}
@@ -917,6 +957,14 @@ interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
917957
bindGroupLayouts: (GPUBindGroupLayout | null)[];
918958
}
919959

960+
interface GPUPrimitiveState {
961+
cullMode?: GPUCullMode;
962+
frontFace?: GPUFrontFace;
963+
stripIndexFormat?: GPUIndexFormat;
964+
topology?: GPUPrimitiveTopology;
965+
unclippedDepth?: boolean;
966+
}
967+
920968
interface GPUProgrammableStage {
921969
constants?: Record<string, GPUPipelineConstantValue>;
922970
entryPoint?: string;
@@ -977,6 +1025,14 @@ interface GPURenderPassTimestampWrites {
9771025
querySet: GPUQuerySet;
9781026
}
9791027

1028+
interface GPURenderPipelineDescriptor extends GPUPipelineDescriptorBase {
1029+
depthStencil?: GPUDepthStencilState;
1030+
fragment?: GPUFragmentState;
1031+
multisample?: GPUMultisampleState;
1032+
primitive?: GPUPrimitiveState;
1033+
vertex: GPUVertexState;
1034+
}
1035+
9801036
interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
9811037
addressModeU?: GPUAddressMode;
9821038
addressModeV?: GPUAddressMode;
@@ -994,6 +1050,13 @@ interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
9941050
code: string;
9951051
}
9961052

1053+
interface GPUStencilFaceState {
1054+
compare?: GPUCompareFunction;
1055+
depthFailOp?: GPUStencilOperation;
1056+
failOp?: GPUStencilOperation;
1057+
passOp?: GPUStencilOperation;
1058+
}
1059+
9971060
interface GPUTexelCopyBufferInfo extends GPUTexelCopyBufferLayout {
9981061
buffer: GPUBuffer;
9991062
}
@@ -1036,6 +1099,22 @@ interface GPUUncapturedErrorEventInit extends EventInit {
10361099
error: GPUError;
10371100
}
10381101

1102+
interface GPUVertexAttribute {
1103+
format: GPUVertexFormat;
1104+
offset: GPUSize64;
1105+
shaderLocation: GPUIndex32;
1106+
}
1107+
1108+
interface GPUVertexBufferLayout {
1109+
arrayStride: GPUSize64;
1110+
attributes: GPUVertexAttribute[];
1111+
stepMode?: GPUVertexStepMode;
1112+
}
1113+
1114+
interface GPUVertexState extends GPUProgrammableStage {
1115+
buffers?: (GPUVertexBufferLayout | null)[];
1116+
}
1117+
10391118
interface GainOptions extends AudioNodeOptions {
10401119
gain?: number;
10411120
}
@@ -15457,6 +15536,18 @@ interface GPUDevice extends EventTarget, GPUObjectBase {
1545715536
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDevice/createRenderBundleEncoder)
1545815537
*/
1545915538
createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): GPURenderBundleEncoder;
15539+
/**
15540+
* The **`createRenderPipeline()`** method of the GPUDevice interface creates a GPURenderPipeline that can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder.
15541+
*
15542+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDevice/createRenderPipeline)
15543+
*/
15544+
createRenderPipeline(descriptor: GPURenderPipelineDescriptor): GPURenderPipeline;
15545+
/**
15546+
* The **`createRenderPipelineAsync()`** method of the GPUDevice interface returns a Promise that fulfills with a GPURenderPipeline, which can control the vertex and fragment shader stages and be used in a GPURenderPassEncoder or GPURenderBundleEncoder, once the pipeline can be used without any stalling.
15547+
*
15548+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUDevice/createRenderPipelineAsync)
15549+
*/
15550+
createRenderPipelineAsync(descriptor: GPURenderPipelineDescriptor): Promise<GPURenderPipeline>;
1546015551
/**
1546115552
* The **`createSampler()`** method of the GPUDevice interface creates a GPUSampler, which controls how shaders transform and filter texture resource data.
1546215553
*
@@ -43919,7 +44010,9 @@ type GPUBindingResource = GPUSampler | GPUTexture | GPUTextureView | GPUBuffer |
4391944010
type GPUBufferDynamicOffset = number;
4392044011
type GPUBufferUsageFlags = number;
4392144012
type GPUColor = number[] | GPUColorDict;
44013+
type GPUColorWriteFlags = number;
4392244014
type GPUCopyExternalImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLVideoElement | VideoFrame | HTMLCanvasElement | OffscreenCanvas;
44015+
type GPUDepthBias = number;
4392344016
type GPUExtent3D = GPUIntegerCoordinate[] | GPUExtent3DDict;
4392444017
type GPUFlagsConstant = number;
4392544018
type GPUIndex32 = number;
@@ -43929,6 +44022,7 @@ type GPUMapModeFlags = number;
4392944022
type GPUOrigin2D = GPUIntegerCoordinate[] | GPUOrigin2DDict;
4393044023
type GPUOrigin3D = GPUIntegerCoordinate[] | GPUOrigin3DDict;
4393144024
type GPUPipelineConstantValue = number;
44025+
type GPUSampleMask = number;
4393244026
type GPUSignedOffset32 = number;
4393344027
type GPUSize32 = number;
4393444028
type GPUSize32Out = number;
@@ -44044,24 +44138,32 @@ type FontFaceSetLoadStatus = "loaded" | "loading";
4404444138
type FullscreenNavigationUI = "auto" | "hide" | "show";
4404544139
type GPUAddressMode = "clamp-to-edge" | "mirror-repeat" | "repeat";
4404644140
type GPUAutoLayoutMode = "auto";
44141+
type GPUBlendFactor = "constant" | "dst" | "dst-alpha" | "one" | "one-minus-constant" | "one-minus-dst" | "one-minus-dst-alpha" | "one-minus-src" | "one-minus-src-alpha" | "src" | "src-alpha" | "src-alpha-saturated" | "zero";
44142+
type GPUBlendOperation = "add" | "max" | "min" | "reverse-subtract" | "subtract";
4404744143
type GPUBufferMapState = "mapped" | "pending" | "unmapped";
4404844144
type GPUCanvasAlphaMode = "opaque" | "premultiplied";
4404944145
type GPUCanvasToneMappingMode = "extended" | "standard";
4405044146
type GPUCompareFunction = "always" | "equal" | "greater" | "greater-equal" | "less" | "less-equal" | "never" | "not-equal";
4405144147
type GPUCompilationMessageType = "error" | "info" | "warning";
44148+
type GPUCullMode = "back" | "front" | "none";
4405244149
type GPUDeviceLostReason = "destroyed" | "unknown";
4405344150
type GPUErrorFilter = "internal" | "out-of-memory" | "validation";
4405444151
type GPUFilterMode = "linear" | "nearest";
44152+
type GPUFrontFace = "ccw" | "cw";
4405544153
type GPUIndexFormat = "uint16" | "uint32";
4405644154
type GPULoadOp = "clear" | "load";
4405744155
type GPUMipmapFilterMode = "linear" | "nearest";
4405844156
type GPUPipelineErrorReason = "internal" | "validation";
44157+
type GPUPrimitiveTopology = "line-list" | "line-strip" | "point-list" | "triangle-list" | "triangle-strip";
4405944158
type GPUQueryType = "occlusion" | "timestamp";
44159+
type GPUStencilOperation = "decrement-clamp" | "decrement-wrap" | "increment-clamp" | "increment-wrap" | "invert" | "keep" | "replace" | "zero";
4406044160
type GPUStoreOp = "discard" | "store";
4406144161
type GPUTextureAspect = "all" | "depth-only" | "stencil-only";
4406244162
type GPUTextureDimension = "1d" | "2d" | "3d";
4406344163
type GPUTextureFormat = "astc-10x10-unorm" | "astc-10x10-unorm-srgb" | "astc-10x5-unorm" | "astc-10x5-unorm-srgb" | "astc-10x6-unorm" | "astc-10x6-unorm-srgb" | "astc-10x8-unorm" | "astc-10x8-unorm-srgb" | "astc-12x10-unorm" | "astc-12x10-unorm-srgb" | "astc-12x12-unorm" | "astc-12x12-unorm-srgb" | "astc-4x4-unorm" | "astc-4x4-unorm-srgb" | "astc-5x4-unorm" | "astc-5x4-unorm-srgb" | "astc-5x5-unorm" | "astc-5x5-unorm-srgb" | "astc-6x5-unorm" | "astc-6x5-unorm-srgb" | "astc-6x6-unorm" | "astc-6x6-unorm-srgb" | "astc-8x5-unorm" | "astc-8x5-unorm-srgb" | "astc-8x6-unorm" | "astc-8x6-unorm-srgb" | "astc-8x8-unorm" | "astc-8x8-unorm-srgb" | "bc1-rgba-unorm" | "bc1-rgba-unorm-srgb" | "bc2-rgba-unorm" | "bc2-rgba-unorm-srgb" | "bc3-rgba-unorm" | "bc3-rgba-unorm-srgb" | "bc4-r-snorm" | "bc4-r-unorm" | "bc5-rg-snorm" | "bc5-rg-unorm" | "bc6h-rgb-float" | "bc6h-rgb-ufloat" | "bc7-rgba-unorm" | "bc7-rgba-unorm-srgb" | "bgra8unorm" | "bgra8unorm-srgb" | "depth16unorm" | "depth24plus" | "depth24plus-stencil8" | "depth32float" | "depth32float-stencil8" | "eac-r11snorm" | "eac-r11unorm" | "eac-rg11snorm" | "eac-rg11unorm" | "etc2-rgb8a1unorm" | "etc2-rgb8a1unorm-srgb" | "etc2-rgb8unorm" | "etc2-rgb8unorm-srgb" | "etc2-rgba8unorm" | "etc2-rgba8unorm-srgb" | "r16float" | "r16sint" | "r16snorm" | "r16uint" | "r16unorm" | "r32float" | "r32sint" | "r32uint" | "r8sint" | "r8snorm" | "r8uint" | "r8unorm" | "rg11b10ufloat" | "rg16float" | "rg16sint" | "rg16snorm" | "rg16uint" | "rg16unorm" | "rg32float" | "rg32sint" | "rg32uint" | "rg8sint" | "rg8snorm" | "rg8uint" | "rg8unorm" | "rgb10a2uint" | "rgb10a2unorm" | "rgb9e5ufloat" | "rgba16float" | "rgba16sint" | "rgba16snorm" | "rgba16uint" | "rgba16unorm" | "rgba32float" | "rgba32sint" | "rgba32uint" | "rgba8sint" | "rgba8snorm" | "rgba8uint" | "rgba8unorm" | "rgba8unorm-srgb" | "stencil8";
4406444164
type GPUTextureViewDimension = "1d" | "2d" | "2d-array" | "3d" | "cube" | "cube-array";
44165+
type GPUVertexFormat = "float16" | "float16x2" | "float16x4" | "float32" | "float32x2" | "float32x3" | "float32x4" | "sint16" | "sint16x2" | "sint16x4" | "sint32" | "sint32x2" | "sint32x3" | "sint32x4" | "sint8" | "sint8x2" | "sint8x4" | "snorm16" | "snorm16x2" | "snorm16x4" | "snorm8" | "snorm8x2" | "snorm8x4" | "uint16" | "uint16x2" | "uint16x4" | "uint32" | "uint32x2" | "uint32x3" | "uint32x4" | "uint8" | "uint8x2" | "uint8x4" | "unorm10-10-10-2" | "unorm16" | "unorm16x2" | "unorm16x4" | "unorm8" | "unorm8x2" | "unorm8x4" | "unorm8x4-bgra";
44166+
type GPUVertexStepMode = "instance" | "vertex";
4406544167
type GamepadHapticEffectType = "dual-rumble" | "trigger-rumble";
4406644168
type GamepadHapticsResult = "complete" | "preempted";
4406744169
type GamepadMappingType = "" | "standard" | "xr-standard";

0 commit comments

Comments
 (0)