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