@luma.gl/webgpu 9.0.0-alpha.16 → 9.0.0-alpha.17

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 (199) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/adapter/.DS_Store +0 -0
  3. package/dist/adapter/helpers/accessor-to-format.js +1 -100
  4. package/dist/adapter/helpers/accessor-to-format.js.map +1 -0
  5. package/dist/adapter/helpers/convert-texture-format.d.ts +1 -1
  6. package/dist/adapter/helpers/convert-texture-format.js +5 -5
  7. package/dist/adapter/helpers/convert-texture-format.js.map +1 -0
  8. package/dist/adapter/helpers/generate-mipmaps.d.ts +1 -1
  9. package/dist/adapter/helpers/generate-mipmaps.js +85 -88
  10. package/dist/adapter/helpers/generate-mipmaps.js.map +1 -0
  11. package/dist/adapter/helpers/get-bind-group.d.ts +1 -1
  12. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  13. package/dist/adapter/helpers/get-bind-group.js +39 -54
  14. package/dist/adapter/helpers/get-bind-group.js.map +1 -0
  15. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +1 -1
  16. package/dist/adapter/helpers/get-vertex-buffer-layout.js +72 -97
  17. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -0
  18. package/dist/adapter/helpers/webgpu-parameters.d.ts +1 -1
  19. package/dist/adapter/helpers/webgpu-parameters.js +125 -182
  20. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -0
  21. package/dist/adapter/resources/webgpu-buffer.d.ts +1 -1
  22. package/dist/adapter/resources/webgpu-buffer.js +63 -57
  23. package/dist/adapter/resources/webgpu-buffer.js.map +1 -0
  24. package/dist/adapter/resources/webgpu-command-encoder.d.ts +1 -1
  25. package/dist/adapter/resources/webgpu-command-encoder.js +46 -47
  26. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -0
  27. package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
  28. package/dist/adapter/resources/webgpu-compute-pass.js +41 -51
  29. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -0
  30. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +1 -1
  31. package/dist/adapter/resources/webgpu-compute-pipeline.js +20 -22
  32. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -0
  33. package/dist/adapter/resources/webgpu-external-texture.d.ts +1 -1
  34. package/dist/adapter/resources/webgpu-external-texture.js +20 -26
  35. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -0
  36. package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -1
  37. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  38. package/dist/adapter/resources/webgpu-framebuffer.js +86 -89
  39. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -0
  40. package/dist/adapter/resources/webgpu-query.js +1 -42
  41. package/dist/adapter/resources/webgpu-query.js.map +1 -0
  42. package/dist/adapter/resources/webgpu-render-pass.d.ts +1 -1
  43. package/dist/adapter/resources/webgpu-render-pass.js +70 -64
  44. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -0
  45. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +1 -1
  46. package/dist/adapter/resources/webgpu-render-pipeline.js +118 -158
  47. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -0
  48. package/dist/adapter/resources/webgpu-sampler.d.ts +2 -2
  49. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  50. package/dist/adapter/resources/webgpu-sampler.js +16 -16
  51. package/dist/adapter/resources/webgpu-sampler.js.map +1 -0
  52. package/dist/adapter/resources/webgpu-shader.d.ts +2 -2
  53. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  54. package/dist/adapter/resources/webgpu-shader.js +44 -47
  55. package/dist/adapter/resources/webgpu-shader.js.map +1 -0
  56. package/dist/adapter/resources/webgpu-texture.d.ts +2 -1
  57. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  58. package/dist/adapter/resources/webgpu-texture.js +87 -100
  59. package/dist/adapter/resources/webgpu-texture.js.map +1 -0
  60. package/dist/adapter/webgpu-canvas-context.d.ts +1 -1
  61. package/dist/adapter/webgpu-canvas-context.js +68 -77
  62. package/dist/adapter/webgpu-canvas-context.js.map +1 -0
  63. package/dist/adapter/webgpu-device.d.ts +1 -1
  64. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  65. package/dist/adapter/webgpu-device.js +194 -215
  66. package/dist/adapter/webgpu-device.js.map +1 -0
  67. package/dist/adapter/webgpu-types.js +2 -0
  68. package/dist/adapter/webgpu-types.js.map +1 -0
  69. package/dist/dist.dev.js +3061 -0
  70. package/dist/glsl/glsllang.js +6 -9
  71. package/dist/glsl/glsllang.js.map +1 -0
  72. package/dist/index.cjs +1442 -0
  73. package/dist/index.d.ts +0 -2
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +6 -10
  76. package/dist/index.js.map +1 -0
  77. package/dist.min.js +17 -0
  78. package/package.json +17 -8
  79. package/src/.DS_Store +0 -0
  80. package/src/adapter/.DS_Store +0 -0
  81. package/src/adapter/helpers/generate-mipmaps.ts +1 -1
  82. package/src/adapter/helpers/get-bind-group.ts +1 -1
  83. package/src/adapter/helpers/get-vertex-buffer-layout.ts +2 -2
  84. package/src/adapter/helpers/webgpu-parameters.ts +9 -9
  85. package/src/adapter/resources/webgpu-command-encoder.ts +3 -3
  86. package/src/adapter/resources/webgpu-framebuffer.ts +5 -5
  87. package/src/adapter/resources/webgpu-render-pipeline.ts +2 -2
  88. package/src/adapter/webgpu-device.ts +2 -1
  89. package/src/index.ts +1 -4
  90. package/dist/bundle.d.ts +0 -2
  91. package/dist/bundle.d.ts.map +0 -1
  92. package/dist/bundle.js +0 -4
  93. package/dist/dist.js +0 -8051
  94. package/dist/dist.min.js +0 -1
  95. package/dist/es5/adapter/helpers/accessor-to-format.js +0 -2
  96. package/dist/es5/adapter/helpers/accessor-to-format.js.map +0 -1
  97. package/dist/es5/adapter/helpers/convert-texture-format.js +0 -13
  98. package/dist/es5/adapter/helpers/convert-texture-format.js.map +0 -1
  99. package/dist/es5/adapter/helpers/generate-mipmaps.js +0 -103
  100. package/dist/es5/adapter/helpers/generate-mipmaps.js.map +0 -1
  101. package/dist/es5/adapter/helpers/get-bind-group.js +0 -66
  102. package/dist/es5/adapter/helpers/get-bind-group.js.map +0 -1
  103. package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js +0 -149
  104. package/dist/es5/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
  105. package/dist/es5/adapter/helpers/webgpu-parameters.js +0 -150
  106. package/dist/es5/adapter/helpers/webgpu-parameters.js.map +0 -1
  107. package/dist/es5/adapter/resources/webgpu-buffer.js +0 -131
  108. package/dist/es5/adapter/resources/webgpu-buffer.js.map +0 -1
  109. package/dist/es5/adapter/resources/webgpu-command-encoder.js +0 -90
  110. package/dist/es5/adapter/resources/webgpu-command-encoder.js.map +0 -1
  111. package/dist/es5/adapter/resources/webgpu-compute-pass.js +0 -85
  112. package/dist/es5/adapter/resources/webgpu-compute-pass.js.map +0 -1
  113. package/dist/es5/adapter/resources/webgpu-compute-pipeline.js +0 -48
  114. package/dist/es5/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
  115. package/dist/es5/adapter/resources/webgpu-external-texture.js +0 -50
  116. package/dist/es5/adapter/resources/webgpu-external-texture.js.map +0 -1
  117. package/dist/es5/adapter/resources/webgpu-framebuffer.js +0 -126
  118. package/dist/es5/adapter/resources/webgpu-framebuffer.js.map +0 -1
  119. package/dist/es5/adapter/resources/webgpu-query.js +0 -2
  120. package/dist/es5/adapter/resources/webgpu-query.js.map +0 -1
  121. package/dist/es5/adapter/resources/webgpu-render-pass.js +0 -124
  122. package/dist/es5/adapter/resources/webgpu-render-pass.js.map +0 -1
  123. package/dist/es5/adapter/resources/webgpu-render-pipeline.js +0 -185
  124. package/dist/es5/adapter/resources/webgpu-render-pipeline.js.map +0 -1
  125. package/dist/es5/adapter/resources/webgpu-sampler.js +0 -45
  126. package/dist/es5/adapter/resources/webgpu-sampler.js.map +0 -1
  127. package/dist/es5/adapter/resources/webgpu-shader.js +0 -125
  128. package/dist/es5/adapter/resources/webgpu-shader.js.map +0 -1
  129. package/dist/es5/adapter/resources/webgpu-texture.js +0 -138
  130. package/dist/es5/adapter/resources/webgpu-texture.js.map +0 -1
  131. package/dist/es5/adapter/webgpu-canvas-context.js +0 -111
  132. package/dist/es5/adapter/webgpu-canvas-context.js.map +0 -1
  133. package/dist/es5/adapter/webgpu-device.js +0 -317
  134. package/dist/es5/adapter/webgpu-device.js.map +0 -1
  135. package/dist/es5/adapter/webgpu-types.js +0 -2
  136. package/dist/es5/adapter/webgpu-types.js.map +0 -1
  137. package/dist/es5/bundle.js +0 -6
  138. package/dist/es5/bundle.js.map +0 -1
  139. package/dist/es5/glsl/glsllang.js +0 -47
  140. package/dist/es5/glsl/glsllang.js.map +0 -1
  141. package/dist/es5/index.js +0 -44
  142. package/dist/es5/index.js.map +0 -1
  143. package/dist/es5/init.js +0 -7
  144. package/dist/es5/init.js.map +0 -1
  145. package/dist/esm/adapter/helpers/accessor-to-format.js +0 -2
  146. package/dist/esm/adapter/helpers/accessor-to-format.js.map +0 -1
  147. package/dist/esm/adapter/helpers/convert-texture-format.js +0 -7
  148. package/dist/esm/adapter/helpers/convert-texture-format.js.map +0 -1
  149. package/dist/esm/adapter/helpers/generate-mipmaps.js +0 -88
  150. package/dist/esm/adapter/helpers/generate-mipmaps.js.map +0 -1
  151. package/dist/esm/adapter/helpers/get-bind-group.js +0 -51
  152. package/dist/esm/adapter/helpers/get-bind-group.js.map +0 -1
  153. package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js +0 -83
  154. package/dist/esm/adapter/helpers/get-vertex-buffer-layout.js.map +0 -1
  155. package/dist/esm/adapter/helpers/webgpu-parameters.js +0 -137
  156. package/dist/esm/adapter/helpers/webgpu-parameters.js.map +0 -1
  157. package/dist/esm/adapter/resources/webgpu-buffer.js +0 -70
  158. package/dist/esm/adapter/resources/webgpu-buffer.js.map +0 -1
  159. package/dist/esm/adapter/resources/webgpu-command-encoder.js +0 -49
  160. package/dist/esm/adapter/resources/webgpu-command-encoder.js.map +0 -1
  161. package/dist/esm/adapter/resources/webgpu-compute-pass.js +0 -44
  162. package/dist/esm/adapter/resources/webgpu-compute-pass.js.map +0 -1
  163. package/dist/esm/adapter/resources/webgpu-compute-pipeline.js +0 -23
  164. package/dist/esm/adapter/resources/webgpu-compute-pipeline.js.map +0 -1
  165. package/dist/esm/adapter/resources/webgpu-external-texture.js +0 -23
  166. package/dist/esm/adapter/resources/webgpu-external-texture.js.map +0 -1
  167. package/dist/esm/adapter/resources/webgpu-framebuffer.js +0 -93
  168. package/dist/esm/adapter/resources/webgpu-framebuffer.js.map +0 -1
  169. package/dist/esm/adapter/resources/webgpu-query.js +0 -2
  170. package/dist/esm/adapter/resources/webgpu-query.js.map +0 -1
  171. package/dist/esm/adapter/resources/webgpu-render-pass.js +0 -79
  172. package/dist/esm/adapter/resources/webgpu-render-pass.js.map +0 -1
  173. package/dist/esm/adapter/resources/webgpu-render-pipeline.js +0 -130
  174. package/dist/esm/adapter/resources/webgpu-render-pipeline.js.map +0 -1
  175. package/dist/esm/adapter/resources/webgpu-sampler.js +0 -20
  176. package/dist/esm/adapter/resources/webgpu-sampler.js.map +0 -1
  177. package/dist/esm/adapter/resources/webgpu-shader.js +0 -50
  178. package/dist/esm/adapter/resources/webgpu-shader.js.map +0 -1
  179. package/dist/esm/adapter/resources/webgpu-texture.js +0 -95
  180. package/dist/esm/adapter/resources/webgpu-texture.js.map +0 -1
  181. package/dist/esm/adapter/webgpu-canvas-context.js +0 -74
  182. package/dist/esm/adapter/webgpu-canvas-context.js.map +0 -1
  183. package/dist/esm/adapter/webgpu-device.js +0 -196
  184. package/dist/esm/adapter/webgpu-device.js.map +0 -1
  185. package/dist/esm/adapter/webgpu-types.js +0 -2
  186. package/dist/esm/adapter/webgpu-types.js.map +0 -1
  187. package/dist/esm/bundle.js +0 -4
  188. package/dist/esm/bundle.js.map +0 -1
  189. package/dist/esm/glsl/glsllang.js +0 -9
  190. package/dist/esm/glsl/glsllang.js.map +0 -1
  191. package/dist/esm/index.js +0 -8
  192. package/dist/esm/index.js.map +0 -1
  193. package/dist/esm/init.js +0 -4
  194. package/dist/esm/init.js.map +0 -1
  195. package/dist/init.d.ts +0 -2
  196. package/dist/init.d.ts.map +0 -1
  197. package/dist/init.js +0 -3
  198. package/src/bundle.ts +0 -4
  199. package/src/init.ts +0 -4
