@luma.gl/core 9.2.0-alpha.1 → 9.2.0-alpha.5

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.
Files changed (167) hide show
  1. package/dist/adapter/canvas-context.d.ts +19 -5
  2. package/dist/adapter/canvas-context.d.ts.map +1 -1
  3. package/dist/adapter/canvas-context.js +53 -3
  4. package/dist/adapter/canvas-context.js.map +1 -1
  5. package/dist/adapter/device.d.ts +56 -11
  6. package/dist/adapter/device.d.ts.map +1 -1
  7. package/dist/adapter/device.js +78 -22
  8. package/dist/adapter/device.js.map +1 -1
  9. package/dist/adapter/luma.js +1 -1
  10. package/dist/adapter/resources/buffer.d.ts +13 -7
  11. package/dist/adapter/resources/buffer.d.ts.map +1 -1
  12. package/dist/adapter/resources/buffer.js +1 -5
  13. package/dist/adapter/resources/buffer.js.map +1 -1
  14. package/dist/adapter/resources/command-encoder.d.ts +0 -1
  15. package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
  16. package/dist/adapter/resources/command-encoder.js.map +1 -1
  17. package/dist/adapter/resources/framebuffer.d.ts +3 -3
  18. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  19. package/dist/adapter/resources/pipeline-layout.d.ts +13 -0
  20. package/dist/adapter/resources/pipeline-layout.d.ts.map +1 -0
  21. package/dist/adapter/resources/pipeline-layout.js +21 -0
  22. package/dist/adapter/resources/pipeline-layout.js.map +1 -0
  23. package/dist/adapter/resources/render-pipeline.d.ts +4 -4
  24. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  25. package/dist/adapter/resources/resource.d.ts +1 -0
  26. package/dist/adapter/resources/resource.d.ts.map +1 -1
  27. package/dist/adapter/resources/resource.js.map +1 -1
  28. package/dist/adapter/resources/texture-view.d.ts +1 -1
  29. package/dist/adapter/resources/texture-view.d.ts.map +1 -1
  30. package/dist/adapter/resources/texture.d.ts +1 -1
  31. package/dist/adapter/resources/texture.d.ts.map +1 -1
  32. package/dist/adapter/resources/vertex-array.js +1 -1
  33. package/dist/adapter/resources/vertex-array.js.map +1 -1
  34. package/dist/adapter/types/attachments.d.ts +3 -3
  35. package/dist/adapter/types/attachments.d.ts.map +1 -1
  36. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  37. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  38. package/dist/adapter/types/parameters.d.ts +2 -2
  39. package/dist/adapter/types/parameters.d.ts.map +1 -1
  40. package/dist/adapter/types/shader-layout.d.ts +5 -6
  41. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  42. package/dist/adapter-utils/get-attribute-from-layouts.d.ts +3 -3
  43. package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
  44. package/dist/adapter-utils/get-attribute-from-layouts.js +2 -2
  45. package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
  46. package/dist/dist.dev.js +430 -274
  47. package/dist/dist.min.js +5 -4
  48. package/dist/index.cjs +426 -273
  49. package/dist/index.cjs.map +4 -4
  50. package/dist/index.d.ts +18 -20
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +8 -7
  53. package/dist/index.js.map +1 -1
  54. package/dist/portable/uniform-block.d.ts +1 -1
  55. package/dist/portable/uniform-block.d.ts.map +1 -1
  56. package/dist/portable/uniform-buffer-layout.d.ts +3 -3
  57. package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
  58. package/dist/portable/uniform-buffer-layout.js +8 -9
  59. package/dist/portable/uniform-buffer-layout.js.map +1 -1
  60. package/dist/portable/uniform-store.d.ts +2 -1
  61. package/dist/portable/uniform-store.d.ts.map +1 -1
  62. package/dist/portable/uniform-store.js +1 -1
  63. package/dist/portable/uniform-store.js.map +1 -1
  64. package/dist/shadertypes/{data-types.d.ts → data-types/data-types.d.ts} +4 -0
  65. package/dist/shadertypes/data-types/data-types.d.ts.map +1 -0
  66. package/dist/shadertypes/data-types/data-types.js.map +1 -0
  67. package/dist/shadertypes/{utils → data-types}/decode-data-types.d.ts +4 -4
  68. package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -0
  69. package/dist/shadertypes/data-types/decode-data-types.js +74 -0
  70. package/dist/shadertypes/data-types/decode-data-types.js.map +1 -0
  71. package/dist/shadertypes/{utils → data-types}/decode-shader-types.d.ts +2 -2
  72. package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -0
  73. package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -0
  74. package/dist/shadertypes/data-types/shader-types.d.ts.map +1 -0
  75. package/dist/shadertypes/data-types/shader-types.js.map +1 -0
  76. package/dist/shadertypes/textures/pixel-utils.d.ts +112 -0
  77. package/dist/shadertypes/textures/pixel-utils.d.ts.map +1 -0
  78. package/dist/shadertypes/textures/pixel-utils.js +193 -0
  79. package/dist/shadertypes/textures/pixel-utils.js.map +1 -0
  80. package/dist/shadertypes/textures/texture-format-decoder.d.ts +18 -0
  81. package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -0
  82. package/dist/shadertypes/{utils/decode-texture-format.js → textures/texture-format-decoder.js} +48 -35
  83. package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -0
  84. package/dist/shadertypes/textures/texture-format-generics.d.ts +33 -0
  85. package/dist/shadertypes/textures/texture-format-generics.d.ts.map +1 -0
  86. package/dist/shadertypes/{texture-formats.js → textures/texture-format-generics.js} +1 -1
  87. package/dist/shadertypes/textures/texture-format-generics.js.map +1 -0
  88. package/dist/shadertypes/{utils → textures}/texture-format-table.d.ts +2 -1
  89. package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -0
  90. package/dist/shadertypes/{utils → textures}/texture-format-table.js +41 -42
  91. package/dist/shadertypes/textures/texture-format-table.js.map +1 -0
  92. package/dist/shadertypes/textures/texture-formats.d.ts +90 -0
  93. package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -0
  94. package/dist/shadertypes/textures/texture-formats.js +58 -0
  95. package/dist/shadertypes/textures/texture-formats.js.map +1 -0
  96. package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.d.ts +2 -2
  97. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +1 -0
  98. package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.js +4 -4
  99. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +1 -0
  100. package/dist/shadertypes/{vertex-formats.d.ts → vertex-arrays/vertex-formats.d.ts} +5 -3
  101. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +1 -0
  102. package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +1 -0
  103. package/package.json +2 -2
  104. package/src/adapter/canvas-context.ts +66 -8
  105. package/src/adapter/device.ts +132 -47
  106. package/src/adapter/resources/buffer.ts +30 -14
  107. package/src/adapter/resources/command-encoder.ts +0 -2
  108. package/src/adapter/resources/framebuffer.ts +5 -5
  109. package/src/adapter/resources/pipeline-layout.ts +30 -0
  110. package/src/adapter/resources/render-pipeline.ts +6 -6
  111. package/src/adapter/resources/resource.ts +1 -0
  112. package/src/adapter/resources/texture-view.ts +1 -1
  113. package/src/adapter/resources/texture.ts +1 -1
  114. package/src/adapter/resources/vertex-array.ts +1 -1
  115. package/src/adapter/types/attachments.ts +5 -5
  116. package/src/adapter/types/buffer-layout.ts +1 -1
  117. package/src/adapter/types/parameters.ts +2 -2
  118. package/src/adapter/types/shader-layout.ts +8 -5
  119. package/src/adapter-utils/get-attribute-from-layouts.ts +5 -5
  120. package/src/index.ts +60 -36
  121. package/src/portable/uniform-block.ts +1 -1
  122. package/src/portable/uniform-buffer-layout.ts +13 -12
  123. package/src/portable/uniform-store.ts +6 -2
  124. package/src/shadertypes/data-types/data-types.ts +96 -0
  125. package/src/shadertypes/data-types/decode-data-types.ts +91 -0
  126. package/src/shadertypes/{utils → data-types}/decode-shader-types.ts +2 -2
  127. package/src/shadertypes/textures/pixel-utils.ts +239 -0
  128. package/src/shadertypes/{utils/decode-texture-format.ts → textures/texture-format-decoder.ts} +63 -47
  129. package/src/shadertypes/textures/texture-format-generics.ts +190 -0
  130. package/src/shadertypes/{utils → textures}/texture-format-table.ts +62 -52
  131. package/src/shadertypes/{texture-formats.ts → textures/texture-formats.ts} +229 -147
  132. package/src/shadertypes/{utils → vertex-arrays}/decode-vertex-format.ts +6 -10
  133. package/src/shadertypes/{vertex-formats.ts → vertex-arrays/vertex-formats.ts} +20 -6
  134. package/dist/adapter-utils/buffer-layout-helper.d.ts +0 -11
  135. package/dist/adapter-utils/buffer-layout-helper.d.ts.map +0 -1
  136. package/dist/adapter-utils/buffer-layout-helper.js +0 -33
  137. package/dist/adapter-utils/buffer-layout-helper.js.map +0 -1
  138. package/dist/shadertypes/data-types.d.ts.map +0 -1
  139. package/dist/shadertypes/data-types.js.map +0 -1
  140. package/dist/shadertypes/shader-types.d.ts.map +0 -1
  141. package/dist/shadertypes/shader-types.js.map +0 -1
  142. package/dist/shadertypes/texture-formats.d.ts +0 -74
  143. package/dist/shadertypes/texture-formats.d.ts.map +0 -1
  144. package/dist/shadertypes/texture-formats.js.map +0 -1
  145. package/dist/shadertypes/utils/decode-data-types.d.ts.map +0 -1
  146. package/dist/shadertypes/utils/decode-data-types.js +0 -114
  147. package/dist/shadertypes/utils/decode-data-types.js.map +0 -1
  148. package/dist/shadertypes/utils/decode-shader-types.d.ts.map +0 -1
  149. package/dist/shadertypes/utils/decode-shader-types.js.map +0 -1
  150. package/dist/shadertypes/utils/decode-texture-format.d.ts +0 -15
  151. package/dist/shadertypes/utils/decode-texture-format.d.ts.map +0 -1
  152. package/dist/shadertypes/utils/decode-texture-format.js.map +0 -1
  153. package/dist/shadertypes/utils/decode-vertex-format.d.ts.map +0 -1
  154. package/dist/shadertypes/utils/decode-vertex-format.js.map +0 -1
  155. package/dist/shadertypes/utils/texture-format-table.d.ts.map +0 -1
  156. package/dist/shadertypes/utils/texture-format-table.js.map +0 -1
  157. package/dist/shadertypes/vertex-formats.d.ts.map +0 -1
  158. package/dist/shadertypes/vertex-formats.js.map +0 -1
  159. package/src/adapter-utils/buffer-layout-helper.ts +0 -41
  160. package/src/shadertypes/data-types.ts +0 -42
  161. package/src/shadertypes/utils/decode-data-types.ts +0 -131
  162. /package/dist/shadertypes/{data-types.js → data-types/data-types.js} +0 -0
  163. /package/dist/shadertypes/{utils → data-types}/decode-shader-types.js +0 -0
  164. /package/dist/shadertypes/{shader-types.d.ts → data-types/shader-types.d.ts} +0 -0
  165. /package/dist/shadertypes/{shader-types.js → data-types/shader-types.js} +0 -0
  166. /package/dist/shadertypes/{vertex-formats.js → vertex-arrays/vertex-formats.js} +0 -0
  167. /package/src/shadertypes/{shader-types.ts → data-types/shader-types.ts} +0 -0
