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

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 (165) hide show
  1. package/dist/adapter/canvas-context.d.ts +17 -3
  2. package/dist/adapter/canvas-context.d.ts.map +1 -1
  3. package/dist/adapter/canvas-context.js +48 -2
  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 +417 -267
  47. package/dist/dist.min.js +5 -4
  48. package/dist/index.cjs +416 -266
  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 +2 -2
  57. package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
  58. package/dist/portable/uniform-buffer-layout.js +2 -2
  59. package/dist/portable/uniform-buffer-layout.js.map +1 -1
  60. package/dist/portable/uniform-store.d.ts +1 -1
  61. package/dist/portable/uniform-store.d.ts.map +1 -1
  62. package/dist/shadertypes/{data-types.d.ts → data-types/data-types.d.ts} +4 -0
  63. package/dist/shadertypes/data-types/data-types.d.ts.map +1 -0
  64. package/dist/shadertypes/data-types/data-types.js.map +1 -0
  65. package/dist/shadertypes/{utils → data-types}/decode-data-types.d.ts +4 -4
  66. package/dist/shadertypes/data-types/decode-data-types.d.ts.map +1 -0
  67. package/dist/shadertypes/data-types/decode-data-types.js +74 -0
  68. package/dist/shadertypes/data-types/decode-data-types.js.map +1 -0
  69. package/dist/shadertypes/{utils → data-types}/decode-shader-types.d.ts +2 -2
  70. package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +1 -0
  71. package/dist/shadertypes/data-types/decode-shader-types.js.map +1 -0
  72. package/dist/shadertypes/data-types/shader-types.d.ts.map +1 -0
  73. package/dist/shadertypes/data-types/shader-types.js.map +1 -0
  74. package/dist/shadertypes/textures/pixel-utils.d.ts +112 -0
  75. package/dist/shadertypes/textures/pixel-utils.d.ts.map +1 -0
  76. package/dist/shadertypes/textures/pixel-utils.js +193 -0
  77. package/dist/shadertypes/textures/pixel-utils.js.map +1 -0
  78. package/dist/shadertypes/textures/texture-format-decoder.d.ts +18 -0
  79. package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +1 -0
  80. package/dist/shadertypes/{utils/decode-texture-format.js → textures/texture-format-decoder.js} +48 -35
  81. package/dist/shadertypes/textures/texture-format-decoder.js.map +1 -0
  82. package/dist/shadertypes/textures/texture-format-generics.d.ts +33 -0
  83. package/dist/shadertypes/textures/texture-format-generics.d.ts.map +1 -0
  84. package/dist/shadertypes/{texture-formats.js → textures/texture-format-generics.js} +1 -1
  85. package/dist/shadertypes/textures/texture-format-generics.js.map +1 -0
  86. package/dist/shadertypes/{utils → textures}/texture-format-table.d.ts +2 -1
  87. package/dist/shadertypes/textures/texture-format-table.d.ts.map +1 -0
  88. package/dist/shadertypes/{utils → textures}/texture-format-table.js +41 -42
  89. package/dist/shadertypes/textures/texture-format-table.js.map +1 -0
  90. package/dist/shadertypes/textures/texture-formats.d.ts +90 -0
  91. package/dist/shadertypes/textures/texture-formats.d.ts.map +1 -0
  92. package/dist/shadertypes/textures/texture-formats.js +58 -0
  93. package/dist/shadertypes/textures/texture-formats.js.map +1 -0
  94. package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.d.ts +2 -2
  95. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +1 -0
  96. package/dist/shadertypes/{utils → vertex-arrays}/decode-vertex-format.js +4 -4
  97. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +1 -0
  98. package/dist/shadertypes/{vertex-formats.d.ts → vertex-arrays/vertex-formats.d.ts} +5 -3
  99. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +1 -0
  100. package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +1 -0
  101. package/package.json +2 -2
  102. package/src/adapter/canvas-context.ts +60 -5
  103. package/src/adapter/device.ts +132 -47
  104. package/src/adapter/resources/buffer.ts +30 -14
  105. package/src/adapter/resources/command-encoder.ts +0 -2
  106. package/src/adapter/resources/framebuffer.ts +5 -5
  107. package/src/adapter/resources/pipeline-layout.ts +30 -0
  108. package/src/adapter/resources/render-pipeline.ts +6 -6
  109. package/src/adapter/resources/resource.ts +1 -0
  110. package/src/adapter/resources/texture-view.ts +1 -1
  111. package/src/adapter/resources/texture.ts +1 -1
  112. package/src/adapter/resources/vertex-array.ts +1 -1
  113. package/src/adapter/types/attachments.ts +5 -5
  114. package/src/adapter/types/buffer-layout.ts +1 -1
  115. package/src/adapter/types/parameters.ts +2 -2
  116. package/src/adapter/types/shader-layout.ts +8 -5
  117. package/src/adapter-utils/get-attribute-from-layouts.ts +5 -5
  118. package/src/index.ts +60 -36
  119. package/src/portable/uniform-block.ts +1 -1
  120. package/src/portable/uniform-buffer-layout.ts +4 -4
  121. package/src/portable/uniform-store.ts +1 -1
  122. package/src/shadertypes/data-types/data-types.ts +96 -0
  123. package/src/shadertypes/data-types/decode-data-types.ts +91 -0
  124. package/src/shadertypes/{utils → data-types}/decode-shader-types.ts +2 -2
  125. package/src/shadertypes/textures/pixel-utils.ts +239 -0
  126. package/src/shadertypes/{utils/decode-texture-format.ts → textures/texture-format-decoder.ts} +63 -47
  127. package/src/shadertypes/textures/texture-format-generics.ts +190 -0
  128. package/src/shadertypes/{utils → textures}/texture-format-table.ts +62 -52
  129. package/src/shadertypes/{texture-formats.ts → textures/texture-formats.ts} +229 -147
  130. package/src/shadertypes/{utils → vertex-arrays}/decode-vertex-format.ts +6 -10
  131. package/src/shadertypes/{vertex-formats.ts → vertex-arrays/vertex-formats.ts} +20 -6
  132. package/dist/adapter-utils/buffer-layout-helper.d.ts +0 -11
  133. package/dist/adapter-utils/buffer-layout-helper.d.ts.map +0 -1
  134. package/dist/adapter-utils/buffer-layout-helper.js +0 -33
  135. package/dist/adapter-utils/buffer-layout-helper.js.map +0 -1
  136. package/dist/shadertypes/data-types.d.ts.map +0 -1
  137. package/dist/shadertypes/data-types.js.map +0 -1
  138. package/dist/shadertypes/shader-types.d.ts.map +0 -1
  139. package/dist/shadertypes/shader-types.js.map +0 -1
  140. package/dist/shadertypes/texture-formats.d.ts +0 -74
  141. package/dist/shadertypes/texture-formats.d.ts.map +0 -1
  142. package/dist/shadertypes/texture-formats.js.map +0 -1
  143. package/dist/shadertypes/utils/decode-data-types.d.ts.map +0 -1
  144. package/dist/shadertypes/utils/decode-data-types.js +0 -114
  145. package/dist/shadertypes/utils/decode-data-types.js.map +0 -1
  146. package/dist/shadertypes/utils/decode-shader-types.d.ts.map +0 -1
  147. package/dist/shadertypes/utils/decode-shader-types.js.map +0 -1
  148. package/dist/shadertypes/utils/decode-texture-format.d.ts +0 -15
  149. package/dist/shadertypes/utils/decode-texture-format.d.ts.map +0 -1
  150. package/dist/shadertypes/utils/decode-texture-format.js.map +0 -1
  151. package/dist/shadertypes/utils/decode-vertex-format.d.ts.map +0 -1
  152. package/dist/shadertypes/utils/decode-vertex-format.js.map +0 -1
  153. package/dist/shadertypes/utils/texture-format-table.d.ts.map +0 -1
  154. package/dist/shadertypes/utils/texture-format-table.js.map +0 -1
  155. package/dist/shadertypes/vertex-formats.d.ts.map +0 -1
  156. package/dist/shadertypes/vertex-formats.js.map +0 -1
  157. package/src/adapter-utils/buffer-layout-helper.ts +0 -41
  158. package/src/shadertypes/data-types.ts +0 -42
  159. package/src/shadertypes/utils/decode-data-types.ts +0 -131
  160. /package/dist/shadertypes/{data-types.js → data-types/data-types.js} +0 -0
  161. /package/dist/shadertypes/{utils → data-types}/decode-shader-types.js +0 -0
  162. /package/dist/shadertypes/{shader-types.d.ts → data-types/shader-types.d.ts} +0 -0
  163. /package/dist/shadertypes/{shader-types.js → data-types/shader-types.js} +0 -0
  164. /package/dist/shadertypes/{vertex-formats.js → vertex-arrays/vertex-formats.js} +0 -0
  165. /package/src/shadertypes/{shader-types.ts → data-types/shader-types.ts} +0 -0