package/dist/.DS_Store ADDED
Binary file
Binary file
@@ -1,101 +1,2 @@
1
- /*
2
- import {assert} from '@luma.gl/api';
3
- import GL from '@luma.gl/constants';
4
1
 
5
- type Accessor = Record<string, any>;
6
-
7
- const FORMAT_TO_ACCESSOR: Record<GPUVertexFormat, Accessor> = {
8
- uchar2: {type: 'uchar', size: 2},
9
- uchar4: {type: 'uchar', size: 4},
10
- char2: {type: 'char', size: 2},
11
- char4: {type: 'char', size: 4},
12
- uchar2norm: {type: 'uchar', size: 2, normalized: true},
13
- uchar4norm: {type: 'uchar', size: 4, normalized: true},
14
- char2norm: {type: 'char', size: 2, normalized: true},
15
- char4norm: {type: 'char', size: 4, normalized: true},
16
- ushort2: {type: 'ushort', size: 2},
17
- ushort4: {type: 'ushort', size: 4},
18
- short2: {type: 'short', size: 2},
19
- short4: {type: 'short', size: 4},
20
- ushort2norm: {type: 'ushort', size: 2, normalized: true},
21
- ushort4norm: {type: 'ushort', size: 4, normalized: true},
22
- short2norm: {type: 'short', size: 1, normalized: true},
23
- short4norm: {type: 'short', size: 1, normalized: true},
24
- half2: {type: 'half', size: 2},
25
- half4: {type: 'half', size: 4},
26
- float: {type: 'float', size: 1},
27
- float2: {type: 'float', size: 2},
28
- float3: {type: 'float', size: 3},
29
- float4: {type: 'float', size: 4},
30
- uint: {type: 'uint', size: 1, integer: true},
31
- uint2: {type: 'uint', size: 2, integer: true},
32
- uint3: {type: 'uint', size: 3, integer: true},
33
- uint4: {type: 'uint', size: 4, integer: true},
34
- int: {type: 'int', size: 1, integer: true},
35
- int2: {type: 'int', size: 2, integer: true},
36
- int3: {type: 'int', size: 3, integer: true},
37
- int4: {type: 'int', size: 4, integer: true}
38
- };
39
-
40
- /**
41
- * Convert from WebGPU attribute format strings to accessor {type, size, normalized, integer}
42
- * @param {*} format
43
- *
44
- export function mapWebGPUFormatToAccessor(format) {
45
- const accessorDefinition = FORMAT_TO_ACCESSOR[format];
46
- assert(accessorDefinition, 'invalid attribute format');
47
- return Object.freeze(accessorDefinition);
48
- }
49
-
50
- /**
51
- * Convert from accessor {type, size, normalized, integer} to WebGPU attribute format strings
52
- * @param {*} format
53
- *
54
- export function mapAccessorToWebGPUFormat(accessor) {
55
- const {type = GL.FLOAT, size = 1, normalized = false, integer = false} = accessor;
56
- assert(size >=1 && size <=4);
57
- // `norm` suffix (uchar4norm)
58
- const norm = normalized ? 'norm' : '';
59
- // size 1 is ommitted in format names (float vs float2)
60
- const count = size === 1 ? '' : size;
61
- switch (type) {
62
- case GL.UNSIGNED_BYTE:
63
- switch (size) {
64
- case 2:
65
- case 4:
66
- return `uchar${count}${norm}`;
67
- }
68
- case GL.BYTE:
69
- switch (size) {
70
- case 2:
71
- case 4:
72
- return `char${count}${norm}`;
73
- }
74
- case GL.UNSIGNED_SHORT:
75
- switch (size) {
76
- case 2:
77
- case 4:
78
- return `ushort${count}${norm}`;
79
- }
80
- case GL.SHORT:
81
- switch (size) {
82
- case 2:
83
- case 4:
84
- return `short${count}${norm}`;
85
- }
86
- case GL.HALF_FLOAT:
87
- switch (size) {
88
- case 2:
89
- case 4:
90
- return `half${count}`;
91
- }
92
- case GL.FLOAT:
93
- return `float${count}`;
94
- case GL.UNSIGNED_INT:
95
- return `uint${count}`;
96
- case GL.INT:
97
- return `int${count}`;
98
- }
99
- throw new Error('illegal accessor');
100
- }
101
- */
2
+ //# sourceMappingURL=accessor-to-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessor-to-format.js","names":[],"sources":["../../../src/adapter/helpers/accessor-to-format.ts"],"sourcesContent":["/*\nimport {assert} from '@luma.gl/api';\nimport GL from '@luma.gl/constants';\n\ntype Accessor = Record<string, any>;\n\nconst FORMAT_TO_ACCESSOR: Record<GPUVertexFormat, Accessor> = {\n uchar2: {type: 'uchar', size: 2},\n uchar4: {type: 'uchar', size: 4},\n char2: {type: 'char', size: 2},\n char4: {type: 'char', size: 4},\n uchar2norm: {type: 'uchar', size: 2, normalized: true},\n uchar4norm: {type: 'uchar', size: 4, normalized: true},\n char2norm: {type: 'char', size: 2, normalized: true},\n char4norm: {type: 'char', size: 4, normalized: true},\n ushort2: {type: 'ushort', size: 2},\n ushort4: {type: 'ushort', size: 4},\n short2: {type: 'short', size: 2},\n short4: {type: 'short', size: 4},\n ushort2norm: {type: 'ushort', size: 2, normalized: true},\n ushort4norm: {type: 'ushort', size: 4, normalized: true},\n short2norm: {type: 'short', size: 1, normalized: true},\n short4norm: {type: 'short', size: 1, normalized: true},\n half2: {type: 'half', size: 2},\n half4: {type: 'half', size: 4},\n float: {type: 'float', size: 1},\n float2: {type: 'float', size: 2},\n float3: {type: 'float', size: 3},\n float4: {type: 'float', size: 4},\n uint: {type: 'uint', size: 1, integer: true},\n uint2: {type: 'uint', size: 2, integer: true},\n uint3: {type: 'uint', size: 3, integer: true},\n uint4: {type: 'uint', size: 4, integer: true},\n int: {type: 'int', size: 1, integer: true},\n int2: {type: 'int', size: 2, integer: true},\n int3: {type: 'int', size: 3, integer: true},\n int4: {type: 'int', size: 4, integer: true}\n};\n\n/**\n * Convert from WebGPU attribute format strings to accessor {type, size, normalized, integer}\n * @param {*} format\n *\nexport function mapWebGPUFormatToAccessor(format) {\n const accessorDefinition = FORMAT_TO_ACCESSOR[format];\n assert(accessorDefinition, 'invalid attribute format');\n return Object.freeze(accessorDefinition);\n}\n\n/**\n * Convert from accessor {type, size, normalized, integer} to WebGPU attribute format strings\n * @param {*} format\n *\nexport function mapAccessorToWebGPUFormat(accessor) {\n const {type = GL.FLOAT, size = 1, normalized = false, integer = false} = accessor;\n assert(size >=1 && size <=4);\n // `norm` suffix (uchar4norm)\n const norm = normalized ? 'norm' : '';\n // size 1 is ommitted in format names (float vs float2)\n const count = size === 1 ? '' : size;\n switch (type) {\n case GL.UNSIGNED_BYTE:\n switch (size) {\n case 2:\n case 4:\n return `uchar${count}${norm}`;\n }\n case GL.BYTE:\n switch (size) {\n case 2:\n case 4:\n return `char${count}${norm}`;\n }\n case GL.UNSIGNED_SHORT:\n switch (size) {\n case 2:\n case 4:\n return `ushort${count}${norm}`;\n }\n case GL.SHORT:\n switch (size) {\n case 2:\n case 4:\n return `short${count}${norm}`;\n }\n case GL.HALF_FLOAT:\n switch (size) {\n case 2:\n case 4:\n return `half${count}`;\n }\n case GL.FLOAT:\n return `float${count}`;\n case GL.UNSIGNED_INT:\n return `uint${count}`;\n case GL.INT:\n return `int${count}`;\n }\n throw new Error('illegal accessor');\n}\n*/"],"mappings":""}
@@ -1,4 +1,4 @@
1
- /// <reference types="@webgpu/types" />
1
+ /// <reference types="dist" />
2
2
  import { TextureFormat } from '@luma.gl/api';
