@luma.gl/webgpu 9.0.0-alpha.8 → 9.0.0-beta.1

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 (121) hide show
  1. package/LICENSE +3 -1
  2. package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
  3. package/dist/adapter/helpers/convert-texture-format.d.ts +2 -2
  4. package/dist/adapter/helpers/convert-texture-format.d.ts.map +1 -1
  5. package/dist/adapter/helpers/convert-texture-format.js +0 -1
  6. package/dist/adapter/helpers/convert-texture-format.js.map +1 -1
  7. package/dist/adapter/helpers/generate-mipmaps.d.ts +1 -1
  8. package/dist/adapter/helpers/generate-mipmaps.js +20 -15
  9. package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
  10. package/dist/adapter/helpers/get-bind-group.d.ts +4 -4
  11. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  12. package/dist/adapter/helpers/get-bind-group.js +11 -18
  13. package/dist/adapter/helpers/get-bind-group.js.map +1 -1
  14. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +5 -5
  15. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  16. package/dist/adapter/helpers/get-vertex-buffer-layout.js +36 -40
  17. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  18. package/dist/adapter/helpers/webgpu-parameters.d.ts +2 -2
  19. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  20. package/dist/adapter/helpers/webgpu-parameters.js +14 -20
  21. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  22. package/dist/adapter/resources/webgpu-buffer.d.ts +14 -5
  23. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgpu-buffer.js +19 -29
  25. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  26. package/dist/adapter/resources/webgpu-command-encoder.d.ts +7 -14
  27. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  28. package/dist/adapter/resources/webgpu-command-encoder.js +13 -27
  29. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  30. package/dist/adapter/resources/webgpu-compute-pass.d.ts +5 -5
  31. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgpu-compute-pass.js +13 -27
  33. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  34. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +4 -4
  35. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  36. package/dist/adapter/resources/webgpu-compute-pipeline.js +8 -13
  37. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
  38. package/dist/adapter/resources/webgpu-external-texture.d.ts +5 -5
  39. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  40. package/dist/adapter/resources/webgpu-external-texture.js +6 -14
  41. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
  42. package/dist/adapter/resources/webgpu-framebuffer.d.ts +4 -21
  43. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgpu-framebuffer.js +4 -105
  45. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  46. package/dist/adapter/resources/webgpu-query.js.map +1 -1
  47. package/dist/adapter/resources/webgpu-render-pass.d.ts +12 -7
  48. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  49. package/dist/adapter/resources/webgpu-render-pass.js +53 -36
  50. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  51. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +15 -22
  52. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  53. package/dist/adapter/resources/webgpu-render-pipeline.js +45 -115
  54. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  55. package/dist/adapter/resources/webgpu-sampler.d.ts +5 -5
  56. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  57. package/dist/adapter/resources/webgpu-sampler.js +8 -14
  58. package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
  59. package/dist/adapter/resources/webgpu-shader.d.ts +9 -9
  60. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  61. package/dist/adapter/resources/webgpu-shader.js +15 -29
  62. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  63. package/dist/adapter/resources/webgpu-texture.d.ts +18 -8
  64. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  65. package/dist/adapter/resources/webgpu-texture.js +38 -33
  66. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  67. package/dist/adapter/resources/webgpu-vertex-array.d.ts +26 -0
  68. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -0
  69. package/dist/adapter/resources/webgpu-vertex-array.js +45 -0
  70. package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -0
  71. package/dist/adapter/webgpu-canvas-context.d.ts +17 -12
  72. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  73. package/dist/adapter/webgpu-canvas-context.js +26 -47
  74. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  75. package/dist/adapter/webgpu-device.d.ts +34 -17
  76. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  77. package/dist/adapter/webgpu-device.js +94 -103
  78. package/dist/adapter/webgpu-device.js.map +1 -1
  79. package/dist/adapter/webgpu-types.js.map +1 -1
  80. package/dist/dist.dev.js +3130 -0
  81. package/dist/glsl/glsllang.js +0 -1
  82. package/dist/glsl/glsllang.js.map +1 -1
  83. package/dist/index.cjs +1551 -0
  84. package/dist/index.d.ts +5 -7
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +5 -7
  87. package/dist/index.js.map +1 -1
  88. package/dist.min.js +30 -0
  89. package/package.json +18 -9
  90. package/src/adapter/helpers/accessor-to-format.ts +1 -2
  91. package/src/adapter/helpers/convert-texture-format.ts +1 -1
  92. package/src/adapter/helpers/generate-mipmaps.ts +2 -2
  93. package/src/adapter/helpers/get-bind-group.ts +23 -13
  94. package/src/adapter/helpers/get-vertex-buffer-layout.ts +61 -35
  95. package/src/adapter/helpers/webgpu-parameters.ts +20 -14
  96. package/src/adapter/resources/webgpu-buffer.ts +63 -8
  97. package/src/adapter/resources/webgpu-command-encoder.ts +68 -48
  98. package/src/adapter/resources/webgpu-compute-pass.ts +13 -12
  99. package/src/adapter/resources/webgpu-compute-pipeline.ts +8 -7
  100. package/src/adapter/resources/webgpu-external-texture.ts +5 -5
  101. package/src/adapter/resources/webgpu-framebuffer.ts +8 -109
  102. package/src/adapter/resources/webgpu-query.ts +3 -3
  103. package/src/adapter/resources/webgpu-render-pass.ts +68 -15
  104. package/src/adapter/resources/webgpu-render-pipeline.ts +106 -87
  105. package/src/adapter/resources/webgpu-sampler.ts +6 -6
  106. package/src/adapter/resources/webgpu-shader.ts +22 -16
  107. package/src/adapter/resources/webgpu-texture.ts +54 -25
  108. package/src/adapter/resources/webgpu-vertex-array.ts +83 -0
  109. package/src/adapter/webgpu-canvas-context.ts +51 -26
  110. package/src/adapter/webgpu-device.ts +144 -48
  111. package/src/index.ts +7 -9
  112. package/dist/bundle.d.ts +0 -2
  113. package/dist/bundle.d.ts.map +0 -1
  114. package/dist/bundle.js +0 -5
  115. package/dist/bundle.js.map +0 -1
  116. package/dist/init.d.ts +0 -2
  117. package/dist/init.d.ts.map +0 -1
  118. package/dist/init.js +0 -4
  119. package/dist/init.js.map +0 -1
  120. package/src/bundle.ts +0 -4
  121. package/src/init.ts +0 -4