@@ -2,7 +2,61 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NormalizedDataType} from './data-types';
5
+ import {NormalizedDataType} from '../data-types/data-types';
6
+
7
+ /** Information about the structure of a texture format */
8
+ export type TextureFormatInfo = {
9
+ /** The format that is described */
10
+ format: TextureFormat;
11
+ /** Color or depth stencil attachment formats */
12
+ attachment?: 'color' | 'depth' | 'stencil' | 'depth-stencil';
13
+ /** String describing which channels this texture has */
14
+ channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra';
15
+ /** Number of components (corresponds to channels string) */
16
+ components: 1 | 2 | 3 | 4;
17
+ /** What is the data type of each component */
18
+ dataType?: NormalizedDataType;
19
+ /** Number of bytes per pixel */
20
+ bytesPerPixel: number;
21
+ /** Number of bits per channel (may be unreliable for packed formats) */
22
+ bitsPerChannel: [number, number, number, number];
23
+ /** If this is a packed data type */
24
+ packed?: boolean;
25
+ /** SRGB texture format? */
26
+ srgb?: boolean;
27
+ /** WebGL specific texture format? */
28
+ webgl?: boolean;
29
+ /** Is this an integer or floating point format? */
30
+ integer: boolean;
31
+ /** Is this a signed or unsigned format? */
32
+ signed: boolean;
33
+ /** Is this a normalized integer format? */
34
+ normalized: boolean;
35
+ /** Is this a compressed texture format */
36
+ compressed?: boolean;
37
+ /** Compressed formats only: Block size for ASTC formats (texture width must be a multiple of this value) */
38
+ blockWidth?: number;
39
+ /** Compressed formats only: Block size for ASTC formats (texture height must be a multiple of this value) */
40
+ blockHeight?: number;
41
+ };
42
+
43
+ /**
44
+ * Texture format capabilities.
45
+ * @note Not directly usable. Can contain TextureFeature strings that need to be checked against a specific device.
46
+ */
47
+ export type TextureFormatCapabilities = {
48
+ format: TextureFormat;
49
+ /** Can the format be created */
50
+ create: TextureFeature | boolean;
51
+ /** If a feature string, the specified device feature determines if format is renderable. */
52
+ render: TextureFeature | boolean;
53
+ /** If a feature string, the specified device feature determines if format is filterable. */
54
+ filter: TextureFeature | boolean;
55
+ /** If a feature string, the specified device feature determines if format is blendable. */
56
+ blend: TextureFeature | boolean;
57
+ /** If a feature string, the specified device feature determines if format is storeable. */
58
+ store: TextureFeature | boolean;
59
+ };
6
60
 