3
3
  /** Ensure a texture format is WebGPU compatible */
4
4
  export declare function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat;
@@ -1,7 +1,7 @@
1
- /** Ensure a texture format is WebGPU compatible */
2
1
  export function getWebGPUTextureFormat(format) {
3
- if (format.includes('webgl')) {
4
- throw new Error('webgl-only format');
5
- }
6
- return format;
2
+ if (format.includes('webgl')) {
3
+ throw new Error('webgl-only format');
4
+ }
5
+ return format;
7
6
  }
7
+ //# sourceMappingURL=convert-texture-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-texture-format.js","names":["getWebGPUTextureFormat","format","includes","Error"],"sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {TextureFormat} from '@luma.gl/api';\n\n/** Ensure a texture format is WebGPU compatible */\nexport function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat {\n if (format.includes('webgl')) {\n throw new Error('webgl-only format');\n }\n return format as GPUTextureFormat;\n}\n"],"mappings":"AAIA,OAAO,SAASA,sBAAsBA,CAACC,MAAqB,EAAoB;EAC9E,IAAIA,MAAM,CAACC,QAAQ,CAAC,OAAO,CAAC,EAAE;IAC5B,MAAM,IAAIC,KAAK,CAAC,mBAAmB,CAAC;EACtC;EACA,OAAOF,MAAM;AACf"}
@@ -1,4 +1,4 @@
1
- /// <reference types="@webgpu/types" />
1
+ /// <reference types="dist" />
2
2
  /** WebGPU does not have built-in mipmap creation */
