@luma.gl/webgpu 9.0.0-alpha.35 → 9.0.0-alpha.36

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 (40) hide show
  1. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  2. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  3. package/dist/adapter/helpers/webgpu-parameters.js +2 -2
  4. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  5. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  6. package/dist/adapter/resources/webgpu-render-pass.js +23 -4
  7. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  8. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +3 -2
  9. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  10. package/dist/adapter/resources/webgpu-render-pipeline.js +11 -12
  11. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  12. package/dist/adapter/resources/webgpu-shader.js +1 -1
  13. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  14. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  15. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  16. package/dist/adapter/resources/webgpu-vertex-array.d.ts +26 -0
  17. package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -0
  18. package/dist/adapter/resources/webgpu-vertex-array.js +39 -0
  19. package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -0
  20. package/dist/adapter/webgpu-canvas-context.d.ts +8 -2
  21. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  22. package/dist/adapter/webgpu-canvas-context.js +11 -10
  23. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  24. package/dist/adapter/webgpu-device.d.ts +4 -1
  25. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  26. package/dist/adapter/webgpu-device.js +10 -14
  27. package/dist/adapter/webgpu-device.js.map +1 -1
  28. package/dist/dist.dev.js +250 -110
  29. package/dist/index.cjs +130 -59
  30. package/dist.min.js +5 -5
  31. package/package.json +3 -3
  32. package/src/adapter/helpers/get-vertex-buffer-layout.ts +1 -0
  33. package/src/adapter/helpers/webgpu-parameters.ts +2 -2
  34. package/src/adapter/resources/webgpu-render-pass.ts +27 -4
  35. package/src/adapter/resources/webgpu-render-pipeline.ts +18 -15
  36. package/src/adapter/resources/webgpu-shader.ts +1 -1
  37. package/src/adapter/resources/webgpu-texture.ts +7 -0
  38. package/src/adapter/resources/webgpu-vertex-array.ts +73 -0
  39. package/src/adapter/webgpu-canvas-context.ts +36 -16
  40. package/src/adapter/webgpu-device.ts +21 -13