7
61
  /**
8
62
  * These represent the main compressed texture formats
@@ -18,11 +72,40 @@ export type TextureCompression =
18
72
  | 'astc'
19
73
  | 'rgtc';
20
74
 
75
+ // TEXTURE FEATURES (optionally supported by the device)
76
+
77
+ /**
78
+ * Texture feature checks
79
+ * @note these must be a subset of DeviceFeatures.
80
+ */
81
+ export type TextureFeature =
82
+ | 'texture-compression-bc'
83
+ | 'texture-compression-astc'
84
+ | 'texture-compression-etc2'
85
+ | 'texture-compression-etc1-webgl'
86
+ | 'texture-compression-pvrtc-webgl'
87
+ | 'texture-compression-atc-webgl'
88
+ | 'float32-renderable-webgl'
89
+ | 'float16-renderable-webgl'
90
+ | 'rgb9e5ufloat-renderable-webgl'
91
+ | 'snorm8-renderable-webgl'
92
+ | 'norm16-renderable-webgl'
93
+ | 'snorm16-renderable-webgl'
94
+ | 'float32-filterable'
95
+ | 'float16-filterable-webgl';
96
+
97
+ /** Chrome-specific extensions. Expected to eventually become standard features. */
98
+ export type ChromeExperimentalTextureFeature =
99
+ | 'chromium-experimental-unorm16-texture-formats' // 'r16unorm', 'rg16unorm', 'rgba16unorm'
100
+ | 'chromium-experimental-snorm16-texture-formats'; // 'r16snorm', 'rg16snorm', 'rgba16snorm'
101
+
102
+ // TEXTURE FORMATS
103
+
21
104
  /** Texture formats */
22
- export type TextureFormat = ColorTextureFormat | DepthStencilTextureFormat;
105
+ export type TextureFormat = TextureFormatColor | TextureFormatDepthStencil;
23
106
 
24
107
  /** Depth and stencil texture formats */
25
- export type DepthStencilTextureFormat =
108
+ export type TextureFormatDepthStencil =
26
109
  | 'stencil8'
27
110
  | 'depth16unorm'
28
111
  | 'depth24plus'
@@ -32,61 +115,72 @@ export type DepthStencilTextureFormat =
32
115
  | 'depth32float-stencil8';
33
116
 
34
117
  /** Texture formats for color attachments */
35
- export type ColorTextureFormat =
36
- | WebGPUColorTextureFormat
37
- | WebGL2ColorTextureFormat
38
- | CompressedTextureFormat;
118
+ export type TextureFormatColor = TextureFormatColorUncompressed | TextureFormatCompressed;
39
119
 
