@luma.gl/webgpu 9.0.0-alpha.10 → 9.0.0-alpha.12

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 (52) hide show
  1. package/dist/adapter/helpers/get-vertex-buffer-layout.js +0 -2
  2. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  3. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  4. package/dist/adapter/helpers/webgpu-parameters.js +1 -2
  5. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  6. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  7. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  8. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  9. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  10. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  11. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  12. package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
  13. package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
  14. package/dist/adapter/resources/webgpu-framebuffer.js +0 -1
  15. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  16. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  17. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  18. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  19. package/dist/adapter/resources/webgpu-render-pipeline.js +4 -2
  20. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  21. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  22. package/dist/adapter/resources/webgpu-sampler.js +3 -2
  23. package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
  24. package/dist/adapter/resources/webgpu-shader.d.ts +1 -1
  25. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  26. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  27. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  28. package/dist/adapter/resources/webgpu-texture.js +1 -1
  29. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  30. package/dist/adapter/webgpu-canvas-context.d.ts +0 -2
  31. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  32. package/dist/adapter/webgpu-canvas-context.js +5 -4
  33. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  34. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  35. package/dist/adapter/webgpu-device.js +4 -2
  36. package/dist/adapter/webgpu-device.js.map +1 -1
  37. package/package.json +3 -3
  38. package/src/adapter/helpers/get-vertex-buffer-layout.ts +1 -1
  39. package/src/adapter/helpers/webgpu-parameters.ts +3 -2
  40. package/src/adapter/resources/webgpu-buffer.ts +4 -4
  41. package/src/adapter/resources/webgpu-command-encoder.ts +5 -5
  42. package/src/adapter/resources/webgpu-compute-pass.ts +1 -1
  43. package/src/adapter/resources/webgpu-external-texture.ts +1 -1
  44. package/src/adapter/resources/webgpu-framebuffer.ts +1 -1
  45. package/src/adapter/resources/webgpu-query.ts +1 -1
  46. package/src/adapter/resources/webgpu-render-pass.ts +2 -2
  47. package/src/adapter/resources/webgpu-render-pipeline.ts +6 -5
  48. package/src/adapter/resources/webgpu-sampler.ts +3 -3
  49. package/src/adapter/resources/webgpu-shader.ts +2 -2
  50. package/src/adapter/resources/webgpu-texture.ts +3 -3
  51. package/src/adapter/webgpu-canvas-context.ts +6 -3
  52. package/src/adapter/webgpu-device.ts +3 -3
@@ -10,8 +10,6 @@ export function getVertexBufferLayout(layout, bufferMap) {
10
10
  let byteOffset = mapping.byteOffset || 0;
11
11
 
12
12
  if ('attributes' in mapping) {
13
- const arrayStride = mapping.byteStride;
14
-
15
13
  for (const interleaved of mapping.attributes) {
16
14
  const attributeLayout = findAttributeLayout(layout, interleaved.name, usedAttributes);
17
15
  stepMode = attributeLayout.stepMode || 'vertex';
@@ -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,MAAMC,OAAX,IAAsBJ,SAAtB,EAAiC;AAE/B,UAAMK,gBAAsC,GAAG,EAA/C;AAGA,QAAIC,QAA+B,GAAG,QAAtC;AACA,QAAIC,UAAU,GAAG,CAAjB;AACA,QAAIC,UAAU,GAAGJ,OAAO,CAACI,UAAR,IAAsB,CAAvC;;AAGA,QAAI,gBAAgBJ,OAApB,EAA6B;AAC3B,YAAMK,WAAW,GAAGL,OAAO,CAACG,UAA5B;;AACA,WAAK,MAAMG,WAAX,IAA0BN,OAAO,CAACO,UAAlC,EAA8C;AAC5C,cAAMC,eAAe,GAAGC,mBAAmB,CAACd,MAAD,EAASW,WAAW,CAACI,IAArB,EAA2BZ,cAA3B,CAA3C;AAEAI,QAAAA,QAAQ,GAAGM,eAAe,CAACN,QAAhB,IAA4B,QAAvC;AACAD,QAAAA,gBAAgB,CAACU,IAAjB,CAAsB;AACpBC,UAAAA,MAAM,EAAEJ,eAAe,CAACI,MADJ;AAEpBC,UAAAA,MAAM,EAAET,UAAU,GAAGD,UAFD;AAGpBW,UAAAA,cAAc,EAAEN,eAAe,CAACO;AAHZ,SAAtB;AAMAZ,QAAAA,UAAU,IAAIV,kBAAkB,CAACe,eAAe,CAACI,MAAjB,CAAlB,CAA2CI,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AAP;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,"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":["decodeVertexFormat","getVertexBufferLayout","layout","bufferMap","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","byteOffset","interleaved","attributes","attributeLayout","findAttributeLayout","name","push","format","offset","shaderLocation","location","byteLength","arrayStride","attribute","has","getBufferSl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EAA8C;AAC5CR,QAAAA,cAAc,CAACwB,GAAf,CAAmBjB,WAAW,CAACI,IAA/B;AACD;AAEF,KALD,MAKO;AACLX,MAAAA,cAAc,CAACwB,GAAf,CAAmBtB,OAAO,CAACS,IAA3B;AACD;;AACDY,IAAAA,WAAW,CAACrB,OAAO,CAACS,IAAT,CAAX,GAA4BW,UAAU,EAAtC;AACD;;AAGD,OAAK,MAAMH,SAAX,IAAwBtB,MAAM,CAACW,UAA/B,EAA2C;AACzC,QAAI,CAACR,cAAc,CAACoB,GAAf,CAAmBD,SAAS,CAACR,IAA7B,CAAL,EAAyC;AACvCY,MAAAA,WAAW,CAACJ,SAAS,CAACR,IAAX,CAAX,GAA8BW,UAAU,EAAxC;AACD;AACF;;AAED,SAAOC,WAAP;AACD;;AAOD,SAASb,mBAAT,CAA6Bb,MAA7B,EAAmDc,IAAnD,EAAiEc,cAAjE,EAA+G;AAC7G,QAAMN,SAAS,GAAGtB,MAAM,CAACW,UAAP,CAAkBkB,IAAlB,CAAuBP,SAAS,IAAIA,SAAS,CAACR,IAAV,KAAmBA,IAAvD,CAAlB;;AACA,MAAI,CAACQ,SAAL,EAAgB;AACd,UAAM,IAAIQ,KAAJ,6BAA+BhB,IAA/B,EAAN;AACD;;AACD,MAAIc,cAAc,CAACL,GAAf,CAAmBT,IAAnB,CAAJ,EAA8B;AAC5B,UAAM,IAAIgB,KAAJ,+BAAiChB,IAAjC,EAAN;AACD;;AACDc,EAAAA,cAAc,CAACD,GAAf,CAAmBb,IAAnB;AACA,SAAOQ,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; TODO \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 +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,cAAc,CAAC;AAYxC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAsJ9D,CAAC;AA8BF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
@@ -85,8 +85,7 @@ export const PARAMETER_TABLE = {
85
85
  targets[0].writeMask = value;
86
86
  },
87
87
  blendColorOperation: (parameter, value, descriptor) => {
88
- const targets = addColorState(descriptor);
89
- const target = targets[0];
88
+ addColorState(descriptor);
90
89
  }
91
90
  };
92
91
  const DEFAULT_PIPELINE_DESCRIPTOR = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","depthWriteEnabled","depthCompare","depthFormat","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","compare","stencilPassOperation","passOp","stencilFailOperation","failOp","stencilDepthFailOperation","depthFailOp","sampleCount","multisample","count","sampleMask","mask","sampleAlphaToCoverageEnabled","alphaToCoverageEnabled","colorMask","targets","addColorState","writeMask","blendColorOperation","target","DEFAULT_PIPELINE_DESCRIPTOR","topology","vertex","module","undefined","entryPoint","fragment","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","Object","assign","setParameters","key","entries","setterFunction","Error","Array","isArray","length","push"],"mappings":"AAEA,SAASA,eAAT,CAAyBC,UAAzB,EAAwF;AACtFA,EAAAA,UAAU,CAACC,YAAX,GAA0BD,UAAU,CAACC,YAAX,IAA2B;AAEnDC,IAAAA,MAAM,EAAE,aAF2C;AAGnDC,IAAAA,YAAY,EAAE,EAHqC;AAInDC,IAAAA,WAAW,EAAE;AAJsC,GAArD;AAMA,SAAOJ,UAAU,CAACC,YAAlB;AACD;;AAOD,OAAO,MAAMI,eAAmD,GAAG;AAGjEC,E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AAN,CAAX,IAA2B0C,MAAM,CAACI,OAAP,CAAeL,UAAf,CAA3B,EAAuD;AACrD,UAAMM,cAAc,GAAGlD,eAAe,CAACgD,GAAD,CAAtC;;AACA,QAAI,CAACE,cAAL,EAAqB;AACnB,YAAM,IAAIC,KAAJ,6BAA+BH,GAA/B,EAAN;AACD;;AACDE,IAAAA,cAAc,CAACF,GAAD,EAAM7C,KAAN,EAAawC,kBAAb,CAAd;AACD;AACF;;AAED,SAASZ,aAAT,CAAuBpC,UAAvB,EAAuF;AAAA;;AACrFA,EAAAA,UAAU,CAAC8C,QAAX,CAAqBX,OAArB,GAA+B,yBAAAnC,UAAU,CAAC8C,QAAX,8EAAqBX,OAArB,KAAgC,EAA/D;;AACA,MAAI,CAACsB,KAAK,CAACC,OAAN,0BAAc1D,UAAU,CAAC8C,QAAzB,0DAAc,sBAAqBX,OAAnC,CAAL,EAAkD;AAChD,UAAM,IAAIqB,KAAJ,CAAU,YAAV,CAAN;AACD;;AACD,MAAI,0BAAAxD,UAAU,CAAC8C,QAAX,yGAAqBX,OAArB,gFAA8BwB,MAA9B,MAAyC,CAA7C,EAAgD;AAAA;;AAC9C,6BAAA3D,UAAU,CAAC8C,QAAX,CAAoBX,OAApB,gFAA6ByB,IAA7B,CAAkC,EAAlC;AACD;;AACD,kCAAO5D,UAAU,CAAC8C,QAAlB,0DAAO,sBAAqBX,OAA5B;AACD","sourcesContent":["import {Parameters} from '@luma.gl/api';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {}\n };\n return descriptor.depthStencil;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n\n depthCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.compare = value;\n depthStencil.stencilBack!.compare = value;\n },\n\n stencilPassOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.passOp = value;\n depthStencil.stencilBack!.passOp = value;\n },\n\n stencilFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.failOp = value;\n depthStencil.stencilBack!.failOp = value;\n },\n\n stencilDepthFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.depthFailOp = value;\n depthStencil.stencilBack!.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n\n blendColorOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n\n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n\n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n\n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n\n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n }\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\n\nfunction addColorState(descriptor: GPURenderPipelineDescriptor): GPUColorTargetState[] {\n descriptor.fragment!.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets as GPUColorTargetState[];\n}\n"],"file":"webgpu-parameters.js"}