@@ -1 +1 @@
1
- {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqC,MAAM,eAAe,CAAC;AAWlG;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,qBAAqB,EAAE,CAuEzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
1
+ {"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqC,MAAM,eAAe,CAAC;AAWlG;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,qBAAqB,EAAE,CAuEzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-vertex-buffer-layout.js","names":["getAttributeInfosFromLayouts","decodeVertexFormat","getWebGPUVertexFormat","format","endsWith","Error","getVertexBufferLayout","shaderLayout","bufferLayout","attributeInfos","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","attributes","attributeMapping","attributeName","attribute","attributeLayout","findAttributeLayout","push","offset","byteOffset","shaderLocation","location","byteLength","name","arrayStride","has","getBufferSlots","bufferSlot","bufferSlots","interleaved","add","attributeNames","find"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["import type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts, decodeVertexFormat} from '@luma.gl/core';\n\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format as GPUVertexFormat;\n}\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): GPUVertexBufferLayout[] {\n // @ts-expect-error Deduplicate and make use of the new core attribute logic here in webgpu module\n const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);\n\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(mapping.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n byteStride = decodeVertexFormat(mapping.format).byteLength;\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(mapping.format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(\n shaderLayout: ShaderLayout,\n name: string,\n attributeNames: Set<string>\n): AttributeDeclaration {\n const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n 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"],"mappings":"AACA,SAAQA,4BAA4B,EAAEC,kBAAkB,QAAO,eAAe;AAG9E,SAASC,qBAAqBA,CAACC,MAAoB,EAAmB;EACpE,IAAIA,MAAM,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC7B,MAAM,IAAIC,KAAK,CAAE,yCAAwCF,MAAO,EAAC,CAAC;EACpE;EACA,OAAOA,MAAM;AACf;AASA,OAAO,SAASG,qBAAqBA,CACnCC,YAA0B,EAC1BC,YAA4B,EACH;EAEzB,MAAMC,cAAc,GAAGT,4BAA4B,CAACO,YAAY,EAAEC,YAAY,CAAC;EAE/E,MAAME,mBAA4C,GAAG,EAAE;EACvD,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAS,CAAC;EAGxC,KAAK,MAAMC,OAAO,IAAIL,YAAY,EAAE;IAElC,MAAMM,gBAAsC,GAAG,EAAE;IAGjD,IAAIC,QAA+B,GAAG,QAAQ;IAC9C,IAAIC,UAAU,GAAG,CAAC;IAElB,IAAIH,OAAO,C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AA2B,EACL;EACtB,MAAMjB,SAAS,GAAGb,YAAY,CAACU,UAAU,CAACqB,IAAI,CAAClB,SAAS,IAAIA,SAAS,CAACS,IAAI,KAAKA,IAAI,CAAC;EACpF,IAAI,CAACT,SAAS,EAAE;IACd,MAAM,IAAIf,KAAK,CAAE,qBAAoBwB,IAAK,EAAC,CAAC;EAC9C;EACA,IAAIQ,cAAc,CAACN,GAAG,CAACF,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIxB,KAAK,CAAE,uBAAsBwB,IAAK,EAAC,CAAC;EAChD;EACAQ,cAAc,CAACD,GAAG,CAACP,IAAI,CAAC;EACxB,OAAOT,SAAS;AAClB"}
1
+ {"version":3,"file":"get-vertex-buffer-layout.js","names":["getAttributeInfosFromLayouts","decodeVertexFormat","getWebGPUVertexFormat","format","endsWith","Error","getVertexBufferLayout","shaderLayout","bufferLayout","attributeInfos","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","attributes","attributeMapping","attributeName","attribute","attributeLayout","findAttributeLayout","push","offset","byteOffset","shaderLocation","location","byteLength","name","arrayStride","has","getBufferSlots","bufferSlot","bufferSlots","interleaved","add","attributeNames","find"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts, decodeVertexFormat} from '@luma.gl/core';\n\n/** Throw error on any WebGL-only vertex formats */\nfunction getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {\n if (format.endsWith('-webgl')) {\n throw new Error(`WebGPU does not support vertex format ${format}`);\n }\n return format as GPUVertexFormat;\n}\n\n/**\n * Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.\n * Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array\n * @param layout\n * @param bufferLayout The buffer map is optional\n * @returns WebGPU layout intended for a GPURenderPassDescriptor.\n */\nexport function getVertexBufferLayout(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): GPUVertexBufferLayout[] {\n // @ts-expect-error Deduplicate and make use of the new core attribute logic here in webgpu module\n const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);\n\n const vertexBufferLayouts: GPUVertexBufferLayout[] = [];\n const usedAttributes = new Set<string>();\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // Build vertex attributes for one buffer\n const vertexAttributes: GPUVertexAttribute[] = [];\n\n // TODO verify that all stepModes for one buffer are the same\n let stepMode: 'vertex' | 'instance' = 'vertex';\n let byteStride = 0;\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const attributeMapping of mapping.attributes) {\n const attributeName = attributeMapping.attribute;\n const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),\n offset: attributeMapping.byteOffset,\n shaderLocation: attributeLayout.location\n });\n\n byteStride += decodeVertexFormat(mapping.format).byteLength;\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);\n byteStride = decodeVertexFormat(mapping.format).byteLength;\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(mapping.format),\n // We only support 0 offset for non-interleaved buffer layouts\n offset: 0,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - TODO - avoid hardcoded types\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n vertexBufferLayouts.push({\n arrayStride: decodeVertexFormat('float32x3').byteLength,\n stepMode: attribute.stepMode || 'vertex',\n attributes: [\n {\n format: getWebGPUVertexFormat('float32x3'),\n offset: 0,\n shaderLocation: attribute.location\n }\n ]\n });\n }\n }\n\n return vertexBufferLayouts;\n}\n\nexport function getBufferSlots(\n shaderLayout: ShaderLayout,\n bufferLayout: BufferLayout[]\n): Record<string, number> {\n const usedAttributes = new Set<string>();\n let bufferSlot = 0;\n const bufferSlots: Record<string, number> = {};\n\n // First handle any buffers mentioned in `bufferLayout`\n for (const mapping of bufferLayout) {\n // interleaved mapping {..., attributes: [{...}, ...]}\n if ('attributes' in mapping) {\n for (const interleaved of mapping.attributes) {\n usedAttributes.add(interleaved.attribute);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of shaderLayout.attributes) {\n if (!usedAttributes.has(attribute.name)) {\n bufferSlots[attribute.name] = bufferSlot++;\n }\n }\n\n return bufferSlots;\n}\n\n/**\n * Looks up an attribute in the ShaderLayout.\n * @throws if name is not in ShaderLayout\n * @throws if name has already been referenced\n */\nfunction findAttributeLayout(\n shaderLayout: ShaderLayout,\n name: string,\n attributeNames: Set<string>\n): AttributeDeclaration {\n const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);\n if (!attribute) {\n 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"],"mappings":"AAEA,SAAQA,4BAA4B,EAAEC,kBAAkB,QAAO,eAAe;AAG9E,SAASC,qBAAqBA,CAACC,MAAoB,EAAmB;EACpE,IAAIA,MAAM,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC7B,MAAM,IAAIC,KAAK,CAAE,yCAAwCF,MAAO,EAAC,CAAC;EACpE;EACA,OAAOA,MAAM;AACf;AASA,OAAO,SAASG,qBA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WAAW,CAACrB,OAAO,CAACgB,IAAI,CAAC,GAAGI,UAAU,EAAE;EAC1C;EAGA,KAAK,MAAMb,SAAS,IAAIb,YAAY,CAACU,UAAU,EAAE;IAC/C,IAAI,CAACN,cAAc,CAACoB,GAAG,CAACX,SAAS,CAACS,IAAI,CAAC,EAAE;MACvCK,WAAW,CAACd,SAAS,CAACS,IAAI,CAAC,GAAGI,UAAU,EAAE;IAC5C;EACF;EAEA,OAAOC,WAAW;AACpB;AAOA,SAASZ,mBAAmBA,CAC1Bf,YAA0B,EAC1BsB,IAAY,EACZQ,cAA2B,EACL;EACtB,MAAMjB,SAAS,GAAGb,YAAY,CAACU,UAAU,CAACqB,IAAI,CAAClB,SAAS,IAAIA,SAAS,CAACS,IAAI,KAAKA,IAAI,CAAC;EACpF,IAAI,CAACT,SAAS,EAAE;IACd,MAAM,IAAIf,KAAK,CAAE,qBAAoBwB,IAAK,EAAC,CAAC;EAC9C;EACA,IAAIQ,cAAc,CAACN,GAAG,CAACF,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIxB,KAAK,CAAE,uBAAsBwB,IAAK,EAAC,CAAC;EAChD;EACAQ,cAAc,CAACD,GAAG,CAACP,IAAI,CAAC;EACxB,OAAOT,SAAS;AAClB"}
@@ -3,8 +3,8 @@ function addDepthStencil(descriptor) {
3
3
  format: 'depth24plus',
4
4
  stencilFront: {},
5
5
  stencilBack: {},
6
- depthWriteEnabled: undefined,
7
- depthCompare: undefined
6
+ depthWriteEnabled: false,
7
+ depthCompare: 'less-equal'
8
8
  };
9
9
  return descriptor.depthStencil;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-parameters.js","names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","depthWriteEnabled","undefined","depthCompare","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","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","entryPoint","fragment","layout","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","arguments","length","Object","assign","setParameters","key","entries","setterFunction","Error","_descriptor$fragment","_descriptor$fragment2","_descriptor$fragment3","_descriptor$fragment4","Array","isArray","_descriptor$fragment$","push"],"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"sourcesContent":["import {Parameters} from '@luma.gl/core';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: undefined!,\n depthCompare: undefined!\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 layout: 'auto'\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"],"mappings":"A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GAAI,EAAC,CAAC;IAC7C;IACAE,cAAc,CAACF,GAAG,EAAE5C,KAAK,EAAEqC,kBAAkB,CAAC;EAChD;AACF;AAEA,SAASX,aAAaA,CAACrC,UAAuC,EAAyB;EAAA,IAAA2D,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EACrF9D,UAAU,CAAC6C,QAAQ,CAACT,OAAO,GAAG,EAAAuB,oBAAA,GAAA3D,UAAU,CAAC6C,QAAQ,cAAAc,oBAAA,uBAAnBA,oBAAA,CAAqBvB,OAAO,KAAI,EAAE;EAChE,IAAI,CAAC2B,KAAK,CAACC,OAAO,EAAAJ,qBAAA,GAAC5D,UAAU,CAAC6C,QAAQ,cAAAe,qBAAA,uBAAnBA,qBAAA,CAAqBxB,OAAO,CAAC,EAAE;IAChD,MAAM,IAAIsB,KAAK,CAAC,YAAY,CAAC;EAC/B;EACA,IAAI,EAAAG,qBAAA,GAAA7D,UAAU,CAAC6C,QAAQ,cAAAgB,qBAAA,gBAAAA,qBAAA,GAAnBA,qBAAA,CAAqBzB,OAAO,cAAAyB,qBAAA,uBAA5BA,qBAAA,CAA8BV,MAAM,MAAK,CAAC,EAAE;IAAA,IAAAc,qBAAA;IAC9C,CAAAA,qBAAA,GAAAjE,UAAU,CAAC6C,QAAQ,CAACT,OAAO,cAAA6B,qBAAA,uBAA3BA,qBAAA,CAA6BC,IAAI,CAAC,CAAC,CAAC,CAAC;EACvC;EACA,QAAAJ,qBAAA,GAAO9D,UAAU,CAAC6C,QAAQ,cAAAiB,qBAAA,uBAAnBA,qBAAA,CAAqB1B,OAAO;AACrC"}
1
+ {"version":3,"file":"webgpu-parameters.js","names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","depthWriteEnabled","depthCompare","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","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","layout","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","arguments","length","Object","assign","setParameters","key","entries","setterFunction","Error","_descriptor$fragment","_descriptor$fragment2","_descriptor$fragment3","_descriptor$fragment4","Array","isArray","_descriptor$fragment$","push"],"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"sourcesContent":["import {Parameters} from '@luma.gl/core';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {},\n // TODO can this cause trouble? Should we set to WebGPU defaults? Are there defaults?\n depthWriteEnabled: false,\n depthCompare: 'less-equal'\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 layout: 'auto'\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"],"mappings":"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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;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;IAc5C;;;OAGG;IACH,SAAS,CAAC,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB;CA2CrF"}
@@ -1,4 +1,4 @@
1
- import { RenderPass, cast } from '@luma.gl/core';
1
+ import { RenderPass, cast, log } from '@luma.gl/core';
2
2
  export class WebGPURenderPass extends RenderPass {
3
3
  constructor(device) {
4
4
  let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -9,6 +9,9 @@ export class WebGPURenderPass extends RenderPass {
9
9
  this.device = device;
10
10
  const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
11
11
  const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
12
+ log.groupCollapsed(1, `new WebGPURenderPass(${this.id})`)();
13
+ log.probe(1, JSON.stringify(renderPassDescriptor, null, 2))();
14
+ log.groupEnd(1)();
12
15
  this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
13
16
  this.handle.label = this.props.id;
14
17
  }
@@ -41,7 +44,7 @@ export class WebGPURenderPass extends RenderPass {
41
44
  if (options.indexCount) {
42
45
  this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
43
46
  } else {
44
- this.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
47
+ this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);
45
48
  }
46
49
  }
47
50
  drawIndirect() {}
@@ -79,16 +82,32 @@ export class WebGPURenderPass extends RenderPass {
79
82
  colorAttachments: []
80
83
  };
81
84
  renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({
82
- loadOp: 'clear',
85
+ loadOp: this.props.clearColor !== false ? 'clear' : 'load',
83
86
  colorClearValue: this.props.clearColor || [0, 0, 0, 0],
84
87
  storeOp: this.props.discard ? 'discard' : 'store',
85
88
  view: colorAttachment.handle.createView()
86
89
  }));
87
90
  if (framebuffer.depthStencilAttachment) {
88
91
  renderPassDescriptor.depthStencilAttachment = {
89
- ...this.props,
90
92
  view: framebuffer.depthStencilAttachment.handle.createView()
91
93
  };
94
+ const {
95
+ depthStencilAttachment
96
+ } = renderPassDescriptor;
97
+ if (this.props.depthReadOnly) {
98
+ depthStencilAttachment.depthReadOnly = true;
99
+ }
100
+ depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;
101
+ const hasDepthAspect = true;
102
+ if (hasDepthAspect) {
103
+ depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';
104
+ depthStencilAttachment.depthStoreOp = 'store';
105
+ }
106
+ const hasStencilAspect = false;
107
+ if (hasStencilAspect) {
108
+ depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';
109
+ depthStencilAttachment.stencilStoreOp = 'store';
110
+ }
92
111
  }
93
112
  return renderPassDescriptor;
94
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","arguments","length","undefined","handle","pipeline","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","getRenderPassDescriptor","commandEncoder","beginRenderPass","label","id","destroy","end","setPipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","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","colorAttachments","map","colorAttachment","loadOp","colorClearValue","clearColor","storeOp","discard","view","createView","depthStencilAttachment"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding, Framebuffer} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, cast} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport 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 const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\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 end(): void {\n this.handle.end();\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 // INTERNAL\n\n /** \n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor. \n */\n protected getRenderPassDescriptor(framebuffer: Framebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: 'clear',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard? 'discard': 'store',\n // ...colorAttachment,\n view: (colorAttachment as WebGPUTexture).handle.createView()\n }));\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n ...this.props,\n view: (framebuffer.depthStencilAttachment as WebGPUTexture).handle.createView()\n };\n }\n\n return renderPassDescriptor;\n }\n}\n"],"mappings":"AACA,SAAgBA,UAAU,EAAkBC,IAAI,QAAO,eAAe;AAOtE,OAAO,MAAMC,gBAAgB,SAASF,UAAU,CAAC;EAO/CG,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KAPdD,MAAM;IAAA,KACNK,MAAM;IAAA,KAGfC,QAAQ,GAAgC,IAAI;IAI1C,IAAI,CAACN,MAAM,GAAGA,MAAM;IACpB,MAAMO,WAAW,GAAGN,KAAK,CAACM,WAAW,IAAIP,MAAM,CAACQ,aAAa,CAACC,qBAAqB,CAAC,CAAC;IACrF,MAAMC,oBAAoB,GAAG,IAAI,CAACC,uBAAuB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I,EAAG3D,WAAW,CAAC6D,sBAAsB,CAAmB/D,MAAM,CAAC8D,UAAU,CAAC;MAChF,CAAC;IACH;IAEA,OAAOzD,oBAAoB;EAC7B;AACF"}
1
+ {"version":3,"file":"webgpu-render-pass.js","names":["RenderPass","cast","log","WebGPURenderPass","constructor","device","props","arguments","length","undefined","handle","pipeline","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","getRenderPassDescriptor","groupCollapsed","id","probe","JSON","stringify","groupEnd","commandEncoder","beginRenderPass","label","destroy","end","setPipeline","setBindings","bindings","_this$pipeline","_this$pipeline2","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","colorAttachments","map","colorAttachment","loadOp","clearColor","colorClearValue","storeOp","discard","view","createView","depthStencilAttachment","depthReadOnly","depthClearValue","clearDepth","hasDepthAspect","depthLoadOp","depthStoreOp","hasStencilAspect","stencilLoadOp","clearStencil","stencilStoreOp"],"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding, Framebuffer} from '@luma.gl/core';\nimport {Buffer, RenderPass, RenderPipeline, cast, log} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n// import {WebGPUCommandEncoder} from './webgpu-command-encoder';\nimport {WebGPURenderPipeline} from './webgpu-render-pipeline';\n\nexport 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 const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);\n log.groupCollapsed(1, `new WebGPURenderPass(${this.id})`)();\n log.probe(1, JSON.stringify(renderPassDescriptor, null, 2))();\n log.groupEnd(1)();\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 end(): void {\n this.handle.end();\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 || 1,\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 // INTERNAL\n\n /** \n * Partial render pass descriptor. Used by WebGPURenderPass.\n * @returns attachments fields of a renderpass descriptor. \n */\n protected getRenderPassDescriptor(framebuffer: Framebuffer): GPURenderPassDescriptor {\n const renderPassDescriptor: GPURenderPassDescriptor = {\n colorAttachments: []\n };\n\n renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map(colorAttachment => ({\n // clear values\n loadOp: this.props.clearColor !== false ? 'clear' : 'load',\n colorClearValue: this.props.clearColor || [0, 0, 0, 0],\n storeOp: this.props.discard? 'discard': 'store',\n // ...colorAttachment,\n view: (colorAttachment as WebGPUTexture).handle.createView()\n }));\n\n if (framebuffer.depthStencilAttachment) {\n renderPassDescriptor.depthStencilAttachment = {\n view: (framebuffer.depthStencilAttachment as WebGPUTexture).handle.createView()\n };\n const {depthStencilAttachment} = renderPassDescriptor;\n\n // DEPTH\n if (this.props.depthReadOnly) {\n depthStencilAttachment.depthReadOnly = true;\n }\n depthStencilAttachment.depthClearValue = this.props.clearDepth || 0;\n\n // WebGPU only wants us to set these parameters if the texture format actually has a depth aspect\n const hasDepthAspect = true;\n if (hasDepthAspect) {\n depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? 'clear' : 'load';\n depthStencilAttachment.depthStoreOp = 'store'; // TODO - support 'discard'?\n }\n\n // WebGPU only wants us to set these parameters if the texture format actually has a stencil aspect\n const hasStencilAspect = false;\n if (hasStencilAspect) {\n depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? 'clear' : 'load';\n depthStencilAttachment.stencilStoreOp = 'store'; // TODO - support 'discard'?\n }\n }\n\n return renderPassDescriptor;\n }\n}\n"],"mappings":"AACA,SAAgBA,UAAU,EAAkBC,IAAI,EAAEC,GAAG,QAAO,eAAe;AAO3E,OAAO,MAAMC,gBAAgB,SAASH,UAAU,CAAC;EAO/CI,WAAWA,CAACC,MAAoB,EAA+B;IAAA,IAA7BC,KAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC3D,KAAK,CAACF,MAAM,EAAEC,KAAK,CAAC;IAAC,KAPdD,MAAM;IAAA,KACNK,MAAM;IAAA,KAGfC,QAAQ,GAAgC,IAAI;IAI1C,IAAI,CAACN,MAAM,GAAGA,MAAM;IACpB,MAAMO,WAAW,GAAGN,KAAK,CAACM,WAAW,IAAIP,MAAM,CAACQ,aAAa,CAACC,qBAAqB,CAAC,CAAC;IACrF,MAAMC,oBAAoB,GAAG,IAAI,CAACC,uBAAuB,CAACJ,WAAW,CAAC;IACtEV,GAAG,CAACe,cAAc,CAAC,CAAC,EAAG,wBAAuB,IAAI,CAACC,EAAG,GAAE,CAAC,CAAC,CAAC;IAC3DhB,GAAG,CAACiB,KAAK,CAAC,CAAC,EAAEC,I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AGN,eAAe,CAAmB5D,MAAM,CAACmE,UAAU,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,IAAIjE,WAAW,CAACkE,sBAAsB,EAAE;MACtC/D,oBAAoB,CAAC+D,sBAAsB,GAAG;QAC5CF,IAAI,EAAGhE,WAAW,CAACkE,sBAAsB,CAAmBpE,MAAM,CAACmE,UAAU,CAAC;MAChF,CAAC;MACD,MAAM;QAACC;MAAsB,CAAC,GAAG/D,oBAAoB;MAGrD,IAAI,IAAI,CAACT,KAAK,CAACyE,aAAa,EAAE;QAC5BD,sBAAsB,CAACC,aAAa,GAAG,IAAI;MAC7C;MACAD,sBAAsB,CAACE,eAAe,GAAG,IAAI,CAAC1E,KAAK,CAAC2E,UAAU,IAAI,CAAC;MAGnE,MAAMC,cAAc,GAAG,IAAI;MAC3B,IAAIA,cAAc,EAAE;QAClBJ,sBAAsB,CAACK,WAAW,GAAG,IAAI,CAAC7E,KAAK,CAAC2E,UAAU,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM;QACvFH,sBAAsB,CAACM,YAAY,GAAG,OAAO;MAC/C;MAGA,MAAMC,gBAAgB,GAAG,KAAK;MAC9B,IAAIA,gBAAgB,EAAE;QACpBP,sBAAsB,CAACQ,aAAa,GAAG,IAAI,CAAChF,KAAK,CAACiF,YAAY,KAAK,KAAK,GAAG,OAAO,GAAG,MAAM;QAC3FT,sBAAsB,CAACU,cAAc,GAAG,OAAO;MACjD;IACF;IAEA,OAAOzE,oBAAoB;EAC7B;AACF"}
@@ -17,7 +17,6 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
17
17
  private _bindGroupLayout;