40
- export type WebGPUColorTextureFormat =
41
- // 8-bit formats
42
- | 'r8unorm'
43
- | 'r8snorm'
44
- | 'r8uint'
45
- | 'r8sint'
120
+ export type TextureFormatColorUncompressed =
121
+ | TextureFormatUnorm8
122
+ | TextureFormatSnorm8
123
+ | TextureFormatUint8
124
+ | TextureFormatSint8
125
+ | TextureFormatUnorm16
126
+ | TextureFormatSnorm16
127
+ | TextureFormatUint16
128
+ | TextureFormatSint16
129
+ | TextureFormatFloat16
130
+ | TextureFormatUint32
131
+ | TextureFormatSint32
132
+ | TextureFormatFloat32
133
+ | TextureFormatPacked16
134
+ | TextureFormatPacked32;
46
135
 
47
- // 16-bit formats
48
- | 'r16uint'
49
- | 'r16sint'
50
- | 'r16float'
136
+ type TextureFormatUnorm8 =
137
+ | 'r8unorm'
51
138
  | 'rg8unorm'
52
- | 'rg8snorm'
53
- | 'rg8uint'
54
- | 'rg8sint'
55
-
56
- // 32-bit formats
57
- | 'r32uint'
58
- | 'r32sint'
59
- | 'r32float'
60
- | 'rg16uint'
61
- | 'rg16sint'
62
- | 'rg16float'
139
+ | 'rgb8unorm-webgl'
63
140
  | 'rgba8unorm'
64
141
  | 'rgba8unorm-srgb'
65
- | 'rgba8snorm'
66
- | 'rgba8uint'
67
- | 'rgba8sint'
68
142
  | 'bgra8unorm'
69
- | 'bgra8unorm-srgb'
70
- // Packed 32-bit formats
71
- | 'rgb9e5ufloat'
72
- | 'rgb10a2unorm'
73
- | 'rgb10a2uint'
74
- | 'rg11b10ufloat'
143
+ | 'bgra8unorm-srgb';
75
144
 
76
- // 64-bit formats
77
- | 'rg32uint'
78
- | 'rg32sint'
79
- | 'rg32float'
80
- | 'rgba16uint'
81
- | 'rgba16sint'
82
- | 'rgba16float'
145
+ type TextureFormatSnorm8 = 'r8snorm' | 'rg8snorm' | 'rgb8snorm-webgl' | 'rgba8snorm';
83
146
 
84
- // 128-bit formats
85
- | 'rgba32uint'
86
- | 'rgba32sint'
87
- | 'rgba32float';
147
+ type TextureFormatUint8 = 'r8uint' | 'rg8uint' | 'rgba8uint';
148
+
149
+ type TextureFormatSint8 = 'r8sint' | 'rg8sint' | 'rgba8sint';
150
+
151
+ type TextureFormatUnorm16 = 'r16unorm' | 'rg16unorm' | 'rgb16unorm-webgl' | 'rgba16unorm';
152
+
153
+ type TextureFormatSnorm16 = 'r16snorm' | 'rg16snorm' | 'rgb16snorm-webgl' | 'rgba16snorm';
154
+
155
+ type TextureFormatUint16 = 'r16uint' | 'rg16uint' | 'rgba16uint';
156
+
157
+ type TextureFormatSint16 = 'r16sint' | 'rg16sint' | 'rgba16sint';
158
+
159
+ type TextureFormatFloat16 = 'r16float' | 'rg16float' | 'rgba16float';
160
+
161
+ // 96-bit formats (deprecated!)
162
+ type TextureFormatUint32 = 'r32uint' | 'rg32uint' | 'rgba32uint';
163
+
164
+ type TextureFormatSint32 = 'r32sint' | 'rg32sint' | 'rgba32sint';
165
+
166
+ type TextureFormatFloat32 = 'r32float' | 'rg32float' | 'rgb32float-webgl' | 'rgba32float';
167
+
168
+ type TextureFormatPacked16 = 'rgba4unorm-webgl' | 'rgb565unorm-webgl' | 'rgb5a1unorm-webgl';
169
+
170
+ type TextureFormatPacked32 = 'rgb9e5ufloat' | 'rg11b10ufloat' | 'rgb10a2unorm' | 'rgb10a2uint';
171
+
172
+ export type TextureFormatCompressed =
173
+ | 'bc1-rgb-unorm-webgl'
174
+ | 'bc1-rgb-unorm-srgb-webgl'
175
+ | 'pvrtc-rgb4unorm-webgl'
176
+ | 'pvrtc-rgba4unorm-webgl'
177
+ | 'pvrtc-rbg2unorm-webgl'
178
+ | 'pvrtc-rgba2unorm-webgl'
179
+ | 'etc1-rbg-unorm-webgl'
180
+ | 'atc-rgb-unorm-webgl'
181
+ | 'atc-rgba-unorm-webgl'
182
+ | 'atc-rgbai-unorm-webgl'
88
183
 