package/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2020 Urban Computing Foundation
1
+ luma.gl is provided under the MIT license
2
+
3
+ Copyright (c) 2020 vis.gl contributors
2
4
 
3
5
  This software includes parts initially developed by Uber and open sourced under MIT license.
4
6
  Copyright (c) 2015 Uber Technologies, Inc.
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"accessor-to-format.js"}
1
+ {"version":3,"file":"accessor-to-format.js","names":[],"sources":["../../../src/adapter/helpers/accessor-to-format.ts"],"sourcesContent":["/*\nimport {assert} from '@luma.gl/core';\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,5 +1,5 @@
1
- /// <reference types="@webgpu/types" />
2
- import { TextureFormat } from '@luma.gl/api';
1
+ /// <reference types="dist" />
2
+ import { TextureFormat } from '@luma.gl/core';
3
3
  /** Ensure a texture format is WebGPU compatible */
4
4
  export declare function getWebGPUTextureFormat(format: TextureFormat): GPUTextureFormat;
5
5
  //# sourceMappingURL=convert-texture-format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert-texture-format.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,mDAAmD;AACnD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAK9E"}
1
+ {"version":3,"file":"convert-texture-format.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAE5C,mDAAmD;AACnD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,gBAAgB,CAK9E"}
@@ -2,7 +2,6 @@ export function getWebGPUTextureFormat(format) {
2
2
  if (format.includes('webgl')) {
3
3
  throw new Error('webgl-only format');
4
4
  }
5
-
6
5
  return format;
7
6
  }
8
7
  //# sourceMappingURL=convert-texture-format.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/convert-texture-format.ts"],"names":["getWebGPUTextureFormat","format","includes","Error"],"mappings":"AAIA,OAAO,SAASA,sBAAT,CAAgCC,MAAhC,EAAyE;AAC9E,MAAIA,MAAM,CAACC,QAAP,CAAgB,OAAhB,CAAJ,EAA8B;AAC5B,UAAM,IAAIC,KAAJ,CAAU,mBAAV,CAAN;AACD;;AACD,SAAOF,MAAP;AACD","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"],"file":"convert-texture-format.js"}
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/core';\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,14 +1,23 @@
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}";
1
+ const VS_GEN_MIPMAP = `\#version 450
2
+ 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));
3
+ layout(location = 0) out vec2 vTex;
4
+ void main() {
5
+ gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
6
+ vTex = gl_Position / 2.0f + vec2(0.5f);
7
+ }`;
8
+ const FS_GEN_MIPMAP = `#version 450
9
+ layout(set = 0, binding = 0) uniform sampler imgSampler;
10
+ layout(set = 0, binding = 1) uniform texture2D img;
11
+ layout(location = 0) in vec2 vTex;
12
+ layout(location = 0) out vec4 outColor;
13
+ void main() {
14
+ outColor = texture(sampler2D(img, imgSampler), vTex);
15
+ }`;
4
16
  export class WebGPUMipmapGenerator {
5
17
  constructor(device, glslang) {
6
- _defineProperty(this, "device", void 0);
7
-
8
- _defineProperty(this, "mipmapSampler", void 0);
9
-
10
- _defineProperty(this, "mipmapPipeline", void 0);
11
-
18
+ this.device = void 0;
19
+ this.mipmapSampler = void 0;
20
+ this.mipmapPipeline = void 0;
12
21
  this.device = device;
13
22
  this.mipmapSampler = device.createSampler({
14
23
  minFilter: 'linear'
@@ -32,9 +41,8 @@ export class WebGPUMipmapGenerator {
32
41
  }]
33
42
  });
34
43
  }
35
-
36
44
  generateMipmappedTexture(imageBitmap) {
37
- let textureSize = {
45
+ const textureSize = {
38
46
  width: imageBitmap.width,
39
47
  height: imageBitmap.height,
40
48
  depth: 1
@@ -49,10 +57,9 @@ export class WebGPUMipmapGenerator {
49
57
  this.device.queue.copyImageBitmapToTexture({
50
58
  imageBitmap
51
59
  }, {
52
- texture: srcTexture
60
+ texture
53
61
  }, textureSize);
54
62
  const commandEncoder = this.device.createCommandEncoder({});
55
-
56
63
  for (let i = 1; i < mipLevelCount; ++i) {
57
64
  const passEncoder = commandEncoder.beginRenderPass({
58
65
  colorAttachments: [{
@@ -86,10 +93,8 @@ export class WebGPUMipmapGenerator {
86
93
  passEncoder.draw(4);
87
94
  passEncoder.endPass();
88
95
  }
89
-
90
96
  this.device.queue.submit([commandEncoder.finish()]);
91
97
  return texture;
92
98
  }
93
-
94
99
  }
95
100
  //# sourceMappingURL=generate-mipmaps.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/generate-mipmaps.ts"],"names":["VS_GEN_MIPMAP","FS_GEN_MIPMAP","WebGPUMipmapGenerator","constructor","device","glslang","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"],"mappings":";AAMA,MAAMA,aAAa,mRAAnB;AAQA,MAAMC,aAAa,wRAAnB;AAUA,OAAO,MAAMC,qBAAN,CAA4B;AAKjCC,EAAAA,WAAW,CAACC,MAAD,EAAoBC,OAApB,EAA6B;AAAA;;AAAA;;AAAA;;AACtC,SAAKD,MAAL,GAAcA,MAAd;AAEA,SAAKE,aAAL,GAAqBF,MAAM,CAACG,aAAP,CAAqB;AAAEC,MAAAA,SAAS,EAAE;AAAb,KAArB,CAArB;AAEA,SAAKC,cAAL,GAAsBL,MAAM,CAACM,oBAAP,CAA4B;AAChDC,MAAAA,WAAW,EAAE;AACXC,QAAAA,MAAM,EAAER,MAAM,CAACS,kBAAP,CAA0B;AAChCC,UAAAA,IAAI,EAAET,OAAO,CAACU,WAAR,CAAoBf,aAApB,EAAmC,QAAnC;AAD0B,SAA1B,CADG;AAIXgB,QAAAA,UAAU,EAAE;AAJD,OADmC;AAOhDC,MAAAA,aAAa,EAAE;AACbL,QAAAA,MAAM,EAAER,MAAM,CAACS,kBAAP,CAA0B;AAChCC,UAAAA,IAAI,EAAET,OAAO,CAACU,WAAR,CAAoBd,aAApB,EAAmC,UAAnC;AAD0B,SAA1B,CADK;AAIbe,QAAAA,UAAU,EAAE;AAJC,OAPiC;AAahDE,MAAAA,iBAAiB,EAAE,gBAb6B;AAchDC,MAAAA,WAAW,EAAE,CAAC;AACZC,QAAAA,MAAM,EAAE;AADI,OAAD;AAdmC,KAA5B,CAAtB;AAkBD;;AAEDC,EAAAA,wBAAwB,CAACC,WAAD,EAA2B;AACjD,QAAIC,WAAW,GAAG;AAChBC,MAAAA,KAAK,EAAEF,WAAW,CAACE,KADH;AAEhBC,MAAAA,MAAM,EAAEH,WAAW,CAACG,MAFJ;AAGhBC,MAAAA,KAAK,EAAE;AAHS,KAAlB;AAKA,UAAMC,aAAa,GAAGC,IAAI,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A,MAAM,EAAE,KAAKlD,cAAL,CAAoBmD,kBAApB,CAAuC,CAAvC,CADoC;AAE5CC,QAAAA,QAAQ,EAAE,CAAC;AACTC,UAAAA,OAAO,EAAE,CADA;AAETC,UAAAA,QAAQ,EAAE,KAAKzD;AAFN,SAAD,EAGP;AACDwD,UAAAA,OAAO,EAAE,CADR;AAEDC,UAAAA,QAAQ,EAAE/B,OAAO,CAACkB,UAAR,CAAmB;AAC3BC,YAAAA,YAAY,EAAEN,CAAC,GAAG,CADS;AAE3BlB,YAAAA,aAAa,EAAE;AAFY,WAAnB;AAFT,SAHO;AAFkC,OAA5B,CAAlB;AAcAmB,MAAAA,WAAW,CAACkB,WAAZ,CAAwB,KAAKvD,cAA7B;AACAqC,MAAAA,WAAW,CAACmB,YAAZ,CAAyB,CAAzB,EAA4BR,SAA5B;AACAX,MAAAA,WAAW,CAACoB,IAAZ,CAAiB,CAAjB;AACApB,MAAAA,WAAW,CAACqB,OAAZ;AACD;;AAED,SAAK/D,MAAL,CAAYoC,KAAZ,CAAkB4B,MAAlB,CAAyB,CAACzB,cAAc,CAAC0B,MAAf,EAAD,CAAzB;AACA,WAAOrC,OAAP;AACD;;AAjFgC","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 let 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"],"file":"generate-mipmaps.js"}
1
+ {"version":3,"file":"generate-mipmaps.js","names":["VS_GEN_MIPMAP","FS_GEN_MIPMAP","WebGPUMipmapGenerator","constructor","device","glslang","mipmapSampler","mipmapPipeline","createSampler","minFilter","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","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 }, 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,GAAI;AACvB;AACA;AACA;AACA;AACA;AACA,EAAE;AAEF,MAAMC,aAAa,GAAI;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AAGF,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAACC,MAAiB,EAAEC,OAAO,EAAE;IAAA,KAJxCD,MAAM;IAAA,KACNE,aAAa;IAAA,KACbC,cAAc;IAGZ,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACE,aAAa,GAAGF,MAAM,CAACI,aAAa,CAAC;MAAEC,SAAS,EAAE;IAAS,CAAC,CAAC;IAElE,IAAI,CAACF,cAAc,GAAGH,MAAM,CAACM,oBAAoB,CAAC;MAChDC,WAAW,EAAE;QACXC,MAAM,EAAER,MAAM,CAACS,kBAAkB,CAAC;UAChCC,IAAI,EAAET,OAAO,CAACU,WAAW,CAACf,aAAa,EAAE,QAAQ;QACnD,CAAC,CAAC;QACFgB,UAAU,EAAE;MACd,CAAC;MACDC,aAAa,EAAE;QACbL,MAAM,EAAER,MAAM,CAACS,kBAAkB,CAAC;UAChCC,IAAI,EAAET,OAAO,CAACU,WAAW,CAACd,aAAa,EAAE,UAAU;QACrD,CAAC,CAAC;QACFe,UAAU,EAAE;MACd,CAAC;MACDE,iBAAiB,EAAE,gBAAgB;MACnCC,WAAW,EAAE,CAAC;QACZC,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;EACJ;EAEAC,wBAAwBA,CAACC,WAAwB,EAAE;I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D,eAAe,CAAC;QAC5CC,MAAM,EAAE,IAAI,CAACnD,cAAc,CAACoD,kBAAkB,CAAC,CAAC,CAAC;QACjDC,QAAQ,EAAE,CAAC;UACTC,OAAO,EAAE,CAAC;UACVC,QAAQ,EAAE,IAAI,CAACxD;QACjB,CAAC,EAAE;UACDuD,OAAO,EAAE,CAAC;UACVC,QAAQ,EAAE9B,OAAO,CAACiB,UAAU,CAAC;YAC3BC,YAAY,EAAEN,CAAC,GAAG,CAAC;YACnBjB,aAAa,EAAE;UACjB,CAAC;QACH,CAAC;MACH,CAAC,CAAC;MAEFkB,WAAW,CAACkB,WAAW,CAAC,IAAI,CAACxD,cAAc,CAAC;MAC5CsC,WAAW,CAACmB,YAAY,CAAC,CAAC,EAAER,SAAS,CAAC;MACtCX,WAAW,CAACoB,IAAI,CAAC,CAAC,CAAC;MACnBpB,WAAW,CAACqB,OAAO,CAAC,CAAC;IACvB;IAEA,IAAI,CAAC9D,MAAM,CAACoC,KAAK,CAAC2B,MAAM,CAAC,CAACzB,cAAc,CAAC0B,MAAM,CAAC,CAAC,CAAC,CAAC;IACnD,OAAOpC,OAAO;EAChB;AACF"}
@@ -1,5 +1,5 @@
1
- /// <reference types="@webgpu/types" />
2
- import type { ShaderLayout, BindingLayout, Binding } from '@luma.gl/api';
1
+ /// <reference types="dist" />
2
+ import type { ShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
3
3
  /**
4
4
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
5
5
  * @note bind groups can be automatically generated by WebGPU.
@@ -8,6 +8,6 @@ export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGr
8
8
  /**
9
9
  * Create a WebGPU "bind group" from an array of luma.gl bindings
10
10
  */
11
- export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, layout: ShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
- export declare function getShaderLayoutBinding(layout: ShaderLayout, bindingName: string): BindingLayout;
11
+ export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
12
+ export declare function getShaderLayoutBinding(shaderLayout: ShaderLayout, bindingName: string): BindingDeclaration;
13
13
  //# sourceMappingURL=get-bind-group.d.ts.map
@@ -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,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAM7E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAMpB"}
@@ -1,38 +1,31 @@
1
- import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/api';
1
+ import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/core';
2
2
  export function makeBindGroupLayout(device, layout, bindings) {
3
3
  throw new Error('not implemented');
4
4
  }
5
- export function getBindGroup(device, bindGroupLayout, layout, bindings) {
6
- const entries = getBindGroupEntries(bindings, layout);
5
+ export function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
6
+ const entries = getBindGroupEntries(bindings, shaderLayout);
7
7
  return device.createBindGroup({
8
8
  layout: bindGroupLayout,
9
9
  entries
10
10
  });
11
11
  }
12
- export function getShaderLayoutBinding(layout, bindingName) {
13
- const bindingLayout = layout.bindings.find(binding => binding.name === bindingName);
14
-
12
+ export function getShaderLayoutBinding(shaderLayout, bindingName) {
13
+ const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName);
15
14
  if (!bindingLayout) {
16
- log.warn("Binding ".concat(bindingName, " not set: Not found in shader layout."))();
15
+ log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
17
16
  }
18
-
19
17
  return bindingLayout;
20
18
  }
21
-
22
- function getBindGroupEntries(bindings, layout) {
19
+ function getBindGroupEntries(bindings, shaderLayout) {
23
20
  const entries = [];
24
-
25
21
  for (const [bindingName, value] of Object.entries(bindings)) {
26
- const bindingLayout = getShaderLayoutBinding(layout, bindingName);
27
-
22
+ const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);
28
23
  if (bindingLayout) {
29
24
  entries.push(getBindGroupEntry(value, bindingLayout.location));
30
25
  }
31
26
  }
32
-
33
27
  return entries;
34
28
  }
35
-
36
29
  function getBindGroupEntry(binding, index) {
37
30
  if (binding instanceof Buffer) {
38
31
  return {
@@ -42,7 +35,6 @@ function getBindGroupEntry(binding, index) {
42
35
  }
43
36
  };
44
37
  }
45
-
46
38
  if (binding instanceof Sampler) {
47
39
  return {
48
40
  binding: index,
@@ -51,10 +43,11 @@ function getBindGroupEntry(binding, index) {
51
43
  } else if (binding instanceof Texture) {
52
44
  return {
53
45
  binding: index,
54
- resource: cast(binding).handle.createView()
46
+ resource: cast(binding).handle.createView({
47
+ label: 'bind-group-auto-created'
48
+ })
55
49
  };
56
50
  }
57
-
58
51
  throw new Error('invalid binding');
59
52
  }
60
53
  //# sourceMappingURL=get-bind-group.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"mappings":"AAEA,SAAQA,MAAR,EAAgBC,OAAhB,EAAyBC,OAAzB,EAAkCC,GAAlC,EAAuCC,IAAvC,QAAkD,cAAlD;AASC,OAAO,SAASC,mBAAT,CAA6BC,MAA7B,EAAgDC,MAAhD,EAA4EC,QAA5E,EAAqH;AAC3H,QAAM,IAAIC,KAAJ,CAAU,iBAAV,CAAN;AAKD;AAKD,OAAO,SAASC,YAAT,CACLJ,MADK,EAELK,eAFK,EAGLJ,MAHK,EAILC,QAJK,EAKS;AACd,QAAMI,OAAO,GAAGC,mBAAmB,CAACL,QAAD,EAAWD,MAAX,CAAnC;AACA,SAAOD,MAAM,CAACQ,eAAP,CAAuB;AAC5BP,IAAAA,MAAM,EAAEI,eADoB;AAE5BC,IAAAA;AAF4B,GAAvB,CAAP;AAID;AAED,OAAO,SAASG,sBAAT,CAAgCR,MAAhC,EAAsDS,WAAtD,EAA0F;AAC/F,QAAMC,aAAa,GAAGV,MAAM,CAACC,QAAP,CAAgBU,IAAhB,CAAqBC,OAAO,IAAIA,OAAO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U,iBAAV,CAAN;AACD","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 */\n export 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"],"file":"get-bind-group.js"}
1
+ {"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","shaderLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView","label"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingDeclaration, Binding} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/core';\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(\n device: GPUDevice,\n layout: GPUBindGroupLayout,\n bindings: Binding[]\n): 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 shaderLayout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(\n shaderLayout: ShaderLayout,\n bindingName: string\n): BindingDeclaration {\n const bindingLayout = shaderLayout.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(\n bindings: Record<string, Binding>,\n shaderLayout: ShaderLayout\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, 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({label: 'bind-group-auto-created'})\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,eAAe;AASjE,OAAO,SAASC,mBAAmBA,CACjCC,MAAiB,EACjBC,MAA0B,EAC1BC,QAAmB,EACC;EACpB,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAKpC;AAKA,OAAO,SAASC,YAAYA,CAC1BJ,MAAiB,EACjBK,eAAmC,EACnCC,YAA0B,EAC1BJ,QAAiC,EACnB;EACd,MAAMK,OAAO,GAAGC,mBAAmB,CAACN,QAAQ,EAAEI,YAAY,CAAC;EAC3D,OAAON,MAAM,CAACS,eAAe,CAAC;IAC5BR,MAAM,EAAEI,eAAe;IACvBE;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,SAASG,sBAAsBA,CACpCJ,YAA0B,EAC1BK,WAAmB,EACC;EACpB,MAAMC,aAAa,GAAGN,YAAY,CAACJ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IAAIxB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
@@ -1,12 +1,12 @@
1
- /// <reference types="@webgpu/types" />
2
- import type { ShaderLayout, BufferMapping } from '@luma.gl/api';
1
+ /// <reference types="dist" />
2
+ import type { ShaderLayout, BufferLayout } from '@luma.gl/core';
3
3
  /**
4
4
  * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.
5
5
  * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array
6
6
  * @param layout
7
- * @param bufferMap The buffer map is optional
7
+ * @param bufferLayout The buffer map is optional
8
8
  * @returns WebGPU layout intended for a GPURenderPassDescriptor.
9
9
  */
10
- export declare function getVertexBufferLayout(layout: ShaderLayout, bufferMap: BufferMapping[]): GPUVertexBufferLayout[];
11
- export declare function getBufferSlots(layout: ShaderLayout, bufferMap: BufferMapping[]): Record<string, number>;
10
+ export declare function getVertexBufferLayout(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[]): GPUVertexBufferLayout[];
11
+ export declare function getBufferSlots(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[]): Record<string, number>;
12
12
  //# sourceMappingURL=get-vertex-buffer-layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAkB,MAAM,cAAc,CAAC;AAG/E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,qBAAqB,EAAE,CAkE/G;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BvG"}
1
+ {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqC,MAAM,eAAe,CAAC;AAYlG;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,qBAAqB,EAAE,CAuEzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
@@ -1,97 +1,93 @@
1
- import { decodeVertexFormat } from '@luma.gl/api';
2
- export function getVertexBufferLayout(layout, bufferMap) {
1
+ import { log, decodeVertexFormat } from '@luma.gl/core';
2
+ function getWebGPUVertexFormat(format) {
3
+ if (format.endsWith('-webgl')) {
4
+ throw new Error(`WebGPU does not support vertex format ${format}`);
5
+ }
6
+ return format;
7
+ }
8
+ export function getVertexBufferLayout(shaderLayout, bufferLayout) {
3
9
  const vertexBufferLayouts = [];
4
10
  const usedAttributes = new Set();
5
-
6
- for (const mapping of bufferMap) {
11
+ for (const mapping of bufferLayout) {
7
12
  const vertexAttributes = [];
8
13
  let stepMode = 'vertex';
9
14
  let byteStride = 0;
10
- let byteOffset = mapping.byteOffset || 0;
11
-
12
- if ('attributes' in mapping) {
13
- const arrayStride = mapping.byteStride;
14
-
15
- for (const interleaved of mapping.attributes) {
16
- const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
15
+ if (mapping.attributes) {
16
+ for (const attributeMapping of mapping.attributes) {
17
+ const attributeName = attributeMapping.attribute;
18
+ const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);
17
19
  stepMode = attributeLayout.stepMode || 'vertex';
18
20
  vertexAttributes.push({
19
- format: attributeLayout.format,
20
- offset: byteOffset + byteStride,
21
+ format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),
22
+ offset: attributeMapping.byteOffset,
21
23
  shaderLocation: attributeLayout.location
22
24
  });
23
- byteStride += decodeVertexFormat(attributeLayout.format).byteLength;
25
+ byteStride += decodeVertexFormat(mapping.format).byteLength;
24
26
  }
25
27
  } else {
26
- const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);
27
- byteStride = decodeVertexFormat(attributeLayout.format).byteLength, stepMode = attributeLayout.stepMode || 'vertex';
28
+ const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
29
+ if (!attributeLayout) {
30
+ continue;
31
+ }
32
+ byteStride = decodeVertexFormat(mapping.format).byteLength;
33
+ stepMode = attributeLayout.stepMode || 'vertex';
28
34
  vertexAttributes.push({
29
- format: attributeLayout.format,
30
- offset: byteOffset,
35
+ format: getWebGPUVertexFormat(mapping.format),
36
+ offset: 0,
31
37
  shaderLocation: attributeLayout.location
32
38
  });
33
39
  }
34
-
35
40
  vertexBufferLayouts.push({
36
41
  arrayStride: mapping.byteStride || byteStride,
37
42
  stepMode: stepMode || 'vertex',
38
43
  attributes: vertexAttributes
39
44
  });
40
45
  }
41
-
42
- for (const attribute of layout.attributes) {
46
+ for (const attribute of shaderLayout.attributes) {
43
47
  if (!usedAttributes.has(attribute.name)) {
44
48
  vertexBufferLayouts.push({
45
- arrayStride: decodeVertexFormat(attribute.format).byteLength,
49
+ arrayStride: decodeVertexFormat('float32x3').byteLength,
46
50
  stepMode: attribute.stepMode || 'vertex',
47
51
  attributes: [{
48
- format: attribute.format,
52
+ format: getWebGPUVertexFormat('float32x3'),
49
53
  offset: 0,
50
54
  shaderLocation: attribute.location
51
55
  }]
52
56
  });
53
57
  }
54
58
  }
55
-
56
59
  return vertexBufferLayouts;
57
60
  }
58
- export function getBufferSlots(layout, bufferMap) {
61
+ export function getBufferSlots(shaderLayout, bufferLayout) {
59
62
  const usedAttributes = new Set();
60
63
  let bufferSlot = 0;
61
64
  const bufferSlots = {};
62
-
63
- for (const mapping of bufferMap) {
65
+ for (const mapping of bufferLayout) {
64
66
  if ('attributes' in mapping) {
65
67
  for (const interleaved of mapping.attributes) {
66
- usedAttributes.add(interleaved.name);
68
+ usedAttributes.add(interleaved.attribute);
67
69
  }
68
70
  } else {
69
71
  usedAttributes.add(mapping.name);
70
72
  }
71
-
72
73
  bufferSlots[mapping.name] = bufferSlot++;
73
74
  }
74
-
75
- for (const attribute of layout.attributes) {
75
+ for (const attribute of shaderLayout.attributes) {
76
76
  if (!usedAttributes.has(attribute.name)) {
77
77
  bufferSlots[attribute.name] = bufferSlot++;
78
78
  }
79
79
  }
80
-
81
80
  return bufferSlots;
82
81
  }
83
-
84
- function findAttributeLayout(layout, name, attributeNames) {
85
- const attribute = layout.attributes.find(attribute => attribute.name === name);
86
-
82
+ function findAttributeLayout(shaderLayout, name, attributeNames) {
83
+ const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);
87
84
  if (!attribute) {
88
- throw new Error("Unknown attribute ".concat(name));
85
+ log.warn(`Unknown attribute ${name}`)();
86
+ return null;
89
87
  }
90
-
91
88
  if (attributeNames.has(name)) {
92
- throw new Error("Duplicate attribute ".concat(name));
89
+ throw new Error(`Duplicate attribute ${name}`);
93
90
  }
94
-
95
91
  attributeNames.add(name);
96
92
  return attribute;
97
93
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":["decodeVertexFormat","getVertexBufferLayout","layout","bufferMap","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","byteOffset","arrayStride","interleaved","attributes","attributeLayout","findAttributeLayout","name","push","format","offset","shaderLocation","location","byteLength","attribute","has","getBufferSlots","bufferSlot","bufferSlots","add","attributeNames","find","Error"],"mappings":"AACA,SAAQA,kBAAR,QAAiC,cAAjC;AASA,OAAO,SAASC,qBAAT,CAA+BC,MAA/B,EAAqDC,SAArD,EAA0G;AAC/G,QAAMC,mBAA4C,GAAG,EAArD;AACA,QAAMC,cAAc,GAAG,IAAIC,GAAJ,EAAvB;;AAGA,OAAK,MAA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AAO,CAACU,IAAT,CAAX,GAA4BU,UAAU,EAAtC;AACD;;AAGD,OAAK,MAAMH,SAAX,IAAwBtB,MAAM,CAACY,UAA/B,EAA2C;AACzC,QAAI,CAACT,cAAc,CAACoB,GAAf,CAAmBD,SAAS,CAACP,IAA7B,CAAL,EAAyC;AACvCW,MAAAA,WAAW,CAACJ,SAAS,CAACP,IAAX,CAAX,GAA8BU,UAAU,EAAxC;AACD;AACF;;AAED,SAAOC,WAAP;AACD;;AAOD,SAASZ,mBAAT,CAA6Bd,MAA7B,EAAmDe,IAAnD,EAAiEa,cAAjE,EAA+G;AAC7G,QAAMN,SAAS,GAAGtB,MAAM,CAACY,UAAP,CAAkBiB,IAAlB,CAAuBP,SAAS,IAAIA,SAAS,CAACP,IAAV,KAAmBA,IAAvD,CAAlB;;AACA,MAAI,CAACO,SAAL,EAAgB;AACd,UAAM,IAAIQ,KAAJ,6BAA+Bf,IAA/B,EAAN;AACD;;AACD,MAAIa,cAAc,CAACL,GAAf,CAAmBR,IAAnB,CAAJ,EAA8B;AAC5B,UAAM,IAAIe,KAAJ,+BAAiCf,IAAjC,EAAN;AACD;;AACDa,EAAAA,cAAc,CAACD,GAAf,CAAmBZ,IAAnB;AACA,SAAOO,SAAP;AACD","sourcesContent":["import type {ShaderLayout, BufferMapping, AttributeLayout} from '@luma.gl/api';\nimport {decodeVertexFormat} from '@luma.gl/api';\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferMap The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(layout: ShaderLayout, bufferMap: BufferMapping[]): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n let byteOffset = mapping.byteOffset || 0;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n const arrayStride = mapping.byteStride;\n for (const interleaved of mapping.attributes) {\n const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset + byteStride,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(attributeLayout.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(layout, mapping.name, usedAttributes);\n byteStride = decodeVertexFormat(attributeLayout.format).byteLength,\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: attributeLayout.format,\n offset: byteOffset,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat(attribute.format).byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [{\n format: attribute.format,\n offset: 0,\n shaderLocation: attribute.location\n }]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(layout: ShaderLayout, bufferMap: BufferMapping[]): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferMapping`\n for (const mapping of bufferMap) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.name);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of layout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(layout: ShaderLayout, name: string, attributeNames: Set<string>): AttributeLayout {\n const attribute = layout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n throw new Error(`Unknown attribute ${name}`);\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n"],"file":"get-vertex-buffer-layout.js"}
1
+ {"version":3,"file":"get-vertex-buffer-layout.js","names":["log","decodeVertexFormat","getWebGPUVertexFormat","format","endsWith","Error","getVertexBufferLayout","shaderLayout","bufferLayout","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","attributes","attributeMapping","attributeName","attribute","attributeLayout","findAttributeLayout","push","offset","byteOffset","shaderLocation","location","byteLength","name","arrayStride","has","getBufferSlots","bufferSlot","bufferSlots","interleaved","add","attributeNames","find","warn"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {log, decodeVertexFormat} from '@luma.gl/core';\n// import {getAttributeInfosFromLayouts} from '@luma.gl/core';\n\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format as GPUVertexFormat;\n}\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): GPUVertexBufferLayout[] {\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(mapping.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n if (!attributeLayout) {\n continue; // eslint-disable-line no-continue\n }\n byteStride = decodeVertexFormat(mapping.format).byteLength;\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(mapping.format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(\n shaderLayout: ShaderLayout,\n name: string,\n attributeNames: Set<string>\n): AttributeDeclaration {\n const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n log.warn(`Unknown attribute ${name}`)();\n return null;\n }\n if (attributeNames.has(name)) {\n throw new Error(`Duplicate attribute ${name}`);\n }\n attributeNames.add(name);\n return attribute;\n}\n"],"mappings":"AAEA,SAAQA,GAAG,EAAEC,kBAAkB,QAAO,eAAe;AAIrD,SAASC,qBAAqBA,CAACC,MAAoB,EAAmB;EACpE,IAAIA,MAAM,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC7B,MAAM,IAAIC,KAAK,CAAE,yCAAwCF,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,OAAO,CAACgB,IAAI,CAAC;IAClC;IACAK,WAAW,CAACrB,OAAO,CAACgB,IAAI,CAAC,GAAGI,UAAU,EAAE;EAC1C;EAGA,KAAK,MAAMb,SAAS,IAAIZ,YAAY,CAACS,UAAU,EAAE;IAC/C,IAAI,CAACN,cAAc,CAACoB,GAAG,CAACX,SAAS,CAACS,IAAI,CAAC,EAAE;MACvCK,WAAW,CAACd,SAAS,CAACS,IAAI,CAAC,GAAGI,UAAU,EAAE;IAC5C;EACF;EAEA,OAAOC,WAAW;AACpB;AAOA,SAASZ,mBAAmBA,CAC1Bd,YAA0B,EAC1BqB,IAAY,EACZQ,cAA2B,EACL;EACtB,MAAMjB,SAAS,GAAGZ,YAAY,CAACS,UAAU,CAACqB,IAAI,CAAClB,SAAS,IAAIA,SAAS,CAACS,IAAI,KAAKA,IAAI,CAAC;EACpF,IAAI,CAACT,SAAS,EAAE;IACdnB,GAAG,CAACsC,IAAI,CAAE,qBAAoBV,IAAK,EAAC,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI;EACb;EACA,IAAIQ,cAAc,CAACN,GAAG,CAACF,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIvB,KAAK,CAAE,uBAAsBuB,IAAK,EAAC,CAAC;EAChD;EACAQ,cAAc,CAACD,GAAG,CAACP,IAAI,CAAC;EACxB,OAAOT,SAAS;AAClB"}
@@ -1,5 +1,5 @@
1
- /// <reference types="@webgpu/types" />
2
- import { Parameters } from '@luma.gl/api';
1
+ /// <reference types="dist" />
2
+ import { Parameters } from '@luma.gl/core';
3
3
  /**
4
4
  * Supports for luma.gl's flat parameter space
5
5
  * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAYxC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAqJ9D,CAAC;AA8BF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
1
+ {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAezC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAsJ9D,CAAC;AAgCF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
@@ -2,11 +2,12 @@ function addDepthStencil(descriptor) {
2
2
  descriptor.depthStencil = descriptor.depthStencil || {
3
3
  format: 'depth24plus',
4
4
  stencilFront: {},
5
- stencilBack: {}
5
+ stencilBack: {},
6
+ depthWriteEnabled: false,
7
+ depthCompare: 'less-equal'
6
8
  };
7
9
  return descriptor.depthStencil;
8
10
  }
9
-
10
11
  export const PARAMETER_TABLE = {
11
12
  cullMode: (parameter, value, descriptor) => {
12
13
  descriptor.primitive = descriptor.primitive || {};
@@ -85,8 +86,7 @@ export const PARAMETER_TABLE = {
85
86
  targets[0].writeMask = value;
86
87
  },
87
88
  blendColorOperation: (parameter, value, descriptor) => {
88
- const targets = addColorState(descriptor);
89
- const target = targets[0];
89
+ addColorState(descriptor);
90
90
  }
91
91
  };
92
92
  const DEFAULT_PIPELINE_DESCRIPTOR = {
@@ -102,42 +102,36 @@ const DEFAULT_PIPELINE_DESCRIPTOR = {
102
102
  module: undefined,
103
103
  entryPoint: 'main',
104
104
  targets: []
105
- }
105
+ },
106
+ layout: 'auto'
106
107
  };
107
- export function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {
108
- Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR,
108
+ export function applyParametersToRenderPipelineDescriptor(pipelineDescriptor) {
109
+ let parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
110
+ Object.assign(pipelineDescriptor, {
111
+ ...DEFAULT_PIPELINE_DESCRIPTOR,
109
112
  ...pipelineDescriptor
110
113
  });
111
114
  setParameters(pipelineDescriptor, parameters);
112
115
  }
113
-
114
116
  function setParameters(pipelineDescriptor, parameters) {
115
117
  for (const [key, value] of Object.entries(parameters)) {
116
118
  const setterFunction = PARAMETER_TABLE[key];
117
-
118
119
  if (!setterFunction) {
119
- throw new Error("Illegal parameter ".concat(key));
120
+ throw new Error(`Illegal parameter ${key}`);
120
121
  }
121
-
122
122
  setterFunction(key, value, pipelineDescriptor);
123
123
  }
124
124
  }
125
-
126
125
  function addColorState(descriptor) {
127
- var _descriptor$fragment, _descriptor$fragment2, _descriptor$fragment3, _descriptor$fragment4, _descriptor$fragment5;
128
-
126
+ var _descriptor$fragment, _descriptor$fragment2, _descriptor$fragment3, _descriptor$fragment4;
129
127
  descriptor.fragment.targets = ((_descriptor$fragment = descriptor.fragment) === null || _descriptor$fragment === void 0 ? void 0 : _descriptor$fragment.targets) || [];
130
-
131
128
  if (!Array.isArray((_descriptor$fragment2 = descriptor.fragment) === null || _descriptor$fragment2 === void 0 ? void 0 : _descriptor$fragment2.targets)) {
132
129
  throw new Error('colorstate');
133
130
  }
134
-
135
- if (((_descriptor$fragment3 = descriptor.fragment) === null || _descriptor$fragment3 === void 0 ? void 0 : (_descriptor$fragment4 = _descriptor$fragment3.targets) === null || _descriptor$fragment4 === void 0 ? void 0 : _descriptor$fragment4.length) === 0) {
131
+ if (((_descriptor$fragment3 = descriptor.fragment) === null || _descriptor$fragment3 === void 0 || (_descriptor$fragment3 = _descriptor$fragment3.targets) === null || _descriptor$fragment3 === void 0 ? void 0 : _descriptor$fragment3.length) === 0) {
136
132
  var _descriptor$fragment$;
137
-
138
133
  (_descriptor$fragment$ = descriptor.fragment.targets) === null || _descriptor$fragment$ === void 0 ? void 0 : _descriptor$fragment$.push({});
139
134
  }
140
-
141
- return (_descriptor$fragment5 = descriptor.fragment) === null || _descriptor$fragment5 === void 0 ? void 0 : _descriptor$fragment5.targets;
135
+ return (_descriptor$fragment4 = descriptor.fragment) === null || _descriptor$fragment4 === void 0 ? void 0 : _descriptor$fragment4.targets;
142
136
  }
143
137
  //# sourceMappingURL=webgpu-parameters.js.map