@zephyr3d/device 0.2.2 → 0.2.4

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.
package/dist/gpuobject.js CHANGED
@@ -1754,6 +1754,48 @@ const vertexAttribFormatMap = {
1754
1754
  'u32',
1755
1755
  4
1756
1756
  ],
1757
+ blendweights_f16x1: [
1758
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1759
+ PBPrimitiveType.F16,
1760
+ 2,
1761
+ 'f16',
1762
+ 1
1763
+ ],
1764
+ blendweights_f32x1: [
1765
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1766
+ PBPrimitiveType.F32,
1767
+ 4,
1768
+ 'f32',
1769
+ 1
1770
+ ],
1771
+ blendweights_f16x2: [
1772
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1773
+ PBPrimitiveType.F16VEC2,
1774
+ 4,
1775
+ 'f16',
1776
+ 2
1777
+ ],
1778
+ blendweights_f32x2: [
1779
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1780
+ PBPrimitiveType.F32VEC2,
1781
+ 8,
1782
+ 'f32',
1783
+ 2
1784
+ ],
1785
+ blendweights_f16x3: [
1786
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1787
+ PBPrimitiveType.F16VEC3,
1788
+ 6,
1789
+ 'f16',
1790
+ 3
1791
+ ],
1792
+ blendweights_f32x3: [
1793
+ VERTEX_ATTRIB_BLEND_WEIGHT,
1794
+ PBPrimitiveType.F32VEC3,
1795
+ 12,
1796
+ 'f32',
1797
+ 3
1798
+ ],
1757
1799
  blendweights_f16x4: [
1758
1800
  VERTEX_ATTRIB_BLEND_WEIGHT,
1759
1801
  PBPrimitiveType.F16VEC4,
@@ -1768,6 +1810,90 @@ const vertexAttribFormatMap = {
1768
1810
  'f32',
1769
1811
  4
1770
1812
  ],
1813
+ blendindices_u16x1: [
1814
+ VERTEX_ATTRIB_BLEND_INDICES,
1815
+ PBPrimitiveType.U16,
1816
+ 2,
1817
+ 'u16',
1818
+ 1
1819
+ ],
1820
+ blendindices_f16x1: [
1821
+ VERTEX_ATTRIB_BLEND_INDICES,
1822
+ PBPrimitiveType.F16,
1823
+ 2,
1824
+ 'f16',
1825
+ 1
1826
+ ],
1827
+ blendindices_f32x1: [
1828
+ VERTEX_ATTRIB_BLEND_INDICES,
1829
+ PBPrimitiveType.F32,
1830
+ 4,
1831
+ 'f32',
1832
+ 1
1833
+ ],
1834
+ blendindices_u32x1: [
1835
+ VERTEX_ATTRIB_BLEND_INDICES,
1836
+ PBPrimitiveType.U32,
1837
+ 4,
1838
+ 'u32',
1839
+ 1
1840
+ ],
1841
+ blendindices_u16x2: [
1842
+ VERTEX_ATTRIB_BLEND_INDICES,
1843
+ PBPrimitiveType.U16VEC2,
1844
+ 4,
1845
+ 'u16',
1846
+ 2
1847
+ ],
1848
+ blendindices_f16x2: [
1849
+ VERTEX_ATTRIB_BLEND_INDICES,
1850
+ PBPrimitiveType.F16VEC2,
1851
+ 4,
1852
+ 'f16',
1853
+ 2
1854
+ ],
1855
+ blendindices_f32x2: [
1856
+ VERTEX_ATTRIB_BLEND_INDICES,
1857
+ PBPrimitiveType.F32VEC2,
1858
+ 8,
1859
+ 'f32',
1860
+ 2
1861
+ ],
1862
+ blendindices_u32x2: [
1863
+ VERTEX_ATTRIB_BLEND_INDICES,
1864
+ PBPrimitiveType.U32VEC2,
1865
+ 8,
1866
+ 'u32',
1867
+ 2
1868
+ ],
1869
+ blendindices_u16x3: [
1870
+ VERTEX_ATTRIB_BLEND_INDICES,
1871
+ PBPrimitiveType.U16VEC3,
1872
+ 6,
1873
+ 'u16',
1874
+ 3
1875
+ ],
1876
+ blendindices_f16x3: [
1877
+ VERTEX_ATTRIB_BLEND_INDICES,
1878
+ PBPrimitiveType.F16VEC3,
1879
+ 6,
1880
+ 'f16',
1881
+ 3
1882
+ ],
1883
+ blendindices_f32x3: [
1884
+ VERTEX_ATTRIB_BLEND_INDICES,
1885
+ PBPrimitiveType.F32VEC3,
1886
+ 12,
1887
+ 'f32',
1888
+ 3
1889
+ ],
1890
+ blendindices_u32x3: [
1891
+ VERTEX_ATTRIB_BLEND_INDICES,
1892
+ PBPrimitiveType.U32VEC3,
1893
+ 12,
1894
+ 'u32',
1895
+ 3
1896
+ ],
1771
1897
  blendindices_u16x4: [
1772
1898
  VERTEX_ATTRIB_BLEND_INDICES,
1773
1899
  PBPrimitiveType.U16VEC4,
@@ -1846,22 +1972,28 @@ var GPUResourceUsageFlags;
1846
1972
  })(GPUResourceUsageFlags || (GPUResourceUsageFlags = {}));
1847
1973
  /**
1848
1974
  * Get vertex attribute index by semantic
1849
- * @internal
1975
+ * @public
1850
1976
  */ function getVertexAttribByName(name) {
1851
1977
  return vertexAttribNameMap[name];
1852
1978
  }
1853
1979
  /**
1854
1980
  * Get vertex semantic by attribute index
1855
- * @internal
1981
+ * @public
1856
1982
  */ function getVertexAttribName(attrib) {
1857
1983
  return vertexAttribNameRevMap[attrib];
1858
1984
  }
1859
1985
  /**
1860
1986
  * Get byte size of specified vertex format
1861
- * @internal
1987
+ * @public
1862
1988
  */ function getVertexFormatSize(fmt) {
1863
1989
  return vertexAttribFormatMap[fmt][2];
1864
1990
  }