89
- export type CompressedTextureFormat =
90
184
  // BC compressed formats usable if 'texture-compression-bc' is both
91
185
  // supported by the device/user agent and enabled in requestDevice.
92
186
  | 'bc1-rgba-unorm'
@@ -149,104 +243,92 @@ export type CompressedTextureFormat =
149
243
  | 'astc-12x12-unorm'
150
244
  | 'astc-12x12-unorm-srgb';
151
245
 
152
- /** Sized formats in WebGL 2 that are not (yet?) supported by WebGPU */
153
- export type WebGL2ColorTextureFormat =
154
- | 'r16unorm-webgl'
155
- | 'r16snorm-webgl'
156
- | 'rgba4unorm-webgl'
157
- | 'rgb565unorm-webgl'
158
- | 'rgb5a1unorm-webgl'
159
- | 'rgb8unorm-webgl'
160
- | 'rgb8snorm-webgl'
161
- | 'rg16unorm-webgl'
162
- | 'rg16snorm-webgl'
163
- | 'rgb10a2uint'
164
- | 'rgb16unorm-webgl'
165
- | 'rgb16snorm-webgl'
166
- | 'rgba16unorm-webgl'
167
- | 'rgba16snorm-webgl'
168
- | 'rgb32float-webgl'
169
- | 'bc1-rgb-unorm-webgl'
170
- | 'bc1-rgb-unorm-srgb-webgl'
171
- | 'pvrtc-rgb4unorm-webgl'
172
- | 'pvrtc-rgba4unorm-webgl'
173
- | 'pvrtc-rbg2unorm-webgl'
174
- | 'pvrtc-rgba2unorm-webgl'
175
- | 'etc1-rbg-unorm-webgl'
176
- | 'atc-rgb-unorm-webgl'
177
- | 'atc-rgba-unorm-webgl'
178
- | 'atc-rgbai-unorm-webgl';
246
+ // Texture format helper types
179
247
 
180
- /**
181
- * Texture feature checks
182
- * @note these must be a subset of DeviceFeatures.
183
- */
184
- export type TextureFeature =
185
- | 'texture-compression-bc'
186
- | 'texture-compression-astc'
187
- | 'texture-compression-etc2'
188
- | 'texture-compression-etc1-webgl'
189
- | 'texture-compression-pvrtc-webgl'
190
- | 'texture-compression-atc-webgl'
191
- | 'float32-renderable-webgl'
192
- | 'float16-renderable-webgl'
193
- | 'rgb9e5ufloat-renderable-webgl'
194
- | 'snorm8-renderable-webgl'
195
- | 'norm16-renderable-webgl'
196
- | 'snorm16-renderable-webgl'
197
- | 'float32-filterable'
198
- | 'float16-filterable-webgl';
248
+ export type TextureFormatDataType<T extends TextureFormat> = T extends TextureFormatUint8
249
+ ? 'uint8'
250
+ : T extends TextureFormatSint8
251
+ ? 'sint8'
252
+ : T extends TextureFormatUnorm8
253
+ ? 'unorm8'
254
+ : T extends TextureFormatSnorm8
255
+ ? 'snorm8'
256
+ : T extends TextureFormatUint16
257
+ ? 'uint16'
258
+ : T extends TextureFormatSint16
259
+ ? 'sint16'
260
+ : T extends TextureFormatUnorm16
261
+ ? 'unorm16'
262
+ : T extends TextureFormatSnorm16
263
+ ? 'snorm16'
264
+ : T extends TextureFormatUint32
265
+ ? 'uint32'
266
+ : T extends TextureFormatSint32
267
+ ? 'sint32'
268
+ : T extends TextureFormatFloat16
269
+ ? 'float16'
270
+ : T extends TextureFormatFloat32
271
+ ? 'float32'
272
+ : T extends TextureFormatDepthStencil
273
+ ? 'uint32'
274
+ : T extends TextureFormatCompressed
275
+ ? 'uint8'
276
+ : T extends TextureFormatPacked16
277
+ ? 'uint16'
278
+ : T extends TextureFormatPacked32
279
+ ? 'uint32'
280
+ : never;
199
281
 