18
18
  private _bindGroup;
19
19
  constructor(device: WebGPUDevice, props: RenderPipelineProps);
20
- protected createHandle(): GPURenderPipeline;
21
20
  destroy(): void;
22
21
  setIndexBuffer(indexBuffer: Buffer): void;
23
22
  setAttributes(attributes: Record<string, Buffer>): void;
@@ -27,7 +26,9 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
27
26
  _getBuffers(): Buffer[];
28
27
  /** Return a bind group created by setBindings */
29
28
  _getBindGroup(): GPUBindGroup;
30
- /** Populate the complex WebGPU GPURenderPipelineDescriptor */
29
+ /**
30
+ * Populate the complex WebGPU GPURenderPipelineDescriptor
31
+ */
31
32
  protected _getRenderPipelineDescriptor(): GPURenderPipelineDescriptor;
32
33
  draw(options: {
33
34
  renderPass?: RenderPass;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,eAAe,CAAC;AASpG,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAI3D,2DAA2D;AAC3D,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAE1B,EAAE,EAAE,YAAY,CAAC;IACjB,EAAE,EAAE,YAAY,GAAG,IAAI,CAAQ;IAE/B,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,YAAY,CAA6B;IAIjD,4CAA4C;IAC5C,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,UAAU,CAA6B;gBAEnC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAc5D,SAAS,CAAC,YAAY,IAAI,iBAAiB;IASlC,OAAO,IAAI,IAAI;IAIxB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAA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B,GAAG,IAAI;IAkCR,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB;CAwCxD"}
@@ -13,24 +13,22 @@ export class WebGPURenderPipeline extends RenderPipeline {
13
13
  this._bufferSlots = void 0;
14
14
  this._buffers = void 0;
15
15
  this._indexBuffer = null;
16
- this._bindGroupLayout = void 0;
16
+ this._bindGroupLayout = null;
17
17
  this._bindGroup = null;
18
18
  this.device = device;
19
- this.handle = this.props.handle || this.createHandle();
19
+ this.handle = this.props.handle;
20
+ if (!this.handle) {
21
+ const descriptor = this._getRenderPipelineDescriptor();
22
+ log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();
23
+ log.probe(1, JSON.stringify(descriptor, null, 2))();
24
+ log.groupEnd(1)();
25
+ this.handle = this.device.handle.createRenderPipeline(descriptor);
26
+ }
20
27
  this.handle.label = this.props.id;
21
28
  this.vs = cast(props.vs);
22
29
  this.fs = cast(props.fs);
23
30
  this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);
24
31
  this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
25
- this._bindGroupLayout = this.handle.getBindGroupLayout(0);
26
- }
27
- createHandle() {
28
- const descriptor = this._getRenderPipelineDescriptor();
29
- const renderPipeline = this.device.handle.createRenderPipeline(descriptor);
30
- log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();
31
- log.log(1, JSON.stringify(descriptor, null, 2))();
32
- log.groupEnd(1)();
33
- return renderPipeline;
34
32
  }
35
33
  destroy() {}
36
34
  setIndexBuffer(indexBuffer) {
@@ -52,6 +50,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
52
50
  setBindings(bindings) {
53
51
  if (!isObjectEmpty(this.props.bindings)) {
54
52
  Object.assign(this.props.bindings, bindings);
53
+ this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
55
54
  this._bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this.props.bindings);
56
55
  }
57
56
  }
@@ -111,7 +110,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
111
110
  if (options.indexCount) {
112
111
  webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
113
112
  } else {
114
- webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
113
+ webgpuRenderPass.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstInstance);
115
114
  }