@@ -0,0 +1,90 @@
1
+ import { NormalizedDataType } from "../data-types/data-types.js";
2
+ /** Information about the structure of a texture format */
3
+ export type TextureFormatInfo = {
4
+ /** The format that is described */
5
+ format: TextureFormat;
6
+ /** Color or depth stencil attachment formats */
7
+ attachment?: 'color' | 'depth' | 'stencil' | 'depth-stencil';
8
+ /** String describing which channels this texture has */
9
+ channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra';
10
+ /** Number of components (corresponds to channels string) */
11
+ components: 1 | 2 | 3 | 4;
12
+ /** What is the data type of each component */
13
+ dataType?: NormalizedDataType;
14
+ /** Number of bytes per pixel */
15
+ bytesPerPixel: number;
16
+ /** Number of bits per channel (may be unreliable for packed formats) */
17
+ bitsPerChannel: [number, number, number, number];
18
+ /** If this is a packed data type */
19
+ packed?: boolean;
20
+ /** SRGB texture format? */
21
+ srgb?: boolean;
22
+ /** WebGL specific texture format? */
23
+ webgl?: boolean;
24
+ /** Is this an integer or floating point format? */
25
+ integer: boolean;
26
+ /** Is this a signed or unsigned format? */
27
+ signed: boolean;
28
+ /** Is this a normalized integer format? */
29
+ normalized: boolean;
30
+ /** Is this a compressed texture format */
31
+ compressed?: boolean;
32
+ /** Compressed formats only: Block size for ASTC formats (texture width must be a multiple of this value) */
33
+ blockWidth?: number;
34
+ /** Compressed formats only: Block size for ASTC formats (texture height must be a multiple of this value) */
35
+ blockHeight?: number;
36
+ };
37
+ /**
38
+ * Texture format capabilities.
39
+ * @note Not directly usable. Can contain TextureFeature strings that need to be checked against a specific device.
40
+ */
41
+ export type TextureFormatCapabilities = {
42
+ format: TextureFormat;
43
+ /** Can the format be created */
44
+ create: TextureFeature | boolean;
45
+ /** If a feature string, the specified device feature determines if format is renderable. */
46
+ render: TextureFeature | boolean;
47
+ /** If a feature string, the specified device feature determines if format is filterable. */
48
+ filter: TextureFeature | boolean;
49
+ /** If a feature string, the specified device feature determines if format is blendable. */
50
+ blend: TextureFeature | boolean;
51
+ /** If a feature string, the specified device feature determines if format is storeable. */
52
+ store: TextureFeature | boolean;
53
+ };
54
+ /**
55
+ * These represent the main compressed texture formats
56
+ * Each format typically has a number of more specific subformats
57
+ */
58
+ export type TextureCompression = 'dxt' | 'dxt-srgb' | 'etc1' | 'etc2' | 'pvrtc' | 'atc' | 'astc' | 'rgtc';
59
+ /**
60
+ * Texture feature checks
61
+ * @note these must be a subset of DeviceFeatures.
62
+ */
63
+ export type TextureFeature = 'texture-compression-bc' | 'texture-compression-astc' | 'texture-compression-etc2' | 'texture-compression-etc1-webgl' | 'texture-compression-pvrtc-webgl' | 'texture-compression-atc-webgl' | 'float32-renderable-webgl' | 'float16-renderable-webgl' | 'rgb9e5ufloat-renderable-webgl' | 'snorm8-renderable-webgl' | 'norm16-renderable-webgl' | 'snorm16-renderable-webgl' | 'float32-filterable' | 'float16-filterable-webgl';
64
+ /** Chrome-specific extensions. Expected to eventually become standard features. */
65
+ export type ChromeExperimentalTextureFeature = 'chromium-experimental-unorm16-texture-formats' | 'chromium-experimental-snorm16-texture-formats';
66
+ /** Texture formats */
67
+ export type TextureFormat = TextureFormatColor | TextureFormatDepthStencil;
68
+ /** Depth and stencil texture formats */
69
+ export type TextureFormatDepthStencil = 'stencil8' | 'depth16unorm' | 'depth24plus' | 'depth24plus-stencil8' | 'depth32float' | 'depth32float-stencil8';
70
+ /** Texture formats for color attachments */
71
+ export type TextureFormatColor = TextureFormatColorUncompressed | TextureFormatCompressed;
72
+ export type TextureFormatColorUncompressed = TextureFormatUnorm8 | TextureFormatSnorm8 | TextureFormatUint8 | TextureFormatSint8 | TextureFormatUnorm16 | TextureFormatSnorm16 | TextureFormatUint16 | TextureFormatSint16 | TextureFormatFloat16 | TextureFormatUint32 | TextureFormatSint32 | TextureFormatFloat32 | TextureFormatPacked16 | TextureFormatPacked32;
73
+ type TextureFormatUnorm8 = 'r8unorm' | 'rg8unorm' | 'rgb8unorm-webgl' | 'rgba8unorm' | 'rgba8unorm-srgb' | 'bgra8unorm' | 'bgra8unorm-srgb';
74
+ type TextureFormatSnorm8 = 'r8snorm' | 'rg8snorm' | 'rgb8snorm-webgl' | 'rgba8snorm';
75
+ type TextureFormatUint8 = 'r8uint' | 'rg8uint' | 'rgba8uint';
76
+ type TextureFormatSint8 = 'r8sint' | 'rg8sint' | 'rgba8sint';
77
+ type TextureFormatUnorm16 = 'r16unorm' | 'rg16unorm' | 'rgb16unorm-webgl' | 'rgba16unorm';
78
+ type TextureFormatSnorm16 = 'r16snorm' | 'rg16snorm' | 'rgb16snorm-webgl' | 'rgba16snorm';
79
+ type TextureFormatUint16 = 'r16uint' | 'rg16uint' | 'rgba16uint';
80
+ type TextureFormatSint16 = 'r16sint' | 'rg16sint' | 'rgba16sint';
81
+ type TextureFormatFloat16 = 'r16float' | 'rg16float' | 'rgba16float';
82
+ type TextureFormatUint32 = 'r32uint' | 'rg32uint' | 'rgba32uint';
83
+ type TextureFormatSint32 = 'r32sint' | 'rg32sint' | 'rgba32sint';
84
+ type TextureFormatFloat32 = 'r32float' | 'rg32float' | 'rgb32float-webgl' | 'rgba32float';
85
+ type TextureFormatPacked16 = 'rgba4unorm-webgl' | 'rgb565unorm-webgl' | 'rgb5a1unorm-webgl';
86
+ type TextureFormatPacked32 = 'rgb9e5ufloat' | 'rg11b10ufloat' | 'rgb10a2unorm' | 'rgb10a2uint';
87
+ export type TextureFormatCompressed = 'bc1-rgb-unorm-webgl' | 'bc1-rgb-unorm-srgb-webgl' | 'pvrtc-rgb4unorm-webgl' | 'pvrtc-rgba4unorm-webgl' | 'pvrtc-rbg2unorm-webgl' | 'pvrtc-rgba2unorm-webgl' | 'etc1-rbg-unorm-webgl' | 'atc-rgb-unorm-webgl' | 'atc-rgba-unorm-webgl' | 'atc-rgbai-unorm-webgl' | 'bc1-rgba-unorm' | 'bc1-rgba-unorm-srgb' | 'bc2-rgba-unorm' | 'bc2-rgba-unorm-srgb' | 'bc3-rgba-unorm' | 'bc3-rgba-unorm-srgb' | 'bc4-r-unorm' | 'bc4-r-snorm' | 'bc5-rg-unorm' | 'bc5-rg-snorm' | 'bc6h-rgb-ufloat' | 'bc6h-rgb-float' | 'bc7-rgba-unorm' | 'bc7-rgba-unorm-srgb' | 'etc2-rgb8unorm' | 'etc2-rgb8unorm-srgb' | 'etc2-rgb8a1unorm' | 'etc2-rgb8a1unorm-srgb' | 'etc2-rgba8unorm' | 'etc2-rgba8unorm-srgb' | 'eac-r11unorm' | 'eac-r11snorm' | 'eac-rg11unorm' | 'eac-rg11snorm' | 'astc-4x4-unorm' | 'astc-4x4-unorm-srgb' | 'astc-5x4-unorm' | 'astc-5x4-unorm-srgb' | 'astc-5x5-unorm' | 'astc-5x5-unorm-srgb' | 'astc-6x5-unorm' | 'astc-6x5-unorm-srgb' | 'astc-6x6-unorm' | 'astc-6x6-unorm-srgb' | 'astc-8x5-unorm' | 'astc-8x5-unorm-srgb' | 'astc-8x6-unorm' | 'astc-8x6-unorm-srgb' | 'astc-8x8-unorm' | 'astc-8x8-unorm-srgb' | 'astc-10x5-unorm' | 'astc-10x5-unorm-srgb' | 'astc-10x6-unorm' | 'astc-10x6-unorm-srgb' | 'astc-10x8-unorm' | 'astc-10x8-unorm-srgb' | 'astc-10x10-unorm' | 'astc-10x10-unorm-srgb' | 'astc-12x10-unorm' | 'astc-12x10-unorm-srgb' | 'astc-12x12-unorm' | 'astc-12x12-unorm-srgb';
88
+ export type TextureFormatDataType<T extends TextureFormat> = T extends TextureFormatUint8 ? 'uint8' : T extends TextureFormatSint8 ? 'sint8' : T extends TextureFormatUnorm8 ? 'unorm8' : T extends TextureFormatSnorm8 ? 'snorm8' : T extends TextureFormatUint16 ? 'uint16' : T extends TextureFormatSint16 ? 'sint16' : T extends TextureFormatUnorm16 ? 'unorm16' : T extends TextureFormatSnorm16 ? 'snorm16' : T extends TextureFormatUint32 ? 'uint32' : T extends TextureFormatSint32 ? 'sint32' : T extends TextureFormatFloat16 ? 'float16' : T extends TextureFormatFloat32 ? 'float32' : T extends TextureFormatDepthStencil ? 'uint32' : T extends TextureFormatCompressed ? 'uint8' : T extends TextureFormatPacked16 ? 'uint16' : T extends TextureFormatPacked32 ? 'uint32' : never;
89
+ export {};
90
+ //# sourceMappingURL=texture-formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/shadertypes/textures/texture-formats.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,kBAAkB,EAAC,oCAAiC;AAE5D,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,mCAAmC;IACnC,MAAM,EAAE,aAAa,CAAC;IACtB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,eAAe,CAAC;IAC7D,wDAAwD;IACxD,QAAQ,EAAE,GAAG,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/C,4DAA4D;IAC5D,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,oCAAoC;IACpC,MAA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B,uBAAuB,CAAC;AAI5B,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,SAAS,kBAAkB,GACrF,OAAO,GACP,CAAC,SAAS,kBAAkB,GAC1B,OAAO,GACP,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,oBAAoB,GAC5B,SAAS,GACT,CAAC,SAAS,oBAAoB,GAC5B,SAAS,GACT,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,mBAAmB,GAC3B,QAAQ,GACR,CAAC,SAAS,oBAAoB,GAC5B,SAAS,GACT,CAAC,SAAS,oBAAoB,GAC5B,SAAS,GACT,CAAC,SAAS,yBAAyB,GACjC,QAAQ,GACR,CAAC,SAAS,uBAAuB,GAC/B,OAAO,GACP,CAAC,SAAS,qBAAqB,GAC7B,QAAQ,GACR,CAAC,SAAS,qBAAqB,GAC7B,QAAQ,GACR,KAAK,CAAC"}
@@ -0,0 +1,58 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
5
+ /*
6
+ export type TextureFormatColorWebGPU =
7
+ // 8-bit formats
8
+ | 'r8unorm'
9
+ | 'r8snorm'
10
+ | 'r8uint'
11
+ | 'r8sint'
12
+ | 'rg8unorm'
13
+ | 'rg8snorm'
14
+ | 'rg8uint'
15
+ | 'rg8sint'
16
+ | 'rgba8unorm'
17
+ | 'rgba8unorm-srgb'
18
+ | 'rgba8snorm'
19
+ | 'rgba8uint'
20
+ | 'rgba8sint'
21
+ | 'bgra8unorm'
22
+ | 'bgra8unorm-srgb'
23
+
24
+ // 16-bit formats
25
+ | 'r16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
26
+ | 'r16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
27
+ | 'r16uint'
28
+ | 'r16sint'
29
+ | 'r16float'
30
+ | 'rg16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
31
+ | 'rg16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
32
+ | 'rgba16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
33
+ | 'rgba16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
34
+ | 'rg16uint'
35
+ | 'rgba16uint'
36
+ | 'rg16sint'
37
+ | 'rgba16sint'
38
+ | 'rg16float'
39
+ | 'rgba16float'
40
+
41
+ // 32-bit formats
42
+ | 'r32uint'
43
+ | 'rg32uint'
44
+ | 'rgba32uint'
45
+ | 'r32sint'
46
+ | 'rg32sint'
47
+ | 'rgba32sint'
48
+ | 'r32float'
49
+ | 'rg32float'
50
+ | 'rgba32float'
51
+
52
+ // Packed 32-bit formats
53
+ | 'rgb9e5ufloat'
54
+ | 'rgb10a2unorm'
55
+ | 'rgb10a2uint'
56
+ | 'rg11b10ufloat';
57
+ */
58
+ //# sourceMappingURL=texture-formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texture-formats.js","sourceRoot":"","sources":["../../../src/shadertypes/textures/texture-formats.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;;AAuRpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDE"}
@@ -1,6 +1,6 @@
1
1
  import type { TypedArray } from "../../types.js";