1991
+ /**
1992
+ * Get number of components of specified vertex format
1993
+ * @public
1994
+ */ function getVertexFormatComponentCount(fmt) {
1995
+ return vertexAttribFormatMap[fmt][4];
1996
+ }
1865
1997
  /**
1866
1998
  * Get vertex format by semantic and component type and component count
1867
1999
  * @param semantic - The vertex semantic
@@ -2043,5 +2175,5 @@ var GPUResourceUsageFlags;
2043
2175
  }
2044
2176
  }
2045
2177
 
2046
- export { GPUResourceUsageFlags, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, genDefaultName, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatSize, makeVertexBufferType, semanticList, semanticToAttrib };
2178
+ export { GPUResourceUsageFlags, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, genDefaultName, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, makeVertexBufferType, semanticList, semanticToAttrib };
2047
2179
  //# sourceMappingURL=gpuobject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gpuobject.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TypedArray, IEventTarget, CubeFace, VectorBase, Vector4 } from '@zephyr3d/base';
1
+ import { TypedArray, IEventTarget, CubeFace, VectorBase, MaybeArray, Vector4 } from '@zephyr3d/base';
2
2
 
3
3
  /**
4
4
  * Struct layout types
@@ -599,7 +599,7 @@ type TextureImageElement = ImageBitmap | HTMLCanvasElement;
599
599
  * The vertex format types
600
600
  * @public
601
601
  */