116
115
  }
117
116
  _setAttributeBuffers(webgpuRenderPass) {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","vs","fs","_bufferSlots","_buffers","_indexBuffer","_bindGroupLayout","_bindGroup","createHandle","label","id","shaderLayout","bufferLayout","Array","Object","keys","length","fill","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","setBindings","bindings","assign","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\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 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.shaderLayout, this.props.bufferLayout);\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 setConstantAttributes(attributes: Record<string, TypedArray>): void {\n throw new Error('not implemented');\n }\n\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.shaderLayout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, UniformValue>): 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.shaderLayout, this.props.bufferLayout)\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-webgl':\n case 'line-loop-webgl':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\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.shaderLayout.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.bufferLayout)) {\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"],"mappings":"AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,eAAe;AAAC,SAC5FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAjBvBD,MAAM;IAAA,KACNE,MAAM;IAAA,KAENC,EAAE;IAAA,KACFC,EAAE,GAAwB,IAAI;IAAA,KAEtBC,YAAY;IAAA,KACZC,QAAQ;IAAA,KACRC,YAAY,GAAwB,IAAI;IAAA,KAKxCC,gBAAgB;IAAA,KAChBC,UAAU,GAAwB,IAAI;IAI5C,IAAI,CAACT,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAI,IAAI,CAACD,KAAK,CAACC,MAAM,IAA0B,IAAI,CAACQ,YAAY,CAAC,CAAC;IAC7E,IAAI,CAACR,MAAM,CAACS,KAAK,GAAG,IAAI,CAACV,KAAK,CAACW,EAAE;IAEj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AACY,YAAY,CAACoB,UAAU,CAACgD,IAAI,CACtDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAIzC,KAAK,CACZ,qCAAoC,CAAA0C,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE9C,IAAI,KAAI,EAAG,eAAc,IAAI,CAACjC,KAAK,CAACW,EAAG,GACzF,CAAC;MACH;MACAoD,gBAAgB,CAAC9D,MAAM,CAACiF,eAAe,CAACJ,CAAC,EAAE5C,MAAM,CAACjC,MAAM,CAAC;IAC3D;EAsBF;AACF"}