2
- import type { PrimitiveDataType, SignedDataType } from "../data-types.js";
3
- import type { VertexFormat, VertexFormatInfo } from "../vertex-formats.js";
2
+ import type { PrimitiveDataType, SignedDataType } from "../data-types/data-types.js";
3
+ import type { VertexFormat, VertexFormatInfo } from "./vertex-formats.js";
4
4
  /**
5
5
  * Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
6
6
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-vertex-format.d.ts","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/decode-vertex-format.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAC,uBAAoB;AAC5C,OAAO,KAAK,EAAqB,iBAAiB,EAAE,cAAc,EAAC,oCAAiC;AACpG,OAAO,KAAK,EAAC,YAAY,EAAE,gBAAgB,EAAC,4BAAyB;AAGrE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CAyB1E;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EACzB,UAAU,CAAC,EAAE,OAAO,GACnB,YAAY,CAmCd;AAED,sEAAsE;AACtE,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,OAAO,GACnB,YAAY,CAQd;AAED;4EAC4E;AAE5E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,aAAa,EAAE,iBAAiB,CAAC;IACjC,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC3B,GAAG,YAAY,CAqBf"}
@@ -1,7 +1,7 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { getDataTypeInfo, getDataTypeFromTypedArray, makeNormalizedDataType } from "./decode-data-types.js";
4
+ import { getDataTypeInfo, getDataType, getNormalizedDataType } from "../data-types/decode-data-types.js";
5
5
  /**
6
6
  * Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
7
7
  */