602
- type VertexAttribFormat = 'position_u8normx2' | 'position_u8normx4' | 'position_i8normx2' | 'position_i8normx4' | 'position_u16x2' | 'position_u16x4' | 'position_i16x2' | 'position_i16x4' | 'position_u16normx2' | 'position_u16normx4' | 'position_i16normx2' | 'position_i16normx4' | 'position_f16x2' | 'position_f16x4' | 'position_f32' | 'position_f32x2' | 'position_f32x3' | 'position_f32x4' | 'position_i32' | 'position_i32x2' | 'position_i32x3' | 'position_i32x4' | 'position_u32' | 'position_u32x2' | 'position_u32x3' | 'position_u32x4' | 'normal_f16x4' | 'normal_f32x3' | 'normal_f32x4' | 'diffuse_u8normx4' | 'diffuse_u16x4' | 'diffuse_u16normx4' | 'diffuse_f16x4' | 'diffuse_f32x3' | 'diffuse_f32x4' | 'diffuse_u32x3' | 'diffuse_u32x4' | 'tangent_f16x4' | 'tangent_f32x3' | 'tangent_f32x4' | 'tex0_u8normx2' | 'tex0_u8normx4' | 'tex0_i8normx2' | 'tex0_i8normx4' | 'tex0_u16x2' | 'tex0_u16x4' | 'tex0_i16x2' | 'tex0_i16x4' | 'tex0_u16normx2' | 'tex0_u16normx4' | 'tex0_i16normx2' | 'tex0_i16normx4' | 'tex0_f16x2' | 'tex0_f16x4' | 'tex0_f32' | 'tex0_f32x2' | 'tex0_f32x3' | 'tex0_f32x4' | 'tex0_i32' | 'tex0_i32x2' | 'tex0_i32x3' | 'tex0_i32x4' | 'tex0_u32' | 'tex0_u32x2' | 'tex0_u32x3' | 'tex0_u32x4' | 'tex1_u8normx2' | 'tex1_u8normx4' | 'tex1_i8normx2' | 'tex1_i8normx4' | 'tex1_u16x2' | 'tex1_u16x4' | 'tex1_i16x2' | 'tex1_i16x4' | 'tex1_u16normx2' | 'tex1_u16normx4' | 'tex1_i16normx2' | 'tex1_i16normx4' | 'tex1_f16x2' | 'tex1_f16x4' | 'tex1_f32' | 'tex1_f32x2' | 'tex1_f32x3' | 'tex1_f32x4' | 'tex1_i32' | 'tex1_i32x2' | 'tex1_i32x3' | 'tex1_i32x4' | 'tex1_u32' | 'tex1_u32x2' | 'tex1_u32x3' | 'tex1_u32x4' | 'tex2_u8normx2' | 'tex2_u8normx4' | 'tex2_i8normx2' | 'tex2_i8normx4' | 'tex2_u16x2' | 'tex2_u16x4' | 'tex2_i16x2' | 'tex2_i16x4' | 'tex2_u16normx2' | 'tex2_u16normx4' | 'tex2_i16normx2' | 'tex2_i16normx4' | 'tex2_f16x2' | 'tex2_f16x4' | 'tex2_f32' | 'tex2_f32x2' | 'tex2_f32x3' | 'tex2_f32x4' | 'tex2_i32' | 'tex2_i32x2' | 'tex2_i32x3' | 'tex2_i32x4' | 'tex2_u32' | 'tex2_u32x2' | 'tex2_u32x3' | 'tex2_u32x4' | 'tex3_u8normx2' | 'tex3_u8normx4' | 'tex3_i8normx2' | 'tex3_i8normx4' | 'tex3_u16x2' | 'tex3_u16x4' | 'tex3_i16x2' | 'tex3_i16x4' | 'tex3_u16normx2' | 'tex3_u16normx4' | 'tex3_i16normx2' | 'tex3_i16normx4' | 'tex3_f16x2' | 'tex3_f16x4' | 'tex3_f32' | 'tex3_f32x2' | 'tex3_f32x3' | 'tex3_f32x4' | 'tex3_i32' | 'tex3_i32x2' | 'tex3_i32x3' | 'tex3_i32x4' | 'tex3_u32' | 'tex3_u32x2' | 'tex3_u32x3' | 'tex3_u32x4' | 'tex4_u8normx2' | 'tex4_u8normx4' | 'tex4_i8normx2' | 'tex4_i8normx4' | 'tex4_u16x2' | 'tex4_u16x4' | 'tex4_i16x2' | 'tex4_i16x4' | 'tex4_u16normx2' | 'tex4_u16normx4' | 'tex4_i16normx2' | 'tex4_i16normx4' | 'tex4_f16x2' | 'tex4_f16x4' | 'tex4_f32' | 'tex4_f32x2' | 'tex4_f32x3' | 'tex4_f32x4' | 'tex4_i32' | 'tex4_i32x2' | 'tex4_i32x3' | 'tex4_i32x4' | 'tex4_u32' | 'tex4_u32x2' | 'tex4_u32x3' | 'tex4_u32x4' | 'tex5_u8normx2' | 'tex5_u8normx4' | 'tex5_i8normx2' | 'tex5_i8normx4' | 'tex5_u16x2' | 'tex5_u16x4' | 'tex5_i16x2' | 'tex5_i16x4' | 'tex5_u16normx2' | 'tex5_u16normx4' | 'tex5_i16normx2' | 'tex5_i16normx4' | 'tex5_f16x2' | 'tex5_f16x4' | 'tex5_f32' | 'tex5_f32x2' | 'tex5_f32x3' | 'tex5_f32x4' | 'tex5_i32' | 'tex5_i32x2' | 'tex5_i32x3' | 'tex5_i32x4' | 'tex5_u32' | 'tex5_u32x2' | 'tex5_u32x3' | 'tex5_u32x4' | 'tex6_u8normx2' | 'tex6_u8normx4' | 'tex6_i8normx2' | 'tex6_i8normx4' | 'tex6_u16x2' | 'tex6_u16x4' | 'tex6_i16x2' | 'tex6_i16x4' | 'tex6_u16normx2' | 'tex6_u16normx4' | 'tex6_i16normx2' | 'tex6_i16normx4' | 'tex6_f16x2' | 'tex6_f16x4' | 'tex6_f32' | 'tex6_f32x2' | 'tex6_f32x3' | 'tex6_f32x4' | 'tex6_i32' | 'tex6_i32x2' | 'tex6_i32x3' | 'tex6_i32x4' | 'tex6_u32' | 'tex6_u32x2' | 'tex6_u32x3' | 'tex6_u32x4' | 'tex7_u8normx2' | 'tex7_u8normx4' | 'tex7_i8normx2' | 'tex7_i8normx4' | 'tex7_u16x2' | 'tex7_u16x4' | 'tex7_i16x2' | 'tex7_i16x4' | 'tex7_u16normx2' | 'tex7_u16normx4' | 'tex7_i16normx2' | 'tex7_i16normx4' | 'tex7_f16x2' | 'tex7_f16x4' | 'tex7_f32' | 'tex7_f32x2' | 'tex7_f32x3' | 'tex7_f32x4' | 'tex7_i32' | 'tex7_i32x2' | 'tex7_i32x3' | 'tex7_i32x4' | 'tex7_u32' | 'tex7_u32x2' | 'tex7_u32x3' | 'tex7_u32x4' | 'blendweights_f16x4' | 'blendweights_f32x4' | 'blendindices_u16x4' | 'blendindices_f16x4' | 'blendindices_f32x4' | 'blendindices_u32x4';
602
+ type VertexAttribFormat = 'position_u8normx2' | 'position_u8normx4' | 'position_i8normx2' | 'position_i8normx4' | 'position_u16x2' | 'position_u16x4' | 'position_i16x2' | 'position_i16x4' | 'position_u16normx2' | 'position_u16normx4' | 'position_i16normx2' | 'position_i16normx4' | 'position_f16x2' | 'position_f16x4' | 'position_f32' | 'position_f32x2' | 'position_f32x3' | 'position_f32x4' | 'position_i32' | 'position_i32x2' | 'position_i32x3' | 'position_i32x4' | 'position_u32' | 'position_u32x2' | 'position_u32x3' | 'position_u32x4' | 'normal_f16x4' | 'normal_f32x3' | 'normal_f32x4' | 'diffuse_u8normx4' | 'diffuse_u16x4' | 'diffuse_u16normx4' | 'diffuse_f16x4' | 'diffuse_f32x3' | 'diffuse_f32x4' | 'diffuse_u32x3' | 'diffuse_u32x4' | 'tangent_f16x4' | 'tangent_f32x3' | 'tangent_f32x4' | 'tex0_u8normx2' | 'tex0_u8normx4' | 'tex0_i8normx2' | 'tex0_i8normx4' | 'tex0_u16x2' | 'tex0_u16x4' | 'tex0_i16x2' | 'tex0_i16x4' | 'tex0_u16normx2' | 'tex0_u16normx4' | 'tex0_i16normx2' | 'tex0_i16normx4' | 'tex0_f16x2' | 'tex0_f16x4' | 'tex0_f32' | 'tex0_f32x2' | 'tex0_f32x3' | 'tex0_f32x4' | 'tex0_i32' | 'tex0_i32x2' | 'tex0_i32x3' | 'tex0_i32x4' | 'tex0_u32' | 'tex0_u32x2' | 'tex0_u32x3' | 'tex0_u32x4' | 'tex1_u8normx2' | 'tex1_u8normx4' | 'tex1_i8normx2' | 'tex1_i8normx4' | 'tex1_u16x2' | 'tex1_u16x4' | 'tex1_i16x2' | 'tex1_i16x4' | 'tex1_u16normx2' | 'tex1_u16normx4' | 'tex1_i16normx2' | 'tex1_i16normx4' | 'tex1_f16x2' | 'tex1_f16x4' | 'tex1_f32' | 'tex1_f32x2' | 'tex1_f32x3' | 'tex1_f32x4' | 'tex1_i32' | 'tex1_i32x2' | 'tex1_i32x3' | 'tex1_i32x4' | 'tex1_u32' | 'tex1_u32x2' | 'tex1_u32x3' | 'tex1_u32x4' | 'tex2_u8normx2' | 'tex2_u8normx4' | 'tex2_i8normx2' | 'tex2_i8normx4' | 'tex2_u16x2' | 'tex2_u16x4' | 'tex2_i16x2' | 'tex2_i16x4' | 'tex2_u16normx2' | 'tex2_u16normx4' | 'tex2_i16normx2' | 'tex2_i16normx4' | 'tex2_f16x2' | 'tex2_f16x4' | 'tex2_f32' | 'tex2_f32x2' | 'tex2_f32x3' | 'tex2_f32x4' | 'tex2_i32' | 'tex2_i32x2' | 'tex2_i32x3' | 'tex2_i32x4' | 'tex2_u32' | 'tex2_u32x2' | 'tex2_u32x3' | 'tex2_u32x4' | 'tex3_u8normx2' | 'tex3_u8normx4' | 'tex3_i8normx2' | 'tex3_i8normx4' | 'tex3_u16x2' | 'tex3_u16x4' | 'tex3_i16x2' | 'tex3_i16x4' | 'tex3_u16normx2' | 'tex3_u16normx4' | 'tex3_i16normx2' | 'tex3_i16normx4' | 'tex3_f16x2' | 'tex3_f16x4' | 'tex3_f32' | 'tex3_f32x2' | 'tex3_f32x3' | 'tex3_f32x4' | 'tex3_i32' | 'tex3_i32x2' | 'tex3_i32x3' | 'tex3_i32x4' | 'tex3_u32' | 'tex3_u32x2' | 'tex3_u32x3' | 'tex3_u32x4' | 'tex4_u8normx2' | 'tex4_u8normx4' | 'tex4_i8normx2' | 'tex4_i8normx4' | 'tex4_u16x2' | 'tex4_u16x4' | 'tex4_i16x2' | 'tex4_i16x4' | 'tex4_u16normx2' | 'tex4_u16normx4' | 'tex4_i16normx2' | 'tex4_i16normx4' | 'tex4_f16x2' | 'tex4_f16x4' | 'tex4_f32' | 'tex4_f32x2' | 'tex4_f32x3' | 'tex4_f32x4' | 'tex4_i32' | 'tex4_i32x2' | 'tex4_i32x3' | 'tex4_i32x4' | 'tex4_u32' | 'tex4_u32x2' | 'tex4_u32x3' | 'tex4_u32x4' | 'tex5_u8normx2' | 'tex5_u8normx4' | 'tex5_i8normx2' | 'tex5_i8normx4' | 'tex5_u16x2' | 'tex5_u16x4' | 'tex5_i16x2' | 'tex5_i16x4' | 'tex5_u16normx2' | 'tex5_u16normx4' | 'tex5_i16normx2' | 'tex5_i16normx4' | 'tex5_f16x2' | 'tex5_f16x4' | 'tex5_f32' | 'tex5_f32x2' | 'tex5_f32x3' | 'tex5_f32x4' | 'tex5_i32' | 'tex5_i32x2' | 'tex5_i32x3' | 'tex5_i32x4' | 'tex5_u32' | 'tex5_u32x2' | 'tex5_u32x3' | 'tex5_u32x4' | 'tex6_u8normx2' | 'tex6_u8normx4' | 'tex6_i8normx2' | 'tex6_i8normx4' | 'tex6_u16x2' | 'tex6_u16x4' | 'tex6_i16x2' | 'tex6_i16x4' | 'tex6_u16normx2' | 'tex6_u16normx4' | 'tex6_i16normx2' | 'tex6_i16normx4' | 'tex6_f16x2' | 'tex6_f16x4' | 'tex6_f32' | 'tex6_f32x2' | 'tex6_f32x3' | 'tex6_f32x4' | 'tex6_i32' | 'tex6_i32x2' | 'tex6_i32x3' | 'tex6_i32x4' | 'tex6_u32' | 'tex6_u32x2' | 'tex6_u32x3' | 'tex6_u32x4' | 'tex7_u8normx2' | 'tex7_u8normx4' | 'tex7_i8normx2' | 'tex7_i8normx4' | 'tex7_u16x2' | 'tex7_u16x4' | 'tex7_i16x2' | 'tex7_i16x4' | 'tex7_u16normx2' | 'tex7_u16normx4' | 'tex7_i16normx2' | 'tex7_i16normx4' | 'tex7_f16x2' | 'tex7_f16x4' | 'tex7_f32' | 'tex7_f32x2' | 'tex7_f32x3' | 'tex7_f32x4' | 'tex7_i32' | 'tex7_i32x2' | 'tex7_i32x3' | 'tex7_i32x4' | 'tex7_u32' | 'tex7_u32x2' | 'tex7_u32x3' | 'tex7_u32x4' | 'blendweights_f16x1' | 'blendweights_f32x1' | 'blendweights_f16x2' | 'blendweights_f32x2' | 'blendweights_f16x3' | 'blendweights_f32x3' | 'blendweights_f16x4' | 'blendweights_f32x4' | 'blendindices_f16x1' | 'blendindices_u16x1' | 'blendindices_f32x1' | 'blendindices_u32x1' | 'blendindices_f16x2' | 'blendindices_u16x2' | 'blendindices_f32x2' | 'blendindices_u32x2' | 'blendindices_f16x3' | 'blendindices_u16x3' | 'blendindices_f32x3' | 'blendindices_u32x3' | 'blendindices_f16x4' | 'blendindices_u16x4' | 'blendindices_f32x4' | 'blendindices_u32x4';
603
603
  /**
604
604
  * The semantic type of vertex
605
605
  * @public
@@ -688,6 +688,26 @@ declare enum GPUResourceUsageFlags {
688
688
  DYNAMIC = 2048,
689
689
  MANAGED = 4096
690
690
  }
691
+ /**
692
+ * Get vertex attribute index by semantic
693
+ * @public
694
+ */
695
+ declare function getVertexAttribByName(name: VertexSemantic): number;
696
+ /**
697
+ * Get vertex semantic by attribute index
698
+ * @public
699
+ */
700
+ declare function getVertexAttribName(attrib: number): VertexSemantic;
701
+ /**
702
+ * Get byte size of specified vertex format
703
+ * @public
704
+ */
705
+ declare function getVertexFormatSize(fmt: VertexAttribFormat): number;
706
+ /**
707
+ * Get number of components of specified vertex format
708
+ * @public
709
+ */
710
+ declare function getVertexFormatComponentCount(fmt: VertexAttribFormat): number;
691
711
  /**
692
712
  * Get vertex format by semantic and component type and component count
693
713
  * @param semantic - The vertex semantic
@@ -889,7 +909,7 @@ interface StorageTextureBindingLayout {
889
909
  /** The texture format */