1
+ {"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","handle","vs","fs","_bufferSlots","_buffers","_indexBuffer","_bindGroupLayout","_bindGroup","descriptor","_getRenderPipelineDescriptor","groupCollapsed","id","probe","JSON","stringify","groupEnd","createRenderPipeline","label","shaderLayout","bufferLayout","Array","Object","keys","length","fill","destroy","setIndexBuffer","indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","setBindings","bindings","assign","getBindGroupLayout","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","layout","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {TypedArray, Binding, UniformValue, RenderPass} from '@luma.gl/core';\nimport {Buffer, RenderPipeline, RenderPipelineProps, cast, log, isObjectEmpty} from '@luma.gl/core';\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 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 | null = null;\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;\n if (!this.handle) {\n const descriptor = this._getRenderPipelineDescriptor();\n log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();\n log.probe(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n this.handle = this.device.handle.createRenderPipeline(descriptor); \n }\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.shaderLayout, this.props.bufferLayout);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\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 setConstantAttributes(attributes: Record<string, TypedArray>): void {\n throw new Error('not implemented');\n }\n\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n // Do we want to save things on CPU side?\n Object.assign(this.props.bindings, bindings);\n\n // Get hold of the bind group layout. We don't want to do this unless we know there is at least one bind group\n this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);\n\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.shaderLayout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, UniformValue>): 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 /** \n * Populate the complex WebGPU GPURenderPipelineDescriptor \n */\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.shaderLayout, this.props.bufferLayout)\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-webgl':\n case 'line-loop-webgl':\n throw new Error(`WebGPU does not support primitive topology ${this.props.topology}`);\n default:\n }\n\n // Create a partially populated descriptor\n const descriptor: GPURenderPipelineDescriptor = {\n vertex,\n fragment,\n primitive: {\n topology: this.props.topology\n },\n layout: 'auto'\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 || 1, // If 0, nothing will be drawn\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.shaderLayout.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.bufferLayout)) {\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"],"mappings":"AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,eAAe;AAAC,SAC5FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAEC,cAAc;AAa7C,OAAO,MAAMC,oBAAoB,SAAST,cAAc,CAAC;EAiBvDU,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAjBvBD,MAAM;IAAA,KACNE,MAAM;IAAA,KAENC,EAAE;IAAA,KACFC,EAAE,GAAwB,IAAI;IAAA,KAEtBC,YAAY;IAAA,KACZC,QAAQ;IAAA,KACRC,YAAY,GAAwB,IAAI;IAAA,KAKxCC,gBAAgB,GAA8B,IAAI;IAAA,KAClDC,UAAU,GAAwB,IAAI;IAI5C,IAAI,CAACT,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAA2B;IACpD,IAAI,CAAC,IAAI,CAACA,MAAM,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I,CAAC7C,MAAM,EAAE;QACX,MAAM8C,SAAS,GAAG,IAAI,CAAC9E,KAAK,CAACmB,YAAY,CAACW,UAAU,CAACiD,IAAI,CACtDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAI1C,KAAK,CACZ,qCAAoC,CAAA2C,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE/C,IAAI,KAAI,EAAG,eAAc,IAAI,CAAC/B,KAAK,CAACY,EAAG,GACzF,CAAC;MACH;MACAkD,gBAAgB,CAAC7D,MAAM,CAACgF,eAAe,CAACJ,CAAC,EAAE7C,MAAM,CAAC/B,MAAM,CAAC;IAC3D;EAsBF;AACF"}
@@ -25,7 +25,7 @@ export class WebGPUShader extends Shader {
25
25
  stage
26
26
  } = this.props;