@@ -34,13 +34,13 @@ export function getVertexFormatInfo(format) {
34
34
  /** Build a vertex format from a signed data type and a component */
35
35
  export function makeVertexFormat(signedDataType, components, normalized) {
36
36
  const dataType = normalized
37
- ? makeNormalizedDataType(signedDataType)
37
+ ? getNormalizedDataType(signedDataType)
38
38
  : signedDataType;
39
39
  switch (dataType) {
40
40
  // TODO - Special cases for WebGL (not supported on WebGPU), overrides the check below
41
41
  case 'unorm8':
42
42
  if (components === 1) {
43
- return 'unorm8-webgl';
43
+ return 'unorm8';
44
44
  }
45
45
  if (components === 3) {
46
46
  return 'unorm8x3-webgl';
@@ -71,7 +71,7 @@ export function getVertexFormatFromAttribute(typedArray, size, normalized) {
71
71
  throw new Error(`size ${size}`);
72
72
  }
73
73
  const components = size;
74
- const signedDataType = getDataTypeFromTypedArray(typedArray);
74
+ const signedDataType = getDataType(typedArray);
75
75
  return makeVertexFormat(signedDataType, components, normalized);
76
76
  }
77
77
  /** Return a "default" vertex format for a certain shader data type
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode-vertex-format.js","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/decode-vertex-format.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAKpC,OAAO,EAAC,eAAe,EAAE,WAAW,EAAE,qBAAqB,EAAC,2CAAwC;AAEpG;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAoB;IACtD,qCAAqC;IACrC,IAAI,SAA8B,CAAC;IACnC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC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AU,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAC5D,CAAC;IAED,uCAAuC;IACvC,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;AAC5C,CAAC"}
@@ -1,11 +1,11 @@
1
- import { NormalizedDataType } from "./data-types.js";
1
+ import { NormalizedDataType } from "../data-types/data-types.js";
2
2
  /**
3
3
  * Describes the **memory format** and interpretation (normalization) of a buffer that will be supplied to vertex attributes
4
4
  * @note Must be compatible with the AttributeShaderType of the shaders, see documentation.
5
- * @note This is a superset of WebGPU vertex formats to allow foe some flexibility for WebGL only applications
5
+ * @note This is a superset of WebGPU vertex formats to allow for some flexibility for WebGL only applications
6
6
  * @todo Add device.isTextureFormatSupported() method?
7
7
  */
8
- export type VertexFormat = 'uint8x2' | 'uint8x4' | 'sint8x2' | 'sint8x4' | 'unorm8-webgl' | 'unorm8x2' | 'unorm8x3-webgl' | 'unorm8x4' | 'snorm8-webgl' | 'snorm8x2' | 'snorm8x3-webgl' | 'snorm8x4' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4';
8
+ export type VertexFormat = 'uint8' | 'uint8x2' | 'uint8x4' | 'sint8' | 'sint8x2' | 'sint8x4' | 'unorm8' | 'unorm8x2' | 'unorm8x3-webgl' | 'unorm8x4' | 'unorm8x4-bgra' | 'unorm10-10-10-2' | 'snorm8' | 'snorm8x2' | 'snorm8x3-webgl' | 'snorm8x4' | 'uint16' | 'sint16' | 'unorm16' | 'snorm16' | 'uint16x2' | 'uint16x4' | 'sint16x2' | 'sint16x4' | 'unorm16x2' | 'unorm16x4' | 'snorm16x2' | 'snorm16x4' | 'uint32' | 'uint32x2' | 'uint32x3' | 'uint32x4' | 'sint32' | 'sint32x2' | 'sint32x3' | 'sint32x4' | 'float16' | 'float16x2' | 'float16x4' | 'float32' | 'float32x2' | 'float32x3' | 'float32x4';
9
9
  export type VertexFormatInfo = {
10
10
  /** Type of each component */
11
11
  type: NormalizedDataType;
@@ -19,6 +19,8 @@ export type VertexFormatInfo = {
19
19
  signed: boolean;
20
20
  /** Is this a normalized format? */
21
21
  normalized: boolean;
22
+ /** Is this a bgra format? */
23
+ bgra?: boolean;
22
24
  /** Is this a webgl only format? */
23
25
  webglOnly?: boolean;
24
26
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-formats.d.ts","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/vertex-formats.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,kBAAkB,EAAC,oCAAiC;AAI5D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAEpB,OAAO,GACP,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,UAAU,GACV,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,iBAAiB,GAEjB,QAAQ,GACR,UAAU,GACV,gBAAgB,GAChB,UAAU,GAEV,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,WAAW,GACX,WAAW,GAEX,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GACV,QAAQ,GACR,UAAU,GACV,UAAU,GACV,UAAU,GAWV,SAAS,GACT,WAAW,GACX,WAAW,GACX,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,mCAAmC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vertex-formats.js","sourceRoot":"","sources":["../../../src/shadertypes/vertex-arrays/vertex-formats.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/core",
3
- "version": "9.2.0-alpha.1",
3
+ "version": "9.2.0-alpha.5",
4
4
  "description": "The luma.gl core Device API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,5 +46,5 @@
46
46
  "@probe.gl/stats": "^4.0.8",
47
47
  "@types/offscreencanvas": "^2019.6.4"
48
48
  },
49
- "gitHead": "d6d2f791f2ce96f4b5acb68e05faea62c35440fb"
49
+ "gitHead": "bf8346ab62619ec2c3e0b6dd54be3142328c6377"
50
50
  }
@@ -5,7 +5,7 @@
5
5
  import {isBrowser} from '@probe.gl/env';
6
6
  import type {Device} from './device';
7
7
  import type {Framebuffer} from './resources/framebuffer';
8
- import type {DepthStencilTextureFormat} from '../shadertypes/texture-formats';
8
+ import type {TextureFormatDepthStencil} from '../shadertypes/textures/texture-formats';
9
9
  import {uid} from '../utils/uid';
10
10
  import {withResolvers} from '../utils/promise-utils';
11
11
 
@@ -23,14 +23,16 @@ export type CanvasContextProps = {
23
23
  height?: number;
24
24
  /** Visibility (only used if new canvas is created). */
25
25
  visible?: boolean;
26
- /** Whether to size the drawing buffer to the pixel size during auto resize */
27
- useDevicePixels?: boolean;
28
- /** Whether to track window resizes */
26
+ /** Whether to size the drawing buffer to the pixel size during auto resize. If a number is provided it is used as a static pixel ratio */
27
+ useDevicePixels?: boolean | number;
28
+ /** Whether to track window resizes. */
29
29
  autoResize?: boolean;
30
30
  /** @see https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#alphamode */
31
31
  alphaMode?: 'opaque' | 'premultiplied';
32
32
  /** @see https://developer.mozilla.org/en-US/docs/Web/API/GPUCanvasContext/configure#colorspace */
33
33
  colorSpace?: 'srgb'; // GPUPredefinedColorSpace
34
+ /** Whether to track position changes. Calls this.device.onPositionChange */
35
+ trackPosition?: boolean;
34
36
  };
35
37
 
36
38
  /**
@@ -59,7 +61,8 @@ export abstract class CanvasContext {
59
61
  container: null,
60
62
  visible: true,
61
63
  alphaMode: 'opaque',
62
- colorSpace: 'srgb'
64
+ colorSpace: 'srgb',
65
+ trackPosition: false
63
66
  };
64
67
 
65
68
  abstract readonly device: Device;
@@ -101,6 +104,8 @@ export abstract class CanvasContext {
101
104
  protected _initializedResolvers = withResolvers<void>();
102
105
  protected readonly _resizeObserver: ResizeObserver | undefined;
103
106
  protected readonly _intersectionObserver: IntersectionObserver | undefined;
107
+ protected _position: [number, number];
108
+ protected destroyed = false;
104
109
 
105
110
  abstract get [Symbol.toStringTag](): string;
106
111
 
@@ -140,7 +145,7 @@ export abstract class CanvasContext {
140
145
  this.type = 'node';
141
146
  }
142
147
 
143
- // Initialize size variables (these will be updated by ResizeObserver)
148
+ // Initialize size variables to some sane values (these will be updated by ResizeObserver)
144
149
  this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;
145
150
  this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;
146
151
  this.devicePixelWidth = this.canvas.width;
@@ -148,6 +153,7 @@ export abstract class CanvasContext {
148
153
  this.drawingBufferWidth = this.canvas.width;
149
154
  this.drawingBufferHeight = this.canvas.height;
150
155
  this.devicePixelRatio = globalThis.devicePixelRatio || 1;
156
+ this._position = [0, 0];
151
157
 
152
158
  if (CanvasContext.isHTMLCanvas(this.canvas)) {
153
159
  // Track visibility changes
@@ -168,12 +174,21 @@ export abstract class CanvasContext {
168
174
  // Track device pixel ratio changes.
169
175
  // Defer call to after construction completes to ensure `this.device` is available.
170
176
  setTimeout(() => this._observeDevicePixelRatio(), 0);
177
+
178
+ // Track top/left position changes
179
+ if (this.props.trackPosition) {
180
+ this._trackPosition();
181
+ }
171
182
  }
172
183
  }
173
184
 
185
+ destroy() {
186
+ this.destroyed = true;
187
+ }
188
+
174
189
  /** Returns a framebuffer with properly resized current 'swap chain' textures */
175
190
  abstract getCurrentFramebuffer(options?: {
176
- depthStencilFormat?: DepthStencilTextureFormat | false;
191
+ depthStencilFormat?: TextureFormatDepthStencil | false;
177
192
  }): Framebuffer;
178
193
 
179
194
  // SIZE METHODS
@@ -187,6 +202,10 @@ export abstract class CanvasContext {
187
202
  return [this.cssWidth, this.cssHeight];
188
203
  }
189
204
 
205
+ getPosition() {
206
+ return this._position;
207
+ }
208
+
190
209
  /**
191
210
  * Returns the size covered by the canvas in actual device pixels.
192
211
  * @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
@@ -343,7 +362,10 @@ export abstract class CanvasContext {
343
362
 
344
363
  // Update the canvas drawing buffer size
345
364
  if (this.props.autoResize) {
346
- if (this.props.useDevicePixels) {
365
+ if (typeof this.props.useDevicePixels === 'number') {
366
+ const dpr = this.props.useDevicePixels;
367
+ this.setDrawingBufferSize(this.cssWidth * dpr, this.cssHeight * dpr);
368
+ } else if (this.props.useDevicePixels) {
347
369
  this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
348
370
  } else {
349
371
  this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
@@ -357,6 +379,8 @@ export abstract class CanvasContext {
357
379
  this._initializedResolvers.resolve();
358
380
  this.isInitialized = true;
359
381
 
382
+ this.updatePosition();
383
+
360
384
  // Inform the device
361
385
  this.device.props.onResize(this, {oldPixelSize});
362
386
  }
@@ -366,6 +390,8 @@ export abstract class CanvasContext {
366
390
  const oldRatio = this.devicePixelRatio;
367
391
  this.devicePixelRatio = window.devicePixelRatio;
368
392
 
393
+ this.updatePosition();
394
+
369
395
  // Inform the device
370
396
  this.device.props.onDevicePixelRatioChange(this, {oldRatio});
371
397
  // Set up a one time query against the current resolution.
@@ -375,6 +401,38 @@ export abstract class CanvasContext {
375
401
  {once: true}
376
402
  );
377
403
  }
404
+
405
+ /** Start tracking positions with a timer */
406
+ _trackPosition(intervalMs: number = 100): void {
407
+ const intervalId = setInterval(() => {
408
+ if (this.destroyed) {
409
+ clearInterval(intervalId);
410
+ } else {
411
+ this.updatePosition();
412
+ }
413
+ }, intervalMs);
414
+ }
415
+
416
+ /**
417
+ * Calculated the absolute position of the canvas
418
+ * @note - getBoundingClientRect() is normally cheap but can be expensive
419
+ * if called before browser has finished a reflow. Should not be the case here.
420
+ */
421
+ updatePosition() {
422
+ const newRect = this.htmlCanvas?.getBoundingClientRect();
423
+ if (newRect) {
424
+ // We only track position since we rely on the more precise ResizeObserver for size
425
+ const position: [number, number] = [newRect.left, newRect.top];
426
+ this._position ??= position;
427
+ const positionChanged =
428
+ position[0] !== this._position[0] || position[1] !== this._position[1];
429
+ if (positionChanged) {
430
+ const oldPosition = this._position;
431
+ this._position = position;
432
+ this.device.props.onPositionChange?.(this, {oldPosition});
433
+ }
434
+ }
435
+ }
378
436
  }
379
437
 
380
438
  // HELPER FUNCTIONS