200
- /** Information about the structure of a texture format */
201
- export type TextureFormatInfo = {
202
- /** The format that is described */
203
- format: TextureFormat;
204
- /** Color or depth stencil attachment formats */
205
- attachment?: 'color' | 'depth' | 'stencil' | 'depth-stencil';
206
- /** String describing which channels this texture has */
207
- channels: 'r' | 'rg' | 'rgb' | 'rgba' | 'bgra';
208
- /** Number of components (corresponds to channels string) */
209
- components: 1 | 2 | 3 | 4;
210
- /** What is the data type of each component */
211
- dataType?: NormalizedDataType;
212
- /** If this is a packed data type */
213
- packed?: boolean;
214
- /** Number of bytes per pixel */
215
- bytesPerPixel?: number;
216
- /** Number of bits per channel (may be unreliable for packed formats) */
217
- bitsPerChannel: [number, number, number, number];
218
- /** SRGB texture format? */
219
- srgb?: boolean;
220
- /** WebGL specific texture format? */
221
- webgl?: boolean;
222
- /** Is this an integer or floating point format? */
223
- integer: boolean;
224
- /** Is this a signed or unsigned format? */
225
- signed: boolean;
226
- /** Is this a normalized integer format? */
227
- normalized: boolean;
228
- /** Is this a compressed texture format */
229
- compressed?: boolean;
230
- /** Compressed formats only: Block size for ASTC formats (texture width must be a multiple of this value) */
231
- blockWidth?: number;
232
- /** Compressed formats only: Block size for ASTC formats (texture height must be a multiple of this value) */
233
- blockHeight?: number;
234
- };
282
+ /*
283
+ export type TextureFormatColorWebGPU =
284
+ // 8-bit formats
285
+ | 'r8unorm'
286
+ | 'r8snorm'
287
+ | 'r8uint'
288
+ | 'r8sint'
289
+ | 'rg8unorm'
290
+ | 'rg8snorm'
291
+ | 'rg8uint'
292
+ | 'rg8sint'
293
+ | 'rgba8unorm'
294
+ | 'rgba8unorm-srgb'
295
+ | 'rgba8snorm'
296
+ | 'rgba8uint'
297
+ | 'rgba8sint'
298
+ | 'bgra8unorm'
299
+ | 'bgra8unorm-srgb'
235
300
 
236
- /**
237
- * Texture format capabilities.
238
- * @note Not directly usable. Can contain TextureFeature strings that need to be checked against a specific device.
239
- */
240
- export type TextureFormatCapabilities = {
241
- format: TextureFormat;
242
- /** Can the format be created */
243
- create: TextureFeature | boolean;
244
- /** If a feature string, the specified device feature determines if format is renderable. */
245
- render: TextureFeature | boolean;
246
- /** If a feature string, the specified device feature determines if format is filterable. */
247
- filter: TextureFeature | boolean;
248
- /** If a feature string, the specified device feature determines if format is blendable. */
249
- blend: TextureFeature | boolean;
250
- /** If a feature string, the specified device feature determines if format is storeable. */
251
- store: TextureFeature | boolean;
252
- };
301
+ // 16-bit formats
302
+ | 'r16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
303
+ | 'r16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
304
+ | 'r16uint'
305
+ | 'r16sint'
306
+ | 'r16float'
307
+ | 'rg16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
308
+ | 'rg16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
309
+ | 'rgba16unorm' // feature: 'chromium-experimental-snorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16unorm', 'rg16unorm', 'rgba16unorm',
310
+ | 'rgba16snorm' // feature: 'chromium-experimental-unorm16-texture-formats' chrome://flags/#enable-unsafe-webgpu 'r16snorm', 'rg16snorm', 'rgba16snorm'.
311
+ | 'rg16uint'
312
+ | 'rgba16uint'
313
+ | 'rg16sint'
314
+ | 'rgba16sint'
315
+ | 'rg16float'
316
+ | 'rgba16float'
317
+
318
+ // 32-bit formats
319
+ | 'r32uint'
320
+ | 'rg32uint'
321
+ | 'rgba32uint'
322
+ | 'r32sint'
323
+ | 'rg32sint'
324
+ | 'rgba32sint'
325
+ | 'r32float'
326
+ | 'rg32float'
327
+ | 'rgba32float'
328
+
329
+ // Packed 32-bit formats
330
+ | 'rgb9e5ufloat'
331
+ | 'rgb10a2unorm'
332
+ | 'rgb10a2uint'
333
+ | 'rg11b10ufloat';
334
+ */
@@ -3,13 +3,9 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import type {TypedArray} from '../../types';
6
- import type {NormalizedDataType, PrimitiveDataType, SignedDataType} from '../data-types';
7
- import type {VertexFormat, VertexFormatInfo} from '../vertex-formats';
8
- import {
9
- getDataTypeInfo,
10
- getDataTypeFromTypedArray,
11
- makeNormalizedDataType
12
- } from './decode-data-types';
6
+ import type {NormalizedDataType, PrimitiveDataType, SignedDataType} from '../data-types/data-types';
7
+ import type {VertexFormat, VertexFormatInfo} from './vertex-formats';
8
+ import {getDataTypeInfo, getDataType, getNormalizedDataType} from '../data-types/decode-data-types';
13
9
 