3
3
  export declare class WebGPUMipmapGenerator {
4
4
  device: GPUDevice;
@@ -1,91 +1,88 @@
1
- // luma.gl, MIT license
2
- // Forked from Kangz/mipmapper.js under MIT license Copyright 2020 Brandon Jones
3
- // https://gist.github.com/Kangz/782d5f1ae502daf53910a13f55db2f83
4
- // @ts-nocheck this is written against outdated WebGPU API, needs an update pass
5
- const VS_GEN_MIPMAP = `\#version 450
6
- const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));
7
- layout(location = 0) out vec2 vTex;
8
- void main() {
9
- gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
10
- vTex = gl_Position / 2.0f + vec2(0.5f);
11
- }`;
12
- const FS_GEN_MIPMAP = `#version 450
13
- layout(set = 0, binding = 0) uniform sampler imgSampler;
14
- layout(set = 0, binding = 1) uniform texture2D img;
15
- layout(location = 0) in vec2 vTex;
16
- layout(location = 0) out vec4 outColor;
17
- void main() {
18
- outColor = texture(sampler2D(img, imgSampler), vTex);
19
- }`;
20
- /** WebGPU does not have built-in mipmap creation */
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ const VS_GEN_MIPMAP = "#version 450\nconst vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\nlayout(location = 0) out vec2 vTex;\nvoid main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n vTex = gl_Position / 2.0f + vec2(0.5f);\n}";
3
+ const FS_GEN_MIPMAP = "#version 450\nlayout(set = 0, binding = 0) uniform sampler imgSampler;\nlayout(set = 0, binding = 1) uniform texture2D img;\nlayout(location = 0) in vec2 vTex;\nlayout(location = 0) out vec4 outColor;\nvoid main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n}";
21
4
  export class WebGPUMipmapGenerator {
22
- constructor(device, glslang) {
23
- this.device = device;
24
- this.mipmapSampler = device.createSampler({ minFilter: 'linear' });
25
- this.mipmapPipeline = device.createRenderPipeline({
26
- vertexStage: {
27
- module: device.createShaderModule({
28
- code: glslang.compileGLSL(VS_GEN_MIPMAP, 'vertex')
29
- }),
30
- entryPoint: 'main'
31
- },
32
- fragmentStage: {
33
- module: device.createShaderModule({
34
- code: glslang.compileGLSL(FS_GEN_MIPMAP, 'fragment')
35
- }),
36
- entryPoint: 'main'
37
- },
38
- primitiveTopology: 'triangle-strip',
39
- colorStates: [{
40
- format: 'rgba8unorm',
41
- }]
42
- });
43
- }
44
- generateMipmappedTexture(imageBitmap) {
45
- let textureSize = {
46
- width: imageBitmap.width,
47
- height: imageBitmap.height,
48
- depth: 1,
49
- };
50
- const mipLevelCount = Math.floor(Math.log2(Math.max(imageBitmap.width, imageBitmap.height))) + 1;
51
- // Populate the top level of the srcTexture with the imageBitmap.
52
- const texture = this.device.createTexture({
53
- size: textureSize,
54
- format: 'rgba8unorm',
55
- usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.SAMPLED | GPUTextureUsage.OUTPUT_ATTACHMENT,
56
- mipLevelCount
57
- });
58
- this.device.queue.copyImageBitmapToTexture({ imageBitmap }, { texture: srcTexture }, textureSize);
59
- const commandEncoder = this.device.createCommandEncoder({});
60
- for (let i = 1; i < mipLevelCount; ++i) {
61
- const passEncoder = commandEncoder.beginRenderPass({
62
- colorAttachments: [{
63
- attachment: texture.createView({
64
- baseMipLevel: i,
65
- mipLevelCount: 1
66
- }),
67
- loadValue: { r: 1.0, g: 0.0, b: 0.0, a: 0.0 },
68
- }],
69
- });
70
- const bindGroup = this.device.createBindGroup({
71
- layout: this.mipmapPipeline.getBindGroupLayout(0),
72
- bindings: [{
73
- binding: 0,
74
- resource: this.mipmapSampler,
75
- }, {
76
- binding: 1,
77
- resource: texture.createView({
78
- baseMipLevel: i - 1,
79
- mipLevelCount: 1
80
- }),
81
- }],
82
- });
83
- passEncoder.setPipeline(this.mipmapPipeline);
84
- passEncoder.setBindGroup(0, bindGroup);
85
- passEncoder.draw(4);
86
- passEncoder.endPass();
87
- }
88
- this.device.queue.submit([commandEncoder.finish()]);
89
- return texture;
5
+ constructor(device, glslang) {
6
+ _defineProperty(this, "device", void 0);
7
+ _defineProperty(this, "mipmapSampler", void 0);
8
+ _defineProperty(this, "mipmapPipeline", void 0);
9
+ this.device = device;
10
+ this.mipmapSampler = device.createSampler({
11
+ minFilter: 'linear'
12
+ });
13
+ this.mipmapPipeline = device.createRenderPipeline({
14
+ vertexStage: {
15
+ module: device.createShaderModule({
16
+ code: glslang.compileGLSL(VS_GEN_MIPMAP, 'vertex')
17
+ }),
18
+ entryPoint: 'main'
19
+ },
20
+ fragmentStage: {
21
+ module: device.createShaderModule({
22
+ code: glslang.compileGLSL(FS_GEN_MIPMAP, 'fragment')
23
+ }),
24
+ entryPoint: 'main'
25
+ },
26
+ primitiveTopology: 'triangle-strip',
27
+ colorStates: [{
28
+ format: 'rgba8unorm'
29
+ }]
30
+ });
31
+ }
32
+ generateMipmappedTexture(imageBitmap) {
33
+ const textureSize = {
34
+ width: imageBitmap.width,
35
+ height: imageBitmap.height,
36
+ depth: 1
37
+ };
38
+ const mipLevelCount = Math.floor(Math.log2(Math.max(imageBitmap.width, imageBitmap.height))) + 1;
39
+ const texture = this.device.createTexture({
40
+ size: textureSize,
41
+ format: 'rgba8unorm',
42
+ usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.SAMPLED | GPUTextureUsage.OUTPUT_ATTACHMENT,
43
+ mipLevelCount
44
+ });
45
+ this.device.queue.copyImageBitmapToTexture({
46
+ imageBitmap
47
+ }, {
48
+ texture: srcTexture
49
+ }, textureSize);
50
+ const commandEncoder = this.device.createCommandEncoder({});
51
+ for (let i = 1; i < mipLevelCount; ++i) {
52
+ const passEncoder = commandEncoder.beginRenderPass({
53
+ colorAttachments: [{
54
+ attachment: texture.createView({
55
+ baseMipLevel: i,
56
+ mipLevelCount: 1
57
+ }),
58
+ loadValue: {
59
+ r: 1.0,
60
+ g: 0.0,
61
+ b: 0.0,
62
+ a: 0.0
63
+ }
64
+ }]
65
+ });
66
+ const bindGroup = this.device.createBindGroup({
67
+ layout: this.mipmapPipeline.getBindGroupLayout(0),
68
+ bindings: [{
69
+ binding: 0,
70
+ resource: this.mipmapSampler
71
+ }, {
72
+ binding: 1,
73
+ resource: texture.createView({
74
+ baseMipLevel: i - 1,
75
+ mipLevelCount: 1
76
+ })
77
+ }]
78
+ });
79
+ passEncoder.setPipeline(this.mipmapPipeline);
80
+ passEncoder.setBindGroup(0, bindGroup);
81
+ passEncoder.draw(4);
82
+ passEncoder.endPass();
90
83
  }
84
+ this.device.queue.submit([commandEncoder.finish()]);
85
+ return texture;
86
+ }
91
87
  }
88
+ //# sourceMappingURL=generate-mipmaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-mipmaps.js","names":["VS_GEN_MIPMAP","FS_GEN_MIPMAP","WebGPUMipmapGenerator","constructor","device","glslang","_defineProperty","mipmapSampler","createSampler","minFilter","mipmapPipeline","createRenderPipeline","vertexStage","module","createShaderModule","code","compileGLSL","entryPoint","fragmentStage","primitiveTopology","colorStates","format","generateMipmappedTexture","imageBitmap","textureSize","width","height","depth","mipLevelCount","Math","floor","log2","max","texture","createTexture","size","usage","GPUTextureUsage","COPY_DST","SAMPLED","OUTPUT_ATTACHMENT","queue","copyImageBitmapToTexture","srcTexture","commandEncoder","createCommandEncoder","i","passEncoder","beginRenderPass","colorAttachments","attachment","createView","baseMipLevel","loadValue","r","g","b","a","bindGroup","createBindGroup","layout","getBindGroupLayout","bindings","binding","resource","setPipeline","setBindGroup","draw","endPass","submit","finish"],"sources":["../../../src/adapter/helpers/generate-mipmaps.ts"],"sourcesContent":["// luma.gl, MIT license\n// Forked from Kangz/mipmapper.js under MIT license Copyright 2020 Brandon Jones\n// https://gist.github.com/Kangz/782d5f1ae502daf53910a13f55db2f83\n\n// @ts-nocheck this is written against outdated WebGPU API, needs an update pass\n\nconst VS_GEN_MIPMAP = `\\#version 450\nconst vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\nlayout(location = 0) out vec2 vTex;\nvoid main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n vTex = gl_Position / 2.0f + vec2(0.5f);\n}`;\n\nconst FS_GEN_MIPMAP = `#version 450\nlayout(set = 0, binding = 0) uniform sampler imgSampler;\nlayout(set = 0, binding = 1) uniform texture2D img;\nlayout(location = 0) in vec2 vTex;\nlayout(location = 0) out vec4 outColor;\nvoid main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n}`;\n\n/** WebGPU does not have built-in mipmap creation */\nexport class WebGPUMipmapGenerator {\n device: GPUDevice;\n mipmapSampler: GPUSampler;\n mipmapPipeline: GPURenderPipeline;\n\n constructor(device: GPUDevice, glslang) {\n this.device = device;\n\n this.mipmapSampler = device.createSampler({ minFilter: 'linear' });\n\n this.mipmapPipeline = device.createRenderPipeline({\n vertexStage: {\n module: device.createShaderModule({\n code: glslang.compileGLSL(VS_GEN_MIPMAP, 'vertex')\n }),\n entryPoint: 'main'\n },\n fragmentStage: {\n module: device.createShaderModule({\n code: glslang.compileGLSL(FS_GEN_MIPMAP, 'fragment')\n }),\n entryPoint: 'main'\n },\n primitiveTopology: 'triangle-strip',\n colorStates: [{\n format: 'rgba8unorm',\n }]\n });\n }\n\n generateMipmappedTexture(imageBitmap: ImageBitmap) {\n const textureSize = {\n width: imageBitmap.width,\n height: imageBitmap.height,\n depth: 1,\n }\n const mipLevelCount = Math.floor(Math.log2(Math.max(imageBitmap.width, imageBitmap.height))) + 1;\n\n // Populate the top level of the srcTexture with the imageBitmap.\n const texture = this.device.createTexture({\n size: textureSize,\n format: 'rgba8unorm',\n usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.SAMPLED | GPUTextureUsage.OUTPUT_ATTACHMENT,\n mipLevelCount\n });\n this.device.queue.copyImageBitmapToTexture({ imageBitmap }, { texture: srcTexture }, textureSize);\n\n const commandEncoder = this.device.createCommandEncoder({});\n for (let i = 1; i < mipLevelCount; ++i) {\n const passEncoder = commandEncoder.beginRenderPass({\n colorAttachments: [{\n attachment: texture.createView({\n baseMipLevel: i,\n mipLevelCount: 1\n }),\n loadValue: { r: 1.0, g: 0.0, b: 0.0, a: 0.0 },\n }],\n });\n\n const bindGroup = this.device.createBindGroup({\n layout: this.mipmapPipeline.getBindGroupLayout(0),\n bindings: [{\n binding: 0,\n resource: this.mipmapSampler,\n }, {\n binding: 1,\n resource: texture.createView({\n baseMipLevel: i - 1,\n mipLevelCount: 1\n }),\n }],\n });\n\n passEncoder.setPipeline(this.mipmapPipeline);\n passEncoder.setBindGroup(0, bindGroup);\n passEncoder.draw(4);\n passEncoder.endPass();\n }\n\n this.device.queue.submit([commandEncoder.finish()]);\n return texture;\n }\n}\n"],"mappings":";AAMA,MAAMA,aAAa,mRAMjB;AAEF,MAAMC,aAAa,wRAOjB;AAGF,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAACC,MAAiB,EAAEC,OAAO,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACtC,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACG,aAAa,GAAGH,MAAM,CAACI,aAAa,CAAC;MAAEC,SAAS,EAAE;IAAS,CAAC,CA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AAC;IACnD,OAAOrC,OAAO;EAChB;AACF"}
@@ -1,4 +1,4 @@
1
- /// <reference types="@webgpu/types" />
1
+ /// <reference types="dist" />
2
2
  import type { ShaderLayout, BindingLayout, Binding } from '@luma.gl/api';
3
3
  /**
4
4
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
@@ -1 +1 @@
1
- {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAMvE;;;GAGG;AACF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAM3H;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAM/F"}
1
+ {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAMvE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAM1H;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAM/F"}
@@ -1,66 +1,51 @@
1
1
  import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/api';
2
- /**
3
- * Create a WebGPU "bind group layout" from an array of luma.gl bindings
4
- * @note bind groups can be automatically generated by WebGPU.
5
- */
6
2
  export function makeBindGroupLayout(device, layout, bindings) {
7
- throw new Error('not implemented');
8
- // return device.createBindGroupLayout({
9
- // layout,
10
- // entries: getBindGroupEntries(bindings)
11
- // })
3
+ throw new Error('not implemented');
12
4
  }
13
- /**
14
- * Create a WebGPU "bind group" from an array of luma.gl bindings
15
- */
16
5
  export function getBindGroup(device, bindGroupLayout, layout, bindings) {
17
- const entries = getBindGroupEntries(bindings, layout);
18
- return device.createBindGroup({
19
- layout: bindGroupLayout,
20
- entries
21
- });
6
+ const entries = getBindGroupEntries(bindings, layout);
7
+ return device.createBindGroup({
8
+ layout: bindGroupLayout,
9
+ entries
10
+ });
22
11
  }
23
12
  export function getShaderLayoutBinding(layout, bindingName) {
24
- const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);
25
- if (!bindingLayout) {
26
- log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
27
- }
28
- return bindingLayout;
13
+ const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);
14
+ if (!bindingLayout) {
15
+ log.warn("Binding ".concat(bindingName, " not set: Not found in shader layout."))();
16
+ }
17
+ return bindingLayout;
29
18
  }
