@viji-dev/core 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -229,7 +229,12 @@ declare global {
229
229
  interface CaptureFrameOptions {
230
230
  /** Output format: `'blob'` for an encoded image, `'bitmap'` for a GPU-friendly `ImageBitmap`. Default: `'blob'`. */
231
231
  format?: 'blob' | 'bitmap';
232
- /** MIME type for `'blob'` output (ignored for `'bitmap'`). Examples: `'image/png'`, `'image/jpeg'`, `'image/webp'`. */
232
+ /**
233
+ * MIME type for `'blob'` output (ignored for `'bitmap'`). Examples:
234
+ * `'image/png'`, `'image/jpeg'`, `'image/webp'`. Default: `'image/png'`
235
+ * (lossless, preserves alpha). Pass a lossy type for smaller files when
236
+ * transparency does not matter.
237
+ */
233
238
  type?: string;
234
239
  /**
235
240
  * Encoding quality for lossy `'blob'` formats (`'image/jpeg'`, `'image/webp'`),
@@ -1345,7 +1350,7 @@ declare global {
1345
1350
  isEnding: boolean;
1346
1351
  }
1347
1352
 
1348
- const VERSION = "0.14.0";
1353
+ const VERSION = "0.16.0";
1349
1354
 
1350
1355
  /**
1351
1356
  * Real-time video API: drawable frame, dimensions, and the source-side
@@ -1543,6 +1548,8 @@ declare global {
1543
1548
  ctx?: OffscreenCanvasRenderingContext2D;
1544
1549
  /** WebGL rendering context. `undefined` until `viji.useContext('webgl')` or `'webgl2'` is called; afterwards equals the cached context. */
1545
1550
  gl?: WebGLRenderingContext | WebGL2RenderingContext;
1551
+ /** WebGPU canvas context. `undefined` until `viji.useContext('webgpu')` (or a direct `viji.canvas.getContext('webgpu')`) succeeds; afterwards equals the acquired context. Stays `undefined` on browsers without WebGPU support. */
1552
+ gpu?: GPUCanvasContext;
1546
1553
  /** Current canvas width in pixels. Updates automatically when the host resizes the canvas; read every frame. */
1547
1554
  width: number;
1548
1555
  /** Current canvas height in pixels. Updates automatically when the host resizes the canvas; read every frame. */
@@ -1683,8 +1690,3452 @@ declare global {
1683
1690
  * `null`. Choose ONE type and use it for the entire scene.
1684
1691
  */
1685
1692
  useContext(type: 'webgl2'): WebGL2RenderingContext;
1693
+ /**
1694
+ * Selects a WebGPU canvas context. Returns the raw `GPUCanvasContext` and
1695
+ * also stores it on `viji.gpu`. Adapter and device acquisition stay in scene
1696
+ * code (`navigator.gpu` is available; top-level `await` works), and the
1697
+ * scene must call `configure()` on the context before rendering. A canvas
1698
+ * only supports one context type. Returns `null` when a different context
1699
+ * type was already requested OR when the browser has no WebGPU support,
1700
+ * so always guard and provide a fallback. Choose ONE type and use it for
1701
+ * the entire scene.
1702
+ *
1703
+ * @example
1704
+ * const gctx = viji.useContext('webgpu');
1705
+ * if (!navigator.gpu || !gctx) {
1706
+ * // fall back, e.g. render a message via a 2d scene variant
1707
+ * } else {
1708
+ * const adapter = await navigator.gpu.requestAdapter();
1709
+ * const device = await adapter.requestDevice();
1710
+ * const format = navigator.gpu.getPreferredCanvasFormat();
1711
+ * gctx.configure({ device, format, alphaMode: 'opaque' });
1712
+ * }
1713
+ */
1714
+ useContext(type: 'webgpu'): GPUCanvasContext | null;
1686
1715
  }
1687
1716
 
1717
+ // ===== WEBGPU TYPES (inlined from @webgpu/types v0.1.72) =====
1718
+ // *********************************************************************************************
1719
+ // This file is manually-edited by diffing against an autogenerated file. See README.md.
1720
+ // *********************************************************************************************
1721
+
1722
+ // *********************************************************************************************
1723
+ // Manually-written - auto copied from extra.d.ts
1724
+ // *********************************************************************************************
1725
+
1726
+ // AllowSharedBufferSource wasn't introduced until TypeScript 5.2.
1727
+ // But it also didn't include SharedArrayBuffer in the union.
1728
+ // This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't.
1729
+ // So, we use our own definition for AllowSharedBufferSource.
1730
+
1731
+ type GPUAllowSharedBufferSource =
1732
+
1733
+ | BufferSource
1734
+ | SharedArrayBuffer;
1735
+
1736
+ // Stronger typing for getContext()
1737
+
1738
+ interface HTMLCanvasElement {
1739
+ getContext(
1740
+ contextId:
1741
+ | "webgpu"
1742
+ ): GPUCanvasContext | null;
1743
+ }
1744
+ interface OffscreenCanvas {
1745
+ getContext(
1746
+ contextId:
1747
+ | "webgpu"
1748
+ ): GPUCanvasContext | null;
1749
+ }
1750
+
1751
+ // Defined as an empty interface here to prevent errors when using these types in a worker.
1752
+
1753
+ interface HTMLVideoElement {}
1754
+
1755
+ // Strict types defined to help developers catch a common class of errors.
1756
+ // This interface defines depth as an undefined, which will cause a type check failure if someone
1757
+ // attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.)
1758
+
1759
+ type GPUOrigin2DStrict =
1760
+
1761
+ | Iterable<GPUIntegerCoordinate>
1762
+ | GPUOrigin2DDictStrict;
1763
+ interface GPUOrigin2DDictStrict
1764
+ extends GPUOrigin2DDict {
1765
+ /** @deprecated Does not exist for GPUOrigin2D. */
1766
+ z?: undefined;
1767
+ }
1768
+ type GPUExtent3DStrict =
1769
+
1770
+ | Iterable<GPUIntegerCoordinate>
1771
+ | GPUExtent3DDictStrict;
1772
+ interface GPUExtent3DDictStrict
1773
+ extends GPUExtent3DDict {
1774
+ /** @deprecated The correct name is `depthOrArrayLayers`. */
1775
+ depth?: undefined;
1776
+ }
1777
+
1778
+ // Stronger typing for event listeners.
1779
+
1780
+ /** @internal */
1781
+ interface __GPUDeviceEventMap {
1782
+ uncapturederror: GPUUncapturedErrorEvent;
1783
+ }
1784
+
1785
+ // Extensions to the generated definition below.
1786
+ interface GPUDevice {
1787
+ addEventListener<
1788
+ K extends keyof __GPUDeviceEventMap
1789
+ >(
1790
+ type: K,
1791
+ listener: (
1792
+ this: GPUDevice,
1793
+ ev: __GPUDeviceEventMap[K]
1794
+ ) => any,
1795
+ options?:
1796
+ | boolean
1797
+ | AddEventListenerOptions
1798
+ ): void;
1799
+ addEventListener(
1800
+ type: string,
1801
+ listener: EventListenerOrEventListenerObject,
1802
+ options?:
1803
+ | boolean
1804
+ | AddEventListenerOptions
1805
+ ): void;
1806
+ removeEventListener<
1807
+ K extends keyof __GPUDeviceEventMap
1808
+ >(
1809
+ type: K,
1810
+ listener: (
1811
+ this: GPUDevice,
1812
+ ev: __GPUDeviceEventMap[K]
1813
+ ) => any,
1814
+ options?:
1815
+ | boolean
1816
+ | EventListenerOptions
1817
+ ): void;
1818
+ removeEventListener(
1819
+ type: string,
1820
+ listener: EventListenerOrEventListenerObject,
1821
+ options?:
1822
+ | boolean
1823
+ | EventListenerOptions
1824
+ ): void;
1825
+ }
1826
+
1827
+ interface GPUCanvasConfigurationOut
1828
+ extends Required<
1829
+ Omit<
1830
+ GPUCanvasConfiguration,
1831
+ "toneMapping"
1832
+ >
1833
+ > {
1834
+ /** {@inheritDoc GPUCanvasConfiguration.viewFormats} */
1835
+ viewFormats: GPUTextureFormat[];
1836
+ /**
1837
+ * {@inheritDoc GPUCanvasConfiguration.toneMapping}
1838
+ */
1839
+ toneMapping?: GPUCanvasToneMapping;
1840
+ }
1841
+
1842
+ /** @deprecated Use {@link GPUTexelCopyBufferLayout} */
1843
+ type GPUImageDataLayout =
1844
+ GPUTexelCopyBufferLayout;
1845
+ /** @deprecated Use {@link GPUTexelCopyBufferInfo} */
1846
+ type GPUImageCopyBuffer =
1847
+ GPUTexelCopyBufferInfo;
1848
+ /** @deprecated Use {@link GPUTexelCopyTextureInfo} */
1849
+ type GPUImageCopyTexture =
1850
+ GPUTexelCopyTextureInfo;
1851
+ /** @deprecated Use {@link GPUCopyExternalImageDestInfo} */
1852
+ type GPUImageCopyTextureTagged =
1853
+ GPUCopyExternalImageDestInfo;
1854
+ /** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */
1855
+ type GPUImageCopyExternalImage =
1856
+ GPUCopyExternalImageSourceInfo;
1857
+ /** @deprecated Use {@link GPUCopyExternalImageSource} */
1858
+ type GPUImageCopyExternalImageSource =
1859
+ GPUCopyExternalImageSource;
1860
+
1861
+ // *********************************************************************************************
1862
+ // Semi-auto-generated (by manual diff with autogenerated types)
1863
+ // *********************************************************************************************
1864
+
1865
+ type GPUBindingResource =
1866
+
1867
+ | GPUSampler
1868
+ | GPUTexture
1869
+ | GPUTextureView
1870
+ | GPUBuffer
1871
+ | GPUBufferBinding
1872
+ | GPUExternalTexture;
1873
+ type GPUBufferDynamicOffset =
1874
+ number;
1875
+ type GPUBufferUsageFlags =
1876
+ number;
1877
+ type GPUColor =
1878
+
1879
+ | Iterable<number>
1880
+ | GPUColorDict;
1881
+ type GPUColorWriteFlags =
1882
+ number;
1883
+ type GPUCopyExternalImageSource =
1884
+
1885
+ | ImageBitmap
1886
+ | ImageData
1887
+ | HTMLImageElement
1888
+ | HTMLVideoElement
1889
+ | VideoFrame
1890
+ | HTMLCanvasElement
1891
+ | OffscreenCanvas;
1892
+ type GPUDepthBias =
1893
+ number;
1894
+ type GPUExtent3D =
1895
+
1896
+ | Iterable<GPUIntegerCoordinate>
1897
+ | GPUExtent3DDict;
1898
+ type GPUFlagsConstant =
1899
+ number;
1900
+ type GPUIndex32 =
1901
+ number;
1902
+ type GPUIntegerCoordinate =
1903
+ number;
1904
+ type GPUIntegerCoordinateOut =
1905
+ number;
1906
+ type GPUMapModeFlags =
1907
+ number;
1908
+ type GPUOrigin2D =
1909
+
1910
+ | Iterable<GPUIntegerCoordinate>
1911
+ | GPUOrigin2DDict;
1912
+ type GPUOrigin3D =
1913
+
1914
+ | Iterable<GPUIntegerCoordinate>
1915
+ | GPUOrigin3DDict;
1916
+ type GPUPipelineConstantValue =
1917
+ number;
1918
+ type GPUSampleMask =
1919
+ number;
1920
+ type GPUShaderStageFlags =
1921
+ number;
1922
+ type GPUSignedOffset32 =
1923
+ number;
1924
+ type GPUSize32 =
1925
+ number;
1926
+ type GPUSize32Out =
1927
+ number;
1928
+ type GPUSize64 =
1929
+ number;
1930
+ type GPUSize64Out =
1931
+ number;
1932
+ type GPUStencilValue =
1933
+ number;
1934
+ type GPUTextureUsageFlags =
1935
+ number;
1936
+ type GPUAddressMode =
1937
+
1938
+ | "clamp-to-edge"
1939
+ | "repeat"
1940
+ | "mirror-repeat";
1941
+ type GPUAutoLayoutMode =
1942
+ "auto";
1943
+ type GPUBlendFactor =
1944
+
1945
+ | "zero"
1946
+ | "one"
1947
+ | "src"
1948
+ | "one-minus-src"
1949
+ | "src-alpha"
1950
+ | "one-minus-src-alpha"
1951
+ | "dst"
1952
+ | "one-minus-dst"
1953
+ | "dst-alpha"
1954
+ | "one-minus-dst-alpha"
1955
+ | "src-alpha-saturated"
1956
+ | "constant"
1957
+ | "one-minus-constant"
1958
+ | "src1"
1959
+ | "one-minus-src1"
1960
+ | "src1-alpha"
1961
+ | "one-minus-src1-alpha";
1962
+ type GPUBlendOperation =
1963
+
1964
+ | "add"
1965
+ | "subtract"
1966
+ | "reverse-subtract"
1967
+ | "min"
1968
+ | "max";
1969
+ type GPUBufferBindingType =
1970
+
1971
+ | "uniform"
1972
+ | "storage"
1973
+ | "read-only-storage";
1974
+ type GPUBufferMapState =
1975
+
1976
+ | "unmapped"
1977
+ | "pending"
1978
+ | "mapped";
1979
+ type GPUCanvasAlphaMode =
1980
+
1981
+ | "opaque"
1982
+ | "premultiplied";
1983
+ type GPUCanvasToneMappingMode =
1984
+
1985
+ | "standard"
1986
+ | "extended";
1987
+ type GPUCompareFunction =
1988
+
1989
+ | "never"
1990
+ | "less"
1991
+ | "equal"
1992
+ | "less-equal"
1993
+ | "greater"
1994
+ | "not-equal"
1995
+ | "greater-equal"
1996
+ | "always";
1997
+ type GPUCompilationMessageType =
1998
+
1999
+ | "error"
2000
+ | "warning"
2001
+ | "info";
2002
+ type GPUCullMode =
2003
+
2004
+ | "none"
2005
+ | "front"
2006
+ | "back";
2007
+ type GPUDeviceLostReason =
2008
+
2009
+ | "unknown"
2010
+ | "destroyed";
2011
+ type GPUErrorFilter =
2012
+
2013
+ | "validation"
2014
+ | "out-of-memory"
2015
+ | "internal";
2016
+ type GPUFeatureName =
2017
+
2018
+ | "core-features-and-limits"
2019
+ | "depth-clip-control"
2020
+ | "depth32float-stencil8"
2021
+ | "texture-compression-bc"
2022
+ | "texture-compression-bc-sliced-3d"
2023
+ | "texture-compression-etc2"
2024
+ | "texture-compression-astc"
2025
+ | "texture-compression-astc-sliced-3d"
2026
+ | "timestamp-query"
2027
+ | "indirect-first-instance"
2028
+ | "shader-f16"
2029
+ | "rg11b10ufloat-renderable"
2030
+ | "bgra8unorm-storage"
2031
+ | "float32-filterable"
2032
+ | "float32-blendable"
2033
+ | "clip-distances"
2034
+ | "dual-source-blending"
2035
+ | "subgroups"
2036
+ | "texture-formats-tier1"
2037
+ | "texture-formats-tier2"
2038
+ | "primitive-index"
2039
+ | "texture-component-swizzle"
2040
+ | "subgroup-size-control";
2041
+ type GPUFilterMode =
2042
+
2043
+ | "nearest"
2044
+ | "linear";
2045
+ type GPUFrontFace =
2046
+
2047
+ | "ccw"
2048
+ | "cw";
2049
+ type GPUIndexFormat =
2050
+
2051
+ | "uint16"
2052
+ | "uint32";
2053
+ type GPULoadOp =
2054
+
2055
+ | "load"
2056
+ | "clear";
2057
+ type GPUMipmapFilterMode =
2058
+
2059
+ | "nearest"
2060
+ | "linear";
2061
+ type GPUPipelineErrorReason =
2062
+
2063
+ | "validation"
2064
+ | "internal";
2065
+ type GPUPowerPreference =
2066
+
2067
+ | "low-power"
2068
+ | "high-performance";
2069
+ type GPUPrimitiveTopology =
2070
+
2071
+ | "point-list"
2072
+ | "line-list"
2073
+ | "line-strip"
2074
+ | "triangle-list"
2075
+ | "triangle-strip";
2076
+ type GPUQueryType =
2077
+
2078
+ | "occlusion"
2079
+ | "timestamp";
2080
+ type GPUSamplerBindingType =
2081
+
2082
+ | "filtering"
2083
+ | "non-filtering"
2084
+ | "comparison";
2085
+ type GPUStencilOperation =
2086
+
2087
+ | "keep"
2088
+ | "zero"
2089
+ | "replace"
2090
+ | "invert"
2091
+ | "increment-clamp"
2092
+ | "decrement-clamp"
2093
+ | "increment-wrap"
2094
+ | "decrement-wrap";
2095
+ type GPUStorageTextureAccess =
2096
+
2097
+ | "write-only"
2098
+ | "read-only"
2099
+ | "read-write";
2100
+ type GPUStoreOp =
2101
+
2102
+ | "store"
2103
+ | "discard";
2104
+ type GPUTextureAspect =
2105
+
2106
+ | "all"
2107
+ | "stencil-only"
2108
+ | "depth-only";
2109
+ type GPUTextureDimension =
2110
+
2111
+ | "1d"
2112
+ | "2d"
2113
+ | "3d";
2114
+ type GPUTextureFormat =
2115
+
2116
+ | "r8unorm"
2117
+ | "r8snorm"
2118
+ | "r8uint"
2119
+ | "r8sint"
2120
+ | "r16unorm"
2121
+ | "r16snorm"
2122
+ | "r16uint"
2123
+ | "r16sint"
2124
+ | "r16float"
2125
+ | "rg8unorm"
2126
+ | "rg8snorm"
2127
+ | "rg8uint"
2128
+ | "rg8sint"
2129
+ | "r32uint"
2130
+ | "r32sint"
2131
+ | "r32float"
2132
+ | "rg16unorm"
2133
+ | "rg16snorm"
2134
+ | "rg16uint"
2135
+ | "rg16sint"
2136
+ | "rg16float"
2137
+ | "rgba8unorm"
2138
+ | "rgba8unorm-srgb"
2139
+ | "rgba8snorm"
2140
+ | "rgba8uint"
2141
+ | "rgba8sint"
2142
+ | "bgra8unorm"
2143
+ | "bgra8unorm-srgb"
2144
+ | "rgb9e5ufloat"
2145
+ | "rgb10a2uint"
2146
+ | "rgb10a2unorm"
2147
+ | "rg11b10ufloat"
2148
+ | "rg32uint"
2149
+ | "rg32sint"
2150
+ | "rg32float"
2151
+ | "rgba16unorm"
2152
+ | "rgba16snorm"
2153
+ | "rgba16uint"
2154
+ | "rgba16sint"
2155
+ | "rgba16float"
2156
+ | "rgba32uint"
2157
+ | "rgba32sint"
2158
+ | "rgba32float"
2159
+ | "stencil8"
2160
+ | "depth16unorm"
2161
+ | "depth24plus"
2162
+ | "depth24plus-stencil8"
2163
+ | "depth32float"
2164
+ | "depth32float-stencil8"
2165
+ | "bc1-rgba-unorm"
2166
+ | "bc1-rgba-unorm-srgb"
2167
+ | "bc2-rgba-unorm"
2168
+ | "bc2-rgba-unorm-srgb"
2169
+ | "bc3-rgba-unorm"
2170
+ | "bc3-rgba-unorm-srgb"
2171
+ | "bc4-r-unorm"
2172
+ | "bc4-r-snorm"
2173
+ | "bc5-rg-unorm"
2174
+ | "bc5-rg-snorm"
2175
+ | "bc6h-rgb-ufloat"
2176
+ | "bc6h-rgb-float"
2177
+ | "bc7-rgba-unorm"
2178
+ | "bc7-rgba-unorm-srgb"
2179
+ | "etc2-rgb8unorm"
2180
+ | "etc2-rgb8unorm-srgb"
2181
+ | "etc2-rgb8a1unorm"
2182
+ | "etc2-rgb8a1unorm-srgb"
2183
+ | "etc2-rgba8unorm"
2184
+ | "etc2-rgba8unorm-srgb"
2185
+ | "eac-r11unorm"
2186
+ | "eac-r11snorm"
2187
+ | "eac-rg11unorm"
2188
+ | "eac-rg11snorm"
2189
+ | "astc-4x4-unorm"
2190
+ | "astc-4x4-unorm-srgb"
2191
+ | "astc-5x4-unorm"
2192
+ | "astc-5x4-unorm-srgb"
2193
+ | "astc-5x5-unorm"
2194
+ | "astc-5x5-unorm-srgb"
2195
+ | "astc-6x5-unorm"
2196
+ | "astc-6x5-unorm-srgb"
2197
+ | "astc-6x6-unorm"
2198
+ | "astc-6x6-unorm-srgb"
2199
+ | "astc-8x5-unorm"
2200
+ | "astc-8x5-unorm-srgb"
2201
+ | "astc-8x6-unorm"
2202
+ | "astc-8x6-unorm-srgb"
2203
+ | "astc-8x8-unorm"
2204
+ | "astc-8x8-unorm-srgb"
2205
+ | "astc-10x5-unorm"
2206
+ | "astc-10x5-unorm-srgb"
2207
+ | "astc-10x6-unorm"
2208
+ | "astc-10x6-unorm-srgb"
2209
+ | "astc-10x8-unorm"
2210
+ | "astc-10x8-unorm-srgb"
2211
+ | "astc-10x10-unorm"
2212
+ | "astc-10x10-unorm-srgb"
2213
+ | "astc-12x10-unorm"
2214
+ | "astc-12x10-unorm-srgb"
2215
+ | "astc-12x12-unorm"
2216
+ | "astc-12x12-unorm-srgb";
2217
+ type GPUTextureSampleType =
2218
+
2219
+ | "float"
2220
+ | "unfilterable-float"
2221
+ | "depth"
2222
+ | "sint"
2223
+ | "uint";
2224
+ type GPUTextureViewDimension =
2225
+
2226
+ | "1d"
2227
+ | "2d"
2228
+ | "2d-array"
2229
+ | "cube"
2230
+ | "cube-array"
2231
+ | "3d";
2232
+ type GPUVertexFormat =
2233
+
2234
+ | "uint8"
2235
+ | "uint8x2"
2236
+ | "uint8x4"
2237
+ | "sint8"
2238
+ | "sint8x2"
2239
+ | "sint8x4"
2240
+ | "unorm8"
2241
+ | "unorm8x2"
2242
+ | "unorm8x4"
2243
+ | "snorm8"
2244
+ | "snorm8x2"
2245
+ | "snorm8x4"
2246
+ | "uint16"
2247
+ | "uint16x2"
2248
+ | "uint16x4"
2249
+ | "sint16"
2250
+ | "sint16x2"
2251
+ | "sint16x4"
2252
+ | "unorm16"
2253
+ | "unorm16x2"
2254
+ | "unorm16x4"
2255
+ | "snorm16"
2256
+ | "snorm16x2"
2257
+ | "snorm16x4"
2258
+ | "float16"
2259
+ | "float16x2"
2260
+ | "float16x4"
2261
+ | "float32"
2262
+ | "float32x2"
2263
+ | "float32x3"
2264
+ | "float32x4"
2265
+ | "uint32"
2266
+ | "uint32x2"
2267
+ | "uint32x3"
2268
+ | "uint32x4"
2269
+ | "sint32"
2270
+ | "sint32x2"
2271
+ | "sint32x3"
2272
+ | "sint32x4"
2273
+ | "unorm10-10-10-2"
2274
+ | "snorm10-10-10-2"
2275
+ | "unorm8x4-bgra";
2276
+ type GPUVertexStepMode =
2277
+
2278
+ | "vertex"
2279
+ | "instance";
2280
+
2281
+ interface GPUBindGroupDescriptor
2282
+ extends GPUObjectDescriptorBase {
2283
+ /**
2284
+ * The {@link GPUBindGroupLayout} the entries of this bind group will conform to.
2285
+ */
2286
+ layout: GPUBindGroupLayout;
2287
+ /**
2288
+ * A list of entries describing the resources to expose to the shader for each binding
2289
+ * described by the {@link GPUBindGroupDescriptor#layout}.
2290
+ */
2291
+ entries: Iterable<GPUBindGroupEntry>;
2292
+ }
2293
+
2294
+ interface GPUBindGroupEntry {
2295
+ /**
2296
+ * A unique identifier for a resource binding within the {@link GPUBindGroup}, corresponding to a
2297
+ * {@link GPUBindGroupLayoutEntry#binding | GPUBindGroupLayoutEntry.binding} and a @binding
2298
+ * attribute in the {@link GPUShaderModule}.
2299
+ */
2300
+ binding: GPUIndex32;
2301
+ /**
2302
+ * The resource to bind, which may be a {@link GPUSampler}, {@link GPUTexture}, {@link GPUTextureView},
2303
+ * {@link GPUBuffer}, {@link GPUBufferBinding}, or {@link GPUExternalTexture}.
2304
+ */
2305
+ resource: GPUBindingResource;
2306
+ }
2307
+
2308
+ interface GPUBindGroupLayoutDescriptor
2309
+ extends GPUObjectDescriptorBase {
2310
+ /**
2311
+ * A list of entries describing the shader resource bindings for a bind group.
2312
+ */
2313
+ entries: Iterable<GPUBindGroupLayoutEntry>;
2314
+ }
2315
+
2316
+ interface GPUBindGroupLayoutEntry {
2317
+ /**
2318
+ * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding
2319
+ * to a {@link GPUBindGroupEntry#binding | GPUBindGroupEntry.binding} and a @binding
2320
+ * attribute in the {@link GPUShaderModule}.
2321
+ */
2322
+ binding: GPUIndex32;
2323
+ /**
2324
+ * A bitset of the members of {@link GPUShaderStage}.
2325
+ * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource
2326
+ * will be accessible from the associated shader stage.
2327
+ */
2328
+ visibility: GPUShaderStageFlags;
2329
+ /**
2330
+ */
2331
+ buffer?: GPUBufferBindingLayout;
2332
+ /**
2333
+ */
2334
+ sampler?: GPUSamplerBindingLayout;
2335
+ /**
2336
+ */
2337
+ texture?: GPUTextureBindingLayout;
2338
+ /**
2339
+ */
2340
+ storageTexture?: GPUStorageTextureBindingLayout;
2341
+ /**
2342
+ * Exactly one of these members must be set, indicating the binding type.
2343
+ * The contents of the member specify options specific to that type.
2344
+ * The corresponding resource in {@link GPUDevice#createBindGroup} requires
2345
+ * the corresponding binding resource type for this binding.
2346
+ */
2347
+ externalTexture?: GPUExternalTextureBindingLayout;
2348
+ }
2349
+
2350
+ interface GPUBlendComponent {
2351
+ /**
2352
+ * Defines the {@link GPUBlendOperation} used to calculate the values written to the target
2353
+ * attachment components.
2354
+ */
2355
+ operation?: GPUBlendOperation;
2356
+ /**
2357
+ * Defines the {@link GPUBlendFactor} operation to be performed on values from the fragment shader.
2358
+ */
2359
+ srcFactor?: GPUBlendFactor;
2360
+ /**
2361
+ * Defines the {@link GPUBlendFactor} operation to be performed on values from the target attachment.
2362
+ */
2363
+ dstFactor?: GPUBlendFactor;
2364
+ }
2365
+
2366
+ interface GPUBlendState {
2367
+ /**
2368
+ * Defines the blending behavior of the corresponding render target for color channels.
2369
+ */
2370
+ color: GPUBlendComponent;
2371
+ /**
2372
+ * Defines the blending behavior of the corresponding render target for the alpha channel.
2373
+ */
2374
+ alpha: GPUBlendComponent;
2375
+ }
2376
+
2377
+ interface GPUBufferBinding {
2378
+ /**
2379
+ * The {@link GPUBuffer} to bind.
2380
+ */
2381
+ buffer: GPUBuffer;
2382
+ /**
2383
+ * The offset, in bytes, from the beginning of {@link GPUBufferBinding#buffer} to the
2384
+ * beginning of the range exposed to the shader by the buffer binding.
2385
+ */
2386
+ offset?: GPUSize64;
2387
+ /**
2388
+ * The size, in bytes, of the buffer binding.
2389
+ * If not map/exist|provided, specifies the range starting at
2390
+ * {@link GPUBufferBinding#offset} and ending at the end of {@link GPUBufferBinding#buffer}.
2391
+ */
2392
+ size?: GPUSize64;
2393
+ }
2394
+
2395
+ interface GPUBufferBindingLayout {
2396
+ /**
2397
+ * Indicates the type required for buffers bound to this binding.
2398
+ */
2399
+ type?: GPUBufferBindingType;
2400
+ /**
2401
+ * Indicates whether this binding requires a dynamic offset.
2402
+ */
2403
+ hasDynamicOffset?: boolean;
2404
+ /**
2405
+ * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point.
2406
+ * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.
2407
+ * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]
2408
+ * that this value &ge; the minimum buffer binding size of the variable.
2409
+ * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands
2410
+ * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup}
2411
+ * satisfies the minimum buffer binding size of the variable.
2412
+ * Note:
2413
+ * Similar execution-time validation is theoretically possible for other
2414
+ * binding-related fields specified for early validation, like
2415
+ * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},
2416
+ * which currently can only be validated in pipeline creation.
2417
+ * However, such execution-time validation could be costly or unnecessarily complex, so it is
2418
+ * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the
2419
+ * most ergonomic impact.
2420
+ */
2421
+ minBindingSize?: GPUSize64;
2422
+ }
2423
+
2424
+ interface GPUBufferDescriptor
2425
+ extends GPUObjectDescriptorBase {
2426
+ /**
2427
+ * The size of the buffer in bytes.
2428
+ */
2429
+ size: GPUSize64;
2430
+ /**
2431
+ * The allowed usages for the buffer.
2432
+ */
2433
+ usage: GPUBufferUsageFlags;
2434
+ /**
2435
+ * If `true` creates the buffer in an already mapped state, allowing
2436
+ * {@link GPUBuffer#getMappedRange} to be called immediately. It is valid to set
2437
+ * {@link GPUBufferDescriptor#mappedAtCreation} to `true` even if {@link GPUBufferDescriptor#usage}
2438
+ * does not contain {@link GPUBufferUsage#MAP_READ} or {@link GPUBufferUsage#MAP_WRITE}. This can be
2439
+ * used to set the buffer's initial data.
2440
+ * Guarantees that even if the buffer creation eventually fails, it will still appear as if the
2441
+ * mapped range can be written/read to until it is unmapped.
2442
+ */
2443
+ mappedAtCreation?: boolean;
2444
+ }
2445
+
2446
+ interface GPUCanvasConfiguration {
2447
+ /**
2448
+ * The {@link GPUDevice} that textures returned by {@link GPUCanvasContext#getCurrentTexture} will be
2449
+ * compatible with.
2450
+ */
2451
+ device: GPUDevice;
2452
+ /**
2453
+ * The format that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.
2454
+ * Must be one of the Supported context formats.
2455
+ */
2456
+ format: GPUTextureFormat;
2457
+ /**
2458
+ * The usage that textures returned by {@link GPUCanvasContext#getCurrentTexture} will have.
2459
+ * {@link GPUTextureUsage#RENDER_ATTACHMENT} is the default, but is not automatically included
2460
+ * if the usage is explicitly set. Be sure to include {@link GPUTextureUsage#RENDER_ATTACHMENT}
2461
+ * when setting a custom usage if you wish to use textures returned by
2462
+ * {@link GPUCanvasContext#getCurrentTexture} as color targets for a render pass.
2463
+ */
2464
+ usage?: GPUTextureUsageFlags;
2465
+ /**
2466
+ * The formats that views created from textures returned by
2467
+ * {@link GPUCanvasContext#getCurrentTexture} may use.
2468
+ */
2469
+ viewFormats?: Iterable<GPUTextureFormat>;
2470
+ /**
2471
+ * The color space that values written into textures returned by
2472
+ * {@link GPUCanvasContext#getCurrentTexture} should be displayed with.
2473
+ */
2474
+ colorSpace?: PredefinedColorSpace;
2475
+ /**
2476
+ * The tone mapping determines how the content of textures returned by
2477
+ * {@link GPUCanvasContext#getCurrentTexture} are to be displayed.
2478
+ * <div class=note heading>
2479
+ * This is a required feature, but user agents might not yet implement it,
2480
+ * effectively supporting only the default {@link GPUCanvasToneMapping}.
2481
+ * In such implementations, this member **should not** exist in its implementation of
2482
+ * {@link GPUCanvasConfiguration}, to make feature detection possible using
2483
+ * {@link GPUCanvasContext#getConfiguration}.
2484
+ * This is especially important in implementations which otherwise have HDR capabilities
2485
+ * (where a <l>'@media/dynamic-range'</l> of <l>''@media/dynamic-range/high''</l> would be
2486
+ * exposed).
2487
+ * If an implementation exposes this member and a `high` dynamic range, it **should** render the
2488
+ * canvas as an HDR element, not clamp values to the SDR range of the HDR display.
2489
+ * </div>
2490
+ */
2491
+ toneMapping?: GPUCanvasToneMapping;
2492
+ /**
2493
+ * Determines the effect that alpha values will have on the content of textures returned by
2494
+ * {@link GPUCanvasContext#getCurrentTexture} when read, displayed, or used as an image source.
2495
+ */
2496
+ alphaMode?: GPUCanvasAlphaMode;
2497
+ }
2498
+
2499
+ interface GPUCanvasToneMapping {
2500
+ mode?: GPUCanvasToneMappingMode;
2501
+ }
2502
+
2503
+ interface GPUColorDict {
2504
+ /**
2505
+ * The red channel value.
2506
+ */
2507
+ r: number;
2508
+ /**
2509
+ * The green channel value.
2510
+ */
2511
+ g: number;
2512
+ /**
2513
+ * The blue channel value.
2514
+ */
2515
+ b: number;
2516
+ /**
2517
+ * The alpha channel value.
2518
+ */
2519
+ a: number;
2520
+ }
2521
+
2522
+ interface GPUColorTargetState {
2523
+ /**
2524
+ * The {@link GPUTextureFormat} of this color target. The pipeline will only be compatible with
2525
+ * {@link GPURenderPassEncoder}s which use a {@link GPUTextureView} of this format in the
2526
+ * corresponding color attachment.
2527
+ */
2528
+ format: GPUTextureFormat;
2529
+ /**
2530
+ * The blending behavior for this color target. If left undefined, disables blending for this
2531
+ * color target.
2532
+ */
2533
+ blend?: GPUBlendState;
2534
+ /**
2535
+ * Bitmask controlling which channels are are written to when drawing to this color target.
2536
+ */
2537
+ writeMask?: GPUColorWriteFlags;
2538
+ }
2539
+
2540
+ type GPUCommandBufferDescriptor =
2541
+ GPUObjectDescriptorBase;
2542
+ type GPUCommandEncoderDescriptor =
2543
+ GPUObjectDescriptorBase;
2544
+
2545
+ interface GPUComputePassDescriptor
2546
+ extends GPUObjectDescriptorBase {
2547
+ /**
2548
+ * Defines which timestamp values will be written for this pass, and where to write them to.
2549
+ */
2550
+ timestampWrites?: GPUComputePassTimestampWrites;
2551
+ }
2552
+
2553
+ interface GPUComputePassTimestampWrites {
2554
+ /**
2555
+ * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be
2556
+ * written to.
2557
+ */
2558
+ querySet: GPUQuerySet;
2559
+ /**
2560
+ * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
2561
+ * which the timestamp at the beginning of the compute pass will be written.
2562
+ */
2563
+ beginningOfPassWriteIndex?: GPUSize32;
2564
+ /**
2565
+ * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
2566
+ * which the timestamp at the end of the compute pass will be written.
2567
+ */
2568
+ endOfPassWriteIndex?: GPUSize32;
2569
+ }
2570
+
2571
+ interface GPUComputePipelineDescriptor
2572
+ extends GPUPipelineDescriptorBase {
2573
+ /**
2574
+ * Describes the compute shader entry point of the pipeline.
2575
+ */
2576
+ compute: GPUProgrammableStage;
2577
+ }
2578
+
2579
+ interface GPUCopyExternalImageDestInfo
2580
+ extends GPUTexelCopyTextureInfo {
2581
+ /**
2582
+ * Describes the color space and encoding used to encode data into the destination texture.
2583
+ * This {@link https://www.w3.org/TR/webgpu/#color-space-conversions | may result} in values outside of the range [0, 1]
2584
+ * being written to the target texture, if its format can represent them.
2585
+ * Otherwise, the results are clamped to the target texture format's range.
2586
+ * Note:
2587
+ * If {@link GPUCopyExternalImageDestInfo#colorSpace} matches the source image,
2588
+ * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.
2589
+ */
2590
+ colorSpace?: PredefinedColorSpace;
2591
+ /**
2592
+ * Describes whether the data written into the texture should have its RGB channels
2593
+ * premultiplied by the alpha channel, or not.
2594
+ * If this option is set to `true` and the {@link GPUCopyExternalImageSourceInfo#source} is also
2595
+ * premultiplied, the source RGB values must be preserved even if they exceed their
2596
+ * corresponding alpha values.
2597
+ * Note:
2598
+ * If {@link GPUCopyExternalImageDestInfo#premultipliedAlpha} matches the source image,
2599
+ * conversion might not be necessary. See {@link https://www.w3.org/TR/webgpu/#color-space-conversion-elision}.
2600
+ */
2601
+ premultipliedAlpha?: boolean;
2602
+ }
2603
+
2604
+ interface GPUCopyExternalImageSourceInfo {
2605
+ /**
2606
+ * The source of the texel copy. The copy source data is captured at the moment that
2607
+ * {@link GPUQueue#copyExternalImageToTexture} is issued. Source size is determined as described
2608
+ * by the external source dimensions table.
2609
+ */
2610
+ source: GPUCopyExternalImageSource;
2611
+ /**
2612
+ * Defines the origin of the copy - the minimum (top-left) corner of the source sub-region to copy from.
2613
+ * Together with `copySize`, defines the full copy sub-region.
2614
+ */
2615
+ origin?: GPUOrigin2D;
2616
+ /**
2617
+ * Describes whether the source image is vertically flipped, or not.
2618
+ * If this option is set to `true`, the copy is flipped vertically: the bottom row of the source
2619
+ * region is copied into the first row of the destination region, and so on.
2620
+ * The {@link GPUCopyExternalImageSourceInfo#origin} option is still relative to the top-left corner
2621
+ * of the source image, increasing downward.
2622
+ */
2623
+ flipY?: boolean;
2624
+ }
2625
+
2626
+ interface GPUDepthStencilState {
2627
+ /**
2628
+ * The {@link GPUTextureViewDescriptor#format} of {@link GPURenderPassDescriptor#depthStencilAttachment}
2629
+ * this {@link GPURenderPipeline} will be compatible with.
2630
+ */
2631
+ format: GPUTextureFormat;
2632
+ /**
2633
+ * Indicates if this {@link GPURenderPipeline} can modify
2634
+ * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.
2635
+ */
2636
+ depthWriteEnabled?: boolean;
2637
+ /**
2638
+ * The comparison operation used to test fragment depths against
2639
+ * {@link GPURenderPassDescriptor#depthStencilAttachment} depth values.
2640
+ */
2641
+ depthCompare?: GPUCompareFunction;
2642
+ /**
2643
+ * Defines how stencil comparisons and operations are performed for front-facing primitives.
2644
+ */
2645
+ stencilFront?: GPUStencilFaceState;
2646
+ /**
2647
+ * Defines how stencil comparisons and operations are performed for back-facing primitives.
2648
+ */
2649
+ stencilBack?: GPUStencilFaceState;
2650
+ /**
2651
+ * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value
2652
+ * bits are read when performing stencil comparison tests.
2653
+ */
2654
+ stencilReadMask?: GPUStencilValue;
2655
+ /**
2656
+ * Bitmask controlling which {@link GPURenderPassDescriptor#depthStencilAttachment} stencil value
2657
+ * bits are written to when performing stencil operations.
2658
+ */
2659
+ stencilWriteMask?: GPUStencilValue;
2660
+ /**
2661
+ * Constant depth bias added to each triangle fragment. See [$biased fragment depth$] for details.
2662
+ */
2663
+ depthBias?: GPUDepthBias;
2664
+ /**
2665
+ * Depth bias that scales with the triangle fragment’s slope. See [$biased fragment depth$] for details.
2666
+ */
2667
+ depthBiasSlopeScale?: number;
2668
+ /**
2669
+ * The maximum depth bias of a triangle fragment. See [$biased fragment depth$] for details.
2670
+ */
2671
+ depthBiasClamp?: number;
2672
+ }
2673
+
2674
+ interface GPUDeviceDescriptor
2675
+ extends GPUObjectDescriptorBase {
2676
+ /**
2677
+ * Specifies the features that are required by the device request.
2678
+ * The request will fail if the adapter cannot provide these features.
2679
+ * Exactly the specified set of features, and no more or less, will be allowed in validation
2680
+ * of API calls on the resulting device.
2681
+ */
2682
+ requiredFeatures?: Iterable<GPUFeatureName>;
2683
+ /**
2684
+ * Specifies the limits that are required by the device request.
2685
+ * The request will fail if the adapter cannot provide these limits.
2686
+ * Each key with a non-`undefined` value must be the name of a member of supported limits.
2687
+ * API calls on the resulting device perform validation according to the exact limits of the
2688
+ * device (not the adapter; see {@link https://www.w3.org/TR/webgpu/#limits}).
2689
+ * <!-- If we ever need limit types other than GPUSize32/GPUSize64, we can change the value
2690
+ * type to `double` or `any` in the future and write out the type conversion explicitly (by
2691
+ * reference to WebIDL spec). Or change the entire type to `any` and add back a `dictionary
2692
+ * GPULimits` and define the conversion of the whole object by reference to WebIDL. -->
2693
+ */
2694
+ requiredLimits?: Record<
2695
+ string,
2696
+ | GPUSize64
2697
+ | undefined
2698
+ >;
2699
+ /**
2700
+ * The descriptor for the default {@link GPUQueue}.
2701
+ */
2702
+ defaultQueue?: GPUQueueDescriptor;
2703
+ }
2704
+
2705
+ interface GPUExtent3DDict {
2706
+ /**
2707
+ * The width of the extent.
2708
+ */
2709
+ width: GPUIntegerCoordinate;
2710
+ /**
2711
+ * The height of the extent.
2712
+ */
2713
+ height?: GPUIntegerCoordinate;
2714
+ /**
2715
+ * The depth of the extent or the number of array layers it contains.
2716
+ * If used with a {@link GPUTexture} with a {@link GPUTextureDimension} of {@link GPUTextureDimension} `"3d"`
2717
+ * defines the depth of the texture. If used with a {@link GPUTexture} with a {@link GPUTextureDimension}
2718
+ * of {@link GPUTextureDimension} `"2d"` defines the number of array layers in the texture.
2719
+ */
2720
+ depthOrArrayLayers?: GPUIntegerCoordinate;
2721
+ }
2722
+
2723
+ interface GPUExternalTextureBindingLayout {}
2724
+
2725
+ interface GPUExternalTextureDescriptor
2726
+ extends GPUObjectDescriptorBase {
2727
+ /**
2728
+ * The video source to import the external texture from. Source size is determined as described
2729
+ * by the external source dimensions table.
2730
+ */
2731
+ source:
2732
+ | HTMLVideoElement
2733
+ | VideoFrame;
2734
+ /**
2735
+ * The color space the image contents of {@link GPUExternalTextureDescriptor#source} will be
2736
+ * converted into when reading.
2737
+ */
2738
+ colorSpace?: PredefinedColorSpace;
2739
+ }
2740
+
2741
+ interface GPUFragmentState
2742
+ extends GPUProgrammableStage {
2743
+ /**
2744
+ * A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets
2745
+ * this pipeline writes to.
2746
+ */
2747
+ targets: Iterable<
2748
+ | GPUColorTargetState
2749
+ | null
2750
+ | undefined
2751
+ >;
2752
+ }
2753
+
2754
+ interface GPUMultisampleState {
2755
+ /**
2756
+ * Number of samples per pixel. This {@link GPURenderPipeline} will be compatible only
2757
+ * with attachment textures ({@link GPURenderPassDescriptor#colorAttachments}
2758
+ * and {@link GPURenderPassDescriptor#depthStencilAttachment})
2759
+ * with matching {@link GPUTextureDescriptor#sampleCount}s.
2760
+ */
2761
+ count?: GPUSize32;
2762
+ /**
2763
+ * Mask determining which samples are written to.
2764
+ */
2765
+ mask?: GPUSampleMask;
2766
+ /**
2767
+ * When `true` indicates that a fragment's alpha channel should be used to generate a sample
2768
+ * coverage mask.
2769
+ */
2770
+ alphaToCoverageEnabled?: boolean;
2771
+ }
2772
+
2773
+ interface GPUObjectDescriptorBase {
2774
+ /**
2775
+ * The initial value of {@link GPUObjectBase#label | GPUObjectBase.label}.
2776
+ */
2777
+ label?: string;
2778
+ }
2779
+
2780
+ interface GPUOrigin2DDict {
2781
+ x?: GPUIntegerCoordinate;
2782
+ y?: GPUIntegerCoordinate;
2783
+ }
2784
+
2785
+ interface GPUOrigin3DDict {
2786
+ x?: GPUIntegerCoordinate;
2787
+ y?: GPUIntegerCoordinate;
2788
+ z?: GPUIntegerCoordinate;
2789
+ }
2790
+
2791
+ interface GPUPipelineDescriptorBase
2792
+ extends GPUObjectDescriptorBase {
2793
+ /**
2794
+ * The {@link GPUPipelineLayout} for this pipeline, or {@link GPUAutoLayoutMode} `"auto"` to generate
2795
+ * the pipeline layout automatically.
2796
+ * Note: If {@link GPUAutoLayoutMode} `"auto"` is used the pipeline cannot share {@link GPUBindGroup}s
2797
+ * with any other pipelines.
2798
+ */
2799
+ layout:
2800
+ | GPUPipelineLayout
2801
+ | GPUAutoLayoutMode;
2802
+ }
2803
+
2804
+ interface GPUPipelineErrorInit {
2805
+ reason: GPUPipelineErrorReason;
2806
+ }
2807
+
2808
+ interface GPUPipelineLayoutDescriptor
2809
+ extends GPUObjectDescriptorBase {
2810
+ /**
2811
+ * A list of optional {@link GPUBindGroupLayout}s the pipeline will use. Each element corresponds
2812
+ * to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding
2813
+ * with `@group(N)`.
2814
+ */
2815
+ bindGroupLayouts: Iterable<
2816
+ | GPUBindGroupLayout
2817
+ | null
2818
+ | undefined
2819
+ >;
2820
+ /**
2821
+ * The size, in bytes, of the immediate data range used by the pipeline.
2822
+ */
2823
+ immediateSize?: GPUSize32;
2824
+ }
2825
+
2826
+ interface GPUPrimitiveState {
2827
+ /**
2828
+ * The type of primitive to be constructed from the vertex inputs.
2829
+ */
2830
+ topology?: GPUPrimitiveTopology;
2831
+ /**
2832
+ * For pipelines with strip topologies
2833
+ * ({@link GPUPrimitiveTopology} `"line-strip"` or {@link GPUPrimitiveTopology} `"triangle-strip"`),
2834
+ * this determines the index buffer format and primitive restart value
2835
+ * ({@link GPUIndexFormat} `"uint16"`/`0xFFFF` or {@link GPUIndexFormat} `"uint32"`/`0xFFFFFFFF`).
2836
+ * It is not allowed on pipelines with non-strip topologies.
2837
+ * Note: Some implementations require knowledge of the primitive restart value to compile
2838
+ * pipeline state objects.
2839
+ * To use a strip-topology pipeline with an indexed draw call
2840
+ * ({@link GPURenderCommandsMixin#drawIndexed()} or {@link GPURenderCommandsMixin#drawIndexedIndirect}),
2841
+ * this must be set, and it must match the index buffer format used with the draw call
2842
+ * (set in {@link GPURenderCommandsMixin#setIndexBuffer}).
2843
+ * See {@link https://www.w3.org/TR/webgpu/#primitive-assembly} for additional details.
2844
+ */
2845
+ stripIndexFormat?: GPUIndexFormat;
2846
+ /**
2847
+ * Defines which polygons are considered front-facing.
2848
+ */
2849
+ frontFace?: GPUFrontFace;
2850
+ /**
2851
+ * Defines which polygon orientation will be culled, if any.
2852
+ */
2853
+ cullMode?: GPUCullMode;
2854
+ /**
2855
+ * If true, indicates that depth clipping is disabled.
2856
+ * Requires the {@link GPUFeatureName} `"depth-clip-control"` feature to be enabled.
2857
+ */
2858
+ unclippedDepth?: boolean;
2859
+ }
2860
+
2861
+ interface GPUProgrammableStage {
2862
+ /**
2863
+ * The {@link GPUShaderModule} containing the code that this programmable stage will execute.
2864
+ */
2865
+ module: GPUShaderModule;
2866
+ /**
2867
+ * The name of the function in {@link GPUProgrammableStage#module} that this stage will use to
2868
+ * perform its work.
2869
+ * NOTE: Since the {@link GPUProgrammableStage#entryPoint} dictionary member is
2870
+ * not required, methods which consume a {@link GPUProgrammableStage} must use the
2871
+ * "[$get the entry point$]" algorithm to determine which entry point
2872
+ * it refers to.
2873
+ */
2874
+ entryPoint?: string;
2875
+ /**
2876
+ * Specifies the values of pipeline-overridable constants in the shader module
2877
+ * {@link GPUProgrammableStage#module}.
2878
+ * Each such pipeline-overridable constant is uniquely identified by a single
2879
+ * pipeline-overridable constant identifier string, representing the pipeline
2880
+ * constant ID of the constant if its declaration specifies one, and otherwise the
2881
+ * constant's identifier name.
2882
+ * The key of each key-value pair must equal the
2883
+ * pipeline-overridable constant identifier string|identifier string
2884
+ * of one such constant, with the comparison performed
2885
+ * according to the rules for WGSL identifier comparison.
2886
+ * When the pipeline is executed, that constant will have the specified value.
2887
+ * Values are specified as <dfn typedef for="">GPUPipelineConstantValue</dfn>, which is a `double`.
2888
+ * They are converted [$to WGSL type$] of the pipeline-overridable constant (`bool`/`i32`/`u32`/`f32`/`f16`).
2889
+ * If conversion fails, a validation error is generated.
2890
+ * <div class=example>
2891
+ * Pipeline-overridable constants defined in WGSL:
2892
+ * ```wgsl
2893
+ * @id(0) override has_point_light: bool = true; // Algorithmic control.
2894
+ * @id(1200) override specular_param: f32 = 2.3; // Numeric control.
2895
+ * @id(1300) override gain: f32; // Must be overridden.
2896
+ * override width: f32 = 0.0; // Specifed at the API level
2897
+ * // using the name "width".
2898
+ * override depth: f32; // Specifed at the API level
2899
+ * // using the name "depth".
2900
+ * // Must be overridden.
2901
+ * override height = 2 * depth; // The default value
2902
+ * // (if not set at the API level),
2903
+ * // depends on another
2904
+ * // overridable constant.
2905
+ * ```
2906
+ * Corresponding JavaScript code, providing only the overrides which are required
2907
+ * (have no defaults):
2908
+ * ```js
2909
+ * {
2910
+ * // ...
2911
+ * constants: {
2912
+ * 1300: 2.0, // "gain"
2913
+ * depth: -1, // "depth"
2914
+ * }
2915
+ * }
2916
+ * ```
2917
+ * Corresponding JavaScript code, overriding all constants:
2918
+ * ```js
2919
+ * {
2920
+ * // ...
2921
+ * constants: {
2922
+ * 0: false, // "has_point_light"
2923
+ * 1200: 3.0, // "specular_param"
2924
+ * 1300: 2.0, // "gain"
2925
+ * width: 20, // "width"
2926
+ * depth: -1, // "depth"
2927
+ * height: 15, // "height"
2928
+ * }
2929
+ * }
2930
+ * ```
2931
+ * </div>
2932
+ */
2933
+ constants?: Record<
2934
+ string,
2935
+ GPUPipelineConstantValue
2936
+ >;
2937
+ }
2938
+
2939
+ interface GPUQuerySetDescriptor
2940
+ extends GPUObjectDescriptorBase {
2941
+ /**
2942
+ * The type of queries managed by {@link GPUQuerySet}.
2943
+ */
2944
+ type: GPUQueryType;
2945
+ /**
2946
+ * The number of queries managed by {@link GPUQuerySet}.
2947
+ */
2948
+ count: GPUSize32;
2949
+ }
2950
+
2951
+ type GPUQueueDescriptor =
2952
+ GPUObjectDescriptorBase;
2953
+ type GPURenderBundleDescriptor =
2954
+ GPUObjectDescriptorBase;
2955
+
2956
+ interface GPURenderBundleEncoderDescriptor
2957
+ extends GPURenderPassLayout {
2958
+ /**
2959
+ * If `true`, indicates that the render bundle does not modify the depth component of the
2960
+ * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed
2961
+ * in.
2962
+ * See read-only depth-stencil.
2963
+ */
2964
+ depthReadOnly?: boolean;
2965
+ /**
2966
+ * If `true`, indicates that the render bundle does not modify the stencil component of the
2967
+ * {@link GPURenderPassDepthStencilAttachment} of any render pass the render bundle is executed
2968
+ * in.
2969
+ * See read-only depth-stencil.
2970
+ */
2971
+ stencilReadOnly?: boolean;
2972
+ }
2973
+
2974
+ interface GPURenderPassColorAttachment {
2975
+ /**
2976
+ * Describes the texture subresource that will be output to for this color attachment.
2977
+ * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#view}).
2978
+ */
2979
+ view:
2980
+ | GPUTexture
2981
+ | GPUTextureView;
2982
+ /**
2983
+ * Indicates the depth slice index of {@link GPUTextureViewDimension} `"3d"` {@link GPURenderPassColorAttachment#view}
2984
+ * that will be output to for this color attachment.
2985
+ */
2986
+ depthSlice?: GPUIntegerCoordinate;
2987
+ /**
2988
+ * Describes the texture subresource that will receive the resolved output for this color
2989
+ * attachment if {@link GPURenderPassColorAttachment#view} is multisampled.
2990
+ * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassColorAttachment#resolveTarget}).
2991
+ */
2992
+ resolveTarget?:
2993
+ | GPUTexture
2994
+ | GPUTextureView;
2995
+ /**
2996
+ * Indicates the value to clear {@link GPURenderPassColorAttachment#view} to prior to executing the
2997
+ * render pass. If not map/exist|provided, defaults to `{r: 0, g: 0, b: 0, a: 0}`. Ignored
2998
+ * if {@link GPURenderPassColorAttachment#loadOp} is not {@link GPULoadOp} `"clear"`.
2999
+ * The components of {@link GPURenderPassColorAttachment#clearValue} are all double values.
3000
+ * They are converted [$to a texel value of texture format$] matching the render attachment.
3001
+ * If conversion fails, a validation error is generated.
3002
+ */
3003
+ clearValue?: GPUColor;
3004
+ /**
3005
+ * Indicates the load operation to perform on {@link GPURenderPassColorAttachment#view} prior to
3006
+ * executing the render pass.
3007
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details.
3008
+ */
3009
+ loadOp: GPULoadOp;
3010
+ /**
3011
+ * The store operation to perform on {@link GPURenderPassColorAttachment#view}
3012
+ * after executing the render pass.
3013
+ */
3014
+ storeOp: GPUStoreOp;
3015
+ }
3016
+
3017
+ interface GPURenderPassDepthStencilAttachment {
3018
+ /**
3019
+ * Describes the texture subresource that will be output to and read from for this
3020
+ * depth/stencil attachment.
3021
+ * The subresource is determined by calling [$get as texture view$]({@link GPURenderPassDepthStencilAttachment#view}).
3022
+ */
3023
+ view:
3024
+ | GPUTexture
3025
+ | GPUTextureView;
3026
+ /**
3027
+ * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component
3028
+ * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}
3029
+ * is not {@link GPULoadOp} `"clear"`. Must be between 0.0 and 1.0, inclusive.
3030
+ * <!-- POSTV1(unrestricted-depth): unless unrestricted depth is enabled -->
3031
+ */
3032
+ depthClearValue?: number;
3033
+ /**
3034
+ * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
3035
+ * depth component prior to executing the render pass.
3036
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details.
3037
+ */
3038
+ depthLoadOp?: GPULoadOp;
3039
+ /**
3040
+ * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
3041
+ * depth component after executing the render pass.
3042
+ */
3043
+ depthStoreOp?: GPUStoreOp;
3044
+ /**
3045
+ * Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}
3046
+ * is read only.
3047
+ */
3048
+ depthReadOnly?: boolean;
3049
+ /**
3050
+ * Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
3051
+ * to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
3052
+ * is not {@link GPULoadOp} `"clear"`.
3053
+ * The value will be converted to the type of the stencil aspect of `view` by taking the same
3054
+ * number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
3055
+ */
3056
+ stencilClearValue?: GPUStencilValue;
3057
+ /**
3058
+ * Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
3059
+ * stencil component prior to executing the render pass.
3060
+ * Note: It is recommended to prefer clearing; see {@link GPULoadOp} `"clear"` for details.
3061
+ */
3062
+ stencilLoadOp?: GPULoadOp;
3063
+ /**
3064
+ * The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
3065
+ * stencil component after executing the render pass.
3066
+ */
3067
+ stencilStoreOp?: GPUStoreOp;
3068
+ /**
3069
+ * Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}
3070
+ * is read only.
3071
+ */
3072
+ stencilReadOnly?: boolean;
3073
+ }
3074
+
3075
+ interface GPURenderPassDescriptor
3076
+ extends GPUObjectDescriptorBase {
3077
+ /**
3078
+ * The set of {@link GPURenderPassColorAttachment} values in this sequence defines which
3079
+ * color attachments will be output to when executing this render pass.
3080
+ * Due to compatible usage list|usage compatibility, no color attachment
3081
+ * may alias another attachment or any resource used inside the render pass.
3082
+ */
3083
+ colorAttachments: Iterable<
3084
+ | GPURenderPassColorAttachment
3085
+ | null
3086
+ | undefined
3087
+ >;
3088
+ /**
3089
+ * The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil
3090
+ * attachment that will be output to and tested against when executing this render pass.
3091
+ * Due to compatible usage list|usage compatibility, no writable depth/stencil attachment
3092
+ * may alias another attachment or any resource used inside the render pass.
3093
+ */
3094
+ depthStencilAttachment?: GPURenderPassDepthStencilAttachment;
3095
+ /**
3096
+ * The {@link GPUQuerySet} value defines where the occlusion query results will be stored for this pass.
3097
+ */
3098
+ occlusionQuerySet?: GPUQuerySet;
3099
+ /**
3100
+ * Defines which timestamp values will be written for this pass, and where to write them to.
3101
+ */
3102
+ timestampWrites?: GPURenderPassTimestampWrites;
3103
+ /**
3104
+ * The maximum number of draw calls that will be done in the render pass. Used by some
3105
+ * implementations to size work injected before the render pass. Keeping the default value
3106
+ * is a good default, unless it is known that more draw calls will be done.
3107
+ */
3108
+ maxDrawCount?: GPUSize64;
3109
+ }
3110
+
3111
+ interface GPURenderPassLayout
3112
+ extends GPUObjectDescriptorBase {
3113
+ /**
3114
+ * A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.
3115
+ */
3116
+ colorFormats: Iterable<
3117
+ | GPUTextureFormat
3118
+ | null
3119
+ | undefined
3120
+ >;
3121
+ /**
3122
+ * The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.
3123
+ */
3124
+ depthStencilFormat?: GPUTextureFormat;
3125
+ /**
3126
+ * Number of samples per pixel in the attachments for this pass or bundle.
3127
+ */
3128
+ sampleCount?: GPUSize32;
3129
+ }
3130
+
3131
+ interface GPURenderPassTimestampWrites {
3132
+ /**
3133
+ * The {@link GPUQuerySet}, of type {@link GPUQueryType} `"timestamp"`, that the query results will be
3134
+ * written to.
3135
+ */
3136
+ querySet: GPUQuerySet;
3137
+ /**
3138
+ * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
3139
+ * which the timestamp at the beginning of the render pass will be written.
3140
+ */
3141
+ beginningOfPassWriteIndex?: GPUSize32;
3142
+ /**
3143
+ * If defined, indicates the query index in {@link GPURenderPassTimestampWrites#querySet} into
3144
+ * which the timestamp at the end of the render pass will be written.
3145
+ */
3146
+ endOfPassWriteIndex?: GPUSize32;
3147
+ }
3148
+
3149
+ interface GPURenderPipelineDescriptor
3150
+ extends GPUPipelineDescriptorBase {
3151
+ /**
3152
+ * Describes the vertex shader entry point of the pipeline and its input buffer layouts.
3153
+ */
3154
+ vertex: GPUVertexState;
3155
+ /**
3156
+ * Describes the primitive-related properties of the pipeline.
3157
+ */
3158
+ primitive?: GPUPrimitiveState;
3159
+ /**
3160
+ * Describes the optional depth-stencil properties, including the testing, operations, and bias.
3161
+ */
3162
+ depthStencil?: GPUDepthStencilState;
3163
+ /**
3164
+ * Describes the multi-sampling properties of the pipeline.
3165
+ */
3166
+ multisample?: GPUMultisampleState;
3167
+ /**
3168
+ * Describes the fragment shader entry point of the pipeline and its output colors. If
3169
+ * not map/exist|provided, the {@link https://www.w3.org/TR/webgpu/#no-color-output} mode is enabled.
3170
+ */
3171
+ fragment?: GPUFragmentState;
3172
+ }
3173
+
3174
+ interface GPURequestAdapterOptions {
3175
+ /**
3176
+ * Requests an adapter that supports at least a particular set of capabilities.
3177
+ * This influences the {@link adapter#[[default feature level]]} of devices created
3178
+ * from this adapter. The capabilities for each level are defined below, and the exact
3179
+ * steps are defined in {@link GPU#requestAdapter} and "a new device".
3180
+ * If the implementation or system does not support all of the capabilities in the
3181
+ * requested feature level, {@link GPU#requestAdapter} will return `null`.
3182
+ * Note:
3183
+ * Applications should typically make a single {@link GPU#requestAdapter} call with the lowest
3184
+ * feature level they support, then inspect the adapter for additional capabilities they can
3185
+ * use optionally, and request those in {@link GPUAdapter#requestDevice}.
3186
+ * The allowed <dfn dfn for="">feature level string</dfn> values are:
3187
+ * <dl dfn-type=dfn dfn-for="feature level string">
3188
+ * : <dfn noexport>"core"</dfn>
3189
+ * The following set of capabilities:
3190
+ * - The limit/Default limits.
3191
+ * - {@link GPUFeatureName} `"core-features-and-limits"`.
3192
+ * Note:
3193
+ * Adapters with this {@link adapter#[[default feature level]]} may
3194
+ * conventionally be referred to as "Core-defaulting".
3195
+ * : <dfn noexport>"compatibility"</dfn>
3196
+ * The following set of capabilities:
3197
+ * - The limit/Compatibility Mode Default limits.
3198
+ * - No features. (It excludes the {@link GPUFeatureName} `"core-features-and-limits"` feature.)
3199
+ * If the implementation cannot enforce the stricter "Compatibility Mode"
3200
+ * validation rules, {@link GPU#requestAdapter} will ignore this request and
3201
+ * treat it as a request for feature level string/"core".
3202
+ * Note:
3203
+ * Adapters with this {@link adapter#[[default feature level]]} may
3204
+ * conventionally be referred to as "Compatibility-defaulting".
3205
+ */
3206
+ featureLevel?: string;
3207
+ /**
3208
+ * Optionally provides a hint indicating what class of adapter should be selected from
3209
+ * the system's available adapters.
3210
+ * The value of this hint may influence which adapter is chosen, but it must not
3211
+ * influence whether an adapter is returned or not.
3212
+ * Note:
3213
+ * The primary utility of this hint is to influence which GPU is used in a multi-GPU system.
3214
+ * For instance, some laptops have a low-power integrated GPU and a high-performance
3215
+ * discrete GPU. This hint may also affect the power configuration of the selected GPU to
3216
+ * match the requested power preference.
3217
+ * Note:
3218
+ * Depending on the exact hardware configuration, such as battery status and attached displays
3219
+ * or removable GPUs, the user agent may select different adapters given the same power
3220
+ * preference.
3221
+ * Typically, given the same hardware configuration and state and
3222
+ * `powerPreference`, the user agent is likely to select the same adapter.
3223
+ */
3224
+ powerPreference?: GPUPowerPreference;
3225
+ /**
3226
+ * When set to `true` indicates that only a fallback adapter may be returned. If the user
3227
+ * agent does not support a fallback adapter, will cause {@link GPU#requestAdapter} to
3228
+ * resolve to `null`.
3229
+ * Note:
3230
+ * {@link GPU#requestAdapter} may still return a fallback adapter if
3231
+ * {@link GPURequestAdapterOptions#forceFallbackAdapter} is set to `false` and either no
3232
+ * other appropriate adapter is available or the user agent chooses to return a
3233
+ * fallback adapter. Developers that wish to prevent their applications from running on
3234
+ * fallback adapters should check the {@link GPUAdapter#info}.{@link GPUAdapterInfo#isFallbackAdapter}
3235
+ * attribute prior to requesting a {@link GPUDevice}.
3236
+ */
3237
+ forceFallbackAdapter?: boolean;
3238
+ xrCompatible?: boolean;
3239
+ }
3240
+
3241
+ interface GPUSamplerBindingLayout {
3242
+ /**
3243
+ * Indicates the required type of a sampler bound to this bindings.
3244
+ */
3245
+ type?: GPUSamplerBindingType;
3246
+ }
3247
+
3248
+ interface GPUSamplerDescriptor
3249
+ extends GPUObjectDescriptorBase {
3250
+ /**
3251
+ */
3252
+ addressModeU?: GPUAddressMode;
3253
+ /**
3254
+ */
3255
+ addressModeV?: GPUAddressMode;
3256
+ /**
3257
+ * Specifies the {@link GPUAddressMode | address modes} for the texture width, height, and depth
3258
+ * coordinates, respectively.
3259
+ */
3260
+ addressModeW?: GPUAddressMode;
3261
+ /**
3262
+ * Specifies the sampling behavior when the sampled area is smaller than or equal to one
3263
+ * texel.
3264
+ */
3265
+ magFilter?: GPUFilterMode;
3266
+ /**
3267
+ * Specifies the sampling behavior when the sampled area is larger than one texel.
3268
+ */
3269
+ minFilter?: GPUFilterMode;
3270
+ /**
3271
+ * Specifies behavior for sampling between mipmap levels.
3272
+ */
3273
+ mipmapFilter?: GPUMipmapFilterMode;
3274
+ /**
3275
+ */
3276
+ lodMinClamp?: number;
3277
+ /**
3278
+ * Specifies the minimum and maximum levels of detail, respectively, used internally when
3279
+ * sampling a texture.
3280
+ */
3281
+ lodMaxClamp?: number;
3282
+ /**
3283
+ * When provided the sampler will be a comparison sampler with the specified
3284
+ * {@link GPUCompareFunction}.
3285
+ * Note: Comparison samplers may use filtering, but the sampling results will be
3286
+ * implementation-dependent and may differ from the normal filtering rules.
3287
+ */
3288
+ compare?: GPUCompareFunction;
3289
+ /**
3290
+ * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
3291
+ * enabled when {@link GPUSamplerDescriptor#maxAnisotropy} is &gt; 1 and the implementation supports it.
3292
+ * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
3293
+ * angles. Higher {@link GPUSamplerDescriptor#maxAnisotropy} values indicate the maximum ratio of
3294
+ * anisotropy supported when filtering.
3295
+ * <div class=note heading>
3296
+ * Most implementations support {@link GPUSamplerDescriptor#maxAnisotropy} values in range
3297
+ * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor#maxAnisotropy}
3298
+ * will be clamped to the maximum value that the platform supports.
3299
+ * The precise filtering behavior is implementation-dependent.
3300
+ * </div>
3301
+ */
3302
+ maxAnisotropy?: number;
3303
+ }
3304
+
3305
+ interface GPUShaderModuleCompilationHint {
3306
+ entryPoint: string;
3307
+ /**
3308
+ * A {@link GPUPipelineLayout} that the {@link GPUShaderModule} may be used with in a future
3309
+ * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline} call.
3310
+ * If set to {@link GPUAutoLayoutMode} `"auto"` the layout will be the [$default pipeline layout$]
3311
+ * for the entry point associated with this hint will be used.
3312
+ */
3313
+ layout?:
3314
+ | GPUPipelineLayout
3315
+ | GPUAutoLayoutMode;
3316
+ }
3317
+
3318
+ interface GPUShaderModuleDescriptor
3319
+ extends GPUObjectDescriptorBase {
3320
+ /**
3321
+ * The <a href="https://gpuweb.github.io/gpuweb/wgsl/">WGSL</a> source code for the shader
3322
+ * module.
3323
+ */
3324
+ code: string;
3325
+ /**
3326
+ * A list of {@link GPUShaderModuleCompilationHint}s.
3327
+ * Any hint provided by an application **should** contain information about one entry point of
3328
+ * a pipeline that will eventually be created from the entry point.
3329
+ * Implementations **should** use any information present in the {@link GPUShaderModuleCompilationHint}
3330
+ * to perform as much compilation as is possible within {@link GPUDevice#createShaderModule}.
3331
+ * Aside from type-checking, these hints are not validated in any way.
3332
+ * <div class=note heading>
3333
+ * Supplying information in {@link GPUShaderModuleDescriptor#compilationHints} does not have any
3334
+ * observable effect, other than performance. It may be detrimental to performance to
3335
+ * provide hints for pipelines that never end up being created.
3336
+ * Because a single shader module can hold multiple entry points, and multiple pipelines
3337
+ * can be created from a single shader module, it can be more performant for an
3338
+ * implementation to do as much compilation as possible once in
3339
+ * {@link GPUDevice#createShaderModule} rather than multiple times in the multiple calls to
3340
+ * {@link GPUDevice#createComputePipeline()} or {@link GPUDevice#createRenderPipeline}.
3341
+ * Hints are only applied to the entry points they explicitly name.
3342
+ * Unlike {@link GPUProgrammableStage#entryPoint | GPUProgrammableStage.entryPoint},
3343
+ * there is no default, even if only one entry point is present in the module.
3344
+ * </div>
3345
+ * Note:
3346
+ * Hints are not validated in an observable way, but user agents **may** surface identifiable
3347
+ * errors (like unknown entry point names or incompatible pipeline layouts) to developers,
3348
+ * for example in the browser developer console.
3349
+ */
3350
+ compilationHints?: Iterable<GPUShaderModuleCompilationHint>;
3351
+ }
3352
+
3353
+ interface GPUStencilFaceState {
3354
+ /**
3355
+ * The {@link GPUCompareFunction} used when testing the RenderState.`[[stencilReference]]` value
3356
+ * against the fragment's {@link GPURenderPassDescriptor#depthStencilAttachment} stencil values.
3357
+ */
3358
+ compare?: GPUCompareFunction;
3359
+ /**
3360
+ * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by
3361
+ * {@link GPUStencilFaceState#compare} fails.
3362
+ */
3363
+ failOp?: GPUStencilOperation;
3364
+ /**
3365
+ * The {@link GPUStencilOperation} performed if the fragment depth comparison described by
3366
+ * {@link GPUDepthStencilState#depthCompare} fails.
3367
+ */
3368
+ depthFailOp?: GPUStencilOperation;
3369
+ /**
3370
+ * The {@link GPUStencilOperation} performed if the fragment stencil comparison test described by
3371
+ * {@link GPUStencilFaceState#compare} passes.
3372
+ */
3373
+ passOp?: GPUStencilOperation;
3374
+ }
3375
+
3376
+ interface GPUStorageTextureBindingLayout {
3377
+ /**
3378
+ * The access mode for this binding, indicating readability and writability.
3379
+ */
3380
+ access?: GPUStorageTextureAccess;
3381
+ /**
3382
+ * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.
3383
+ */
3384
+ format: GPUTextureFormat;
3385
+ /**
3386
+ * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
3387
+ * this binding.
3388
+ */
3389
+ viewDimension?: GPUTextureViewDimension;
3390
+ }
3391
+
3392
+ interface GPUTexelCopyBufferInfo
3393
+ extends GPUTexelCopyBufferLayout {
3394
+ /**
3395
+ * A buffer which either contains texel data to be copied or will store the texel data being
3396
+ * copied, depending on the method it is being passed to.
3397
+ */
3398
+ buffer: GPUBuffer;
3399
+ }
3400
+
3401
+ interface GPUTexelCopyBufferLayout {
3402
+ /**
3403
+ * The offset, in bytes, from the beginning of the texel data source (such as a
3404
+ * {@link GPUTexelCopyBufferInfo#buffer | GPUTexelCopyBufferInfo.buffer}) to the start of the texel data
3405
+ * within that source.
3406
+ */
3407
+ offset?: GPUSize64;
3408
+ /**
3409
+ * The stride, in bytes, between the beginning of each texel block row and the subsequent
3410
+ * texel block row.
3411
+ * Required if there are multiple texel block rows (i.e. the copy height or depth is more
3412
+ * than one block).
3413
+ */
3414
+ bytesPerRow?: GPUSize32;
3415
+ /**
3416
+ * Number of texel block rows per single texel image of the texture.
3417
+ * {@link GPUTexelCopyBufferLayout#rowsPerImage} &times;
3418
+ * {@link GPUTexelCopyBufferLayout#bytesPerRow} is the stride, in bytes, between the beginning of each
3419
+ * texel image of data and the subsequent texel image.
3420
+ * Required if there are multiple texel images (i.e. the copy depth is more than one).
3421
+ */
3422
+ rowsPerImage?: GPUSize32;
3423
+ }
3424
+
3425
+ interface GPUTexelCopyTextureInfo {
3426
+ /**
3427
+ * Texture to copy to/from.
3428
+ */
3429
+ texture: GPUTexture;
3430
+ /**
3431
+ * Mip-map level of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.
3432
+ */
3433
+ mipLevel?: GPUIntegerCoordinate;
3434
+ /**
3435
+ * Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.
3436
+ * Together with `copySize`, defines the full copy sub-region.
3437
+ */
3438
+ origin?: GPUOrigin3D;
3439
+ /**
3440
+ * Defines which aspects of the {@link GPUTexelCopyTextureInfo#texture} to copy to/from.
3441
+ */
3442
+ aspect?: GPUTextureAspect;
3443
+ }
3444
+
3445
+ interface GPUTextureBindingLayout {
3446
+ /**
3447
+ * Indicates the type required for texture views bound to this binding.
3448
+ */
3449
+ sampleType?: GPUTextureSampleType;
3450
+ /**
3451
+ * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
3452
+ * this binding.
3453
+ */
3454
+ viewDimension?: GPUTextureViewDimension;
3455
+ /**
3456
+ * Indicates whether or not texture views bound to this binding must be multisampled.
3457
+ */
3458
+ multisampled?: boolean;
3459
+ }
3460
+
3461
+ interface GPUTextureDescriptor
3462
+ extends GPUObjectDescriptorBase {
3463
+ /**
3464
+ * The width, height, and depth or layer count of the texture.
3465
+ */
3466
+ size: GPUExtent3DStrict;
3467
+ /**
3468
+ * The number of mip levels the texture will contain.
3469
+ */
3470
+ mipLevelCount?: GPUIntegerCoordinate;
3471
+ /**
3472
+ * The sample count of the texture. A {@link GPUTextureDescriptor#sampleCount} &gt; `1` indicates
3473
+ * a multisampled texture.
3474
+ */
3475
+ sampleCount?: GPUSize32;
3476
+ /**
3477
+ * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
3478
+ */
3479
+ dimension?: GPUTextureDimension;
3480
+ /**
3481
+ * The format of the texture.
3482
+ */
3483
+ format: GPUTextureFormat;
3484
+ /**
3485
+ * The allowed usages for the texture.
3486
+ */
3487
+ usage: GPUTextureUsageFlags;
3488
+ /**
3489
+ * Specifies what view {@link GPUTextureViewDescriptor#format} values will be allowed when calling
3490
+ * {@link GPUTexture#createView} on this texture (in addition to the texture's actual
3491
+ * {@link GPUTextureDescriptor#format}).
3492
+ * <div class=note heading>
3493
+ * Adding a format to this list may have a significant performance impact, so it is best
3494
+ * to avoid adding formats unnecessarily.
3495
+ * The actual performance impact is highly dependent on the target system; developers must
3496
+ * test various systems to find out the impact on their particular application.
3497
+ * For example, on some systems any texture with a {@link GPUTextureDescriptor#format} or
3498
+ * {@link GPUTextureDescriptor#viewFormats} entry including
3499
+ * {@link GPUTextureFormat} `"rgba8unorm-srgb"` will perform less optimally than a
3500
+ * {@link GPUTextureFormat} `"rgba8unorm"` texture which does not.
3501
+ * Similar caveats exist for other formats and pairs of formats on other systems.
3502
+ * </div>
3503
+ * Formats in this list must be texture view format compatible with the texture format.
3504
+ * <div algorithm data-timeline=const>
3505
+ * Two {@link GPUTextureFormat}s `format` and `viewFormat` are <dfn dfn for="">texture view format compatible</dfn> on a given `device` if:
3506
+ * - `format` equals `viewFormat`, or
3507
+ * - `format` and `viewFormat` differ only in whether they are `srgb` formats (have the `-srgb` suffix) and `device.features` list/contains {@link GPUFeatureName} `"core-features-and-limits"`.
3508
+ * </div>
3509
+ */
3510
+ viewFormats?: Iterable<GPUTextureFormat>;
3511
+ /**
3512
+ * <div class=compatmode>
3513
+ * On devices without {@link GPUFeatureName} `"core-features-and-limits"`,
3514
+ * views created from this texture must have this as their {@link GPUTextureViewDescriptor#dimension}.
3515
+ * If not specified, a default is chosen.
3516
+ * </div>
3517
+ * On devices with {@link GPUFeatureName} `"core-features-and-limits"`,
3518
+ * this is ignored, and there is no such restriction.
3519
+ */
3520
+ textureBindingViewDimension?: GPUTextureViewDimension;
3521
+ }
3522
+
3523
+ interface GPUTextureViewDescriptor
3524
+ extends GPUObjectDescriptorBase {
3525
+ /**
3526
+ * The format of the texture view. Must be either the {@link GPUTextureDescriptor#format} of the
3527
+ * texture or one of the {@link GPUTextureDescriptor#viewFormats} specified during its creation.
3528
+ */
3529
+ format?: GPUTextureFormat;
3530
+ /**
3531
+ * The dimension to view the texture as.
3532
+ */
3533
+ dimension?: GPUTextureViewDimension;
3534
+ /**
3535
+ * The allowed {@link GPUTextureUsage | usage(s)} for the texture view. Must be a subset of the
3536
+ * {@link GPUTexture#usage} flags of the texture. If 0, defaults to the full set of
3537
+ * {@link GPUTexture#usage} flags of the texture.
3538
+ * Note: If the view's {@link GPUTextureViewDescriptor#format} doesn't support all of the
3539
+ * texture's {@link GPUTextureDescriptor#usage}s, the default will fail,
3540
+ * and the view's {@link GPUTextureViewDescriptor#usage} must be specified explicitly.
3541
+ */
3542
+ usage?: GPUTextureUsageFlags;
3543
+ /**
3544
+ * Which {@link GPUTextureAspect | aspect(s)} of the texture are accessible to the texture view.
3545
+ */
3546
+ aspect?: GPUTextureAspect;
3547
+ /**
3548
+ * The first (most detailed) mipmap level accessible to the texture view.
3549
+ */
3550
+ baseMipLevel?: GPUIntegerCoordinate;
3551
+ /**
3552
+ * How many mipmap levels, starting with {@link GPUTextureViewDescriptor#baseMipLevel}, are accessible to
3553
+ * the texture view.
3554
+ */
3555
+ mipLevelCount?: GPUIntegerCoordinate;
3556
+ /**
3557
+ * The index of the first array layer accessible to the texture view.
3558
+ */
3559
+ baseArrayLayer?: GPUIntegerCoordinate;
3560
+ /**
3561
+ * How many array layers, starting with {@link GPUTextureViewDescriptor#baseArrayLayer}, are accessible
3562
+ * to the texture view.
3563
+ */
3564
+ arrayLayerCount?: GPUIntegerCoordinate;
3565
+ /**
3566
+ * A string of length four, with each character mapping to the texture view's red/green/blue/alpha
3567
+ * channels, respectively.
3568
+ * When accessed by a shader, the red/green/blue/alpha channels are replaced by the value
3569
+ * corresponding to the component specified in `swizzle[0]`, `swizzle[1]`, `swizzle[2]`, and
3570
+ * `swizzle[3]`, respectively:
3571
+ * - `"r"`: Take its value from the red channel of the texture.
3572
+ * - `"g"`: Take its value from the green channel of the texture.
3573
+ * - `"b"`: Take its value from the blue channel of the texture.
3574
+ * - `"a"`: Take its value from the alpha channel of the texture.
3575
+ * - `"0"`: Force its value to 0.
3576
+ * - `"1"`: Force its value to 1.
3577
+ * Requires the {@link GPUFeatureName} `"texture-component-swizzle"` feature to be enabled.
3578
+ */
3579
+ swizzle?: string;
3580
+ }
3581
+
3582
+ interface GPUUncapturedErrorEventInit
3583
+ extends EventInit {
3584
+ error: GPUError;
3585
+ }
3586
+
3587
+ interface GPUVertexAttribute {
3588
+ /**
3589
+ * The {@link GPUVertexFormat} of the attribute.
3590
+ */
3591
+ format: GPUVertexFormat;
3592
+ /**
3593
+ * The offset, in bytes, from the beginning of the element to the data for the attribute.
3594
+ */
3595
+ offset: GPUSize64;
3596
+ /**
3597
+ * The numeric location associated with this attribute, which will correspond with a
3598
+ * <a href="https://gpuweb.github.io/gpuweb/wgsl/#input-output-locations">"@location" attribute</a>
3599
+ * declared in the {@link GPURenderPipelineDescriptor#vertex}.{@link GPUProgrammableStage#module | module}.
3600
+ */
3601
+ shaderLocation: GPUIndex32;
3602
+ }
3603
+
3604
+ interface GPUVertexBufferLayout {
3605
+ /**
3606
+ * The stride, in bytes, between elements of this array.
3607
+ */
3608
+ arrayStride: GPUSize64;
3609
+ /**
3610
+ * Whether each element of this array represents per-vertex data or per-instance data
3611
+ */
3612
+ stepMode?: GPUVertexStepMode;
3613
+ /**
3614
+ * An array defining the layout of the vertex attributes within each element.
3615
+ */
3616
+ attributes: Iterable<GPUVertexAttribute>;
3617
+ }
3618
+
3619
+ interface GPUVertexState
3620
+ extends GPUProgrammableStage {
3621
+ /**
3622
+ * A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a
3623
+ * vertex buffer used by this pipeline.
3624
+ */
3625
+ buffers?: Iterable<
3626
+ | GPUVertexBufferLayout
3627
+ | null
3628
+ | undefined
3629
+ >;
3630
+ }
3631
+
3632
+ interface GPUBindingCommandsMixin {
3633
+ /**
3634
+ * Sets the current {@link GPUBindGroup} for the given index.
3635
+ * @param index - The index to set the bind group at.
3636
+ * @param bindGroup - Bind group to use for subsequent render or compute commands.
3637
+ * @param dynamicOffsets - Array containing buffer offsets in bytes for each entry in
3638
+ * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.-->
3639
+ */
3640
+ setBindGroup(
3641
+ index: GPUIndex32,
3642
+ bindGroup:
3643
+ | GPUBindGroup
3644
+ | null
3645
+ | undefined,
3646
+ dynamicOffsets?: Iterable<GPUBufferDynamicOffset>
3647
+ ): undefined;
3648
+ /**
3649
+ * Sets the current {@link GPUBindGroup} for the given index, specifying dynamic offsets as a subset
3650
+ * of a Uint32Array.
3651
+ * @param index - The index to set the bind group at.
3652
+ * @param bindGroup - Bind group to use for subsequent render or compute commands.
3653
+ * @param dynamicOffsetsData - Array containing buffer offsets in bytes for each entry in
3654
+ * `bindGroup` marked as {@link GPUBindGroupLayoutEntry#buffer}.{@link GPUBufferBindingLayout#hasDynamicOffset}.
3655
+ * @param dynamicOffsetsDataStart - Offset in elements into `dynamicOffsetsData` where the
3656
+ * buffer offset data begins.
3657
+ * @param dynamicOffsetsDataLength - Number of buffer offsets to read from `dynamicOffsetsData`.
3658
+ */
3659
+ setBindGroup(
3660
+ index: GPUIndex32,
3661
+ bindGroup:
3662
+ | GPUBindGroup
3663
+ | null
3664
+ | undefined,
3665
+ dynamicOffsetsData: Uint32Array,
3666
+ dynamicOffsetsDataStart: GPUSize64,
3667
+ dynamicOffsetsDataLength: GPUSize32
3668
+ ): undefined;
3669
+ /**
3670
+ * Sets immediate data for subsequent render or compute commands.
3671
+ * @param rangeOffset - Offset in bytes into the immediate data range to begin writing at.
3672
+ * @param data - Data to write into the immediate data range.
3673
+ * @param dataOffset - Offset into `data` to begin writing from. Given in elements if
3674
+ * `data` is a {@link TypedArray} and bytes otherwise.
3675
+ * @param dataSize - Size of content to write from `data`. Given in elements if
3676
+ * `data` is a {@link TypedArray} and bytes otherwise.
3677
+ */
3678
+ setImmediates(
3679
+ rangeOffset: GPUSize32,
3680
+ data: GPUAllowSharedBufferSource,
3681
+ dataOffset?: GPUSize64,
3682
+ dataSize?: GPUSize64
3683
+ ): undefined;
3684
+ }
3685
+
3686
+ interface GPUCommandsMixin {}
3687
+
3688
+ interface GPUDebugCommandsMixin {
3689
+ /**
3690
+ * Begins a labeled debug group containing subsequent commands.
3691
+ * @param groupLabel - The label for the command group.
3692
+ */
3693
+ pushDebugGroup(
3694
+ groupLabel: string
3695
+ ): undefined;
3696
+ /**
3697
+ * Ends the labeled debug group most recently started by {@link GPUDebugCommandsMixin#pushDebugGroup}.
3698
+ */
3699
+ popDebugGroup(): undefined;
3700
+ /**
3701
+ * Marks a point in a stream of commands with a label.
3702
+ * @param markerLabel - The label to insert.
3703
+ */
3704
+ insertDebugMarker(
3705
+ markerLabel: string
3706
+ ): undefined;
3707
+ }
3708
+
3709
+ interface GPUObjectBase {
3710
+ label: string;
3711
+ }
3712
+
3713
+ interface GPUPipelineBase {
3714
+ /**
3715
+ * Gets a {@link GPUBindGroupLayout} that is compatible with the {@link GPUPipelineBase}'s
3716
+ * {@link GPUBindGroupLayout} at `index`.
3717
+ * @param index - Index into the pipeline layout's {@link GPUPipelineLayout}.`[[bindGroupLayouts]]`
3718
+ * sequence.
3719
+ */
3720
+ getBindGroupLayout(
3721
+ index: number
3722
+ ): GPUBindGroupLayout;
3723
+ }
3724
+
3725
+ interface GPURenderCommandsMixin {
3726
+ /**
3727
+ * Sets the current {@link GPURenderPipeline}.
3728
+ * @param pipeline - The render pipeline to use for subsequent drawing commands.
3729
+ */
3730
+ setPipeline(
3731
+ pipeline: GPURenderPipeline
3732
+ ): undefined;
3733
+ /**
3734
+ * Sets the current index buffer.
3735
+ * @param buffer - Buffer containing index data to use for subsequent drawing commands.
3736
+ * @param indexFormat - Format of the index data contained in `buffer`.
3737
+ * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
3738
+ * @param size - Size in bytes of the index data in `buffer`.
3739
+ * Defaults to the size of the buffer minus the offset.
3740
+ */
3741
+ setIndexBuffer(
3742
+ buffer: GPUBuffer,
3743
+ indexFormat: GPUIndexFormat,
3744
+ offset?: GPUSize64,
3745
+ size?: GPUSize64
3746
+ ): undefined;
3747
+ /**
3748
+ * Sets the current vertex buffer for the given slot.
3749
+ * @param slot - The vertex buffer slot to set the vertex buffer for.
3750
+ * @param buffer - Buffer containing vertex data to use for subsequent drawing commands.
3751
+ * @param offset - Offset in bytes into `buffer` where the vertex data begins. Defaults to `0`.
3752
+ * @param size - Size in bytes of the vertex data in `buffer`.
3753
+ * Defaults to the size of the buffer minus the offset.
3754
+ */
3755
+ setVertexBuffer(
3756
+ slot: GPUIndex32,
3757
+ buffer:
3758
+ | GPUBuffer
3759
+ | null
3760
+ | undefined,
3761
+ offset?: GPUSize64,
3762
+ size?: GPUSize64
3763
+ ): undefined;
3764
+ /**
3765
+ * Draws primitives.
3766
+ * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.
3767
+ * @param vertexCount - The number of vertices to draw.
3768
+ * @param instanceCount - The number of instances to draw.
3769
+ * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
3770
+ * @param firstInstance - First instance to draw.
3771
+ */
3772
+ draw(
3773
+ vertexCount: GPUSize32,
3774
+ instanceCount?: GPUSize32,
3775
+ firstVertex?: GPUSize32,
3776
+ firstInstance?: GPUSize32
3777
+ ): undefined;
3778
+ /**
3779
+ * Draws indexed primitives.
3780
+ * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.
3781
+ * @param indexCount - The number of indices to draw.
3782
+ * @param instanceCount - The number of instances to draw.
3783
+ * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
3784
+ * @param baseVertex - Added to each index value before indexing into the vertex buffers.
3785
+ * @param firstInstance - First instance to draw.
3786
+ */
3787
+ drawIndexed(
3788
+ indexCount: GPUSize32,
3789
+ instanceCount?: GPUSize32,
3790
+ firstIndex?: GPUSize32,
3791
+ baseVertex?: GPUSignedOffset32,
3792
+ firstInstance?: GPUSize32
3793
+ ): undefined;
3794
+ /**
3795
+ * Draws primitives using parameters read from a {@link GPUBuffer}.
3796
+ * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.
3797
+ * packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same
3798
+ * order as the arguments for {@link GPURenderCommandsMixin#draw}. For example:
3799
+ * @param indirectBuffer - Buffer containing the indirect draw parameters.
3800
+ * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
3801
+ */
3802
+ drawIndirect(
3803
+ indirectBuffer: GPUBuffer,
3804
+ indirectOffset: GPUSize64
3805
+ ): undefined;
3806
+ /**
3807
+ * Draws indexed primitives using parameters read from a {@link GPUBuffer}.
3808
+ * See {@link https://www.w3.org/TR/webgpu/#rendering-operations} for the detailed specification.
3809
+ * tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in
3810
+ * the same order as the arguments for {@link GPURenderCommandsMixin#drawIndexed}. For example:
3811
+ * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
3812
+ * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
3813
+ */
3814
+ drawIndexedIndirect(
3815
+ indirectBuffer: GPUBuffer,
3816
+ indirectOffset: GPUSize64
3817
+ ): undefined;
3818
+ }
3819
+
3820
+ interface NavigatorGPU {
3821
+ /**
3822
+ * A global singleton providing top-level entry points like {@link GPU#requestAdapter}.
3823
+ */
3824
+ readonly gpu: GPU;
3825
+ }
3826
+
3827
+ interface GPU {
3828
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3829
+ readonly __brand: "GPU";
3830
+ /**
3831
+ * Requests an adapter from the user agent.
3832
+ * The user agent chooses whether to return an adapter, and, if so,
3833
+ * chooses according to the provided options.
3834
+ * @param options - Criteria used to select the adapter.
3835
+ */
3836
+ requestAdapter(
3837
+ options?: GPURequestAdapterOptions
3838
+ ): Promise<GPUAdapter | null>;
3839
+ /**
3840
+ * Returns an optimal {@link GPUTextureFormat} for displaying 8-bit depth, standard dynamic range
3841
+ * content on this system. Must only return {@link GPUTextureFormat} `"rgba8unorm"` or
3842
+ * {@link GPUTextureFormat} `"bgra8unorm"`.
3843
+ * The returned value can be passed as the {@link GPUCanvasConfiguration#format} to
3844
+ * {@link GPUCanvasContext#configure} calls on a {@link GPUCanvasContext} to ensure the associated
3845
+ * canvas is able to display its contents efficiently.
3846
+ * Note: Canvases which are not displayed to the screen may or may not benefit from using this
3847
+ * format.
3848
+ */
3849
+ getPreferredCanvasFormat(): GPUTextureFormat;
3850
+ readonly wgslLanguageFeatures: WGSLLanguageFeatures;
3851
+ }
3852
+
3853
+ var GPU: {
3854
+ prototype: GPU;
3855
+ new (): never;
3856
+ };
3857
+
3858
+ interface GPUAdapter {
3859
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3860
+ readonly __brand: "GPUAdapter";
3861
+ /**
3862
+ * The set of values in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[features]]}.
3863
+ */
3864
+ readonly features: GPUSupportedFeatures;
3865
+ /**
3866
+ * The limits in `this`.{@link GPUAdapter#[[adapter]]}.{@link adapter#[[limits]]}.
3867
+ */
3868
+ readonly limits: GPUSupportedLimits;
3869
+ /**
3870
+ * Information about the physical adapter underlying this {@link GPUAdapter}.
3871
+ * For a given {@link GPUAdapter}, the {@link GPUAdapterInfo} values exposed are constant over time.
3872
+ * The same object is returned each time. To create that object for the first time:
3873
+ * <div algorithm=GPUAdapter.info>
3874
+ * <div data-timeline=content>
3875
+ * **Called on:** {@link GPUAdapter} `this`.
3876
+ * **Returns:** {@link GPUAdapterInfo}
3877
+ * Content timeline steps:
3878
+ * 1. Return a [$new adapter info$] for `this.adapter`.
3879
+ * </div>
3880
+ * </div>
3881
+ */
3882
+ readonly info: GPUAdapterInfo;
3883
+ /**
3884
+ * Requests a device from the adapter.
3885
+ * This is a one-time action: if a device is returned successfully,
3886
+ * the adapter becomes {@link adapter#[[state]]#"consumed"}.
3887
+ * @param descriptor - Description of the {@link GPUDevice} to request.
3888
+ */
3889
+ requestDevice(
3890
+ descriptor?: GPUDeviceDescriptor
3891
+ ): Promise<GPUDevice>;
3892
+ }
3893
+
3894
+ var GPUAdapter: {
3895
+ prototype: GPUAdapter;
3896
+ new (): never;
3897
+ };
3898
+
3899
+ interface GPUAdapterInfo {
3900
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3901
+ readonly __brand: "GPUAdapterInfo";
3902
+ /**
3903
+ * The name of the vendor of the adapter, if available. Empty string otherwise.
3904
+ */
3905
+ readonly vendor: string;
3906
+ /**
3907
+ * The name of the family or class of GPUs the adapter belongs to, if available. Empty
3908
+ * string otherwise.
3909
+ */
3910
+ readonly architecture: string;
3911
+ /**
3912
+ * A vendor-specific identifier for the adapter, if available. Empty string otherwise.
3913
+ * Note: This is a value that represents the type of adapter. For example, it may be a
3914
+ * [PCI device ID](https://pcisig.com/). It does not uniquely identify a given piece of
3915
+ * hardware like a serial number.
3916
+ */
3917
+ readonly device: string;
3918
+ /**
3919
+ * A human readable string describing the adapter as reported by the driver, if available.
3920
+ * Empty string otherwise.
3921
+ * Note: Because no formatting is applied to {@link GPUAdapterInfo#description} attempting to parse
3922
+ * this value is not recommended. Applications which change their behavior based on the
3923
+ * {@link GPUAdapterInfo}, such as applying workarounds for known driver issues, should rely on the
3924
+ * other fields when possible.
3925
+ */
3926
+ readonly description: string;
3927
+ /**
3928
+ * If the "subgroups" feature is supported, the minimum supported subgroup size for the
3929
+ * adapter.
3930
+ *
3931
+ * @todo Temporarily optional until all browsers have implemented it.
3932
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
3933
+ */
3934
+ readonly subgroupMinSize?: number;
3935
+ /**
3936
+ * If the "subgroups" feature is supported, the maximum supported subgroup size for the
3937
+ * adapter.
3938
+ *
3939
+ * @todo Temporarily optional until all browsers have implemented it.
3940
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
3941
+ */
3942
+ readonly subgroupMaxSize?: number;
3943
+ /**
3944
+ * Whether the adapter is a fallback adapter.
3945
+ **/
3946
+ readonly isFallbackAdapter: boolean;
3947
+ }
3948
+
3949
+ var GPUAdapterInfo: {
3950
+ prototype: GPUAdapterInfo;
3951
+ new (): never;
3952
+ };
3953
+
3954
+ interface GPUBindGroup
3955
+ extends GPUObjectBase {
3956
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3957
+ readonly __brand: "GPUBindGroup";
3958
+ }
3959
+
3960
+ var GPUBindGroup: {
3961
+ prototype: GPUBindGroup;
3962
+ new (): never;
3963
+ };
3964
+
3965
+ interface GPUBindGroupLayout
3966
+ extends GPUObjectBase {
3967
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3968
+ readonly __brand: "GPUBindGroupLayout";
3969
+ }
3970
+
3971
+ var GPUBindGroupLayout: {
3972
+ prototype: GPUBindGroupLayout;
3973
+ new (): never;
3974
+ };
3975
+
3976
+ interface GPUBuffer
3977
+ extends GPUObjectBase {
3978
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
3979
+ readonly __brand: "GPUBuffer";
3980
+ readonly size: GPUSize64Out;
3981
+ readonly usage: GPUFlagsConstant;
3982
+ readonly mapState: GPUBufferMapState;
3983
+ /**
3984
+ * Maps the given range of the {@link GPUBuffer} and resolves the returned Promise when the
3985
+ * {@link GPUBuffer}'s content is ready to be accessed with {@link GPUBuffer#getMappedRange}.
3986
+ * The resolution of the returned Promise **only** indicates that the buffer has been mapped.
3987
+ * It does not guarantee the completion of any other operations visible to the content timeline,
3988
+ * and in particular does not imply that any other Promise returned from
3989
+ * {@link GPUQueue#onSubmittedWorkDone()} or {@link GPUBuffer#mapAsync} on other {@link GPUBuffer}s
3990
+ * have resolved.
3991
+ * The resolution of the Promise returned from {@link GPUQueue#onSubmittedWorkDone}
3992
+ * **does** imply the completion of
3993
+ * {@link GPUBuffer#mapAsync} calls made prior to that call,
3994
+ * on {@link GPUBuffer}s last used exclusively on that queue.
3995
+ * @param mode - Whether the buffer should be mapped for reading or writing.
3996
+ * @param offset - Offset in bytes into the buffer to the start of the range to map.
3997
+ * @param size - Size in bytes of the range to map.
3998
+ */
3999
+ mapAsync(
4000
+ mode: GPUMapModeFlags,
4001
+ offset?: GPUSize64,
4002
+ size?: GPUSize64
4003
+ ): Promise<undefined>;
4004
+ /**
4005
+ * Returns an ArrayBuffer with the contents of the {@link GPUBuffer} in the given mapped range.
4006
+ * @param offset - Offset in bytes into the buffer to return buffer contents from.
4007
+ * @param size - Size in bytes of the ArrayBuffer to return.
4008
+ */
4009
+ getMappedRange(
4010
+ offset?: GPUSize64,
4011
+ size?: GPUSize64
4012
+ ): ArrayBuffer;
4013
+ /**
4014
+ * Unmaps the mapped range of the {@link GPUBuffer} and makes its contents available for use by the
4015
+ * GPU again.
4016
+ */
4017
+ unmap(): undefined;
4018
+ /**
4019
+ * Destroys the {@link GPUBuffer}.
4020
+ * Note: It is valid to destroy a buffer multiple times.
4021
+ * Note: Since no further operations can be enqueued using this buffer, implementations can
4022
+ * free resource allocations, including mapped memory that was just unmapped.
4023
+ */
4024
+ destroy(): undefined;
4025
+ }
4026
+
4027
+ var GPUBuffer: {
4028
+ prototype: GPUBuffer;
4029
+ new (): never;
4030
+ };
4031
+
4032
+ interface GPUCanvasContext {
4033
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4034
+ readonly __brand: "GPUCanvasContext";
4035
+ /**
4036
+ * The canvas this context was created from.
4037
+ */
4038
+ readonly canvas:
4039
+ | HTMLCanvasElement
4040
+ | OffscreenCanvas;
4041
+ /**
4042
+ * Configures the context for this canvas.
4043
+ * This clears the drawing buffer to transparent black (in [$Replace the drawing buffer$]).
4044
+ * See {@link GPUCanvasContext#getConfiguration} for information on feature detection.
4045
+ * @param configuration - Desired configuration for the context.
4046
+ */
4047
+ configure(
4048
+ configuration: GPUCanvasConfiguration
4049
+ ): undefined;
4050
+ /**
4051
+ * Removes the context configuration. Destroys any textures produced while configured.
4052
+ */
4053
+ unconfigure(): undefined;
4054
+ /**
4055
+ * Returns the context configuration, or `null` if the context is not configured.
4056
+ * Note:
4057
+ * This method exists primarily for feature detection of members (and sub-members) of
4058
+ * {@link GPUCanvasConfiguration}; see those members for details.
4059
+ * For supported members, it returns the originally-supplied values.
4060
+ */
4061
+ getConfiguration(): GPUCanvasConfigurationOut | null;
4062
+ /**
4063
+ * Get the {@link GPUTexture} that will be composited to the document by the {@link GPUCanvasContext}
4064
+ * next.
4065
+ * Note: The same {@link GPUTexture} object will be returned by every
4066
+ * call to {@link GPUCanvasContext#getCurrentTexture} until "[$Expire the current texture$]"
4067
+ * runs, even if that {@link GPUTexture} is destroyed, failed validation, or failed to allocate.
4068
+ */
4069
+ getCurrentTexture(): GPUTexture;
4070
+ }
4071
+
4072
+ var GPUCanvasContext: {
4073
+ prototype: GPUCanvasContext;
4074
+ new (): never;
4075
+ };
4076
+
4077
+ interface GPUCommandBuffer
4078
+ extends GPUObjectBase {
4079
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4080
+ readonly __brand: "GPUCommandBuffer";
4081
+ }
4082
+
4083
+ var GPUCommandBuffer: {
4084
+ prototype: GPUCommandBuffer;
4085
+ new (): never;
4086
+ };
4087
+
4088
+ interface GPUCommandEncoder
4089
+ extends GPUObjectBase,
4090
+ GPUCommandsMixin,
4091
+ GPUDebugCommandsMixin {
4092
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4093
+ readonly __brand: "GPUCommandEncoder";
4094
+ /**
4095
+ * Begins encoding a render pass described by `descriptor`.
4096
+ * @param descriptor - Description of the {@link GPURenderPassEncoder} to create.
4097
+ */
4098
+ beginRenderPass(
4099
+ descriptor: GPURenderPassDescriptor
4100
+ ): GPURenderPassEncoder;
4101
+ beginComputePass(
4102
+ descriptor?: GPUComputePassDescriptor
4103
+ ): GPUComputePassEncoder;
4104
+ /**
4105
+ * Shorthand, equivalent to {@link GPUCommandEncoder#copyBufferToBuffer}.
4106
+ */
4107
+ copyBufferToBuffer(
4108
+ source: GPUBuffer,
4109
+ destination: GPUBuffer,
4110
+ size?: GPUSize64
4111
+ ): undefined;
4112
+ /**
4113
+ * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a
4114
+ * {@link GPUBuffer} to a sub-region of another {@link GPUBuffer}.
4115
+ * @param source - The {@link GPUBuffer} to copy from.
4116
+ * @param sourceOffset - Offset in bytes into `source` to begin copying from.
4117
+ * @param destination - The {@link GPUBuffer} to copy to.
4118
+ * @param destinationOffset - Offset in bytes into `destination` to place the copied data.
4119
+ * @param size - Bytes to copy. Defaults to the size of the buffer `source` minus `sourceOffset`.
4120
+ */
4121
+ copyBufferToBuffer(
4122
+ source: GPUBuffer,
4123
+ sourceOffset: GPUSize64,
4124
+ destination: GPUBuffer,
4125
+ destinationOffset: GPUSize64,
4126
+ size?: GPUSize64
4127
+ ): undefined;
4128
+ /**
4129
+ * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of a
4130
+ * {@link GPUBuffer} to a sub-region of one or multiple continuous texture subresources.
4131
+ * @param source - Combined with `copySize`, defines the region of the source buffer.
4132
+ * @param destination - Combined with `copySize`, defines the region of the destination texture subresource.
4133
+ * `copySize`:
4134
+ */
4135
+ copyBufferToTexture(
4136
+ source: GPUTexelCopyBufferInfo,
4137
+ destination: GPUTexelCopyTextureInfo,
4138
+ copySize: GPUExtent3DStrict
4139
+ ): undefined;
4140
+ /**
4141
+ * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one or
4142
+ * multiple continuous texture subresources to a sub-region of a {@link GPUBuffer}.
4143
+ * @param source - Combined with `copySize`, defines the region of the source texture subresources.
4144
+ * @param destination - Combined with `copySize`, defines the region of the destination buffer.
4145
+ * `copySize`:
4146
+ */
4147
+ copyTextureToBuffer(
4148
+ source: GPUTexelCopyTextureInfo,
4149
+ destination: GPUTexelCopyBufferInfo,
4150
+ copySize: GPUExtent3DStrict
4151
+ ): undefined;
4152
+ /**
4153
+ * Encode a command into the {@link GPUCommandEncoder} that copies data from a sub-region of one
4154
+ * or multiple contiguous texture subresources to another sub-region of one or
4155
+ * multiple continuous texture subresources.
4156
+ * @param source - Combined with `copySize`, defines the region of the source texture subresources.
4157
+ * @param destination - Combined with `copySize`, defines the region of the destination texture subresources.
4158
+ * `copySize`:
4159
+ */
4160
+ copyTextureToTexture(
4161
+ source: GPUTexelCopyTextureInfo,
4162
+ destination: GPUTexelCopyTextureInfo,
4163
+ copySize: GPUExtent3DStrict
4164
+ ): undefined;
4165
+ /**
4166
+ * Encode a command into the {@link GPUCommandEncoder} that fills a sub-region of a
4167
+ * {@link GPUBuffer} with zeros.
4168
+ * @param buffer - The {@link GPUBuffer} to clear.
4169
+ * @param offset - Offset in bytes into `buffer` where the sub-region to clear begins.
4170
+ * @param size - Size in bytes of the sub-region to clear. Defaults to the size of the buffer minus `offset`.
4171
+ */
4172
+ clearBuffer(
4173
+ buffer: GPUBuffer,
4174
+ offset?: GPUSize64,
4175
+ size?: GPUSize64
4176
+ ): undefined;
4177
+ /**
4178
+ * Resolves query results from a {@link GPUQuerySet} out into a range of a {@link GPUBuffer}.
4179
+ * querySet:
4180
+ * firstQuery:
4181
+ * queryCount:
4182
+ * destination:
4183
+ * destinationOffset:
4184
+ */
4185
+ resolveQuerySet(
4186
+ querySet: GPUQuerySet,
4187
+ firstQuery: GPUSize32,
4188
+ queryCount: GPUSize32,
4189
+ destination: GPUBuffer,
4190
+ destinationOffset: GPUSize64
4191
+ ): undefined;
4192
+ /**
4193
+ * Completes recording of the commands sequence and returns a corresponding {@link GPUCommandBuffer}.
4194
+ * descriptor:
4195
+ */
4196
+ finish(
4197
+ descriptor?: GPUCommandBufferDescriptor
4198
+ ): GPUCommandBuffer;
4199
+ }
4200
+
4201
+ var GPUCommandEncoder: {
4202
+ prototype: GPUCommandEncoder;
4203
+ new (): never;
4204
+ };
4205
+
4206
+ interface GPUCompilationInfo {
4207
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4208
+ readonly __brand: "GPUCompilationInfo";
4209
+ readonly messages: ReadonlyArray<GPUCompilationMessage>;
4210
+ }
4211
+
4212
+ var GPUCompilationInfo: {
4213
+ prototype: GPUCompilationInfo;
4214
+ new (): never;
4215
+ };
4216
+
4217
+ interface GPUCompilationMessage {
4218
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4219
+ readonly __brand: "GPUCompilationMessage";
4220
+ /**
4221
+ * The human-readable, localizable text for this compilation message.
4222
+ * Note: The {@link GPUCompilationMessage#message} should follow the best practices for language
4223
+ * and direction information. This includes making use of any future standards which may
4224
+ * emerge regarding the reporting of string language and direction metadata.
4225
+ * <p class="note editorial"><span class=marker>Editorial note:</span>
4226
+ * At the time of this writing, no language/direction recommendation is available that provides
4227
+ * compatibility and consistency with legacy APIs, but when there is, adopt it formally.
4228
+ */
4229
+ readonly message: string;
4230
+ /**
4231
+ * The severity level of the message.
4232
+ * If the {@link GPUCompilationMessage#type} is {@link GPUCompilationMessageType} `"error"`, it
4233
+ * corresponds to a shader-creation error.
4234
+ */
4235
+ readonly type: GPUCompilationMessageType;
4236
+ /**
4237
+ * The line number in the shader {@link GPUShaderModuleDescriptor#code} the
4238
+ * {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a lineNum of
4239
+ * `1` indicates the first line of the shader {@link GPUShaderModuleDescriptor#code}. Lines are
4240
+ * delimited by line breaks.
4241
+ * If the {@link GPUCompilationMessage#message} corresponds to a substring this points to
4242
+ * the line on which the substring begins. Must be `0` if the {@link GPUCompilationMessage#message}
4243
+ * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.
4244
+ */
4245
+ readonly lineNum: number;
4246
+ /**
4247
+ * The offset, in UTF-16 code units, from the beginning of line {@link GPUCompilationMessage#lineNum}
4248
+ * of the shader {@link GPUShaderModuleDescriptor#code} to the point or beginning of the substring
4249
+ * that the {@link GPUCompilationMessage#message} corresponds to. Value is one-based, such that a
4250
+ * {@link GPUCompilationMessage#linePos} of `1` indicates the first code unit of the line.
4251
+ * If {@link GPUCompilationMessage#message} corresponds to a substring this points to the
4252
+ * first UTF-16 code unit of the substring. Must be `0` if the {@link GPUCompilationMessage#message}
4253
+ * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.
4254
+ */
4255
+ readonly linePos: number;
4256
+ /**
4257
+ * The offset from the beginning of the shader {@link GPUShaderModuleDescriptor#code} in UTF-16
4258
+ * code units to the point or beginning of the substring that {@link GPUCompilationMessage#message}
4259
+ * corresponds to. Must reference the same position as {@link GPUCompilationMessage#lineNum} and
4260
+ * {@link GPUCompilationMessage#linePos}. Must be `0` if the {@link GPUCompilationMessage#message}
4261
+ * does not correspond to any specific point in the shader {@link GPUShaderModuleDescriptor#code}.
4262
+ */
4263
+ readonly offset: number;
4264
+ /**
4265
+ * The number of UTF-16 code units in the substring that {@link GPUCompilationMessage#message}
4266
+ * corresponds to. If the message does not correspond with a substring then
4267
+ * {@link GPUCompilationMessage#length} must be 0.
4268
+ */
4269
+ readonly length: number;
4270
+ }
4271
+
4272
+ var GPUCompilationMessage: {
4273
+ prototype: GPUCompilationMessage;
4274
+ new (): never;
4275
+ };
4276
+
4277
+ interface GPUComputePassEncoder
4278
+ extends GPUObjectBase,
4279
+ GPUCommandsMixin,
4280
+ GPUDebugCommandsMixin,
4281
+ GPUBindingCommandsMixin {
4282
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4283
+ readonly __brand: "GPUComputePassEncoder";
4284
+ /**
4285
+ * Sets the current {@link GPUComputePipeline}.
4286
+ * @param pipeline - The compute pipeline to use for subsequent dispatch commands.
4287
+ */
4288
+ setPipeline(
4289
+ pipeline: GPUComputePipeline
4290
+ ): undefined;
4291
+ /**
4292
+ * Dispatch work to be performed with the current {@link GPUComputePipeline}.
4293
+ * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.
4294
+ * @param workgroupCountX - X dimension of the grid of workgroups to dispatch.
4295
+ * @param workgroupCountY - Y dimension of the grid of workgroups to dispatch.
4296
+ * @param workgroupCountZ - Z dimension of the grid of workgroups to dispatch.
4297
+ */
4298
+ dispatchWorkgroups(
4299
+ workgroupCountX: GPUSize32,
4300
+ workgroupCountY?: GPUSize32,
4301
+ workgroupCountZ?: GPUSize32
4302
+ ): undefined;
4303
+ /**
4304
+ * Dispatch work to be performed with the current {@link GPUComputePipeline} using parameters read
4305
+ * from a {@link GPUBuffer}.
4306
+ * See {@link https://www.w3.org/TR/webgpu/#computing-operations} for the detailed specification.
4307
+ * packed block of **three 32-bit unsigned integer values (12 bytes total)**,
4308
+ * given in the same order as the arguments for {@link GPUComputePassEncoder#dispatchWorkgroups}.
4309
+ * For example:
4310
+ * @param indirectBuffer - Buffer containing the indirect dispatch parameters.
4311
+ * @param indirectOffset - Offset in bytes into `indirectBuffer` where the dispatch data begins.
4312
+ */
4313
+ dispatchWorkgroupsIndirect(
4314
+ indirectBuffer: GPUBuffer,
4315
+ indirectOffset: GPUSize64
4316
+ ): undefined;
4317
+ /**
4318
+ * Completes recording of the compute pass commands sequence.
4319
+ */
4320
+ end(): undefined;
4321
+ }
4322
+
4323
+ var GPUComputePassEncoder: {
4324
+ prototype: GPUComputePassEncoder;
4325
+ new (): never;
4326
+ };
4327
+
4328
+ interface GPUComputePipeline
4329
+ extends GPUObjectBase,
4330
+ GPUPipelineBase {
4331
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4332
+ readonly __brand: "GPUComputePipeline";
4333
+ }
4334
+
4335
+ var GPUComputePipeline: {
4336
+ prototype: GPUComputePipeline;
4337
+ new (): never;
4338
+ };
4339
+
4340
+ interface GPUDevice
4341
+ extends EventTarget,
4342
+ GPUObjectBase {
4343
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4344
+ readonly __brand: "GPUDevice";
4345
+ /**
4346
+ * A set containing the {@link GPUFeatureName} values of the features
4347
+ * supported by the device (i.e. the ones with which it was created).
4348
+ */
4349
+ readonly features: GPUSupportedFeatures;
4350
+ /**
4351
+ * Exposes the limits supported by the device
4352
+ * (which are exactly the ones with which it was created).
4353
+ */
4354
+ readonly limits: GPUSupportedLimits;
4355
+ /**
4356
+ * Information about the physical adapter which created the device
4357
+ * that this GPUDevice refers to.
4358
+ * For a given GPUDevice, the GPUAdapterInfo values exposed are constant
4359
+ * over time.
4360
+ */
4361
+ readonly adapterInfo: GPUAdapterInfo;
4362
+ /**
4363
+ * The primary {@link GPUQueue} for this device.
4364
+ */
4365
+ readonly queue: GPUQueue;
4366
+ /**
4367
+ * Destroys the device, preventing further operations on it.
4368
+ * Outstanding asynchronous operations will fail.
4369
+ * Note: It is valid to destroy a device multiple times.
4370
+ * Note: Since no further operations can be enqueued on this device, implementations can abort
4371
+ * outstanding asynchronous operations immediately and free resource allocations, including
4372
+ * mapped memory that was just unmapped.
4373
+ */
4374
+ destroy(): undefined;
4375
+ /**
4376
+ * Creates a {@link GPUBuffer}.
4377
+ * @param descriptor - Description of the {@link GPUBuffer} to create.
4378
+ */
4379
+ createBuffer(
4380
+ descriptor: GPUBufferDescriptor
4381
+ ): GPUBuffer;
4382
+ /**
4383
+ * Creates a {@link GPUTexture}.
4384
+ * @param descriptor - Description of the {@link GPUTexture} to create.
4385
+ */
4386
+ createTexture(
4387
+ descriptor: GPUTextureDescriptor
4388
+ ): GPUTexture;
4389
+ /**
4390
+ * Creates a {@link GPUSampler}.
4391
+ * @param descriptor - Description of the {@link GPUSampler} to create.
4392
+ */
4393
+ createSampler(
4394
+ descriptor?: GPUSamplerDescriptor
4395
+ ): GPUSampler;
4396
+ /**
4397
+ * Creates a {@link GPUExternalTexture} wrapping the provided image source.
4398
+ * @param descriptor - Provides the external image source object (and any creation options).
4399
+ */
4400
+ importExternalTexture(
4401
+ descriptor: GPUExternalTextureDescriptor
4402
+ ): GPUExternalTexture;
4403
+ /**
4404
+ * Creates a {@link GPUBindGroupLayout}.
4405
+ * @param descriptor - Description of the {@link GPUBindGroupLayout} to create.
4406
+ */
4407
+ createBindGroupLayout(
4408
+ descriptor: GPUBindGroupLayoutDescriptor
4409
+ ): GPUBindGroupLayout;
4410
+ /**
4411
+ * Creates a {@link GPUPipelineLayout}.
4412
+ * @param descriptor - Description of the {@link GPUPipelineLayout} to create.
4413
+ */
4414
+ createPipelineLayout(
4415
+ descriptor: GPUPipelineLayoutDescriptor
4416
+ ): GPUPipelineLayout;
4417
+ /**
4418
+ * Creates a {@link GPUBindGroup}.
4419
+ * @param descriptor - Description of the {@link GPUBindGroup} to create.
4420
+ */
4421
+ createBindGroup(
4422
+ descriptor: GPUBindGroupDescriptor
4423
+ ): GPUBindGroup;
4424
+ /**
4425
+ * Creates a {@link GPUShaderModule}.
4426
+ * @param descriptor - Description of the {@link GPUShaderModule} to create.
4427
+ */
4428
+ createShaderModule(
4429
+ descriptor: GPUShaderModuleDescriptor
4430
+ ): GPUShaderModule;
4431
+ /**
4432
+ * Creates a {@link GPUComputePipeline} using immediate pipeline creation.
4433
+ * @param descriptor - Description of the {@link GPUComputePipeline} to create.
4434
+ */
4435
+ createComputePipeline(
4436
+ descriptor: GPUComputePipelineDescriptor
4437
+ ): GPUComputePipeline;
4438
+ /**
4439
+ * Creates a {@link GPURenderPipeline} using immediate pipeline creation.
4440
+ * @param descriptor - Description of the {@link GPURenderPipeline} to create.
4441
+ */
4442
+ createRenderPipeline(
4443
+ descriptor: GPURenderPipelineDescriptor
4444
+ ): GPURenderPipeline;
4445
+ /**
4446
+ * Creates a {@link GPUComputePipeline} using async pipeline creation.
4447
+ * The returned Promise resolves when the created pipeline
4448
+ * is ready to be used without additional delay.
4449
+ * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.
4450
+ * (A {@link GPUError} is not dispatched to the device.)
4451
+ * Note: Use of this method is preferred whenever possible, as it prevents blocking the
4452
+ * queue timeline work on pipeline compilation.
4453
+ * @param descriptor - Description of the {@link GPUComputePipeline} to create.
4454
+ */
4455
+ createComputePipelineAsync(
4456
+ descriptor: GPUComputePipelineDescriptor
4457
+ ): Promise<GPUComputePipeline>;
4458
+ /**
4459
+ * Creates a {@link GPURenderPipeline} using async pipeline creation.
4460
+ * The returned Promise resolves when the created pipeline
4461
+ * is ready to be used without additional delay.
4462
+ * If pipeline creation fails, the returned Promise rejects with an {@link GPUPipelineError}.
4463
+ * (A {@link GPUError} is not dispatched to the device.)
4464
+ * Note: Use of this method is preferred whenever possible, as it prevents blocking the
4465
+ * queue timeline work on pipeline compilation.
4466
+ * @param descriptor - Description of the {@link GPURenderPipeline} to create.
4467
+ */
4468
+ createRenderPipelineAsync(
4469
+ descriptor: GPURenderPipelineDescriptor
4470
+ ): Promise<GPURenderPipeline>;
4471
+ /**
4472
+ * Creates a {@link GPUCommandEncoder}.
4473
+ * @param descriptor - Description of the {@link GPUCommandEncoder} to create.
4474
+ */
4475
+ createCommandEncoder(
4476
+ descriptor?: GPUCommandEncoderDescriptor
4477
+ ): GPUCommandEncoder;
4478
+ /**
4479
+ * Creates a {@link GPURenderBundleEncoder}.
4480
+ * @param descriptor - Description of the {@link GPURenderBundleEncoder} to create.
4481
+ */
4482
+ createRenderBundleEncoder(
4483
+ descriptor: GPURenderBundleEncoderDescriptor
4484
+ ): GPURenderBundleEncoder;
4485
+ /**
4486
+ * Creates a {@link GPUQuerySet}.
4487
+ * @param descriptor - Description of the {@link GPUQuerySet} to create.
4488
+ */
4489
+ createQuerySet(
4490
+ descriptor: GPUQuerySetDescriptor
4491
+ ): GPUQuerySet;
4492
+ /**
4493
+ * A slot-backed attribute holding a promise which is created with the device, remains
4494
+ * pending for the lifetime of the device, then resolves when the device is lost.
4495
+ * Upon initialization, it is set to a new promise.
4496
+ */
4497
+ readonly lost: Promise<GPUDeviceLostInfo>;
4498
+ /**
4499
+ * Pushes a new GPU error scope onto the {@link GPUDevice}.`[[errorScopeStack]]` for `this`.
4500
+ * @param filter - Which class of errors this error scope observes.
4501
+ */
4502
+ pushErrorScope(
4503
+ filter: GPUErrorFilter
4504
+ ): undefined;
4505
+ /**
4506
+ * Pops a GPU error scope off the {@link GPUDevice}.`[[errorScopeStack]]` for `this`
4507
+ * and resolves to **any** {@link GPUError} observed by the error scope, or `null` if none.
4508
+ * There is no guarantee of the ordering of promise resolution.
4509
+ */
4510
+ popErrorScope(): Promise<GPUError | null>;
4511
+ /**
4512
+ * An event handler IDL attribute for the `uncapturederror` event type.
4513
+ */
4514
+ onuncapturederror:
4515
+ | ((
4516
+ this: GPUDevice,
4517
+ ev: GPUUncapturedErrorEvent
4518
+ ) => any)
4519
+ | null;
4520
+ }
4521
+
4522
+ var GPUDevice: {
4523
+ prototype: GPUDevice;
4524
+ new (): never;
4525
+ };
4526
+
4527
+ interface GPUDeviceLostInfo {
4528
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4529
+ readonly __brand: "GPUDeviceLostInfo";
4530
+ readonly reason: GPUDeviceLostReason;
4531
+ readonly message: string;
4532
+ }
4533
+
4534
+ var GPUDeviceLostInfo: {
4535
+ prototype: GPUDeviceLostInfo;
4536
+ new (): never;
4537
+ };
4538
+
4539
+ interface GPUError {
4540
+ /**
4541
+ * A human-readable, localizable text message providing information about the error that
4542
+ * occurred.
4543
+ * Note: This message is generally intended for application developers to debug their
4544
+ * applications and capture information for debug reports, not to be surfaced to end-users.
4545
+ * Note: User agents should not include potentially machine-parsable details in this message,
4546
+ * such as free system memory on {@link GPUErrorFilter} `"out-of-memory"` or other details about the
4547
+ * conditions under which memory was exhausted.
4548
+ * Note: The {@link GPUError#message} should follow the best practices for language and
4549
+ * direction information. This includes making use of any future standards which may emerge
4550
+ * regarding the reporting of string language and direction metadata.
4551
+ * <p class="note editorial"><span class=marker>Editorial note:</span>
4552
+ * At the time of this writing, no language/direction recommendation is available that provides
4553
+ * compatibility and consistency with legacy APIs, but when there is, adopt it formally.
4554
+ */
4555
+ readonly message: string;
4556
+ }
4557
+
4558
+ var GPUError: {
4559
+ prototype: GPUError;
4560
+ new (): never;
4561
+ };
4562
+
4563
+ interface GPUExternalTexture
4564
+ extends GPUObjectBase {
4565
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4566
+ readonly __brand: "GPUExternalTexture";
4567
+ }
4568
+
4569
+ var GPUExternalTexture: {
4570
+ prototype: GPUExternalTexture;
4571
+ new (): never;
4572
+ };
4573
+
4574
+ interface GPUInternalError
4575
+ extends GPUError {
4576
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4577
+ readonly __brand: "GPUInternalError";
4578
+ }
4579
+
4580
+ var GPUInternalError: {
4581
+ prototype: GPUInternalError;
4582
+ new (
4583
+ message: string
4584
+ ): GPUInternalError;
4585
+ };
4586
+
4587
+ interface GPUOutOfMemoryError
4588
+ extends GPUError {
4589
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4590
+ readonly __brand: "GPUOutOfMemoryError";
4591
+ }
4592
+
4593
+ var GPUOutOfMemoryError: {
4594
+ prototype: GPUOutOfMemoryError;
4595
+ new (
4596
+ message: string
4597
+ ): GPUOutOfMemoryError;
4598
+ };
4599
+
4600
+ interface GPUPipelineError
4601
+ extends DOMException {
4602
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4603
+ readonly __brand: "GPUPipelineError";
4604
+ /**
4605
+ * A read-only slot-backed attribute exposing the type of error encountered in pipeline creation
4606
+ * as a <dfn enum for="">GPUPipelineErrorReason</dfn>:
4607
+ * <ul dfn-type=enum-value dfn-for=GPUPipelineErrorReason>
4608
+ * - <dfn>"validation"</dfn>: A [$validation error$].
4609
+ * - <dfn>"internal"</dfn>: An [$internal error$].
4610
+ * </ul>
4611
+ */
4612
+ readonly reason: GPUPipelineErrorReason;
4613
+ }
4614
+
4615
+ var GPUPipelineError: {
4616
+ prototype: GPUPipelineError;
4617
+ new (
4618
+ message:
4619
+ | string
4620
+ | undefined,
4621
+ options: GPUPipelineErrorInit
4622
+ ): GPUPipelineError;
4623
+ };
4624
+
4625
+ interface GPUPipelineLayout
4626
+ extends GPUObjectBase {
4627
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4628
+ readonly __brand: "GPUPipelineLayout";
4629
+ }
4630
+
4631
+ var GPUPipelineLayout: {
4632
+ prototype: GPUPipelineLayout;
4633
+ new (): never;
4634
+ };
4635
+
4636
+ interface GPUQuerySet
4637
+ extends GPUObjectBase {
4638
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4639
+ readonly __brand: "GPUQuerySet";
4640
+ /**
4641
+ * Destroys the {@link GPUQuerySet}.
4642
+ */
4643
+ destroy(): undefined;
4644
+ /**
4645
+ * The type of the queries managed by this {@link GPUQuerySet}.
4646
+ */
4647
+ readonly type: GPUQueryType;
4648
+ /**
4649
+ * The number of queries managed by this {@link GPUQuerySet}.
4650
+ */
4651
+ readonly count: GPUSize32Out;
4652
+ }
4653
+
4654
+ var GPUQuerySet: {
4655
+ prototype: GPUQuerySet;
4656
+ new (): never;
4657
+ };
4658
+
4659
+ interface GPUQueue
4660
+ extends GPUObjectBase {
4661
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4662
+ readonly __brand: "GPUQueue";
4663
+ /**
4664
+ * Schedules the execution of the command buffers by the GPU on this queue.
4665
+ * Submitted command buffers cannot be used again.
4666
+ * `commandBuffers`:
4667
+ */
4668
+ submit(
4669
+ commandBuffers: Iterable<GPUCommandBuffer>
4670
+ ): undefined;
4671
+ /**
4672
+ * Returns a Promise that resolves once this queue finishes processing all the work submitted
4673
+ * up to this moment.
4674
+ * Resolution of this Promise implies the completion of
4675
+ * {@link GPUBuffer#mapAsync} calls made prior to that call,
4676
+ * on {@link GPUBuffer}s last used exclusively on that queue.
4677
+ */
4678
+ onSubmittedWorkDone(): Promise<undefined>;
4679
+ /**
4680
+ * Issues a write operation of the provided data into a {@link GPUBuffer}.
4681
+ * @param buffer - The buffer to write to.
4682
+ * @param bufferOffset - Offset in bytes into `buffer` to begin writing at.
4683
+ * @param data - Data to write into `buffer`.
4684
+ * @param dataOffset - Offset in into `data` to begin writing from. Given in elements if
4685
+ * `data` is a `TypedArray` and bytes otherwise.
4686
+ * @param size - Size of content to write from `data` to `buffer`. Given in elements if
4687
+ * `data` is a `TypedArray` and bytes otherwise.
4688
+ */
4689
+ writeBuffer(
4690
+ buffer: GPUBuffer,
4691
+ bufferOffset: GPUSize64,
4692
+ data: GPUAllowSharedBufferSource,
4693
+ dataOffset?: GPUSize64,
4694
+ size?: GPUSize64
4695
+ ): undefined;
4696
+ /**
4697
+ * Issues a write operation of the provided data into a {@link GPUTexture}.
4698
+ * @param destination - The texture subresource and origin to write to.
4699
+ * @param data - Data to write into `destination`.
4700
+ * @param dataLayout - Layout of the content in `data`.
4701
+ * @param size - Extents of the content to write from `data` to `destination`.
4702
+ */
4703
+ writeTexture(
4704
+ destination: GPUTexelCopyTextureInfo,
4705
+ data: GPUAllowSharedBufferSource,
4706
+ dataLayout: GPUTexelCopyBufferLayout,
4707
+ size: GPUExtent3DStrict
4708
+ ): undefined;
4709
+ /**
4710
+ * Issues a copy operation of the contents of a platform image/canvas
4711
+ * into the destination texture.
4712
+ * This operation performs {@link https://www.w3.org/TR/webgpu/#color-space-conversions | color encoding} into the destination
4713
+ * encoding according to the parameters of {@link GPUCopyExternalImageDestInfo}.
4714
+ * Copying into a `-srgb` texture results in the same texture bytes, not the same decoded
4715
+ * values, as copying into the corresponding non-`-srgb` format.
4716
+ * Thus, after a copy operation, sampling the destination texture has
4717
+ * different results depending on whether its format is `-srgb`, all else unchanged.
4718
+ * <!-- POSTV1(srgb-linear): If added, explain here how it interacts. -->
4719
+ * @param source - source image and origin to copy to `destination`.
4720
+ * @param destination - The texture subresource and origin to write to, and its encoding metadata.
4721
+ * @param copySize - Extents of the content to write from `source` to `destination`.
4722
+ */
4723
+ copyExternalImageToTexture(
4724
+ source: GPUCopyExternalImageSourceInfo,
4725
+ destination: GPUCopyExternalImageDestInfo,
4726
+ copySize: GPUExtent3DStrict
4727
+ ): undefined;
4728
+ }
4729
+
4730
+ var GPUQueue: {
4731
+ prototype: GPUQueue;
4732
+ new (): never;
4733
+ };
4734
+
4735
+ interface GPURenderBundle
4736
+ extends GPUObjectBase {
4737
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4738
+ readonly __brand: "GPURenderBundle";
4739
+ }
4740
+
4741
+ var GPURenderBundle: {
4742
+ prototype: GPURenderBundle;
4743
+ new (): never;
4744
+ };
4745
+
4746
+ interface GPURenderBundleEncoder
4747
+ extends GPUObjectBase,
4748
+ GPUCommandsMixin,
4749
+ GPUDebugCommandsMixin,
4750
+ GPUBindingCommandsMixin,
4751
+ GPURenderCommandsMixin {
4752
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4753
+ readonly __brand: "GPURenderBundleEncoder";
4754
+ /**
4755
+ * Completes recording of the render bundle commands sequence.
4756
+ * descriptor:
4757
+ */
4758
+ finish(
4759
+ descriptor?: GPURenderBundleDescriptor
4760
+ ): GPURenderBundle;
4761
+ }
4762
+
4763
+ var GPURenderBundleEncoder: {
4764
+ prototype: GPURenderBundleEncoder;
4765
+ new (): never;
4766
+ };
4767
+
4768
+ interface GPURenderPassEncoder
4769
+ extends GPUObjectBase,
4770
+ GPUCommandsMixin,
4771
+ GPUDebugCommandsMixin,
4772
+ GPUBindingCommandsMixin,
4773
+ GPURenderCommandsMixin {
4774
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4775
+ readonly __brand: "GPURenderPassEncoder";
4776
+ /**
4777
+ * Sets the viewport used during the rasterization stage to linearly map from
4778
+ * NDC|normalized device coordinates to viewport coordinates.
4779
+ * @param x - Minimum X value of the viewport in pixels.
4780
+ * @param y - Minimum Y value of the viewport in pixels.
4781
+ * @param width - Width of the viewport in pixels.
4782
+ * @param height - Height of the viewport in pixels.
4783
+ * @param minDepth - Minimum depth value of the viewport.
4784
+ * @param maxDepth - Maximum depth value of the viewport.
4785
+ */
4786
+ setViewport(
4787
+ x: number,
4788
+ y: number,
4789
+ width: number,
4790
+ height: number,
4791
+ minDepth: number,
4792
+ maxDepth: number
4793
+ ): undefined;
4794
+ /**
4795
+ * Sets the scissor rectangle used during the rasterization stage.
4796
+ * After transformation into viewport coordinates any fragments which fall outside the scissor
4797
+ * rectangle will be discarded.
4798
+ * @param x - Minimum X value of the scissor rectangle in pixels.
4799
+ * @param y - Minimum Y value of the scissor rectangle in pixels.
4800
+ * @param width - Width of the scissor rectangle in pixels.
4801
+ * @param height - Height of the scissor rectangle in pixels.
4802
+ */
4803
+ setScissorRect(
4804
+ x: GPUIntegerCoordinate,
4805
+ y: GPUIntegerCoordinate,
4806
+ width: GPUIntegerCoordinate,
4807
+ height: GPUIntegerCoordinate
4808
+ ): undefined;
4809
+ /**
4810
+ * Sets the constant blend color and alpha values used with {@link GPUBlendFactor} `"constant"`
4811
+ * and {@link GPUBlendFactor} `"one-minus-constant"` {@link GPUBlendFactor}s.
4812
+ * @param color - The color to use when blending.
4813
+ */
4814
+ setBlendConstant(
4815
+ color: GPUColor
4816
+ ): undefined;
4817
+ /**
4818
+ * Sets the RenderState.`[[stencilReference]]` value used during stencil tests with
4819
+ * the {@link GPUStencilOperation} `"replace"` {@link GPUStencilOperation}.
4820
+ * @param reference - The new stencil reference value.
4821
+ */
4822
+ setStencilReference(
4823
+ reference: GPUStencilValue
4824
+ ): undefined;
4825
+ /**
4826
+ * @param queryIndex - The index of the query in the query set.
4827
+ */
4828
+ beginOcclusionQuery(
4829
+ queryIndex: GPUSize32
4830
+ ): undefined;
4831
+ /**
4832
+ */
4833
+ endOcclusionQuery(): undefined;
4834
+ /**
4835
+ * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of
4836
+ * this render pass.
4837
+ * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind
4838
+ * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render
4839
+ * pass's pipeline, bind group, and vertex/index buffer state is cleared
4840
+ * (to the initial, empty values).
4841
+ * Note: The state is cleared, not restored to the previous state.
4842
+ * This occurs even if zero {@link GPURenderBundle | GPURenderBundles} are executed.
4843
+ * @param bundles - List of render bundles to execute.
4844
+ */
4845
+ executeBundles(
4846
+ bundles: Iterable<GPURenderBundle>
4847
+ ): undefined;
4848
+ /**
4849
+ * Completes recording of the render pass commands sequence.
4850
+ */
4851
+ end(): undefined;
4852
+ }
4853
+
4854
+ var GPURenderPassEncoder: {
4855
+ prototype: GPURenderPassEncoder;
4856
+ new (): never;
4857
+ };
4858
+
4859
+ interface GPURenderPipeline
4860
+ extends GPUObjectBase,
4861
+ GPUPipelineBase {
4862
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4863
+ readonly __brand: "GPURenderPipeline";
4864
+ }
4865
+
4866
+ var GPURenderPipeline: {
4867
+ prototype: GPURenderPipeline;
4868
+ new (): never;
4869
+ };
4870
+
4871
+ interface GPUSampler
4872
+ extends GPUObjectBase {
4873
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4874
+ readonly __brand: "GPUSampler";
4875
+ }
4876
+
4877
+ var GPUSampler: {
4878
+ prototype: GPUSampler;
4879
+ new (): never;
4880
+ };
4881
+
4882
+ interface GPUShaderModule
4883
+ extends GPUObjectBase {
4884
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4885
+ readonly __brand: "GPUShaderModule";
4886
+ /**
4887
+ * Returns any messages generated during the {@link GPUShaderModule}'s compilation.
4888
+ * The locations, order, and contents of messages are implementation-defined.
4889
+ * In particular, messages aren't necessarily ordered by {@link GPUCompilationMessage#lineNum}.
4890
+ */
4891
+ getCompilationInfo(): Promise<GPUCompilationInfo>;
4892
+ }
4893
+
4894
+ var GPUShaderModule: {
4895
+ prototype: GPUShaderModule;
4896
+ new (): never;
4897
+ };
4898
+
4899
+ type GPUSupportedFeatures =
4900
+ ReadonlySet<string>;
4901
+
4902
+ interface GPUSupportedLimits {
4903
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4904
+ readonly __brand: "GPUSupportedLimits";
4905
+ readonly maxTextureDimension1D: number;
4906
+ readonly maxTextureDimension2D: number;
4907
+ readonly maxTextureDimension3D: number;
4908
+ readonly maxTextureArrayLayers: number;
4909
+ readonly maxBindGroups: number;
4910
+ readonly maxBindGroupsPlusVertexBuffers: number;
4911
+ readonly maxBindingsPerBindGroup: number;
4912
+ readonly maxDynamicUniformBuffersPerPipelineLayout: number;
4913
+ readonly maxDynamicStorageBuffersPerPipelineLayout: number;
4914
+ readonly maxSampledTexturesPerShaderStage: number;
4915
+ readonly maxSamplersPerShaderStage: number;
4916
+ readonly maxStorageBuffersPerShaderStage: number;
4917
+ /**
4918
+ * @todo Temporarily optional until all browsers have implemented it.
4919
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
4920
+ */
4921
+ readonly maxStorageBuffersInVertexStage?: number;
4922
+ /**
4923
+ * @todo Temporarily optional until all browsers have implemented it.
4924
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
4925
+ */
4926
+ readonly maxStorageBuffersInFragmentStage?: number;
4927
+ readonly maxStorageTexturesPerShaderStage: number;
4928
+ /**
4929
+ * @todo Temporarily optional until all browsers have implemented it.
4930
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
4931
+ */
4932
+ readonly maxStorageTexturesInVertexStage?: number;
4933
+ /**
4934
+ * @todo Temporarily optional until all browsers have implemented it.
4935
+ * Check support before using. (Use the non-null assertion operator `!` where needed.)
4936
+ */
4937
+ readonly maxStorageTexturesInFragmentStage?: number;
4938
+ readonly maxUniformBuffersPerShaderStage: number;
4939
+ readonly maxUniformBufferBindingSize: number;
4940
+ readonly maxStorageBufferBindingSize: number;
4941
+ readonly minUniformBufferOffsetAlignment: number;
4942
+ readonly minStorageBufferOffsetAlignment: number;
4943
+ readonly maxVertexBuffers: number;
4944
+ readonly maxBufferSize: number;
4945
+ readonly maxVertexAttributes: number;
4946
+ readonly maxVertexBufferArrayStride: number;
4947
+ readonly maxInterStageShaderVariables: number;
4948
+ readonly maxColorAttachments: number;
4949
+ readonly maxColorAttachmentBytesPerSample: number;
4950
+ readonly maxComputeWorkgroupStorageSize: number;
4951
+ readonly maxComputeInvocationsPerWorkgroup: number;
4952
+ readonly maxComputeWorkgroupSizeX: number;
4953
+ readonly maxComputeWorkgroupSizeY: number;
4954
+ readonly maxComputeWorkgroupSizeZ: number;
4955
+ readonly maxComputeWorkgroupsPerDimension: number;
4956
+ readonly maxImmediateSize: number;
4957
+ }
4958
+
4959
+ var GPUSupportedLimits: {
4960
+ prototype: GPUSupportedLimits;
4961
+ new (): never;
4962
+ };
4963
+
4964
+ interface GPUTexture
4965
+ extends GPUObjectBase {
4966
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
4967
+ readonly __brand: "GPUTexture";
4968
+ /**
4969
+ * Creates a {@link GPUTextureView}.
4970
+ * @param descriptor - Description of the {@link GPUTextureView} to create.
4971
+ */
4972
+ createView(
4973
+ descriptor?: GPUTextureViewDescriptor
4974
+ ): GPUTextureView;
4975
+ /**
4976
+ * Destroys the {@link GPUTexture}.
4977
+ */
4978
+ destroy(): undefined;
4979
+ /**
4980
+ * The width of this {@link GPUTexture}.
4981
+ */
4982
+ readonly width: GPUIntegerCoordinateOut;
4983
+ /**
4984
+ * The height of this {@link GPUTexture}.
4985
+ */
4986
+ readonly height: GPUIntegerCoordinateOut;
4987
+ /**
4988
+ * The depth or layer count of this {@link GPUTexture}.
4989
+ */
4990
+ readonly depthOrArrayLayers: GPUIntegerCoordinateOut;
4991
+ /**
4992
+ * The number of mip levels of this {@link GPUTexture}.
4993
+ */
4994
+ readonly mipLevelCount: GPUIntegerCoordinateOut;
4995
+ /**
4996
+ * The number of sample count of this {@link GPUTexture}.
4997
+ */
4998
+ readonly sampleCount: GPUSize32Out;
4999
+ /**
5000
+ * The dimension of the set of texel for each of this {@link GPUTexture}'s subresources.
5001
+ */
5002
+ readonly dimension: GPUTextureDimension;
5003
+ /**
5004
+ * The format of this {@link GPUTexture}.
5005
+ */
5006
+ readonly format: GPUTextureFormat;
5007
+ /**
5008
+ * The allowed usages for this {@link GPUTexture}.
5009
+ */
5010
+ readonly usage: GPUFlagsConstant;
5011
+ /**
5012
+ * On devices without "core-features-and-limits", views created from this
5013
+ * texture must have this as their dimension.
5014
+ *
5015
+ * On devices with "core-features-and-limits", this is undefined, and there is
5016
+ * no such restriction.
5017
+ *
5018
+ * @todo Temporarily optional until all browsers have implemented it.
5019
+ * It is safe to access on any browser, as it will just (correctly) return
5020
+ * `undefined` if not implemented. Note, depending on the device, `undefined`
5021
+ * is a valid value even in browsers that implement this attribute. (So be
5022
+ * careful if using the non-null assertion operator `!` on this.)
5023
+ */
5024
+ readonly textureBindingViewDimension?:
5025
+ | GPUTextureViewDimension
5026
+ | undefined;
5027
+ }
5028
+
5029
+ var GPUTexture: {
5030
+ prototype: GPUTexture;
5031
+ new (): never;
5032
+ };
5033
+
5034
+ interface GPUTextureView
5035
+ extends GPUObjectBase {
5036
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
5037
+ readonly __brand: "GPUTextureView";
5038
+ }
5039
+
5040
+ var GPUTextureView: {
5041
+ prototype: GPUTextureView;
5042
+ new (): never;
5043
+ };
5044
+
5045
+ interface GPUUncapturedErrorEvent
5046
+ extends Event {
5047
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
5048
+ readonly __brand: "GPUUncapturedErrorEvent";
5049
+ /**
5050
+ * A slot-backed attribute holding an object representing the error that was uncaptured.
5051
+ * This has the same type as errors returned by {@link GPUDevice#popErrorScope}.
5052
+ */
5053
+ readonly error: GPUError;
5054
+ }
5055
+
5056
+ var GPUUncapturedErrorEvent: {
5057
+ prototype: GPUUncapturedErrorEvent;
5058
+ new (
5059
+ type: string,
5060
+ gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
5061
+ ): GPUUncapturedErrorEvent;
5062
+ };
5063
+
5064
+ interface GPUValidationError
5065
+ extends GPUError {
5066
+ /** @internal Workaround for [nominal typing](https://github.com/microsoft/TypeScript/pull/33038). */
5067
+ readonly __brand: "GPUValidationError";
5068
+ }
5069
+
5070
+ var GPUValidationError: {
5071
+ prototype: GPUValidationError;
5072
+ new (
5073
+ message: string
5074
+ ): GPUValidationError;
5075
+ };
5076
+
5077
+ type WGSLLanguageFeatures =
5078
+ ReadonlySet<string>;
5079
+
5080
+ interface Navigator
5081
+ extends NavigatorGPU {}
5082
+
5083
+ interface WorkerNavigator
5084
+ extends NavigatorGPU {}
5085
+
5086
+ interface GPUBufferUsage {
5087
+ readonly MAP_READ: GPUFlagsConstant;
5088
+ readonly MAP_WRITE: GPUFlagsConstant;
5089
+ readonly COPY_SRC: GPUFlagsConstant;
5090
+ readonly COPY_DST: GPUFlagsConstant;
5091
+ readonly INDEX: GPUFlagsConstant;
5092
+ readonly VERTEX: GPUFlagsConstant;
5093
+ readonly UNIFORM: GPUFlagsConstant;
5094
+ readonly STORAGE: GPUFlagsConstant;
5095
+ readonly INDIRECT: GPUFlagsConstant;
5096
+ readonly QUERY_RESOLVE: GPUFlagsConstant;
5097
+ }
5098
+
5099
+ var GPUBufferUsage: GPUBufferUsage;
5100
+
5101
+ interface GPUColorWrite {
5102
+ readonly RED: GPUFlagsConstant;
5103
+ readonly GREEN: GPUFlagsConstant;
5104
+ readonly BLUE: GPUFlagsConstant;
5105
+ readonly ALPHA: GPUFlagsConstant;
5106
+ readonly ALL: GPUFlagsConstant;
5107
+ }
5108
+
5109
+ var GPUColorWrite: GPUColorWrite;
5110
+
5111
+ interface GPUMapMode {
5112
+ readonly READ: GPUFlagsConstant;
5113
+ readonly WRITE: GPUFlagsConstant;
5114
+ }
5115
+
5116
+ var GPUMapMode: GPUMapMode;
5117
+
5118
+ interface GPUShaderStage {
5119
+ readonly VERTEX: GPUFlagsConstant;
5120
+ readonly FRAGMENT: GPUFlagsConstant;
5121
+ readonly COMPUTE: GPUFlagsConstant;
5122
+ }
5123
+
5124
+ var GPUShaderStage: GPUShaderStage;
5125
+
5126
+ interface GPUTextureUsage {
5127
+ readonly COPY_SRC: GPUFlagsConstant;
5128
+ readonly COPY_DST: GPUFlagsConstant;
5129
+ readonly TEXTURE_BINDING: GPUFlagsConstant;
5130
+ readonly STORAGE_BINDING: GPUFlagsConstant;
5131
+ readonly RENDER_ATTACHMENT: GPUFlagsConstant;
5132
+ readonly TRANSIENT_ATTACHMENT: GPUFlagsConstant;
5133
+ }
5134
+
5135
+ var GPUTextureUsage: GPUTextureUsage;
5136
+
5137
+ // ===== END WEBGPU TYPES =====
5138
+
1688
5139
  // Runtime global - the main viji object
1689
5140
  const viji: VijiAPI;
1690
5141