14
10
  /**
15
11
  * Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized)
@@ -48,14 +44,14 @@ export function makeVertexFormat(
48
44
  normalized?: boolean
49
45
  ): VertexFormat {
50
46
  const dataType: NormalizedDataType = normalized
51
- ? makeNormalizedDataType(signedDataType)
47
+ ? getNormalizedDataType(signedDataType)
52
48
  : signedDataType;
53
49
 
54
50
  switch (dataType) {
55
51
  // TODO - Special cases for WebGL (not supported on WebGPU), overrides the check below
56
52
  case 'unorm8':
57
53
  if (components === 1) {
58
- return 'unorm8-webgl';
54
+ return 'unorm8';
59
55
  }
60
56
  if (components === 3) {
61
57
  return 'unorm8x3-webgl';
@@ -94,7 +90,7 @@ export function getVertexFormatFromAttribute(
94
90
  }
95
91
 
96
92
  const components = size as 1 | 2 | 3 | 4;
97
- const signedDataType = getDataTypeFromTypedArray(typedArray);
93
+ const signedDataType = getDataType(typedArray);
98
94
  return makeVertexFormat(signedDataType, components, normalized);
99
95
  }
100
96
 
@@ -2,29 +2,40 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {NormalizedDataType} from './data-types';
5
+ import {NormalizedDataType} from '../data-types/data-types';
6
6
 
7
+ /*
8
+ */
7
9
  /**
8
10
  * Describes the **memory format** and interpretation (normalization) of a buffer that will be supplied to vertex attributes
9
11
  * @note Must be compatible with the AttributeShaderType of the shaders, see documentation.
10
- * @note This is a superset of WebGPU vertex formats to allow foe some flexibility for WebGL only applications
12
+ * @note This is a superset of WebGPU vertex formats to allow for some flexibility for WebGL only applications
11
13
  * @todo Add device.isTextureFormatSupported() method?
12
14
  */
13
15
  export type VertexFormat =
14
16
  // 8 bit integers, note that only 16 bit aligned formats are supported in WebGPU (x2 and x4)
17
+ | 'uint8' // Chrome 133+
15
18
  | 'uint8x2'
16
19
  | 'uint8x4'
20
+ | 'sint8' // Chrome 133+
17
21
  | 'sint8x2'
18
22
  | 'sint8x4'
19
- | 'unorm8-webgl'
23
+ | 'unorm8' // Chrome 133+
20
24
  | 'unorm8x2'
21
- | 'unorm8x3-webgl'
25
+ | 'unorm8x3-webgl' // Not in WebGPU
22
26
  | 'unorm8x4'
23
- | 'snorm8-webgl'
27
+ | 'unorm8x4-bgra' // Chrome 133+
28
+ | 'unorm10-10-10-2' // Chrome 119+
29
+ // | 'snorm-10-10-10-2' // Not in WebGPU, DXD12 doesn't support
30
+ | 'snorm8' // Chrome 133+
24
31
  | 'snorm8x2'
25
32
  | 'snorm8x3-webgl'
26
33
  | 'snorm8x4'
27
- // 16 bit integers, note that only 32 bit aligned formats are supported in WebGPU (x2 and x4)
34
+ // 16 bit integers, that only 32 bit aligned formats are supported in WebGPU (x2 and x4)
35
+ | 'uint16' // Chrome 133+
36
+ | 'sint16' // Chrome 133+
37
+ | 'unorm16' // Chrome 133+
38
+ | 'snorm16' // Chrome 133+
28
39
  | 'uint16x2'
29
40
  | 'uint16x4'
30
41
  | 'sint16x2'
@@ -52,6 +63,7 @@ export type VertexFormat =
52
63
  // | 'snorm32x3'
53
64
  // | 'snorm32x4'
54
65
  // floats
66
+ | 'float16' // Chrome 133+
55
67
  | 'float16x2'
56
68
  | 'float16x4'
57
69
  | 'float32'
@@ -72,6 +84,8 @@ export type VertexFormatInfo = {
72
84
  signed: boolean;
73
85
  /** Is this a normalized format? */
74
86
  normalized: boolean;
87
+ /** Is this a bgra format? */
88
+ bgra?: boolean;
75
89
  /** Is this a webgl only format? */
76
90
  webglOnly?: boolean;
77
91
  };