30
- /**
31
- * @param bindings
32
- * @returns
33
- */
34
19
  function getBindGroupEntries(bindings, layout) {
35
- const entries = [];
36
- for (const [bindingName, value] of Object.entries(bindings)) {
37
- const bindingLayout = getShaderLayoutBinding(layout, bindingName);
38
- if (bindingLayout) {
39
- entries.push(getBindGroupEntry(value, bindingLayout.location));
40
- }
20
+ const entries = [];
21
+ for (const [bindingName, value] of Object.entries(bindings)) {
22
+ const bindingLayout = getShaderLayoutBinding(layout, bindingName);
23
+ if (bindingLayout) {
24
+ entries.push(getBindGroupEntry(value, bindingLayout.location));
41
25
  }
42
- return entries;
26
+ }
27
+ return entries;
43
28
  }
44
29
  function getBindGroupEntry(binding, index) {
45
- if (binding instanceof Buffer) {
46
- return {
47
- binding: index,
48
- resource: {
49
- buffer: cast(binding).handle
50
- }
51
- };
52
- }
53
- if (binding instanceof Sampler) {
54
- return {
55
- binding: index,
56
- resource: cast(binding).handle
57
- };
58
- }
59
- else if (binding instanceof Texture) {
60
- return {
61
- binding: index,
62
- resource: cast(binding).handle.createView()
63
- };
64
- }
65
- throw new Error('invalid binding');
30
+ if (binding instanceof Buffer) {
31
+ return {
32
+ binding: index,
33
+ resource: {
34
+ buffer: cast(binding).handle
35
+ }
36
+ };
37
+ }
38
+ if (binding instanceof Sampler) {
39
+ return {
40
+ binding: index,
41
+ resource: cast(binding).handle
42
+ };
43
+ } else if (binding instanceof Texture) {
44
+ return {
45
+ binding: index,
46
+ resource: cast(binding).handle.createView()
47
+ };
48
+ }
49
+ throw new Error('invalid binding');
66
50
  }
51
+ //# sourceMappingURL=get-bind-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingLayout, Binding} from '@luma.gl/api';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/api';\nimport type WebGPUBuffer from '../resources/webgpu-buffer';\nimport type WebGPUSampler from '../resources/webgpu-sampler';\nimport type WebGPUTexture from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Binding[]): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n layout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, layout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(layout: ShaderLayout, bindingName: string): BindingLayout {\n const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(bindings: Record<string, Binding>, layout: ShaderLayout): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(layout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(binding: Binding, index: number): GPUBindGroupEntry {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: cast<WebGPUBuffer>(binding).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: cast<WebGPUSampler>(binding).handle\n };\n } else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: cast<WebGPUTexture>(binding).handle.createView()\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,cAA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KAAK;MACdC,QAAQ,EAAE;QACRC,MAAM,EAAE1B,IAAI,CAAee,OAAO,CAAC,CAACY;MACtC;IACF,CAAC;EACH;EACA,IAAIZ,OAAO,YAAYlB,OAAO,EAAE;IAC9B,OAAO;MACLkB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY;IACzC,CAAC;EACH,CAAC,MAAM,IAAIZ,OAAO,YAAYjB,OAAO,EAAE;IACrC,OAAO;MACLiB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAEzB,IAAI,CAAgBe,OAAO,CAAC,CAACY,MAAM,CAACC,UAAU;IAC1D,CAAC;EACH;EACA,MAAM,IAAIvB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
@@ -1,4 +1,4 @@
1
- /// <reference types="@webgpu/types" />
1
+ /// <reference types="dist" />
2
2
  import type { ShaderLayout, BufferMapping } from '@luma.gl/api';
3
3
  /**
4
4
  * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.