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