@@ -1,11 +0,0 @@
1
- import type { BufferLayout } from "../adapter/types/buffer-layout.js";
2
- /** BufferLayoutHelper is a helper class that should not be used directly by applications */
3
- export declare class BufferLayoutHelper {
4
- bufferLayouts: BufferLayout[];
5
- constructor(bufferLayouts: BufferLayout[]);
6
- getBufferLayout(name: string): BufferLayout | null;
7
- /** Get attribute names from a BufferLayout */
8
- getAttributeNamesForBuffer(bufferLayout: BufferLayout): string[];
9
- mergeBufferLayouts(bufferLayouts1: BufferLayout[], bufferLayouts2: BufferLayout[]): BufferLayout[];
10
- }
11
- //# sourceMappingURL=buffer-layout-helper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer-layout-helper.d.ts","sourceRoot":"","sources":["../../src/adapter-utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,0CAAuC;AAEjE,4FAA4F;AAC5F,qBAAa,kBAAkB;IAC7B,aAAa,EAAE,YAAY,EAAE,CAAC;gBAElB,aAAa,EAAE,YAAY,EAAE;IAIzC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAIlD,8CAA8C;IAC9C,0BAA0B,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE;IAMhE,kBAAkB,CAChB,cAAc,EAAE,YAAY,EAAE,EAC9B,cAAc,EAAE,YAAY,EAAE,GAC7B,YAAY,EAAE;CAYlB"}
@@ -1,33 +0,0 @@
1
- // luma.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- /** BufferLayoutHelper is a helper class that should not be used directly by applications */
5
- export class BufferLayoutHelper {
6
- bufferLayouts;
7
- constructor(bufferLayouts) {
8
- this.bufferLayouts = bufferLayouts;
9
- }
10
- getBufferLayout(name) {
11
- return this.bufferLayouts.find(layout => layout.name === name) || null;
12
- }
13
- /** Get attribute names from a BufferLayout */
14
- getAttributeNamesForBuffer(bufferLayout) {
15
- return bufferLayout.attributes
16
- ? bufferLayout.attributes?.map(layout => layout.attribute)
17
- : [bufferLayout.name];
18
- }
19
- mergeBufferLayouts(bufferLayouts1, bufferLayouts2) {
20
- const mergedLayouts = [...bufferLayouts1];
21
- for (const attribute of bufferLayouts2) {
22
- const index = mergedLayouts.findIndex(attribute2 => attribute2.name === attribute.name);
23
- if (index < 0) {
24
- mergedLayouts.push(attribute);
25
- }
26
- else {
27
- mergedLayouts[index] = attribute;
28
- }
29
- }
30
- return mergedLayouts;
31
- }
32
- }
33
- //# sourceMappingURL=buffer-layout-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer-layout-helper.js","sourceRoot":"","sources":["../../src/adapter-utils/buffer-layout-helper.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,4FAA4F;AAC5F,MAAM,OAAO,kBAAkB;IAC7B,aAAa,CAAiB;IAE9B,YAAY,aAA6B;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,eAAe,CAAC,IAAY;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACzE,CAAC;IAED,8CAA8C;IAC9C,0BAA0B,CAAC,YAA0B;QACnD,OAAO,YAAY,CAAC,UAAU;YAC5B,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;YAC1D,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED,kBAAkB,CAChB,cAA8B,EAC9B,cAA8B;QAE9B,MAAM,aAAa,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;QAC1C,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;YACxF,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YACnC,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../../src/shadertypes/data-types.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9F,gEAAgE;AAChE,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,iBAAiB,CAAC;IACjC,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-types.js","sourceRoot":"","sources":["../../src/shadertypes/data-types.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader-types.d.ts","sourceRoot":"","sources":["../../src/shadertypes/shader-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAC,wBAAqB;AAEpD;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,QAAQ,iBAAiB,GAAG,GAC5B,QAAQ,iBAAiB,GAAG,GAC5B,QAAQ,iBAAiB,GAAG,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC1B,iBAAiB,GACjB,QAAQ,iBAAiB,GAAG,GAC5B,QAAQ,iBAAiB,GAAG,GAC5B,QAAQ,iBAAiB,GAAG,GAC5B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,GAC9B,UAAU,iBAAiB,GAAG,CAAC;AAGnC,KAAK,qBAAqB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnD,gDAAgD;AAChD,MAAM,MAAM,wBAAwB,GAChC,OAAO,qBAAqB,EAAE,GAC9B,OAAO,qBAAqB,EAAE,GAC9B,OAAO,qBAAqB,EAAE,CAAC;AAEnC,gDAAgD;AAChD,MAAM,MAAM,uBAAuB,GAC/B,wBAAwB,GACxB,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,GAChC,SAAS,qBAAqB,EAAE,CAAC;AAErC,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAE1F,kCAAkC;AAClC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC9C,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,uBAAuB,GAAG;IACpC,oDAAoD;IACpD,aAAa,EAAE,iBAAiB,CAAC;IACjC,wEAAwE;IACxE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"shader-types.js","sourceRoot":"","sources":["../../src/shadertypes/shader-types.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC"}