27
27
  let language = this.props.language;
28
- if (!language) {
28
+ if (language === 'auto') {
29
29
  language = source.includes('->') ? 'wgsl' : 'glsl';
30
30
  }
31
31
  switch (language) {
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","message","Error","destroy","source","stage","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","getCompilationInfo","messages"],"sources":["../../../src/adapter/resources/webgpu-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUShaderProps = ShaderProps & {\n handle?: GPUShaderModule;\n};\n\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n readonly device: WebGPUDevice;\n readonly handle: GPUShaderModule;\n\n constructor(device: WebGPUDevice, props: WebGPUShaderProps) {\n super(device, props);\n this.device = device;\n\n this.device.handle.pushErrorScope('validation');\n\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n\n async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {\n const error = await errorScope as GPUValidationError;\n if (error) {\n const shaderLog = await this.compilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n\n protected createHandle(): GPUShaderModule {\n const {source, stage} = this.props;\n\n let language = this.props.language;\n // Compile from src\n if (!language) {\n // wgsl uses C++ \"auto\" style arrow notation\n language = source.includes('->') ? 'wgsl' : 'glsl';\n }\n\n switch(language) {\n case 'wgsl':\n return this.device.handle.createShaderModule({code: source});\n case 'glsl':\n return this.device.handle.createShaderModule({\n code: source,\n // @ts-expect-error\n transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)\n });\n default:\n throw new Error(language);\n }\n }\n\n /** Returns compilation info for this shader */\n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,GAAG,QAAO,eAAe;AAUzC,OAAO,MAAMC,YAAY,SAASF,MAAM,CAAC;EAIvCG,WAAWA,CAACC,MAAoB,EAAEC,KAAwB,EAAE;IAC1D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAJdD,MAAM;IAAA,KACNE,MAAM;IAIb,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACA,MAAM,CAACE,MAAM,CAACC,cAAc,CAAC,YAAY,CAAC;IAE/C,IAAI,CAACD,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACE,YAAY,CAAC,CAAC;IACtD,IAAI,CAACF,MAAM,CAACG,KAAK,GAAG,IAAI,CAACJ,KAAK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AA,EAAwC;IAC3D,MAAMA,eAAe,GAAG,MAAM,IAAI,CAACV,MAAM,CAACwB,kBAAkB,CAAC,CAAC;IAC9D,OAAOd,eAAe,CAACe,QAAQ;EACjC;AACF"}
1
+ {"version":3,"file":"webgpu-shader.js","names":["Shader","log","WebGPUShader","constructor","device","props","handle","pushErrorScope","createHandle","label","id","_checkCompilationError","popErrorScope","errorScope","error","shaderLog","compilationInfo","message","Error","destroy","source","stage","language","includes","createShaderModule","code","transform","glsl","glslang","compileGLSL","getCompilationInfo","messages"],"sources":["../../../src/adapter/resources/webgpu-shader.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {ShaderProps, CompilerMessage} from '@luma.gl/core';\nimport {Shader, log} from '@luma.gl/core';\nimport type {WebGPUDevice} from '../webgpu-device';\n\nexport type WebGPUShaderProps = ShaderProps & {\n handle?: GPUShaderModule;\n};\n\n/**\n * Immutable shader\n */\nexport class WebGPUShader extends Shader {\n readonly device: WebGPUDevice;\n readonly handle: GPUShaderModule;\n\n constructor(device: WebGPUDevice, props: WebGPUShaderProps) {\n super(device, props);\n this.device = device;\n\n this.device.handle.pushErrorScope('validation');\n\n this.handle = this.props.handle || this.createHandle();\n this.handle.label = this.props.id;\n\n this._checkCompilationError(this.device.handle.popErrorScope());\n }\n\n async _checkCompilationError(errorScope: Promise<GPUError | null>): Promise<void> {\n const error = await errorScope as GPUValidationError;\n if (error) {\n const shaderLog = await this.compilationInfo();\n log.error(`Shader compilation error: ${error.message}`, shaderLog)();\n // Note: Even though this error is asynchronous and thrown after the constructor completes,\n // it will result in a useful stack trace leading back to the constructor\n throw new Error(`Shader compilation error: ${error.message}`);\n }\n }\n\n override destroy(): void {\n // this.handle.destroy();\n }\n\n protected createHandle(): GPUShaderModule {\n const {source, stage} = this.props;\n\n let language = this.props.language;\n // Compile from src\n if (language === 'auto') {\n // wgsl uses C++ \"auto\" style arrow notation\n language = source.includes('->') ? 'wgsl' : 'glsl';\n }\n\n switch(language) {\n case 'wgsl':\n return this.device.handle.createShaderModule({code: source});\n case 'glsl':\n return this.device.handle.createShaderModule({\n code: source,\n // @ts-expect-error\n transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)\n });\n default:\n throw new Error(language);\n }\n }\n\n /** Returns compilation info for this shader */\n async compilationInfo(): Promise<readonly CompilerMessage[]> {\n const compilationInfo = await this.handle.getCompilationInfo();\n return compilationInfo.messages;\n }\n}\n"],"mappings":"AAGA,SAAQA,MAAM,EAAEC,GAAG,QAAO,eAAe;AAUzC,OAAO,MAAMC,YAAY,SAASF,MAAM,CAAC;EAIvCG,WAAWA,CAACC,MAAoB,EAAEC,KAAwB,EAAE;IAC1D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAJdD,MAAM;IAAA,KACNE,MAAM;IAIb,IAAI,CAACF,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACA,MAAM,CAACE,MAAM,CAACC,cAAc,CAAC,YAAY,CAAC;IAE/C,IAAI,CAACD,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACE,YAAY,CAAC,CAAC;IACtD,IAAI,CAACF,MAAM,CAACG,KAAK,GAAG,IAAI,CAACJ,KAAK,CAACK,EAAE;IAEjC,IAAI,CAACC,sBAAsB,CAAC,IAAI,CAACP,MAAM,CAACE,MAAM,CAACM,aAAa,CAAC,CAAC,CAAC;EACjE;EAEA,MAAMD,sBAAsBA,CAACE,UAAoC,EAAiB;IAChF,MAAMC,KAAK,GAAG,MAAMD,UAAgC;IACpD,IAAIC,KAAK,EAAE;MACT,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,eAAe,CAAC,CAAC;MAC9Cf,GAAG,CAACa,KAAK,CAAE,6BAA4BA,KAAK,CAACG,OAAQ,EAAC,EAAEF,SAAS,CAAC,CAAC,CAAC;MAGpE,MAAM,IAAIG,KAAK,CAAE,6BAA4BJ,KAAK,CAACG,OAAQ,EAAC,CAAC;IAC/D;EACF;EAESE,OAAOA,CA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AAC;KAC9B,GAAG;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC;CA6HpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","handle","view","sampler","height","width","format","Error","createHandle","data","setData","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number;\n override width: number;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"mappings":"AACA,SAAQA,OAAO,QAA4C,eAAe;AAAC,SACnEC,sBAAsB;AAAA,SAEtBC,aAAa;AAErB,MAAMC,eAAmD,GAAG;EAC1D,IAAI,EAAE,IAAI;EACV,IAAI,EAAE,IAAI;EACV,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,IAAI;EAClB,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,aAAa,SAASJ,OAAO,CAAC;EAgBzCK,WAAWA,CAACC,MAAoB,EAAEC,KAAmB,EAAE;IACrD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAhBdD,MAAM;IAAA,KACNE,MAAM;IAAA,KACNC,IAAI;IAAA,KACbC,OAAO;IAAA,KAEEC,MAAM;IAAA,KACNC,KAAK;IAYZ,IAAI,OAAO,IAAI,CAACL,KAAK,CAACM,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,eAAe,CAAC;IAClC;IAEA,IAAI,CAACR,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACO,YAAY,CAAC,CAAC;IAEtD,IAAI,IAAI,CAACR,KAAK,CAACS,IAAI,EAAE;MACnB,IAAI,CAACC,OAAO,CAAC;QAACD,IAAI,EAAE,IAAI,CAACT,KAAK,CAACS;MAAI,CAAG,CAAC;IACzC;IAEA,IAAI,CAACJ,KAAK,GAAG,IAAI,CAACJ,MAAM,CAACI,KAAK;IAC9B,IAAI,CAACD,MAAM,GAAG,IAAI,CAACH,MAAM,CAACG,MAAM;IAIhC,IAAI,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B;AAmFF"}
1
+ {"version":3,"file":"webgpu-texture.js","names":["Texture","getWebGPUTextureFormat","WebGPUSampler","BASE_DIMENSIONS","WebGPUTexture","constructor","device","props","handle","view","sampler","height","width","format","Error","createHandle","data","setData","createView","_this$props$data","_this$props$data2","createTexture","size","depthOrArrayLayers","depth","dimension","usage","mipLevelCount","mipLevels","sampleCount","samples","destroy","setSampler","options","setImage","source","sourceX","sourceY","mipLevel","x","y","z","aspect","colorSpace","premultipliedAlpha","queue","copyExternalImageToTexture","origin","texture"],"sources":["../../../src/adapter/resources/webgpu-texture.ts"],"sourcesContent":["// luma.gl, MIT license\nimport {Texture, TextureProps, Sampler, SamplerProps} from '@luma.gl/core';\nimport {getWebGPUTextureFormat} from '../helpers/convert-texture-format';\nimport type {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUSampler} from './webgpu-sampler';\n\nconst BASE_DIMENSIONS: Record<string, '1d' | '2d' | '3d'> = {\n '1d': '1d',\n '2d': '2d',\n '2d-array': '2d',\n 'cube': '2d',\n 'cube-array': '2d',\n '3d': '3d'\n};\n\nexport class WebGPUTexture extends Texture {\n readonly device: WebGPUDevice;\n readonly handle: GPUTexture;\n readonly view: GPUTextureView;\n sampler: WebGPUSampler;\n\n override height: number;\n override width: number;\n\n // static async createFromImageURL(src, usage = 0) {\n // const img = document.createElement('img');\n // img.src = src;\n // await img.decode();\n // return WebGPUTexture(img, usage);\n // }\n\n constructor(device: WebGPUDevice, props: TextureProps) {\n super(device, props);\n\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n this.device = device;\n this.handle = this.props.handle || this.createHandle();\n\n if (this.props.data) {\n this.setData({data: this.props.data} );\n }\n\n this.width = this.handle.width;\n this.height = this.handle.height;\n // Why not just read all properties directly from the texture\n // this.depthOrArrayLayers = this.handle.depthOrArrayLayers;\n // this.mipLevelCount = this.handle.mipLevelCount;\n // this.sampleCount = this.handle.sampleCount;\n // this.dimension = this.handle.dimension;\n // this.format = this.handle.format;\n // this.usage = this.handle.usage;\n\n // Create a default sampler. This mimics the WebGL1 API where sampler props are stored on the texture\n // this.setSampler(props.sampler);\n this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);\n\n // TODO - To support texture arrays we need to create custom views...\n // But we are not ready to expose TextureViews to the public API.\n this.view = this.handle.createView({\n // format: this.props.format,\n // dimension: this.props.dimension,\n // aspect = \"all\";\n // baseMipLevel: 0;\n // mipLevelCount;\n // baseArrayLayer = 0;\n // arrayLayerCount;\n });\n }\n\n protected createHandle(): GPUTexture {\n if (typeof this.props.format === 'number') {\n throw new Error('number format');\n }\n\n // Deduce size from data - TODO this is a hack\n // @ts-expect-error\n const width = this.props.width || this.props.data?.width || 1;\n // @ts-expect-error\n const height = this.props.height || this.props.data?.height || 1;\n\n return this.device.handle.createTexture({\n size: {\n width,\n height,\n depthOrArrayLayers: this.props.depth\n },\n dimension: BASE_DIMENSIONS[this.props.dimension],\n format: getWebGPUTextureFormat(this.props.format),\n usage: this.props.usage,\n mipLevelCount: this.props.mipLevels,\n sampleCount: this.props.samples\n });\n }\n\n override destroy(): void {\n this.handle.destroy();\n }\n\n /**\n * Set default sampler\n * Accept a sampler instance or set of props;\n */\n setSampler(sampler: Sampler | SamplerProps): this {\n this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);\n return this;\n }\n\n setData(options: {\n data: any;\n }) {\n return this.setImage({source: options.data});\n }\n\n /** Set image */\n setImage(options: {\n source: ImageBitmap | HTMLCanvasElement | OffscreenCanvas;\n width?: number;\n height?: number;\n depth?: number;\n sourceX?: number;\n sourceY?: number;\n mipLevel?: number;\n x?: number;\n y?: number;\n z?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only';\n colorSpace?: 'srgb';\n premultipliedAlpha?: boolean;\n }): {width: number, height: number} {\n const {\n source,\n width = options.source.width,\n height = options.source.height,\n depth = 1,\n sourceX = 0,\n sourceY = 0,\n mipLevel = 0,\n x = 0,\n y = 0,\n z = 0,\n aspect = 'all',\n colorSpace = 'srgb',\n premultipliedAlpha = false\n } = options;\n\n // TODO - max out width\n\n this.device.handle.queue.copyExternalImageToTexture(\n // source: GPUImageCopyExternalImage\n {\n source,\n origin: [sourceX, sourceY]\n },\n // destination: GPUImageCopyTextureTagged\n {\n texture: this.handle,\n origin: [x, y, z],\n mipLevel,\n aspect,\n colorSpace,\n premultipliedAlpha\n },\n // copySize: GPUExtent3D\n [\n width,\n height,\n depth\n ]\n );\n return {width, height};\n }\n\n /*\n async readPixels() {\n const readbackBuffer = device.createBuffer({\n usage: Buffer.COPY_DST | Buffer.MAP_READ,\n size: 4 * textureWidth * textureHeight,\n });\n\n // Copy data from the texture to the buffer.\n const encoder = device.createCommandEncoder();\n encoder.copyTextureToBuffer(\n { texture },\n { buffer, rowPitch: textureWidth * 4 },\n [textureWidth, textureHeight],\n );\n device.submit([encoder.finish()]);\n\n // Get the data on the CPU.\n await buffer.mapAsync(GPUMapMode.READ);\n saveScreenshot(buffer.getMappedRange());\n buffer.unmap();\n }\n\n setImageData(imageData, usage): this {\n let data = null;\n\n const bytesPerRow = Math.ceil((img.width * 4) / 256) * 256;\n if (bytesPerRow == img.width * 4) {\n data = imageData.data;\n } else {\n data = new Uint8Array(bytesPerRow * img.height);\n let imagePixelIndex = 0;\n for (let y = 0; y < img.height; ++y) {\n for (let x = 0; x < img.width; ++x) {\n const i = x * 4 + y * bytesPerRow;\n data[i] = imageData.data[imagePixelIndex];\n data[i + 1] = imageData.data[imagePixelIndex + 1];\n data[i + 2] = imageData.data[imagePixelIndex + 2];\n data[i + 3] = imageData.data[imagePixelIndex + 3];\n imagePixelIndex += 4;\n }\n }\n }\n return this;\n }\n\n setData(data): this {\n const textureDataBuffer = this.device.handle.createBuffer({\n size: data.byteLength,\n usage: Buffer.COPY_DST | Buffer.COPY_SRC,\n mappedAtCreation: true\n });\n new Uint8Array(textureDataBuffer.getMappedRange()).set(data);\n textureDataBuffer.unmap();\n\n this.setBuffer(textureDataBuffer);\n\n textureDataBuffer.destroy();\n return this;\n }\n\n setBuffer(textureDataBuffer, {bytesPerRow}): this {\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToTexture(\n {\n buffer: textureDataBuffer,\n bytesPerRow\n },\n {\n texture: this.handle\n },\n {\n width,\n height,\n depth\n }\n );\n\n this.device.handle.defaultQueue.submit([commandEncoder.finish()]);\n return this;\n }\n */\n}\n"],"mappings":"AACA,SAAQA,OAAO,QAA4C,eAAe;AAAC,SACnEC,sBAAsB;AAAA,SAEtBC,aAAa;AAErB,MAAMC,eAAmD,GAAG;EAC1D,IAAI,EAAE,IAAI;EACV,IAAI,EAAE,IAAI;EACV,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,IAAI;EACZ,YAAY,EAAE,IAAI;EAClB,IAAI,EAAE;AACR,CAAC;AAED,OAAO,MAAMC,aAAa,SAASJ,OAAO,CAAC;EAgBzCK,WAAWA,CAACC,MAAoB,EAAEC,KAAmB,EAAE;IACrD,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAAC,KAhBdD,MAAM;IAAA,KACNE,MAAM;IAAA,KACNC,IAAI;IAAA,KACbC,OAAO;IAAA,KAEEC,MAAM;IAAA,KACNC,KAAK;IAYZ,IAAI,OAAO,IAAI,CAACL,KAAK,CAACM,MAAM,KAAK,QAAQ,EAAE;MACzC,MAAM,IAAIC,KAAK,CAAC,eAAe,CAAC;IAClC;IAEA,IAAI,CAACR,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,MAAM,GAAG,IAAI,CAACD,KAAK,CAACC,MAAM,IAAI,IAAI,CAACO,YAAY,CAAC,CAAC;IAEtD,IAAI,IAAI,CAACR,KAAK,CAACS,IAAI,EAAE;MACnB,IAAI,CAACC,OAAO,CAAC;QAACD,IAAI,EAAE,IAAI,CAACT,KAAK,CAACS;MAAI,CAAG,CAAC;IACzC;IAEA,IAAI,CAACJ,KAAK,GAAG,IAAI,CAACJ,MAAM,CAACI,KA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LD,MAAM,EACNa,KAAK,CAET,CAAC;IACD,OAAO;MAACZ,KAAK;MAAED;IAAM,CAAC;EACxB;AAmFF"}
@@ -0,0 +1,26 @@
1
+ import type { Device, Buffer, VertexArrayProps, RenderPass, TypedArray } from '@luma.gl/core';
2
+ import { VertexArray } from '@luma.gl/core';
3
+ import { WebGPUDevice } from '../webgpu-device';
4
+ /** VertexArrayObject wrapper */
5
+ export declare class WebGPUVertexArray extends VertexArray {
6
+ get [Symbol.toStringTag](): string;
7
+ readonly device: WebGPUDevice;
8
+ /** Vertex Array is a helper class under WebGPU */
9
+ readonly handle: never;
10
+ /** * Attribute 0 can not be disable on most desktop OpenGL based browsers */
11
+ static isConstantAttributeZeroSupported(device: Device): boolean;
12
+ constructor(device: WebGPUDevice, props?: VertexArrayProps);
13
+ destroy(): void;
14
+ /**
15
+ * Set an elements buffer, for indexed rendering.
16
+ * Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.
17
+ */
18
+ setIndexBuffer(buffer: Buffer | null): void;
19
+ /** Set a location in vertex attributes array to a buffer, enables the location, sets divisor */
20
+ setBuffer(location: number, buffer: Buffer): void;
21
+ /** Set a location in vertex attributes array to a constant value, disables the location */
22
+ setConstant(location: number, value: TypedArray): void;
23
+ bindBeforeRender(renderPass: RenderPass, firstIndex?: number, indexCount?: number): void;
24
+ unbindAfterRender(renderPass: RenderPass): void;
25
+ }
26
+ //# sourceMappingURL=webgpu-vertex-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-vertex-array.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-vertex-array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAC,WAAW,EAAM,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAK9C,gCAAgC;AAChC,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,IAAa,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAE1C;IAED,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAEvB,6EAA6E;IAC7E,MAAM,CAAC,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;gBAKpD,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAKjD,OAAO,IAAI,IAAI;IAExB;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK3C,gGAAgG;IAChG,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IASjD,2FAA2F;IAClF,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAItD,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAWxF,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;CAGzD"}