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