1
+ {"version":3,"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","depthWriteEnabled","depthCompare","depthFormat","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","compare","stencilPassOperation","passOp","stencilFailOperation","failOp","stencilDepthFailOperation","depthFailOp","sampleCount","multisample","count","sampleMask","mask","sampleAlphaToCoverageEnabled","alphaToCoverageEnabled","colorMask","targets","addColorState","writeMask","blendColorOperation","DEFAULT_PIPELINE_DESCRIPTOR","topology","vertex","module","undefined","entryPoint","fragment","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","Object","assign","setParameters","key","entries","setterFunction","Error","Array","isArray","length","push"],"mappings":"AAEA,SAASA,eAAT,CAAyBC,UAAzB,EAAwF;AACtFA,EAAAA,UAAU,CAACC,YAAX,GAA0BD,UAAU,CAACC,YAAX,IAA2B;AAEnDC,IAAAA,MAAM,EAAE,aAF2C;AAGnDC,IAAAA,YAAY,EAAE,EAHqC;AAInDC,IAAAA,WAAW,EAAE;AAJsC,GAArD;AAMA,SAAOJ,UAAU,CAACC,YAAlB;AACD;;AAOD,OAAO,MAAMI,eAAmD,GAAG;AAGjEC,EAAAA,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D,UAAMM,cAAc,GAAGjD,eAAe,CAAC+C,GAAD,CAAtC;;AACA,QAAI,CAACE,cAAL,EAAqB;AACnB,YAAM,IAAIC,KAAJ,6BAA+BH,GAA/B,EAAN;AACD;;AACDE,IAAAA,cAAc,CAACF,GAAD,EAAM5C,KAAN,EAAauC,kBAAb,CAAd;AACD;AACF;;AAED,SAASX,aAAT,CAAuBpC,UAAvB,EAAuF;AAAA;;AACrFA,EAAAA,UAAU,CAAC6C,QAAX,CAAqBV,OAArB,GAA+B,yBAAAnC,UAAU,CAAC6C,QAAX,8EAAqBV,OAArB,KAAgC,EAA/D;;AACA,MAAI,CAACqB,KAAK,CAACC,OAAN,0BAAczD,UAAU,CAAC6C,QAAzB,0DAAc,sBAAqBV,OAAnC,CAAL,EAAkD;AAChD,UAAM,IAAIoB,KAAJ,CAAU,YAAV,CAAN;AACD;;AACD,MAAI,0BAAAvD,UAAU,CAAC6C,QAAX,yGAAqBV,OAArB,gFAA8BuB,MAA9B,MAAyC,CAA7C,EAAgD;AAAA;;AAC9C,6BAAA1D,UAAU,CAAC6C,QAAX,CAAoBV,OAApB,gFAA6BwB,IAA7B,CAAkC,EAAlC;AACD;;AACD,kCAAO3D,UAAU,CAAC6C,QAAlB,0DAAO,sBAAqBV,OAA5B;AACD","sourcesContent":["import {Parameters} from '@luma.gl/api';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {}\n };\n return descriptor.depthStencil;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n\n depthCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.compare = value;\n depthStencil.stencilBack!.compare = value;\n },\n\n stencilPassOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.passOp = value;\n depthStencil.stencilBack!.passOp = value;\n },\n\n stencilFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.failOp = value;\n depthStencil.stencilBack!.failOp = value;\n },\n\n stencilDepthFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.depthFailOp = value;\n depthStencil.stencilBack!.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n\n blendColorOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n // const targets = addColorState(descriptor);\n // const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n\n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n\n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n\n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n\n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n }\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\n\nfunction addColorState(descriptor: GPURenderPipelineDescriptor): GPUColorTargetState[] {\n descriptor.fragment!.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets as GPUColorTargetState[];\n}\n"],"file":"webgpu-parameters.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAyBpD,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmBnG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
1
+ {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAyB3C,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmB5G,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":["Buffer","getByteLength","props","byteLength","data","WebGPUBuffer","constructor","device","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish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AAG,KAAK7B,MAAL,CAAY8B,cAAZ,EAApB;AAEA,QAAIE,UAAU,CAACpC,WAAf,CAA2BiC,WAA3B,EAAwCI,GAAxC,CAA4CD,UAA5C;AACD;;AAIDN,EAAAA,QAAQ,CAACQ,IAAD,EAAeC,MAAc,GAAG,CAAhC,EAAmCjC,IAAnC,EAAiE;AACvE,WAAO,KAAKF,MAAL,CAAY0B,QAAZ,CAAqBQ,IAArB,EAA2BC,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAED4B,EAAAA,cAAc,CAACK,MAAc,GAAG,CAAlB,EAAqBjC,IAArB,EAAiD;AAC7D,WAAO,KAAKF,MAAL,CAAY8B,cAAZ,CAA2BK,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAEDS,EAAAA,KAAK,GAAS;AACZ,SAAKX,MAAL,CAAYW,KAAZ;AACD;;AAlF8C","sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps, assert} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"file":"webgpu-buffer.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":["Buffer","getByteLength","props","byteLength","data","WebGPUBuffer","constructor","device","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"mappings":";AACA,SAAQA,MAAR,QAAkC,cAAlC;;AAGA,SAASC,aAAT,CAAuBC,KAAvB,EAAmD;AAAA;;AACjD,SAAOA,KAAK,CAACC,UAAN,oBAAoBD,KAAK,CAACE,IAA1B,gDAAoB,YAAYD,UAAhC,KAA8C,CAArD;AACD;;AAED,eAAe,MAAME,YAAN,SAA2BL,MAA3B,CAAkC;AAK/CM,EAAAA,WAAW,CAACC,MAAD,EAAuBL,KAAvB,EAA2C;AACpD,UAAMK,MAAN,EAAcL,KAAd;;AADoD;;AAAA;;AAAA;;AAEpD,SAAKK,MAAL,GAAcA,MAAd;AAEA,SAAKJ,UAAL,GAAkBF,aAAa,CAACC,KAAD,CAA/B;AACA,UAAMM,SAAS,GAAGC,OAAO,CAACP,KAAK,CAACE,IAAP,CAAzB;AAEA,SAAKM,MAAL,GAAc,KAAKR,KAAL,CAAWQ,MAAX,IAAqB,KAAKH,MAAL,CAAYG,MAAZ,CAAmBC,YAAnB,CAAgC;AACjEC,MAAAA,IAAI,EAAE,KAAKT,UADsD;AAGjEU,MAAAA,KAAK,EAAE,KAAKX,KAAL,CAAWW,KAAX,IAAqBC,cAAc,CAACC,MAAf,GAAwBD,cAAc,CAACE,QAHF;AAIjEC,MAAAA,gBAAgB,EAAE,KAAKf,KAAL,CAAWe,gBAAX,IAA+BT,SAJgB;AAKjEU,MAAAA,KAAK,EAAE,KAAKhB,KAAL,CAAWiB;AAL+C,KAAhC,CAAnC;;AAQA,QAAIjB,KAAK,CAACE,IAAV,EAAgB;AACd,WAAKgB,YAAL,CAAkBlB,KAAK,CAACE,IAAxB;AAED;;AAED,QAAII,SAAS,IAAI,CAACN,KAAK,CAACe,gBAAxB,EAA0C;AACxC,WAAKP,MAAL,CAAYW,KAAZ;AACD;AACF;;AAEQC,EAAAA,OAAO,GAAS;AACvB,SAAKZ,MAAL,CAAYY,OAAZ;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UAAMH,WAAW,GAAG,KAAK7B,MAAL,CAAY8B,cAAZ,EAApB;AAEA,QAAIE,UAAU,CAACpC,WAAf,CAA2BiC,WAA3B,EAAwCI,GAAxC,CAA4CD,UAA5C;AACD;;AAIDN,EAAAA,QAAQ,CAACQ,IAAD,EAAeC,MAAc,GAAG,CAAhC,EAAmCjC,IAAnC,EAAiE;AACvE,WAAO,KAAKF,MAAL,CAAY0B,QAAZ,CAAqBQ,IAArB,EAA2BC,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAED4B,EAAAA,cAAc,CAACK,MAAc,GAAG,CAAlB,EAAqBjC,IAArB,EAAiD;AAC7D,WAAO,KAAKF,MAAL,CAAY8B,cAAZ,CAA2BK,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAEDS,EAAAA,KAAK,GAAS;AACZ,SAAKX,MAAL,CAAYW,KAAZ;AACD;;AAlF8C","sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n override write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n override async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"file":"webgpu-buffer.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAkB,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACxG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,MAAM,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G,YAAY,CAAC;QAE/C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAC7C,GAAG,IAAI;IAuBR,mBAAmB,CAAC,OAAO,EAAE;QAC3B,MAAM,EAAE,mBAAmB,CAAC;QAC5B,WAAW,EAAE,kBAAkB,CAAC;QAChC,QAAQ,EAAE,WAAW,CAAA;KACtB,GAAG,IAAI;IAER,oBAAoB,CAAC,OAAO,EAAE;QAC5B,MAAM,EAAE,mBAAmB,CAAE;QAC7B,WAAW,EAAE,mBAAmB,CAAC;QACjC,QAAQ,EAAE,WAAW,CAAA;KACtB,GAAG,IAAI;IAEC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIxC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAatD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","handle","createCommandEncoder","measureExecutionTime","label","id","destroy","finish","options","copyBufferToBuffer","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,EAA8EC,IAA9E,QAAyF,cAAzF;AAKA,eAAe,MAAMC,oBAAN,SAAmCF,cAAnC,CAAkD;AAI/DG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC5D,UAAMA,KAAN;;AAD4D;;AAAA;;AAE5D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAA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oB;AAH5B,KAPF,EAaE;AAEEC,MAAAA,KAAK,EAAEf,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAFT;AAGEC,MAAAA,MAAM,EAAEjB,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAHV;AAIEE,MAAAA,kBAAkB,EAAElB,OAAO,CAACgB,MAAR,CAAgB,CAAhB;AAJtB,KAbF;AAoBD;;AAEDG,EAAAA,mBAAmB,CAACnB,OAAD,EAIV,CAAE;;AAEXoB,EAAAA,oBAAoB,CAACpB,OAAD,EAIX,CAAE;;AAEXqB,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK7B,MAAL,CAAY4B,cAAZ,CAA2BC,UAA3B;AACD;;AAEDC,EAAAA,aAAa,GAAS;AACpB,SAAK9B,MAAL,CAAY8B,aAAZ;AACD;;AAEDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAKhC,MAAL,CAAY+B,iBAAZ,CAA8BC,WAA9B;AACD;;AA/F8D","sourcesContent":["import {CommandEncoder, CommandEncoderProps, RenderPipeline, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n destroy() {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent![0],\n height: options.extent![1],\n depthOrArrayLayers: options.extent![2]\n }\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"file":"webgpu-command-encoder.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","handle","createCommandEncoder","measureExecutionTime","label","id","destroy","finish","options","copyBufferToBuffer","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,EAA8DC,IAA9D,QAAyE,cAAzE;AAKA,eAAe,MAAMC,oBAAN,SAAmCF,cAAnC,CAAkD;AAI/DG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC5D,UAAMA,KAAN;;AAD4D;;AAAA;;AAE5D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAcD,KAAK,CAACC,MAAN,IAAgB,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,oBAAnB,CAAwC;AACpEC,MAAAA,oBAAoB,EAAE,KAAKH,KAAL,CAAWG;AADmC,KAAxC,CAA9B;AAGA,SAAKF,MAAL,CAAYG,KAAZ,GAAoB,KAAKJ,KAAL,CAAWK,EAA/B;AACD;;AAEQC,EAAAA,OAAO,GAAS,CAAE;;AAE3BC,EAAAA,MAAM,CAACC,OAAD,EAA4C;AAChD,WAAO,KAAKD,MAAL,CAAYC,OAAZ,CAAP;AACD;;AAKDC,EAAAA,kBAAkB,CAACD,OAAD,EAMT;AAAA;;AACP,SAAKP,MAAL,CAAYQ,kBAAZ,CACEb,IAAI,CAAeY,OAAO,CAACE,MAAvB,CAAJ,CAAmCT,MADrC,2BAEEO,OAAO,CAACG,YAFV,yEAE0B,CAF1B,EAGEf,IAAI,CAAeY,OAAO,CAACI,WAAvB,CAAJ,CAAwCX,MAH1C,2BAIEO,OAAO,CAACK,iBAJV,yEAI+B,CAJ/B,mBAKEL,OAAO,CAACM,IALV,yDAKkB,CALlB;AAOD;;AAEDC,EAAAA,mBAAmB,CAACP,OAAD,EAYV;AAAA;;AACP,SAAKP,MAAL,CAAYc,mBAAZ,CACE;AACEC,MAAAA,MAAM,EAAEpB,IAAI,CAAeY,OAAO,CAACE,MAAvB,CAAJ,CAAmCT,MAD7C;AAEEgB,MAAAA,MAAM,qBAAET,OAAO,CAACS,MAAV,6DAAoB,CAF5B;AAGEC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAHvB;AAIEC,MAAAA,YAAY,EAAEX,OAAO,CAACW;AAJxB,KADF,EAOE;AACEC,MAAAA,OAAO,EAAExB,IAAI,CAAgBY,OAAO,CAACI,WAAxB,CAAJ,CAAyCX,MADpD;AAEEoB,MAAAA,QAAQ,uBAAEb,OAAO,CAACa,QAAV,iEAAsB,CAFhC;AAGEC,MAAAA,MAAM,qBAAEd,OAAO,CAACc,MAAV,6DAAoB;AAH5B,KAPF,EAaE;AAEEC,MAAAA,KAAK,EAAEf,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAFT;AAGEC,MAAAA,MAAM,EAAEjB,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAHV;AAIEE,MAAAA,kBAAkB,EAAElB,OAAO,CAACgB,MAAR,CAAgB,CAAhB;AAJtB,KAbF;AAoBD;;AAEDG,EAAAA,mBAAmB,CAACnB,OAAD,EAIV,CAAE;;AAEXoB,EAAAA,oBAAoB,CAACpB,OAAD,EAIX,CAAE;;AAEFqB,EAAAA,cAAc,CAACC,UAAD,EAA2B;AAChD,SAAK7B,MAAL,CAAY4B,cAAZ,CAA2BC,UAA3B;AACD;;AAEQC,EAAAA,aAAa,GAAS;AAC7B,SAAK9B,MAAL,CAAY8B,aAAZ;AACD;;AAEQC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AACpD,SAAKhC,MAAL,CAAY+B,iBAAZ,CAA8BC,WAA9B;AACD;;AA/F8D","sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent![0],\n height: options.extent![1],\n depthOrArrayLayers: options.extent![2]\n }\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"file":"webgpu-command-encoder.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAQ;gBAEvC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IAC9C,OAAO;IAEP,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,IAAI;IAI1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
1
+ {"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,GAAG,IAAI,CAAQ;gBAEvC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IACrC,OAAO,IAAI,IAAI;IAExB,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAMtC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjD;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,cAAc,GAAE,MAAU,GAAG,IAAI;IAI1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","handle","commandEncoder","beginComputePass","label","id","destroy","endPass","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchIndirect","indirectBuffer","indirectOffset","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,WAAR,EAAyEC,IAAzE,QAAoF,cAApF;AAMA,eAAe,MAAMC,iBAAN,SAAgCF,WAAhC,CAA4C;AAKzDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AAAA;;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA;;AAAA,8CAFb,IAEa;;AAEzD,SAAKD,MAAL,GAAcA,MAAd;AAEA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,8BAAqBF,MAAM,CAACG,cAA5B,0DAAqB,sBAAuBC,gBAAvB,CAAwC;AACzEC,MAAAA,KAAK,EAAE,KAAKJ,KAAL,CAAWK;AADuD,KAAxC,CAArB,CAAd;AAID;;AAGDC,EAAAA,OAAO,GAAG,CAAE;;AAEZC,EAAAA,OAAO,GAAS;AACd,SAAKN,MAAL,CAAYM,OAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAkC;AAC3C,UAAMC,YAAY,GAAGd,IAAI,CAAwBa,QAAxB,CAAzB;AACA,SAAKR,MAAL,CAAYO,WAAZ,CAAwBE,YAAY,CAACT,MAArC;AACA,SAAKU,gBAAL,GAAwBD,YAAY,CAACE,mBAAb,EAAxB;AACD;;AAGDC,EAAAA,WAAW,CAACC,QAAD,EAA4B;AACrC,UAAM,IAAIC,KAAJ,CAAU,QAAV,CAAN;AAGD;;AAQDC,EAAAA,QAAQ,CAACC,CAAD,EAAYC,CAAZ,EAAwBC,CAAxB,EAA0C;AAChD,SAAKlB,MAAL,CAAYe,QAAZ,CAAqBC,CAArB,EAAwBC,CAAxB,EAA2BC,CAA3B;AACD;;AAODC,EAAAA,gBAAgB,CAACC,cAAD,EAAyBC,cAAsB,GAAG,CAAlD,EAA2D;AACzE,SAAKrB,MAAL,CAAYmB,gBAAZ,CAA6BxB,IAAI,CAAeyB,cAAf,CAAJ,CAAmCpB,MAAhE,EAAwEqB,cAAxE;AACD;;AAEDC,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAKvB,MAAL,CAAYsB,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAKxB,MAAL,CAAYwB,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK1B,MAAL,CAAYyB,iBAAZ,CAA8BC,WAA9B;AACD;;AA9DwD","sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder?.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatch(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"file":"webgpu-compute-pass.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","handle","commandEncoder","beginComputePass","label","id","destroy","endPass","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchIndirect","indirectBuffer","indirectOffset","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,WAAR,EAAyEC,IAAzE,QAAoF,cAApF;AAMA,eAAe,MAAMC,iBAAN,SAAgCF,WAAhC,CAA4C;AAKzDG,EAAAA,WAAW,CAACC,MA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AZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK1B,MAAL,CAAYyB,iBAAZ,CAA8BC,WAA9B;AACD;;AA9DwD","sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder?.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n override destroy(): void {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatch(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"file":"webgpu-compute-pass.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,eAAe;IAChE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAU7D,OAAO,IAAI,IAAI;IAMf,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAKlD"}
1
+ {"version":3,"file":"webgpu-external-texture.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1F,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AACjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,eAAe;IAChE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;gBAEX,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB;IAUpD,OAAO,IAAI,IAAI;IAMxB,0BAA0B;IAC1B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;CAKlD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"mappings":";AACA,SAAQA,eAAR,QAA2E,cAA3E;AAEA,OAAOC,aAAP,MAA0B,kBAA1B;AAMA,eAAe,MAAMC,qBAAN,SAAoCF,eAApC,CAAoD;AAKjEG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,IAAqB,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,qBAAnB,CAAyC;AAC1EC,MAAAA,MAAM,EAAEH,KAAK,CAACG,MAD4D;AAE1EC,MAAAA,UAAU,EAAEJ,KAAK,CAACI;AAFwD,KAAzC,CAAnC;AAIA,SAAKC,OAAL,GAAe,IAAf;AACD;;AAEDC,EAAAA,OAAO,GAAS,CAIf;;AAGDC,EAAAA,UAAU,CAACF,OAAD,EAAwC;AAEhD,SAAKA,OAAL,GAAeA,OAAO,YAAYT,aAAnB,GAAmCS,OAAnC,GAA6C,IAAIT,aAAJ,CAAkB,KAAKG,MAAvB,EAA+BM,OAA/B,CAA5D;AACA,WAAO,IAAP;AACD;;AA1BgE","sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport default class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n this.sampler = null;\n }\n\n destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n }\n\n /** Set default sampler */\n setSampler(sampler: Sampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n"],"file":"webgpu-external-texture.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-external-texture.ts"],"names":["ExternalTexture","WebGPUSampler","WebGPUExternalTexture","constructor","device","props","handle","importExternalTexture","source","colorSpace","sampler","destroy","setSampler"],"mappings":";AACA,SAAQA,eAAR,QAA2E,cAA3E;AAEA,OAAOC,aAAP,MAA0B,kBAA1B;AAMA,eAAe,MAAMC,qBAAN,SAAoCF,eAApC,CAAoD;AAKjEG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,IAAqB,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,qBAAnB,CAAyC;AAC1EC,MAAAA,MAAM,EAAEH,KAAK,CAACG,MAD4D;AAE1EC,MAAAA,UAAU,EAAEJ,KAAK,CAACI;AAFwD,KAAzC,CAAnC;AAIA,SAAKC,OAAL,GAAe,IAAf;AACD;;AAEQC,EAAAA,OAAO,GAAS,CAIxB;;AAGDC,EAAAA,UAAU,CAACF,OAAD,EAAwC;AAEhD,SAAKA,OAAL,GAAeA,OAAO,YAAYT,aAAnB,GAAmCS,OAAnC,GAA6C,IAAIT,aAAJ,CAAkB,KAAKG,MAAvB,EAA+BM,OAA/B,CAA5D;AACA,WAAO,IAAP;AACD;;AA1BgE","sourcesContent":["// luma.gl, MIT license\nimport {ExternalTexture, ExternalTextureProps, Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\nimport WebGPUSampler from './webgpu-sampler';\n\n/**\n * Cheap, temporary texture view for videos\n * Only valid within same callback, destroyed automatically as a microtask.\n */\nexport default class WebGPUExternalTexture extends ExternalTexture {\n readonly device: WebGPUDevice;\n readonly handle: GPUExternalTexture;\n sampler: WebGPUSampler;\n\n constructor(device: WebGPUDevice, props: ExternalTextureProps) {\n super(device, props);\n this.device = device;\n this.handle = this.props.handle || this.device.handle.importExternalTexture({\n source: props.source,\n colorSpace: props.colorSpace\n });\n this.sampler = null;\n }\n\n override destroy(): void {\n // External textures are destroyed automatically,\n // as a microtask, instead of manually or upon garbage collection like other resources.\n // this.handle.destroy();\n }\n\n /** Set default sampler */\n setSampler(sampler: Sampler | SamplerProps): this {\n // We can accept a sampler instance or set of props;\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n}\n"],"file":"webgpu-external-texture.js"}
@@ -1,7 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { Framebuffer, Texture } from '@luma.gl/api';
3
3
  import WEBGPUTexture from './webgpu-texture';
4
- const MAX_COLOR_ATTACHMENTS = 8;
5
4
  export default class WebGPUFramebuffer extends Framebuffer {
6
5
  constructor(device, props) {
7
6
  super(device, props);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":["Framebuffer","Texture","WEBGPUTexture","MAX_COLOR_ATTACHMENTS","WebGPUFramebuffer","constructor","device","props","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthLoadValue","depthStoreOp","stencilLoadValue","stencilStoreOp","length","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"mappings":";AACA,SAAQA,WAAR,EAAqBC,OAArB,QAAmC,cAAnC;AAGA,OAAOC,aAAP,MAA0B,kBAA1B;AAKA,MAAMC,qBAAqB,GAAG,CAA9B;AAMA,eAAe,MAAMC,iBAAN,SAAgCJ,WAAhC,CAA4C;AAczDK,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA,8CAXvB,EAWuB;;AAAA,oDAVZ,IAUY;;AAAA,kDAJvD;AACFC,MAAAA,gBAAgB,EAAE;AADhB,KAIuD;;AAEzD,SAAKF,MAAL,GAAcA,MAAd;;AAEA,QAAIC,KAAK,CAACE,sBAAV,EAAkC;AAChC,WAAKA,sBAAL,GAA8B,KAAKC,yBAAL,CAA+BH,KAA/B,CAA9B;AACD;;AAED,QAAIA,KAAK,CAACC,gBAAV,EAA4B;AAC1B,WAAKA,gBAAL,GAAwBD,KAAK,CAACC,gBAAN,CAAuBG,GAAvB,CAA2BC,eAAe,IAAI,KAAKC,kBAAL,CAAwB,KAAKN,KAA7B,EAAoCK,eAApC,CAA9C,CAAxB;AACD;;AAED,QAAI,KAAKH,sB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MAAL,CAAYmB,cAAZ,CAA2B,EAAC,GAAG,KAAKhB,sBAAL,CAA4BF,KAAhC;AAAuCqB,QAAAA,KAAvC;AAA8CC,QAAAA;AAA9C,OAA3B,CAAvB;;AACA,WAAKpB,sBAAL,CAA4B4B,OAA5B;AACA,WAAK5B,sBAAL,GAA8B2B,cAA9B;AACA,WAAKtB,oBAAL,CAA0BL,sBAA1B,CAAiDM,IAAjD,GAAwDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAAxD;AACF;AACF;;AAvGwD","sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\nconst MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture | null = null;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthLoadValue: 1.0,\n depthStoreOp: 'store',\n stencilLoadValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"file":"webgpu-framebuffer.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":["Framebuffer","Texture","WEBGPUTexture","WebGPUFramebuffer","constructor","device","props","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthLoadValue","depthStoreOp","stencilLoadValue","stencilStoreOp","length","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"mappings":";AACA,SAAQA,WAAR,EAAqBC,OAArB,QAAmC,cAAnC;AAGA,OAAOC,aAAP,MAA0B,kBAA1B;AAWA,eAAe,MAAMC,iBAAN,SAAgCH,WAAhC,CAA4C;AAczDI,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA,8CAXvB,EAWuB;;AAAA,oDAVZ,IAUY;;AAAA,kDAJvD;AACFC,MAAAA,gBAAgB,EAAE;AADhB,KAIuD;;AAEzD,SAAKF,MAAL,GAAcA,MAAd;;AAEA,QAAIC,KAAK,CAACE,sBAAV,EAAkC;AAChC,WAAKA,sBAAL,GAA8B,KAAKC,yBAAL,CAA+BH,KAA/B,CAA9B;AACD;;AAED,QAAIA,KAAK,CAACC,gBAAV,EAA4B;AAC1B,WAAKA,gBAAL,GAAwBD,KAAK,CAACC,gBAAN,CAAuBG,GAAvB,CAA2BC,eAAe,IAAI,KAAKC,kBAAL,CAAwB,KAAKN,KAA7B,EAAoCK,eAApC,CAA9C,CAAxB;AACD;;AAED,QAAI,KAAKH,sBAAT,EAAiC;AAC/B,WAAKK,oBAAL,CAA0BL,sBAA1B,GAAmD;AACjDM,QAAAA,IAAI,EAAE,KAAKN,sBAAL,CAA4BO,MAA5B,CAAmCC,UAAnC,EAD2C;AAGjDC,QAAAA,cAAc,EAAE,GAHiC;AAIjDC,QAAAA,YAAY,EAAE,OAJmC;AAKjDC,QAAAA,gBAAgB,EAAE,CAL+B;AAMjDC,QAAAA,cAAc,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wDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAAxD;AACF;AACF;;AAvGwD","sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\n// const MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture | null = null;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthLoadValue: 1.0,\n depthStoreOp: 'store',\n stencilLoadValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"file":"webgpu-framebuffer.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAY,MAAM,cAAc,CAAC;AAC3E,OAAO,YAAY,MAAM,kBAAkB,CAAC;AA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M,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAW7C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","endPass","setPipeline","pipeline","setBindings","bindings","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AACA,SAAgBA,UAAhB,EAA4CC,IAA5C,QAA4D,cAA5D;AAMA,eAAe,MAAMC,gBAAN,SAA+BF,UAA/B,CAA0C;AAOvDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAsB,GAAG,EAAhD,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA,sCAFvB,IAEuB;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,UAAME,WAAW,GAAGD,KAAK,CAACC,WAAN,IAAqBF,MAAM,CAACG,aAAP,CAAqBC,qBAArB,EAAzC;AAEA,UAAMC,oBAAoB,GAAGH,WAAW,CAACG,oBAAzC;AACA,SAAKC,MAAL,GAAc,KAAKL,KAAL,CAAWK,MAAX,IAAqBN,MAAM,CAACO,cAAP,CA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AK3C,MAAL,CAAY2C,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK7C,MAAL,CAAY4C,iBAAZ,CAA8BC,WAA9B;AACD;;AAlHsD","sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast, log} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"file":"webgpu-render-pass.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","endPass","setPipeline","pipeline","setBindings","bindings","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AACA,SAAgBA,UAAhB,EAA4CC,IAA5C,QAAuD,cAAvD;AAMA,eAAe,MAAMC,gBAAN,SAA+BF,UAA/B,CAA0C;AAOvDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAsB,GAAG,EAAhD,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA,sCAFvB,IAEuB;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,UAAME,WAAW,GAAGD,KAAK,CAACC,WAAN,IAAqBF,MAAM,CAACG,aAAP,CAAqBC,qBAArB,EAAzC;AAEA,UAAMC,oBAAoB,GAAGH,WAAW,CAACG,oBAAzC;AACA,SAAKC,MAAL,GAAc,KAAKL,KAAL,CAAWK,MAAX,IAAqBN,MAAM,CAACO,cAAP,CAAsBC,eAAtB,CAAsCH,oBAAtC,CAAnC;AACA,SAAKC,MAAL,CAAYG,KAAZ,GAAoB,KAAKR,KAAL,CAAWS,EAA/B;AACD;;AAEQC,EAAAA,OAAO,GAAS,CAAE;;AAE3BC,EAAAA,OAAO,GAAS;AACd,SAAKN,MAAL,CAAYM,OAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAiC;AAC1C,SAAKA,QAAL,GAAgBjB,IAAI,CAAuBiB,QAAvB,CAApB;AACA,SAAKR,MAAL,CAAYO,WAAZ,CAA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UAAM;AAACC,MAAAA,aAAD;AAAgBC,MAAAA,gBAAhB;AAAkCC,MAAAA,WAAlC;AAA+CC,MAAAA;AAA/C,QAA2DJ,UAAjE;;AACA,QAAIC,aAAJ,EAAmB;AACjB,WAAKjC,MAAL,CAAYqC,gBAAZ,CAA6BJ,aAA7B;AACD;;AACD,QAAIC,gBAAJ,EAAsB;AACpB,WAAKlC,MAAL,CAAYsC,mBAAZ,CAAgCJ,gBAAhC;AACD;;AACD,QAAIC,WAAJ,EAAiB;AACf,WAAKnC,MAAL,CAAYuC,cAAZ,CAA2BJ,WAAW,CAAC,CAAD,CAAtC,EAA2CA,WAAW,CAAC,CAAD,CAAtD,EAA2DA,WAAW,CAAC,CAAD,CAAtE,EAA2EA,WAAW,CAAC,CAAD,CAAtF;AACD;;AAED,QAAIC,QAAJ,EAAc;AACZ,WAAKpC,MAAL,CAAYwC,WAAZ,CACEJ,QAAQ,CAAC,CAAD,CADV,EAEEA,QAAQ,CAAC,CAAD,CAFV,EAGEA,QAAQ,CAAC,CAAD,CAHV,EAIEA,QAAQ,CAAC,CAAD,CAJV,EAKEA,QAAQ,CAAC,CAAD,CALV,EAMEA,QAAQ,CAAC,CAAD,CANV;AAQD;AACF;;AAEDK,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK1C,MAAL,CAAYyC,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAK3C,MAAL,CAAY2C,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK7C,MAAL,CAAY4C,iBAAZ,CAA8BC,WAA9B;AACD;;AAlHsD","sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"file":"webgpu-render-pass.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAS,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AASnG,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,sBAAsB,CAAC;AAIz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AAW;IAIX,iDAAiD;IACjD,aAAa;IAKb,8DAA8D;IAC9D,SAAS,CAAC,4BAA4B;IA8CtC,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmCR,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB;CAwCxD"}
@@ -128,8 +128,10 @@ export default class WebGPURenderPipeline extends RenderPipeline {
128
128
  const webgpuRenderPass = cast(options.renderPass) || this.device.getDefaultRenderPass();
129
129
  webgpuRenderPass.handle.setPipeline(this.handle);
130
130
 
131
- if (this._getBindGroup()) {
132
- webgpuRenderPass.handle.setBindGroup(0, this._getBindGroup());
131
+ const bindGroup = this._getBindGroup();
132
+
133
+ if (bindGroup) {
134
+ webgpuRenderPass.handle.setBindGroup(0, bindGroup);
133
135
  }
134
136
 
135
137
  this._setAttributeBuffers(webgpuRenderPass);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","fsEntryPoint","targets","format","canvasContext","topology","primitive","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"mappings":";AACA,SAAgBA,cAAhB,EAAqDC,IAArD,EAA2DC,GAA3D,EAAgEC,aAAhE,QAAoF,cAApF;AACA,SAAQC,yCAAR,QAAwD,8BAAxD;AACA,SAAQC,sBAAR,QAAqC,mCAArC;AACA,SAAQC,YAAR,QAA2B,2BAA3B;AACA,SAAQC,qBAAR,EAA+BC,cAA/B,QAAoD,qCAApD;AAaA,eAAe,MAAMC,oBAAN,SAAmCT,cAAnC,CAAkD;AAiB/DU,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC5D,UAAMD,MAAN,EAAcC,KAAd;;AAD4D;;AAAA;;AAAA;;AAAA,gCAZpC,IAYoC;;AAAA;;AAAA;;AAAA,0CARlB,IAQkB;;AAAA;;AAAA,wCAFpB,IAEoB;;AAE5D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAe,KAAKD,KAAL,CAAWC,MAAZ,IAA4C,KAAKC,YAAL,EAA1D;AACA,SAAKD,MAAL,CAAYE,KAAZ,GAAoB,KAAKH,KAAL,CAAWI,EAA/B;AAEA,SAAKC,EAAL,GAAUhB,IAAI,CAAeW,KAAK,CAACK,EAArB,CAAd;AACA,SAAKC,EAAL,GAAUjB,IAAI,CAAeW,KAAK,CAACM,EAArB,CAAd;AAEA,SAAKC,YAAL,GAAoBX,cAAc,CAAC,KAAKI,KAAL,CAAWQ,MAAZ,EAAoB,KAAKR,KAAL,CAAWS,SAA/B,CAAlC;AACA,SAAKC,QAAL,GAAgB,IAAIC,KAAJ,CAAkBC,MAA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MAAjB,CAAwByD,IAAxB,CACEC,OAAO,CAACa,WAAR,IAAuB,CADzB,EAEEb,OAAO,CAACS,aAFV,EAGET,OAAO,CAACU,UAHV,EAIEV,OAAO,CAACY,aAJV;AAMD;AACF;;AAEDN,EAAAA,oBAAoB,CAACL,gBAAD,EAAqC;AACvD,QAAI,KAAK/B,YAAT,EAAuB;AACrB+B,MAAAA,gBAAgB,CAAC3D,MAAjB,CAAwB0B,cAAxB,CAAuC,KAAKE,YAAL,CAAkB5B,MAAzD,EAAiE,KAAK4B,YAAL,CAAkB7B,KAAlB,CAAwByE,SAAzF;AACD;;AAED,UAAMxB,OAAO,GAAG,KAAKN,WAAL,EAAhB;;AACA,SAAK,IAAI+B,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGzB,OAAO,CAACnC,MAA5B,EAAoC,EAAE4D,CAAtC,EAAyC;AACvC,YAAMzC,MAAM,GAAG5C,IAAI,CAAe4D,OAAO,CAACyB,CAAD,CAAtB,CAAnB;;AACA,UAAI,CAACzC,MAAL,EAAa;AACX,cAAM0C,SAAS,GAAG,KAAK3E,KAAL,CAAWQ,MAAX,CAAkBuB,UAAlB,CAA6B6C,IAA7B,CACfD,SAAD,IAAeA,SAAS,CAACE,QAAV,KAAuBH,CADtB,CAAlB;AAGA,cAAM,IAAItC,KAAJ,6CACiC,CAAAuC,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE3C,IAAX,KAAmB,EADpD,yBACqE,KAAKhC,KAAL,CAAWI,EADhF,OAAN;AAGD;;AACDwD,MAAAA,gBAAgB,CAAC3D,MAAjB,CAAwB6E,eAAxB,CAAwCJ,CAAxC,EAA2CzC,MAAM,CAAChC,MAAlD;AACD;AAsBF;;AAlO8D","sourcesContent":["import type {Binding, RenderPass, Shader} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type WebGPUDevice from '../webgpu-device';\nimport type WebGPUBuffer from './webgpu-buffer';\nimport type WebGPUShader from './webgpu-shader';\nimport type WebGPURenderPass from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport default class WebGPURenderPipeline extends RenderPipeline {\n device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n destroy() {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format!)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan':\n case 'line-loop':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n let descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n }\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n if (this._getBindGroup()) {\n webgpuRenderPass.handle.setBindGroup(0, this._getBindGroup());\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.layout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferMap)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n */\n }\n}\n"],"file":"webgpu-render-pipeline.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","fsEntryPoint","targets","format","canvasContext","topology","primitive","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"mappings":";AACA,SAAgBA,cAAhB,EAAqDC,IAArD,EAA2DC,GAA3D,EAAgEC,aAAhE,QAAoF,cAApF;AACA,SAAQC,yCAAR,QAAwD,8BAAxD;AACA,SAAQC,sBAAR,QAAqC,mCAArC;AACA,SAAQC,YAAR,QAA2B,2BAA3B;AACA,SAAQC,qB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CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG1B,OAAO,CAACnC,MAA5B,EAAoC,EAAE6D,CAAtC,EAAyC;AACvC,YAAM1C,MAAM,GAAG5C,IAAI,CAAe4D,OAAO,CAAC0B,CAAD,CAAtB,CAAnB;;AACA,UAAI,CAAC1C,MAAL,EAAa;AACX,cAAM2C,SAAS,GAAG,KAAK5E,KAAL,CAAWQ,MAAX,CAAkBuB,UAAlB,CAA6B8C,IAA7B,CACfD,SAAD,IAAeA,SAAS,CAACE,QAAV,KAAuBH,CADtB,CAAlB;AAGA,cAAM,IAAIvC,KAAJ,6CACiC,CAAAwC,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE5C,IAAX,KAAmB,EADpD,yBACqE,KAAKhC,KAAL,CAAWI,EADhF,OAAN;AAGD;;AACDwD,MAAAA,gBAAgB,CAAC3D,MAAjB,CAAwB8E,eAAxB,CAAwCJ,CAAxC,EAA2C1C,MAAM,CAAChC,MAAlD;AACD;AAsBF;;AAnO8D","sourcesContent":["import type {Binding, RenderPass} from '@luma.gl/api';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/api';\nimport {applyParametersToRenderPipelineDescriptor} from '../helpers/webgpu-parameters';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport {getBindGroup} from '../helpers/get-bind-group';\nimport {getVertexBufferLayout, getBufferSlots} from '../helpers/get-vertex-buffer-layout';\n// import {convertAttributesVertexBufferToLayout} from '../helpers/get-vertex-buffer-layout';\n// import {mapAccessorToWebGPUFormat} from './helpers/accessor-to-format';\n// import type {BufferAccessors} from './webgpu-pipeline';\n\nimport type WebGPUDevice from '../webgpu-device';\nimport type WebGPUBuffer from './webgpu-buffer';\nimport type WebGPUShader from './webgpu-shader';\nimport type WebGPURenderPass from './webgpu-render-pass';\n\n// RENDER PIPELINE\n\n/** Creates a new render pipeline when parameters change */\nexport default class WebGPURenderPipeline extends RenderPipeline {\n device: WebGPUDevice;\n handle: GPURenderPipeline;\n\n vs: WebGPUShader;\n fs: WebGPUShader | null = null;\n\n private _bufferSlots: Record<string, number>;\n private _buffers: Buffer[];\n private _indexBuffer: WebGPUBuffer | null = null;\n // private _firstIndex: number;\n // private _lastIndex: number;\n\n /** For internal use to create BindGroups */\n private _bindGroupLayout: GPUBindGroupLayout;\n private _bindGroup: GPUBindGroup | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPipelineProps) {\n super(device, props);\n this.device = device;\n this.handle = (this.props.handle as GPURenderPipeline) || this.createHandle();\n this.handle.label = this.props.id;\n\n this.vs = cast<WebGPUShader>(props.vs);\n this.fs = cast<WebGPUShader>(props.fs);\n\n this._bufferSlots = getBufferSlots(this.props.layout, this.props.bufferMap);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format!)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan':\n case 'line-loop':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n let descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n }\n };\n\n // Set parameters on the descriptor\n applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);\n\n return descriptor;\n }\n\n draw(options: {\n renderPass?: RenderPass;\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n const webgpuRenderPass: WebGPURenderPass =\n cast<WebGPURenderPass>(options.renderPass) || this.device.getDefaultRenderPass();\n\n // Set pipeline\n webgpuRenderPass.handle.setPipeline(this.handle);\n\n // Set bindings (uniform buffers, textures etc)\n const bindGroup = this._getBindGroup();\n if (bindGroup) {\n webgpuRenderPass.handle.setBindGroup(0, bindGroup);\n }\n\n // Set attributes\n this._setAttributeBuffers(webgpuRenderPass);\n\n // Draw\n if (options.indexCount) {\n webgpuRenderPass.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n webgpuRenderPass.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n _setAttributeBuffers(webgpuRenderPass: WebGPURenderPass) {\n if (this._indexBuffer) {\n webgpuRenderPass.handle.setIndexBuffer(this._indexBuffer.handle, this._indexBuffer.props.indexType);\n }\n\n const buffers = this._getBuffers();\n for (let i = 0; i < buffers.length; ++i) {\n const buffer = cast<WebGPUBuffer>(buffers[i]);\n if (!buffer) {\n const attribute = this.props.layout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferMap)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n */\n }\n}\n"],"file":"webgpu-render-pipeline.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAc3D,OAAO,IAAI,IAAI;CAGhB"}
1
+ {"version":3,"file":"webgpu-sampler.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,kBAAkB,GAAG,YAAY,GAAG;IAC9C,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAChD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,kBAAkB;IAclD,OAAO,IAAI,IAAI;CAGzB"}
@@ -9,13 +9,14 @@ export default class WebGPUSampler extends Sampler {
9
9
  _defineProperty(this, "handle", void 0);
10
10
 
11
11
  this.device = device;
12
- const samplerProps = this.props;
12
+ const samplerProps = { ...this.props
13
+ };
13
14
 
14
15
  if (samplerProps.type !== 'comparison-sampler') {
15
16
  delete samplerProps.compare;
16
17
  }
17
18
 
18
- this.handle = this.handle || this.device.handle.createSampler(this.props);
19
+ this.handle = this.handle || this.device.handle.createSampler(samplerProps);
19
20
  this.handle.label = this.props.id;
20
21
  }
21
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":["Sampler","WebGPUSampler","constructor","device","props","samplerProps","type","compare","handle","createSampler","label","id","destroy"],"mappings":";AAAA,SAAQA,OAAR,QAAoC,cAApC;AAUA,eAAe,MAAMC,aAAN,SAA4BD,OAA5B,CAAoC;AAIjDE,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAkD;AAC3D,UAAMD,MAAN,EAAcC,KAAd;;AAD2D;;AAAA;;AAE3D,SAAKD,MAAL,GAAcA,MAAd;AAGA,UAAME,YAAY,GAAG,KAAKD,KAA1B;;AACA,QAAIC,YAAY,CAACC,IAAb,KAAsB,oBAA1B,EAAgD;AAC9C,aAAOD,YAAY,CAACE,OAApB;AACD;;AAED,SAAKC,MAAL,GAAc,KAAKA,MAAL,IAAe,KAAKL,MAAL,CAAYK,MAAZ,CAAmBC,aAAnB,CAAiC,KAAKL,KAAtC,CAA7B;AACA,SAAKI,MAAL,CAAYE,KAAZ,GAAoB,KAAKN,KAAL,CAAWO,EAA/B;AACD;;AAEDC,EAAAA,OAAO,GAAS,CAEf;;AApBgD","sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\n */\nexport default class WebGPUSampler extends Sampler {\n readonly device: WebGPUDevice;\n readonly handle: GPUSampler;\n\n constructor(device: WebGPUDevice, props: WebGPUSamplerProps) {\n super(device, props);\n this.device = device;\n\n // Prepare sampler props\n const samplerProps = this.props;\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n\n this.handle = this.handle || this.device.handle.createSampler(this.props);\n this.handle.label = this.props.id;\n }\n\n destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"file":"webgpu-sampler.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-sampler.ts"],"names":["Sampler","WebGPUSampler","constructor","device","props","samplerProps","type","compare","handle","createSampler","label","id","destroy"],"mappings":";AAAA,SAAQA,OAAR,QAAoC,cAApC;AAUA,eAAe,MAAMC,aAAN,SAA4BD,OAA5B,CAAoC;AAIjDE,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAkD;AAC3D,UAAMD,MAAN,EAAcC,KAAd;;AAD2D;;AAAA;;AAE3D,SAAKD,MAAL,GAAcA,MAAd;AAGA,UAAME,YAAyC,GAAG,EAAC,GAAG,KAAKD;AAAT,KAAlD;;AACA,QAAIC,YAAY,CAACC,IAAb,KAAsB,oBAA1B,EAAgD;AAC9C,aAAOD,YAAY,CAACE,OAApB;AACD;;AAED,SAAKC,MAAL,GAAc,KAAKA,MAAL,IAAe,KAAKL,MAAL,CAAYK,MAAZ,CAAmBC,aAAnB,CAAiCJ,YAAjC,CAA7B;AACA,SAAKG,MAAL,CAAYE,KAAZ,GAAoB,KAAKN,KAAL,CAAWO,EAA/B;AACD;;AAEQC,EAAAA,OAAO,GAAS,CAExB;;AApBgD","sourcesContent":["import {Sampler, SamplerProps} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nexport type WebGPUSamplerProps = SamplerProps & {\n handle?: GPUSampler;\n}\n\n/**\n *\n */\nexport default class WebGPUSampler extends Sampler {\n readonly device: WebGPUDevice;\n readonly handle: GPUSampler;\n\n constructor(device: WebGPUDevice, props: WebGPUSamplerProps) {\n super(device, props);\n this.device = device;\n\n // Prepare sampler props\n const samplerProps: Partial<WebGPUSamplerProps> = {...this.props};\n if (samplerProps.type !== 'comparison-sampler') {\n delete samplerProps.compare;\n }\n\n this.handle = this.handle || this.device.handle.createSampler(samplerProps);\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n}\n"],"file":"webgpu-sampler.js"}
@@ -12,7 +12,7 @@ export default class WebGPUShader extends Shader {
12
12
  readonly device: WebGPUDevice;
13
13
  readonly handle: GPUShaderModule;
14
14
  constructor(device: WebGPUDevice, props: WebGPUShaderProps);
15
- _checkCompilationError(errorScope: Promise<GPUError>): Promise<void>;
15
+ _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void>;
16
16
  destroy(): void;
17
17
  protected createHandle(): GPUShaderModule;
18
18
  /** Returns compilation info for this shader */
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAM,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,iBAAiB,GAAG,WAAW,GAAG;IAC5C,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB;IAYpD,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1E,OAAO;IAIP,SAAS,CAAC,YAAY,IAAI,eAAe;IAwBzC,+CAA+C;IACzC,eAAe,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAI7D"}
1
+ {"version":3,"file":"webgpu-shader.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-shader.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAC,MAAM,E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