890
910
  format: TextureFormat;
891
911
  /** View dimension */
892
- viewDimension: '1d' | '2d';
912
+ viewDimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d';
893
913
  }
894
914
  /**
895
915
  * Binding layout of an external texture
@@ -1021,6 +1041,7 @@ interface BaseTexture<T = unknown> extends GPUObject<T> {
1021
1041
  readonly depth: number;
1022
1042
  readonly format: TextureFormat;
1023
1043
  readonly mipLevelCount: number;
1044
+ readonly memCost: number;
1024
1045
  samplerOptions: SamplerOptions;
1025
1046
  init(): void;
1026
1047
  generateMipmaps(): void;
@@ -1135,11 +1156,17 @@ interface FrameBuffer<T = unknown> extends GPUObject<T> {
1135
1156
  getSampleCount(): number;
1136
1157
  getHash(): string;
1137
1158
  setColorAttachmentCubeFace(index: number, face: CubeFace): void;
1159
+ getColorAttachmentCubeFace(index: number): CubeFace;
1138
1160
  setColorAttachmentMipLevel(index: number, level: number): void;
1161
+ getColorAttachmentMipLevel(index: number): number;
1139
1162
  setColorAttachmentLayer(index: number, layer: number): void;
1163
+ getColorAttachmentLayer(index: number): number;
1140
1164
  setColorAttachmentGenerateMipmaps(index: number, generateMipmaps: boolean): void;
1165
+ getColorAttachmentGenerateMipmaps(index: number): boolean;
1141
1166
  setDepthAttachmentCubeFace(face: CubeFace): void;
1167
+ getDepthAttachmentCubeFace(): CubeFace;
1142
1168
  setDepthAttachmentLayer(layer: number): void;
1169
+ getDepthAttachmentLayer(): number;
1143
1170
  getColorAttachments(): BaseTexture[];
1144
1171
  getDepthAttachment(): BaseTexture;
1145
1172
  bind(): boolean;
@@ -2688,6 +2715,102 @@ interface RenderStateSet {
2688
2715
  apply(force?: boolean): void;
2689
2716
  }
2690
2717
 
2718
+ /**
2719
+ * ObjectPool class is responsible for managing and reusing textures and framebuffers.
2720
+ * @public
2721
+ */
2722
+ declare class Pool {
2723
+ /**
2724
+ * Creates an instance of Pool class
2725
+ * @param device - Rendering device
2726
+ */
2727
+ constructor(device: AbstractDevice, memCostThreshold?: number);
2728
+ autoRelease(): void;
2729
+ /**
2730
+ * Fetch a temporal 2D texture from the object pool.
2731
+ * @param autoRelease - Whether the texture should be automatically released at the next frame.
2732
+ * @param format - The format of the texture.
2733
+ * @param width - The width of the texture.
2734
+ * @param height - The height of the texture.
2735
+ * @param mipmapping - Whether this texture support mipmapping
2736
+ * @returns The fetched Texture2D object.
2737
+ */
2738
+ fetchTemporalTexture2D(autoRelease: boolean, format: TextureFormat, width: number, height: number, mipmapping?: boolean): Texture2D;
2739
+ /**
2740
+ * Fetch a temporal 2D array texture from the object pool.
2741
+ * @param autoRelease - Whether the texture should be automatically released at the next frame.
2742
+ * @param format - Format of the texture.
2743
+ * @param width - Width of the texture.
2744
+ * @param height - Height of the texture.
2745
+ * @param numLayers - Layer count of the texture
2746
+ * @param mipmapping - Whether this texture support mipmapping
2747
+ * @returns The fetched Texture2DArray object.
2748
+ */
2749
+ fetchTemporalTexture2DArray(autoRelease: boolean, format: TextureFormat, width: number, height: number, numLayers: number, mipmapping?: boolean): Texture2DArray;
2750
+ /**
2751
+ * Fetch a temporal Cube texture from the object pool.
2752
+ * @param autoRelease - Whether the texture should be automatically released at the next frame.
2753
+ * @param format - Format of the texture.
2754
+ * @param size - size of the texture.
2755
+ * @param mipmapping - Whether this texture support mipmapping
2756
+ * @returns The fetched TextureCube object.
2757
+ */
2758
+ fetchTemporalTextureCube(autoRelease: boolean, format: TextureFormat, size: number, mipmapping?: boolean): TextureCube;
2759
+ /**
2760
+ * Creates a temporal framebuffer from the object pool.
2761
+ * @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
2762
+ * @param width - Width of the framebuffer
2763
+ * @param height - Height of the framebuffer
2764
+ * @param colorAttachments - Array of color attachments or texture format of the framebuffer.
2765
+ * @param depthAttachment - Depth attachment or texture format of the framebuffer.
2766
+ * @param mipmapping - Whether mipmapping should be enabled when creating color attachment textures, default is false.
2767
+ * @param sampleCount - The sample count for the framebuffer, default is 1.
2768
+ * @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
2769
+ * @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0
2770
+ * @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0
2771
+ * @param attachmentLayer - The texture layer to which the color attachment will render, default is 0
2772
+ * @returns The fetched FrameBuffer object.
2773
+ */
2774
+ fetchTemporalFramebuffer<T extends BaseTexture<unknown>>(autoRelease: boolean, width: number, height: number, colorTexOrFormat: MaybeArray<TextureFormat | T>, depthTexOrFormat?: TextureFormat | T, mipmapping?: boolean, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer;
2775
+ /**
2776
+ * Creates a temporal framebuffer from the object pool.
2777
+ * @param autoRelease - Whether the framebuffer should be automatically released at the next frame.
2778
+ * @param colorAttachments - Array of color attachments for the framebuffer.
2779
+ * @param depthAttachment - Depth attachment for the framebuffer.
2780
+ * @param sampleCount - The sample count for the framebuffer, default is 1.
2781
+ * @param ignoreDepthStencil - Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
2782
+ * @param attachmentMipLevel - The mipmap level to which the color attachment will render, default is 0.
2783
+ * @param attachmentCubeface - The cubemap face to which the color attachment will render, default is 0.
2784
+ * @param attachmentLayer - The texture layer to which the color attachment will render, default is 0.
2785
+ * @returns The fetched FrameBuffer object.
2786
+ */
2787
+ createTemporalFramebuffer(autoRelease: boolean, colorAttachments: BaseTexture[], depthAttachment?: BaseTexture, sampleCount?: number, ignoreDepthStencil?: boolean, attachmentMipLevel?: number, attachmentCubeface?: number, attachmentLayer?: number): FrameBuffer<unknown>;
2788
+ /**
2789
+ * Dispose a texture that is allocated from the object pool.
2790
+ * @param texture - The texture to dispose.
2791
+ */
2792
+ disposeTexture(texture: BaseTexture): void;
2793
+ /**
2794
+ * Release a texture back to the object pool.
2795
+ * @param texture - The texture to release.
2796
+ */
2797
+ releaseTexture(texture: BaseTexture): void;
2798
+ /**
2799
+ * Dispose a framebuffer that is allocated from the object pool.
2800
+ * @param fb - The framebuffer to dispose.
2801
+ */
2802
+ disposeFrameBuffer(fb: FrameBuffer): void;
2803
+ /**
2804
+ * Release a framebuffer back to the object pool.
2805
+ * @param fb - The framebuffer to release.
2806
+ */
2807
+ releaseFrameBuffer(fb: FrameBuffer): void;
2808
+ /**
2809
+ * Purge the object pool by disposing all free framebuffers and textures.
2810
+ */
2811
+ purge(): void;
2812
+ }
2813
+
2691
2814
  /**
2692
2815
  * The webgl context type
2693
2816
  * @public
@@ -2722,7 +2845,7 @@ type DataType = 'u8' | 'u8norm' | 'i8' | 'i8norm' | 'u16' | 'u16norm' | 'i16' |
2722
2845
  * Texture format type
2723
2846
  * @public
2724
2847
  */
2725
- type TextureFormat = 'unknown' | 'r8unorm' | 'r8snorm' | 'r16f' | 'r32f' | 'r8ui' | 'r8i' | 'r16ui' | 'r16i' | 'r32ui' | 'r32i' | 'rg8unorm' | 'rg8snorm' | 'rg16f' | 'rg32f' | 'rg8ui' | 'rg8i' | 'rg16ui' | 'rg16i' | 'rg32ui' | 'rg32i' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgba16f' | 'rgba32f' | 'rgba8ui' | 'rgba8i' | 'rgba16ui' | 'rgba16i' | 'rgba32ui' | 'rgba32i' | 'rg11b10uf' | 'd16' | 'd24' | 'd32f' | 'd24s8' | 'd32fs8' | 'dxt1' | 'dxt1-srgb' | 'dxt3' | 'dxt3-srgb' | 'dxt5' | 'dxt5-srgb';
2848
+ type TextureFormat = 'unknown' | 'r8unorm' | 'r8snorm' | 'r16f' | 'r32f' | 'r8ui' | 'r8i' | 'r16ui' | 'r16i' | 'r32ui' | 'r32i' | 'rg8unorm' | 'rg8snorm' | 'rg16f' | 'rg32f' | 'rg8ui' | 'rg8i' | 'rg16ui' | 'rg16i' | 'rg32ui' | 'rg32i' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'rgba8snorm' | 'bgra8unorm' | 'bgra8unorm-srgb' | 'rgba16f' | 'rgba32f' | 'rgba8ui' | 'rgba8i' | 'rgba16ui' | 'rgba16i' | 'rgba32ui' | 'rgba32i' | 'rg11b10uf' | 'd16' | 'd24' | 'd32f' | 'd24s8' | 'd32fs8' | 'dxt1' | 'dxt1-srgb' | 'dxt3' | 'dxt3-srgb' | 'dxt5' | 'dxt5-srgb' | 'bc4' | 'bc4-signed' | 'bc5' | 'bc5-signed' | 'bc7' | 'bc7-srgb' | 'bc6h' | 'bc6h-signed' | 'astc-4x4' | 'astc-4x4-srgb' | 'astc-5x4' | 'astc-5x4-srgb' | 'astc-5x5' | 'astc-5x5-srgb' | 'astc-6x5' | 'astc-6x5-srgb' | 'astc-6x6' | 'astc-6x6-srgb' | 'astc-8x5' | 'astc-8x5-srgb' | 'astc-8x6' | 'astc-8x6-srgb' | 'astc-8x8' | 'astc-8x8-srgb' | 'astc-10x5' | 'astc-10x5-srgb' | 'astc-10x6' | 'astc-10x6-srgb' | 'astc-10x8' | 'astc-10x8-srgb' | 'astc-10x10' | 'astc-10x10-srgb' | 'astc-12x10' | 'astc-12x10-srgb' | 'astc-12x12' | 'astc-12x12-srgb';
2726
2849
  /**
2727
2850
  * Converts a non-sRGB texture format to the corresponding sRGB texture format
2728
2851
  * @param format - The texture format to be converted
@@ -2990,6 +3113,12 @@ interface TextureCaps {
2990
3113
  npo2Repeating: boolean;
2991
3114
  /** True if device supports dxt1, dxt3, dxt5 texture format */
2992
3115
  supportS3TC: boolean;
3116
+ /** True if device supports bptc texture format */
3117
+ supportBPTC: boolean;
3118
+ /** True if device supports rgtc texture format */
3119
+ supportRGTC: boolean;
3120
+ /** True if device supports astc texture format */
3121
+ supportASTC: boolean;
2993
3122
  /** True if device supports dxt1_srgb, dxt3-srgb, dxt5-srgb texture format */
2994
3123
  supportS3TCSRGB: boolean;
2995
3124
  /** True if device supports depth texture */
@@ -3168,6 +3297,12 @@ type DeviceViewport = {
3168
3297
  * @public
3169
3298
  */
3170
3299
  interface AbstractDevice extends IEventTarget<DeviceEventMap> {
3300
+ /** Get pool object */
3301
+ pool: Pool;
3302
+ /** vSync */
3303
+ vSync: boolean;
3304
+ /** Get adapter information */
3305
+ getAdapterInfo(): any;
3171
3306
  /** Get sample count of current frame buffer */
3172
3307
  getFrameBufferSampleCount(): number;
3173
3308
  /** Returns true if device context is lost. */
@@ -3184,6 +3319,10 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
3184
3319
  getBackBufferHeight(): number;
3185
3320
  /** Get the device capabilities */
3186
3321
  getDeviceCaps(): DeviceCaps;
3322
+ /** Schedule next frame */
3323
+ nextFrame(callback: () => void): number;
3324
+ /** Cancel schedule next frame */
3325
+ cancelNextFrame(handle: number): any;
3187
3326
  /** Set font for drawText function */
3188
3327
  setFont(fontName: string): any;
3189
3328
  /**
@@ -3203,6 +3342,16 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
3203
3342
  clearFrameBuffer(clearColor: Vector4, clearDepth: number, clearStencil: number): any;
3204
3343
  /** Creates a render state set object */
3205
3344
  createRenderStateSet(): RenderStateSet;
3345
+ /** Creates a blending state object */
3346
+ createBlendingState(): BlendingState;
3347
+ /** Creates a color state object */
3348
+ createColorState(): ColorState;
3349
+ /** Creates a rasterizer state object */
3350
+ createRasterizerState(): RasterizerState;
3351
+ /** Creates a depth state object */
3352
+ createDepthState(): DepthState;
3353
+ /** Creates a stencil state object */
3354
+ createStencilState(): StencilState;
3206
3355
  /**
3207
3356
  * Creates a texture sampler object
3208
3357
  * @param options - The creation options
@@ -3285,6 +3434,30 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
3285
3434
  * @param el - The video element
3286
3435
  */
3287
3436
  createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
3437
+ /**
3438
+ * Copies a 2d texture to another texture.
3439
+ *
3440
+ * @remarks
3441
+ * The two textures must have the same size and format
3442
+ *
3443
+ * @param src - Texture that will be copied from.
3444
+ * @param srcLevel - Which mipmap level to be copied from.
3445
+ * @param dst - Texture that will be copied to.
3446
+ * @param dstLevel - Which mipmap level to be copied to.
3447
+ */
3448
+ copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): any;
3449
+ /**
3450
+ * Copies a color attachment of a framebuffer to a mipmap level of a texture.
3451
+ *
3452
+ * @remarks
3453
+ * The color attachment and the mipmap level must have the same size and format
3454
+ *
3455
+ * @param src - Framebuffer that will be copied from.
3456
+ * @param index - Color attachment index of the framebuffer.
3457
+ * @param dst - Texture that will be copied to.
3458
+ * @param level - Which mipmap level should be copied to.
3459
+ */
3460
+ copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): any;
3288
3461
  /**
3289
3462
  * Set wether to reverse the winding order
3290
3463
  *
@@ -3389,11 +3562,29 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
3389
3562
  /** Get current render states */
3390
3563
  getRenderStates(): RenderStateSet;
3391
3564
  /**
3392
- * Set current frame buffer
3565
+ * Sets the current framebuffer to the specified FrameBuffer object.
3393
3566
  *
3394
- * @param rt - The frame buffer
3567
+ * @param rt - The FrameBuffer object to set as the current framebuffer.
3395
3568
  */
3396
- setFramebuffer(rt: FrameBuffer): void;
3569
+ setFramebuffer(rt: FrameBuffer): any;
3570
+ /**
3571
+ * Sets the current framebuffer specifying complex color attachments, an optional depth attachment, MIP level, face, and sample count.
3572
+ *
3573
+ * @param color - An array of BaseTextures or objects containing a BaseTexture and optional properties. Each BaseTexture or object will serve as a color attachment.
3574
+ * - If an object is provided, it can specify:
3575
+ * - `texture`: The BaseTexture to use.
3576
+ * - `miplevel`: Optional MIP level for this specific texture. default is 0.
3577
+ * - `face`: Optional face index for cube map textures, specifying the cube face this texture is attached to. default is 0.
3578
+ * - `layer`: Optional layer index, useful for texture arrays. default is 0.
3579
+ * @param depth - Optional BaseTexture to serve as the depth attachment.
3580
+ * @param sampleCount - Optional sample count defining the number of samples for multisampling.
3581
+ */
3582
+ setFramebuffer(color: (BaseTexture | {
3583
+ texture: BaseTexture;
3584
+ miplevel?: number;
3585
+ face?: number;
3586
+ layer?: number;
3587
+ })[], depth?: BaseTexture, miplevel?: number, face?: number, sampleCount?: number): any;
3397
3588
  /** Get current frame buffer */
3398
3589
  getFramebuffer(): FrameBuffer;
3399
3590
  /**
@@ -3638,8 +3829,12 @@ declare abstract class BaseDevice {
3638
3829
  protected _backend: DeviceBackend;
3639
3830
  protected _beginFrameCounter: number;
3640
3831
  protected _programBuilder: ProgramBuilder;
3832
+ protected _pool: Pool;
3833
+ protected _temporalFramebuffer: boolean;
3834
+ protected _vSync: boolean;
3641
3835
  private _stateStack;
3642
3836
  constructor(cvs: HTMLCanvasElement, backend: DeviceBackend);
3837
+ abstract getAdapterInfo(): any;
3643
3838
  abstract getFrameBufferSampleCount(): number;
3644
3839
  abstract isContextLost(): boolean;
3645
3840
  abstract getScale(): number;
@@ -3652,6 +3847,11 @@ declare abstract class BaseDevice {
3652
3847
  abstract clearFrameBuffer(clearColor: Vector4, clearDepth: number, clearStencil: number): any;
3653
3848
  abstract createGPUTimer(): ITimer;
3654
3849
  abstract createRenderStateSet(): RenderStateSet;
3850
+ abstract createBlendingState(): BlendingState;
3851
+ abstract createColorState(): ColorState;
3852
+ abstract createRasterizerState(): RasterizerState;
3853
+ abstract createDepthState(): DepthState;
3854
+ abstract createStencilState(): StencilState;
3655
3855
  abstract createSampler(options: SamplerOptions): TextureSampler;
3656
3856
  abstract createTextureFromMipmapData<T extends BaseTexture>(data: TextureMipmapData, sRGB: boolean, options?: TextureCreationOptions): T;
3657
3857
  abstract createTexture2D(format: TextureFormat, width: number, height: number, options?: TextureCreationOptions): Texture2D;
@@ -3666,6 +3866,8 @@ declare abstract class BaseDevice {
3666
3866
  abstract createTextureVideo(el: HTMLVideoElement, samplerOptions?: SamplerOptions): TextureVideo;
3667
3867
  abstract reverseVertexWindingOrder(reverse: boolean): void;
3668
3868
  abstract isWindingOrderReversed(): boolean;
3869
+ abstract copyTexture2D(src: Texture2D, srcLevel: number, dst: Texture2D, dstLevel: number): any;
3870
+ abstract copyFramebufferToTexture2D(src: FrameBuffer, index: number, dst: Texture2D, level: number): any;
3669
3871
  abstract createGPUProgram(params: GPUProgramConstructParams): GPUProgram;
3670
3872
  abstract createBindGroup(layout: BindGroupLayout): BindGroup;
3671
3873
  abstract createBuffer(sizeInBytes: number, options: BufferCreationOptions): GPUDataBuffer;
@@ -3684,11 +3886,12 @@ declare abstract class BaseDevice {
3684
3886
  abstract getVertexLayout(): VertexLayout;
3685
3887
  abstract setRenderStates(renderStates: RenderStateSet): void;
3686
3888
  abstract getRenderStates(): RenderStateSet;
3687
- abstract setFramebuffer(rt: FrameBuffer): void;
3688
3889
  abstract getFramebuffer(): FrameBuffer;
3689
3890
  abstract setBindGroup(index: number, bindGroup: BindGroup, dynamicOffsets?: Iterable<number>): any;
3690
3891
  abstract getBindGroup(index: number): [BindGroup, Iterable<number>];
3691
3892
  abstract flush(): void;
3893
+ abstract nextFrame(callback: () => void): number;
3894
+ abstract cancelNextFrame(handle: number): any;
3692
3895
  abstract readPixels(index: number, x: number, y: number, w: number, h: number, buffer: TypedArray): Promise<void>;
3693
3896
  abstract readPixelsToBuffer(index: number, x: number, y: number, w: number, h: number, buffer: GPUDataBuffer): void;
3694
3897
  abstract beginCapture(): void;
@@ -3705,10 +3908,20 @@ declare abstract class BaseDevice {
3705
3908
  get isRendering(): boolean;
3706
3909
  get canvas(): HTMLCanvasElement;
3707
3910
  get type(): string;
3911
+ get vSync(): boolean;
3912
+ set vSync(val: boolean);
3913
+ get pool(): Pool;
3708
3914
  get runLoopFunction(): (device: AbstractDevice) => void;
3709
3915
  get programBuilder(): ProgramBuilder;
3710
3916
  setFont(fontName: string): void;
3711
3917
  drawText(text: string, x: number, y: number, color: string): void;
3918
+ setFramebuffer(rt: FrameBuffer): any;
3919
+ setFramebuffer(color: (BaseTexture | {
3920
+ texture: BaseTexture;
3921
+ miplevel?: number;
3922
+ face?: number;
3923
+ layer?: number;
3924
+ })[], depth?: BaseTexture, sampleCount?: number): any;
3712
3925
  disposeObject(obj: GPUObject, remove?: boolean): void;
3713
3926
  restoreObject(obj: GPUObject): Promise<void>;
3714
3927
  enableGPUTimeRecording(enable: boolean): void;
@@ -3736,6 +3949,7 @@ declare abstract class BaseDevice {
3736
3949
  updateVideoMemoryCost(delta: number): void;
3737
3950
  protected abstract onBeginFrame(): boolean;
3738
3951
  protected abstract onEndFrame(): void;
3952
+ protected abstract _setFramebuffer(fb: FrameBuffer): any;
3739
3953
  private _onresize;
3740
3954
  private _registerEventHandlers;
3741
3955
  private updateFrameInfo;
@@ -3963,4 +4177,4 @@ declare class StructuredBufferData {
3963
4177
  set(name: string, value: StructuredValue): void;
3964
4178
  }
3965
4179
 
3966
- export { AbstractDevice, ArrayTypeDetail, AtlasInfo, AtomicTypeInfoDetail, BaseCreationOptions, BaseDevice, BaseTexture, BindGroup, BindGroupLayout, BindGroupLayoutEntry, BindPointInfo, BlendEquation, BlendFunc, BlendingState, BufferBindingLayout, BufferCreationOptions, BufferUsage, CPUTimer, ColorState, CompareFunc, ComputeProgramConstructParams, DataType, DepthState, DeviceBackend, DeviceCaps, DeviceEventMap, DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceGPUObjectRenameEvent, DeviceLostEvent, DeviceOptions, DeviceResizeEvent, DeviceRestoreEvent, DeviceViewport, DrawText, ExpValueNonArrayType, ExpValueType, ExternalTextureBindingLayout, FaceMode, FaceWinding, Font, FrameBuffer, FrameBufferOptions, FrameBufferTextureAttachment, FrameInfo, FramebufferCaps, FunctionTypeDetail, GPUDataBuffer, GPUObject, GPUObjectList, GPUProgram, GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, ITimer, IndexBuffer, MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, PBReflectionTagGetter, PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, PointerTypeDetail, PrimitiveType, PrimitiveTypeDetail, ProgramBuilder, Proxiable, RasterizerState, RenderBundle, RenderProgramConstructParams, RenderStateSet, SamplerBindingLayout, SamplerOptions, SamplerTypeDetail, ShaderCaps, ShaderExpTagRecord, ShaderExpTagValue, ShaderKind, ShaderType, ShaderTypeFunc, StencilOp, StencilState, StorageTextureBindingLayout, StructTypeDetail, StructuredBuffer, StructuredBufferData, StructuredValue, Texture2D, Texture2DArray, Texture3D, TextureAddressMode, TextureAtlasManager, TextureBindingLayout, TextureCaps, TextureColorSpace, TextureCreationOptions, TextureCube, TextureFilterMode, TextureFormat, TextureFormatInfo, TextureImageElement, TextureMipmapData, TextureMipmapLevelData, TextureSampler, TextureType, TextureTypeDetail, TextureVideo, TypeDetailInfo, UniformBufferLayout, UniformLayout, VertexAttribFormat, VertexBufferInfo, VertexData, VertexLayout, VertexLayoutOptions, VertexSemantic, VertexStepMode, WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribFormat, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, semanticList };
4180
+ export { AbstractDevice, ArrayTypeDetail, AtlasInfo, AtomicTypeInfoDetail, BaseCreationOptions, BaseDevice, BaseTexture, BindGroup, BindGroupLayout, BindGroupLayoutEntry, BindPointInfo, BlendEquation, BlendFunc, BlendingState, BufferBindingLayout, BufferCreationOptions, BufferUsage, CPUTimer, ColorState, CompareFunc, ComputeProgramConstructParams, DataType, DepthState, DeviceBackend, DeviceCaps, DeviceEventMap, DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceGPUObjectRenameEvent, DeviceLostEvent, DeviceOptions, DeviceResizeEvent, DeviceRestoreEvent, DeviceViewport, DrawText, ExpValueNonArrayType, ExpValueType, ExternalTextureBindingLayout, FaceMode, FaceWinding, Font, FrameBuffer, FrameBufferOptions, FrameBufferTextureAttachment, FrameInfo, FramebufferCaps, FunctionTypeDetail, GPUDataBuffer, GPUObject, GPUObjectList, GPUProgram, GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, ITimer, IndexBuffer, MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, PBReflectionTagGetter, PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, PointerTypeDetail, PrimitiveType, PrimitiveTypeDetail, ProgramBuilder, Proxiable, RasterizerState, RenderBundle, RenderProgramConstructParams, RenderStateSet, SamplerBindingLayout, SamplerOptions, SamplerTypeDetail, ShaderCaps, ShaderExpTagRecord, ShaderExpTagValue, ShaderKind, ShaderType, ShaderTypeFunc, StencilOp, StencilState, StorageTextureBindingLayout, StructTypeDetail, StructuredBuffer, StructuredBufferData, StructuredValue, Texture2D, Texture2DArray, Texture3D, TextureAddressMode, TextureAtlasManager, TextureBindingLayout, TextureCaps, TextureColorSpace, TextureCreationOptions, TextureCube, TextureFilterMode, TextureFormat, TextureFormatInfo, TextureImageElement, TextureMipmapData, TextureMipmapLevelData, TextureSampler, TextureType, TextureTypeDetail, TextureVideo, TypeDetailInfo, UniformBufferLayout, UniformLayout, VertexAttribFormat, VertexBufferInfo, VertexData, VertexLayout, VertexLayoutOptions, VertexSemantic, VertexStepMode, WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, semanticList };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DeviceGPUObjectAddedEvent, DeviceGPUObjectRemovedEvent, DeviceGPUObjectRenameEvent, DeviceLostEvent, DeviceResizeEvent, DeviceRestoreEvent, ShaderType, encodePixel, encodePixelToArray, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB } from './base_types.js';
2
2
  export { VertexData } from './vertexdata.js';
3
- export { GPUResourceUsageFlags, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, genDefaultName, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatSize, makeVertexBufferType, semanticList, semanticToAttrib } from './gpuobject.js';
3
+ export { GPUResourceUsageFlags, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, genDefaultName, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, makeVertexBufferType, semanticList, semanticToAttrib } from './gpuobject.js';
4
4
  export { BaseDevice } from './device.js';
5
5
  export { PBShaderExp, Proxiable, getCurrentProgramBuilder, makeConstructor, setCurrentProgramBuilder } from './builder/base.js';
6
6
  export { ASTAddressOf, ASTArrayIndex, ASTAssignment, ASTBinaryFunc, ASTBreak, ASTCallFunction, ASTCast, ASTContinue, ASTDeclareVar, ASTDiscard, ASTDoWhile, ASTExpression, ASTFunction, ASTFunctionParameter, ASTGlobalScope, ASTHash, ASTIf, ASTLValue, ASTLValueArray, ASTLValueDeclare, ASTLValueHash, ASTLValueScalar, ASTNakedScope, ASTPrimitive, ASTRange, ASTReferenceOf, ASTReturn, ASTScalar, ASTScope, ASTSelect, ASTShaderExpConstructor, ASTStructDefine, ASTTouch, ASTUnaryFunc, ASTWhile, DeclareType, ShaderAST, ShaderPrecisionType, builtinVariables, genSamplerName, getBuiltinInputStructInstanceName, getBuiltinInputStructName, getBuiltinOutputStructInstanceName, getBuiltinOutputStructName, getBuiltinParamName, getTextureSampleType } from './builder/ast.js';