@luma.gl/webgpu 9.0.0-alpha.30 → 9.0.0-alpha.32
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.
- package/dist/adapter/helpers/get-bind-group.d.ts +3 -3
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +6 -6
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +4 -4
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +17 -17
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +2 -4
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +5 -5
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/dist.dev.js +160 -142
- package/dist/index.cjs +34 -34
- package/dist.min.js +4 -4
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +18 -8
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +39 -27
- package/src/adapter/resources/webgpu-command-encoder.ts +1 -1
- package/src/adapter/resources/webgpu-render-pipeline.ts +8 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { ShaderLayout,
|
|
2
|
+
import type { ShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
|
|
3
3
|
/**
|
|
4
4
|
* Create a WebGPU "bind group layout" from an array of luma.gl bindings
|
|
5
5
|
* @note bind groups can be automatically generated by WebGPU.
|
|
@@ -8,6 +8,6 @@ export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGr
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a WebGPU "bind group" from an array of luma.gl bindings
|
|
10
10
|
*/
|
|
11
|
-
export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout,
|
|
12
|
-
export declare function getShaderLayoutBinding(
|
|
11
|
+
export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
|
|
12
|
+
export declare function getShaderLayoutBinding(shaderLayout: ShaderLayout, bindingName: string): BindingDeclaration;
|
|
13
13
|
//# sourceMappingURL=get-bind-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAC,YAAY,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAM7E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAMd;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAMpB"}
|
|
@@ -2,24 +2,24 @@ import { Buffer, Sampler, Texture, log, cast } from '@luma.gl/core';
|
|
|
2
2
|
export function makeBindGroupLayout(device, layout, bindings) {
|
|
3
3
|
throw new Error('not implemented');
|
|
4
4
|
}
|
|
5
|
-
export function getBindGroup(device, bindGroupLayout,
|
|
6
|
-
const entries = getBindGroupEntries(bindings,
|
|
5
|
+
export function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
|
|
6
|
+
const entries = getBindGroupEntries(bindings, shaderLayout);
|
|
7
7
|
return device.createBindGroup({
|
|
8
8
|
layout: bindGroupLayout,
|
|
9
9
|
entries
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
export function getShaderLayoutBinding(
|
|
13
|
-
const bindingLayout =
|
|
12
|
+
export function getShaderLayoutBinding(shaderLayout, bindingName) {
|
|
13
|
+
const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName);
|
|
14
14
|
if (!bindingLayout) {
|
|
15
15
|
log.warn("Binding ".concat(bindingName, " not set: Not found in shader layout."))();
|
|
16
16
|
}
|
|
17
17
|
return bindingLayout;
|
|
18
18
|
}
|
|
19
|
-
function getBindGroupEntries(bindings,
|
|
19
|
+
function getBindGroupEntries(bindings, shaderLayout) {
|
|
20
20
|
const entries = [];
|
|
21
21
|
for (const [bindingName, value] of Object.entries(bindings)) {
|
|
22
|
-
const bindingLayout = getShaderLayoutBinding(
|
|
22
|
+
const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);
|
|
23
23
|
if (bindingLayout) {
|
|
24
24
|
entries.push(getBindGroupEntry(value, bindingLayout.location));
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout,
|
|
1
|
+
{"version":3,"file":"get-bind-group.js","names":["Buffer","Sampler","Texture","log","cast","makeBindGroupLayout","device","layout","bindings","Error","getBindGroup","bindGroupLayout","shaderLayout","entries","getBindGroupEntries","createBindGroup","getShaderLayoutBinding","bindingName","bindingLayout","find","binding","name","warn","concat","value","Object","push","getBindGroupEntry","location","index","resource","buffer","handle","createView"],"sources":["../../../src/adapter/helpers/get-bind-group.ts"],"sourcesContent":["// luma.gl, MIT license\nimport type {ShaderLayout, BindingDeclaration, Binding} from '@luma.gl/core';\nimport {Buffer, Sampler, Texture, log, cast} from '@luma.gl/core';\nimport type {WebGPUBuffer} from '../resources/webgpu-buffer';\nimport type {WebGPUSampler} from '../resources/webgpu-sampler';\nimport type {WebGPUTexture} from '../resources/webgpu-texture';\n\n/**\n * Create a WebGPU \"bind group layout\" from an array of luma.gl bindings\n * @note bind groups can be automatically generated by WebGPU.\n */\nexport function makeBindGroupLayout(\n device: GPUDevice,\n layout: GPUBindGroupLayout,\n bindings: Binding[]\n): GPUBindGroupLayout {\n throw new Error('not implemented');\n // return device.createBindGroupLayout({\n // layout,\n // entries: getBindGroupEntries(bindings)\n // })\n}\n\n/**\n * Create a WebGPU \"bind group\" from an array of luma.gl bindings\n */\nexport function getBindGroup(\n device: GPUDevice,\n bindGroupLayout: GPUBindGroupLayout,\n shaderLayout: ShaderLayout,\n bindings: Record<string, Binding>\n): GPUBindGroup {\n const entries = getBindGroupEntries(bindings, shaderLayout);\n return device.createBindGroup({\n layout: bindGroupLayout,\n entries\n });\n}\n\nexport function getShaderLayoutBinding(\n shaderLayout: ShaderLayout,\n bindingName: string\n): BindingDeclaration {\n const bindingLayout = shaderLayout.bindings.find(binding => binding.name === bindingName);\n if (!bindingLayout) {\n log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();\n }\n return bindingLayout;\n}\n\n/**\n * @param bindings\n * @returns\n */\nfunction getBindGroupEntries(\n bindings: Record<string, Binding>,\n shaderLayout: ShaderLayout\n): GPUBindGroupEntry[] {\n const entries: GPUBindGroupEntry[] = [];\n\n for (const [bindingName, value] of Object.entries(bindings)) {\n const bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);\n if (bindingLayout) {\n entries.push(getBindGroupEntry(value, bindingLayout.location));\n }\n }\n\n return entries;\n}\n\nfunction getBindGroupEntry(binding: Binding, index: number): GPUBindGroupEntry {\n if (binding instanceof Buffer) {\n return {\n binding: index,\n resource: {\n buffer: cast<WebGPUBuffer>(binding).handle\n }\n };\n }\n if (binding instanceof Sampler) {\n return {\n binding: index,\n resource: cast<WebGPUSampler>(binding).handle\n };\n } else if (binding instanceof Texture) {\n return {\n binding: index,\n resource: cast<WebGPUTexture>(binding).handle.createView()\n };\n }\n throw new Error('invalid binding');\n}\n"],"mappings":"AAEA,SAAQA,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAEC,GAAG,EAAEC,IAAI,QAAO,eAAe;AASjE,OAAO,SAASC,mBAAmBA,CACjCC,MAAiB,EACjBC,MAA0B,EAC1BC,QAAmB,EACC;EACpB,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;AAKpC;AAKA,OAAO,SAASC,YAAYA,CAC1BJ,MAAiB,EACjBK,eAAmC,EACnCC,YAA0B,EAC1BJ,QAAiC,EACnB;EACd,MAAMK,OAAO,GAAGC,mBAAmB,CAACN,QAAQ,EAAEI,YAAY,CAAC;EAC3D,OAAON,MAAM,CAACS,eAAe,CAAC;IAC5BR,MAAM,EAAEI,eAAe;IACvBE;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,SAASG,sBAAsBA,CACpCJ,YAA0B,EAC1BK,WAAmB,EACC;EACpB,MAAMC,aAAa,GAAGN,YAAY,CAACJ,QAAQ,CAACW,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACC,IAAI,KAAKJ,WAAW,CAAC;EACzF,IAAI,CAACC,aAAa,EAAE;IAClBf,GAAG,CAACmB,IAAI,YAAAC,MAAA,CAAYN,WAAW,0CAAuC,CAAC,CAAC,CAAC;EAC3E;EACA,OAAOC,aAAa;AACtB;AAMA,SAASJ,mBAAmBA,CAC1BN,QAAiC,EACjCI,YAA0B,EACL;EACrB,MAAMC,OAA4B,GAAG,EAAE;EAEvC,KAAK,MAAM,CAACI,WAAW,EAAEO,KAAK,CAAC,IAAIC,MAAM,CAACZ,OAAO,CAACL,QAAQ,CAAC,EAAE;IAC3D,MAAMU,aAAa,GAAGF,sBAAsB,CAACJ,YAAY,EAAEK,WAAW,CAAC;IACvE,IAAIC,aAAa,EAAE;MACjBL,OAAO,CAACa,IAAI,CAACC,iBAAiB,CAACH,KAAK,EAAEN,aAAa,CAACU,QAAQ,CAAC,CAAC;IAChE;EACF;EAEA,OAAOf,OAAO;AAChB;AAEA,SAASc,iBAAiBA,CAACP,OAAgB,EAAES,KAAa,EAAqB;EAC7E,IAAIT,OAAO,YAAYpB,MAAM,EAAE;IAC7B,OAAO;MACLoB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAE;QACRC,MAAM,EAAE3B,IAAI,CAAegB,OAAO,CAAC,CAACY;MACtC;IACF,CAAC;EACH;EACA,IAAIZ,OAAO,YAAYnB,OAAO,EAAE;IAC9B,OAAO;MACLmB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAE1B,IAAI,CAAgBgB,OAAO,CAAC,CAACY;IACzC,CAAC;EACH,CAAC,MAAM,IAAIZ,OAAO,YAAYlB,OAAO,EAAE;IACrC,OAAO;MACLkB,OAAO,EAAES,KAAK;MACdC,QAAQ,EAAE1B,IAAI,CAAgBgB,OAAO,CAAC,CAACY,MAAM,CAACC,UAAU,CAAC;IAC3D,CAAC;EACH;EACA,MAAM,IAAIxB,KAAK,CAAC,iBAAiB,CAAC;AACpC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { ShaderLayout,
|
|
2
|
+
import type { ShaderLayout, BufferLayout } from '@luma.gl/core';
|
|
3
3
|
/**
|
|
4
4
|
* Build a WebGPU vertex buffer layout intended for use in a GPURenderPassDescriptor.
|
|
5
5
|
* Converts luma.gl attribute definitions to a WebGPU GPUVertexBufferLayout[] array
|
|
6
6
|
* @param layout
|
|
7
|
-
* @param
|
|
7
|
+
* @param bufferLayout The buffer map is optional
|
|
8
8
|
* @returns WebGPU layout intended for a GPURenderPassDescriptor.
|
|
9
9
|
*/
|
|
10
|
-
export declare function getVertexBufferLayout(
|
|
11
|
-
export declare function getBufferSlots(
|
|
10
|
+
export declare function getVertexBufferLayout(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[]): GPUVertexBufferLayout[];
|
|
11
|
+
export declare function getBufferSlots(shaderLayout: ShaderLayout, bufferLayout: BufferLayout[]): Record<string, number>;
|
|
12
12
|
//# sourceMappingURL=get-vertex-buffer-layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-vertex-buffer-layout.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,
|
|
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,CAoEzB;AAED,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,EAAE,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
|
|
@@ -5,31 +5,31 @@ function getWebGPUVertexFormat(format) {
|
|
|
5
5
|
}
|
|
6
6
|
return format;
|
|
7
7
|
}
|
|
8
|
-
export function getVertexBufferLayout(
|
|
8
|
+
export function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
9
9
|
const vertexBufferLayouts = [];
|
|
10
10
|
const usedAttributes = new Set();
|
|
11
|
-
for (const mapping of
|
|
11
|
+
for (const mapping of bufferLayout) {
|
|
12
12
|
const vertexAttributes = [];
|
|
13
13
|
let stepMode = 'vertex';
|
|
14
14
|
let byteStride = 0;
|
|
15
15
|
const byteOffset = mapping.byteOffset || 0;
|
|
16
|
-
if (
|
|
16
|
+
if (mapping.attributes) {
|
|
17
17
|
for (const interleaved of mapping.attributes) {
|
|
18
|
-
const attributeLayout = findAttributeLayout(
|
|
18
|
+
const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);
|
|
19
19
|
stepMode = attributeLayout.stepMode || 'vertex';
|
|
20
20
|
vertexAttributes.push({
|
|
21
|
-
format: getWebGPUVertexFormat(
|
|
21
|
+
format: getWebGPUVertexFormat(interleaved.format || mapping.format),
|
|
22
22
|
offset: byteOffset + byteStride,
|
|
23
23
|
shaderLocation: attributeLayout.location
|
|
24
24
|
});
|
|
25
|
-
byteStride += decodeVertexFormat(
|
|
25
|
+
byteStride += decodeVertexFormat(mapping.format).byteLength;
|
|
26
26
|
}
|
|
27
27
|
} else {
|
|
28
|
-
const attributeLayout = findAttributeLayout(
|
|
29
|
-
byteStride = decodeVertexFormat(
|
|
28
|
+
const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
|
|
29
|
+
byteStride = decodeVertexFormat(mapping.format).byteLength;
|
|
30
30
|
stepMode = attributeLayout.stepMode || 'vertex';
|
|
31
31
|
vertexAttributes.push({
|
|
32
|
-
format: getWebGPUVertexFormat(
|
|
32
|
+
format: getWebGPUVertexFormat(mapping.format),
|
|
33
33
|
offset: byteOffset,
|
|
34
34
|
shaderLocation: attributeLayout.location
|
|
35
35
|
});
|
|
@@ -40,13 +40,13 @@ export function getVertexBufferLayout(layout, bufferMap) {
|
|
|
40
40
|
attributes: vertexAttributes
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
for (const attribute of
|
|
43
|
+
for (const attribute of shaderLayout.attributes) {
|
|
44
44
|
if (!usedAttributes.has(attribute.name)) {
|
|
45
45
|
vertexBufferLayouts.push({
|
|
46
|
-
arrayStride: decodeVertexFormat(
|
|
46
|
+
arrayStride: decodeVertexFormat('float32x3').byteLength,
|
|
47
47
|
stepMode: attribute.stepMode || 'vertex',
|
|
48
48
|
attributes: [{
|
|
49
|
-
format: getWebGPUVertexFormat(
|
|
49
|
+
format: getWebGPUVertexFormat('float32x3'),
|
|
50
50
|
offset: 0,
|
|
51
51
|
shaderLocation: attribute.location
|
|
52
52
|
}]
|
|
@@ -55,11 +55,11 @@ export function getVertexBufferLayout(layout, bufferMap) {
|
|
|
55
55
|
}
|
|
56
56
|
return vertexBufferLayouts;
|
|
57
57
|
}
|
|
58
|
-
export function getBufferSlots(
|
|
58
|
+
export function getBufferSlots(shaderLayout, bufferLayout) {
|
|
59
59
|
const usedAttributes = new Set();
|
|
60
60
|
let bufferSlot = 0;
|
|
61
61
|
const bufferSlots = {};
|
|
62
|
-
for (const mapping of
|
|
62
|
+
for (const mapping of bufferLayout) {
|
|
63
63
|
if ('attributes' in mapping) {
|
|
64
64
|
for (const interleaved of mapping.attributes) {
|
|
65
65
|
usedAttributes.add(interleaved.name);
|
|
@@ -69,15 +69,15 @@ export function getBufferSlots(layout, bufferMap) {
|
|
|
69
69
|
}
|
|
70
70
|
bufferSlots[mapping.name] = bufferSlot++;
|
|
71
71
|
}
|
|
72
|
-
for (const attribute of
|
|
72
|
+
for (const attribute of shaderLayout.attributes) {
|
|
73
73
|
if (!usedAttributes.has(attribute.name)) {
|
|
74
74
|
bufferSlots[attribute.name] = bufferSlot++;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
return bufferSlots;
|
|
78
78
|
}
|
|
79
|
-
function findAttributeLayout(
|
|
80
|
-
const attribute =
|
|
79
|
+
function findAttributeLayout(shaderLayout, name, attributeNames) {
|
|
80
|
+
const attribute = shaderLayout.attributes.find(attribute => attribute.name === name);
|
|
81
81
|
if (!attribute) {
|
|
82
82
|
throw new Error("Unknown attribute ".concat(name));
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-vertex-buffer-layout.js","names":["decodeVertexFormat","getWebGPUVertexFormat","format","endsWith","Error","concat","getVertexBufferLayout","
|
|
1
|
+
{"version":3,"file":"get-vertex-buffer-layout.js","names":["decodeVertexFormat","getWebGPUVertexFormat","format","endsWith","Error","concat","getVertexBufferLayout","shaderLayout","bufferLayout","vertexBufferLayouts","usedAttributes","Set","mapping","vertexAttributes","stepMode","byteStride","byteOffset","attributes","interleaved","attributeLayout","findAttributeLayout","name","push","offset","shaderLocation","location","byteLength","arrayStride","attribute","has","getBufferSlots","bufferSlot","bufferSlots","add","attributeNames","find"],"sources":["../../../src/adapter/helpers/get-vertex-buffer-layout.ts"],"sourcesContent":["import type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';\nimport {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 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 const byteOffset = mapping.byteOffset || 0;\n\n // interleaved mapping {..., attributes: [{...}, ...]}\n if (mapping.attributes) {\n // const arrayStride = mapping.byteStride; TODO\n for (const interleaved of mapping.attributes) {\n const attributeLayout = findAttributeLayout(shaderLayout, interleaved.name, usedAttributes);\n\n stepMode = attributeLayout.stepMode || 'vertex';\n vertexAttributes.push({\n format: getWebGPUVertexFormat(interleaved.format || mapping.format),\n offset: byteOffset + byteStride,\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 offset: byteOffset,\n shaderLocation: attributeLayout.location\n });\n }\n\n // Store all the attribute bindings for one buffer\n vertexBufferLayouts.push({\n arrayStride: mapping.byteStride || byteStride,\n stepMode: stepMode || 'vertex',\n attributes: vertexAttributes\n });\n }\n\n // Add any non-mapped attributes - 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.name);\n }\n // non-interleaved mapping (just set offset and stride)\n } else {\n usedAttributes.add(mapping.name);\n }\n bufferSlots[mapping.name] = bufferSlot++;\n }\n\n // Add any non-mapped attributes\n for (const attribute of 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,kBAAkB,QAAO,eAAe;AAGhD,SAASC,qBAAqBA,CAACC,MAAoB,EAAmB;EACpE,IAAIA,MAAM,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC7B,MAAM,IAAIC,KAAK,0CAAAC,MAAA,CAA0CH,MAAM,CAAE,CAAC;EACpE;EACA,OAAOA,MAAM;AACf;AASA,OAAO,SAASI,qBAAqBA,CACnCC,YAA0B,EAC1BC,YAA4B,EACH;EACzB,MAAMC,mBAA4C,GAAG,EAAE;EACvD,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAS,CAAC;EAGxC,KAAK,MAAMC,OAAO,IAAIJ,YAAY,EAAE;IAElC,MAAMK,gBAAsC,GAAG,EAAE;IAGjD,IAAIC,QAA+B,GAAG,QAAQ;IAC9C,IAAIC,UAAU,GAAG,CAAC;IAClB,MAAMC,UAAU,GAAGJ,OAAO,CAACI,UAAU,IAAI,CAAC;IAG1C,IAAIJ,OAAO,CAACK,UAAU,EAAE;MAEtB,KAAK,MAAMC,WAAW,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AAS,IAAIA,SAAS,CAACP,IAAI,KAAKA,IAAI,CAAC;EACpF,IAAI,CAACO,SAAS,EAAE;IACd,MAAM,IAAIxB,KAAK,sBAAAC,MAAA,CAAsBgB,IAAI,CAAE,CAAC;EAC9C;EACA,IAAIa,cAAc,CAACL,GAAG,CAACR,IAAI,CAAC,EAAE;IAC5B,MAAM,IAAIjB,KAAK,wBAAAC,MAAA,CAAwBgB,IAAI,CAAE,CAAC;EAChD;EACAa,cAAc,CAACD,GAAG,CAACZ,IAAI,CAAC;EACxB,OAAOO,SAAS;AAClB"}
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import { CommandEncoder, cast } from '@luma.gl/core';
|
|
3
3
|
export class WebGPUCommandEncoder extends CommandEncoder {
|
|
4
4
|
constructor(device, props) {
|
|
5
|
-
super(props);
|
|
5
|
+
super(device, props);
|
|
6
6
|
_defineProperty(this, "device", void 0);
|
|
7
7
|
_defineProperty(this, "handle", void 0);
|
|
8
8
|
this.device = device;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast, \n CopyTextureToTextureOptions, \n CopyTextureToBufferOptions\n // CopyBufferToTextureOptions,\n // CopyBufferToBufferOptions,\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n\nexport class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: // CopyBufferToBufferOptions\n {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }\n ): void {\n this.handle.copyBufferToBuffer(\n cast<WebGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WebGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: // CopyBufferToTextureOptions\n {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }\n ): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WebGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent[0],\n height: options.extent[1],\n depthOrArrayLayers: options.extent[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"mappings":";AAAA,SAAQA,cAAc,EAAwCC,IAAI,QAK3D,eAAe;AAKtB,OAAO,MAAMC,oBAAoB,SAASF,cAAc,CAAC;EAIvDG,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,
|
|
1
|
+
{"version":3,"file":"webgpu-command-encoder.js","names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","_defineProperty","handle","createCommandEncoder","label","id","destroy","finish","options","copyBufferToBuffer","_options$sourceOffset","_options$destinationO","_options$size","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","_options$offset","_options$mipLevel","_options$origin","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"sourcesContent":["import {CommandEncoder, CommandEncoderProps, Buffer, Texture, cast, \n CopyTextureToTextureOptions, \n CopyTextureToBufferOptions\n // CopyBufferToTextureOptions,\n // CopyBufferToBufferOptions,\n} from '@luma.gl/core';\nimport {WebGPUDevice} from '../webgpu-device';\nimport {WebGPUBuffer} from './webgpu-buffer';\nimport {WebGPUTexture} from './webgpu-texture';\n\nexport class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(device, props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n // TODO was this removed in standard?\n // measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n override destroy(): void {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: // CopyBufferToBufferOptions\n {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }\n ): void {\n this.handle.copyBufferToBuffer(\n cast<WebGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WebGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: // CopyBufferToTextureOptions\n {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }\n ): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WebGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent[0],\n height: options.extent[1],\n depthOrArrayLayers: options.extent[2]\n }\n );\n }\n\n copyTextureToBuffer(options: CopyTextureToBufferOptions): void {\n // this.handle.copyTextureToBuffer(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n copyTextureToTexture(options: CopyTextureToTextureOptions): void {\n // this.handle.copyTextureToTexture(\n // // source\n // {},\n // // destination\n // {},\n // // copySize\n // {}\n // );\n }\n\n override pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n override popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n override insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"mappings":";AAAA,SAAQA,cAAc,EAAwCC,IAAI,QAK3D,eAAe;AAKtB,OAAO,MAAMC,oBAAoB,SAASF,cAAc,CAAC;EAIvDG,WAAWA,CAACC,MAAoB,EAAEC,KAA0B,EAAE;IAC5D,KAAK,CAACD,MAAM,EAAEC,KAAK,CAAC;IAACC,eAAA;IAAAA,eAAA;IACrB,IAAI,CAACF,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACG,MAAM,GAAGF,KAAK,CAACE,MAAM,IAAI,IAAI,CAACH,MAAM,CAACG,MAAM,CAACC,oBAAoB,CAAC,CAGtE,CAAC,CAAC;IACF,IAAI,CAACD,MAAM,CAACE,KAAK,GAAG,IAAI,CAACJ,KAAK,CAACK,EAAE;EACnC;EAESC,OAAOA,CAAA,EAAS,CAAC;EAE1BC,MAAMA,CAACC,OAAuB,EAAoB;IAChD,OAAO,IAAI,CAACD,MAAM,CAACC,OAAO,CAAC;EAC7B;EAKAC,kBAAkBA,CAACD,OAOhB,EACK;IAAA,IAAAE,qBAAA,EAAAC,qBAAA,EAAAC,aAAA;IACN,IAAI,CAACV,MAAM,CA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CACF,CAAC;EACH;EAEAG,mBAAmBA,CAACzB,OAAmC,EAAQ,CAS/D;EAEA0B,oBAAoBA,CAAC1B,OAAoC,EAAQ,CASjE;EAES2B,cAAcA,CAACC,UAAkB,EAAQ;IAChD,IAAI,CAAClC,MAAM,CAACiC,cAAc,CAACC,UAAU,CAAC;EACxC;EAESC,aAAaA,CAAA,EAAS;IAC7B,IAAI,CAACnC,MAAM,CAACmC,aAAa,CAAC,CAAC;EAC7B;EAESC,iBAAiBA,CAACC,WAAmB,EAAQ;IACpD,IAAI,CAACrC,MAAM,CAACoC,iBAAiB,CAACC,WAAW,CAAC;EAC5C;AAWF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="dist" />
|
|
2
|
-
import type { Binding,
|
|
2
|
+
import type { TypedArray, Binding, UniformValue, RenderPass } from '@luma.gl/core';
|
|
3
3
|
import { Buffer, RenderPipeline, RenderPipelineProps } from '@luma.gl/core';
|
|
4
4
|
import type { WebGPUDevice } from '../webgpu-device';
|
|
5
5
|
import type { WebGPUShader } from './webgpu-shader';
|
|
@@ -21,11 +21,9 @@ export declare class WebGPURenderPipeline extends RenderPipeline {
|
|
|
21
21
|
destroy(): void;
|
|
22
22
|
setIndexBuffer(indexBuffer: Buffer): void;
|
|
23
23
|
setAttributes(attributes: Record<string, Buffer>): void;
|
|
24
|
-
/** Constant attributes are not available in WebGPU */
|
|
25
24
|
setConstantAttributes(attributes: Record<string, TypedArray>): void;
|
|
26
|
-
/** Set the bindings */
|
|
27
25
|
setBindings(bindings: Record<string, Binding>): void;
|
|
28
|
-
setUniforms(uniforms: Record<string,
|
|
26
|
+
setUniforms(uniforms: Record<string, UniformValue>): void;
|
|
29
27
|
_getBuffers(): Buffer[];
|
|
30
28
|
/** Return a bind group created by setBindings */
|
|
31
29
|
_getBindGroup(): GPUBindGroup;
|
|
@@ -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,OAAO,EAAE,
|
|
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,IAAI;IAIzC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAmBvD,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAInE,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAapD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAMzD,WAAW;IAIX,iDAAiD;IACjD,aAAa;IAKb,8DAA8D;IAC9D,SAAS,CAAC,4BAA4B;IA+CtC,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI;IAmCR,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB;CAwCxD"}
|
|
@@ -21,7 +21,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
21
21
|
this.handle.label = this.props.id;
|
|
22
22
|
this.vs = cast(props.vs);
|
|
23
23
|
this.fs = cast(props.fs);
|
|
24
|
-
this._bufferSlots = getBufferSlots(this.props.
|
|
24
|
+
this._bufferSlots = getBufferSlots(this.props.shaderLayout, this.props.bufferLayout);
|
|
25
25
|
this._buffers = new Array(Object.keys(this._bufferSlots).length).fill(null);
|
|
26
26
|
this._bindGroupLayout = this.handle.getBindGroupLayout(0);
|
|
27
27
|
}
|
|
@@ -48,12 +48,12 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
setConstantAttributes(attributes) {
|
|
51
|
-
|
|
51
|
+
throw new Error('not implemented');
|
|
52
52
|
}
|
|
53
53
|
setBindings(bindings) {
|
|
54
54
|
if (!isObjectEmpty(this.props.bindings)) {
|
|
55
55
|
Object.assign(this.props.bindings, bindings);
|
|
56
|
-
this._bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.
|
|
56
|
+
this._bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.shaderLayout, this.props.bindings);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
setUniforms(uniforms) {
|
|
@@ -71,7 +71,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
71
71
|
const vertex = {
|
|
72
72
|
module: cast(this.props.vs).handle,
|
|
73
73
|
entryPoint: this.props.vsEntryPoint || 'main',
|
|
74
|
-
buffers: getVertexBufferLayout(this.props.
|
|
74
|
+
buffers: getVertexBufferLayout(this.props.shaderLayout, this.props.bufferLayout)
|
|
75
75
|
};
|
|
76
76
|
let fragment;
|
|
77
77
|
if (this.props.fs) {
|
|
@@ -123,7 +123,7 @@ export class WebGPURenderPipeline extends RenderPipeline {
|
|
|
123
123
|
for (let i = 0; i < buffers.length; ++i) {
|
|
124
124
|
const buffer = cast(buffers[i]);
|
|
125
125
|
if (!buffer) {
|
|
126
|
-
const attribute = this.props.
|
|
126
|
+
const attribute = this.props.shaderLayout.attributes.find(attribute => attribute.location === i);
|
|
127
127
|
throw new Error("No buffer provided for attribute '".concat((attribute === null || attribute === void 0 ? void 0 : attribute.name) || '', "' in Model '").concat(this.props.id, "'"));
|
|
128
128
|
}
|
|
129
129
|
webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu-render-pipeline.js","names":["RenderPipeline","cast","log","isObjectEmpty","applyParametersToRenderPipelineDescriptor","getWebGPUTextureFormat","getBindGroup","getVertexBufferLayout","getBufferSlots","WebGPURenderPipeline","constructor","device","props","_defineProperty","handle","createHandle","label","id","vs","fs","_bufferSlots","layout","bufferMap","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","concat","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","console","error","setBindings","bindings","assign","_bindGroup","setUniforms","uniforms","_getBuffers","_getBindGroup","vertex","module","entryPoint","vsEntryPoint","buffers","fragment","_this$device","fsEntryPoint","targets","format","canvasContext","topology","primitive","parameters","draw","options","webgpuRenderPass","renderPass","getDefaultRenderPass","setPipeline","bindGroup","setBindGroup","_setAttributeBuffers","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","indexType","i","attribute","find","location","setVertexBuffer"],"sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"sourcesContent":["// luma.gl MIT license\n\nimport type {Binding, RenderPass, TypedArray} 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.layout, this.props.bufferMap);\n this._buffers = new Array<Buffer>(Object.keys(this._bufferSlots).length).fill(null);\n this._bindGroupLayout = this.handle.getBindGroupLayout(0);\n }\n\n protected createHandle(): GPURenderPipeline {\n const descriptor = this._getRenderPipelineDescriptor();\n const renderPipeline = this.device.handle.createRenderPipeline(descriptor);\n log.groupCollapsed(1, `new WebGPRenderPipeline(${this.id})`)();\n log.log(1, JSON.stringify(descriptor, null, 2))();\n log.groupEnd(1)();\n return renderPipeline;\n }\n\n override destroy(): void {\n // WebGPURenderPipeline has no destroy method.\n }\n\n setIndexBuffer(indexBuffer: Buffer): void {\n this._indexBuffer = cast<WebGPUBuffer>(indexBuffer);\n }\n\n setAttributes(attributes: Record<string, Buffer>): void {\n for (const [name, buffer] of Object.entries(attributes)) {\n const bufferIndex = this._bufferSlots[name];\n if (bufferIndex >= 0) {\n this._buffers[bufferIndex] = buffer;\n } else {\n throw new Error(\n `Setting attribute '${name}' not listed in shader layout for program ${this.id}`\n );\n }\n }\n // for (let i = 0; i < this._bufferSlots.length; ++i) {\n // const bufferName = this._bufferSlots[i];\n // if (attributes[bufferName]) {\n // this.handle\n // }\n // }\n }\n\n /** Constant attributes are not available in WebGPU */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n console.error('not implemented');\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): void {\n if (!isObjectEmpty(this.props.bindings)) {\n Object.assign(this.props.bindings, bindings);\n // Set up the bindings\n this._bindGroup = getBindGroup(\n this.device.handle,\n this._bindGroupLayout,\n this.props.layout,\n this.props.bindings\n );\n }\n }\n\n setUniforms(uniforms: Record<string, any>): void {\n if (!isObjectEmpty(uniforms)) {\n throw new Error('WebGPU does not support uniforms');\n }\n }\n\n _getBuffers() {\n return this._buffers;\n }\n\n /** Return a bind group created by setBindings */\n _getBindGroup() {\n // assert(this._bindGroup);\n return this._bindGroup;\n }\n\n /** Populate the complex WebGPU GPURenderPipelineDescriptor */\n protected _getRenderPipelineDescriptor() {\n // Set up the vertex stage\n const vertex: GPUVertexState = {\n module: cast<WebGPUShader>(this.props.vs).handle,\n entryPoint: this.props.vsEntryPoint || 'main',\n buffers: getVertexBufferLayout(this.props.layout, this.props.bufferMap)\n };\n\n // Set up the fragment stage\n let fragment: GPUFragmentState | undefined;\n if (this.props.fs) {\n fragment = {\n module: cast<WebGPUShader>(this.props.fs).handle,\n entryPoint: this.props.fsEntryPoint || 'main',\n targets: [\n {\n // TODO exclamation mark hack!\n format: getWebGPUTextureFormat(this.device?.canvasContext?.format)\n }\n ]\n };\n }\n\n // WebGPU has more restrictive topology support than WebGL\n switch (this.props.topology) {\n case 'triangle-fan-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.layout.attributes.find(\n (attribute) => attribute.location === i\n );\n throw new Error(\n `No buffer provided for attribute '${attribute?.name || ''}' in Model '${this.props.id}'`\n );\n }\n webgpuRenderPass.handle.setVertexBuffer(i, buffer.handle);\n }\n\n // TODO - HANDLE buffer maps\n /*\n for (const [bufferName, attributeMapping] of Object.entries(this.props.bufferMap)) {\n const buffer = cast<WebGPUBuffer>(this.props.attributes[bufferName]);\n if (!buffer) {\n log.warn(`Missing buffer for buffer map ${bufferName}`)();\n continue;\n }\n\n if ('location' in attributeMapping) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(layout.location, buffer.handle);\n } else {\n for (const [bufferName, mapping] of Object.entries(attributeMapping)) {\n // @ts-expect-error TODO model must not depend on webgpu\n renderPass.handle.setVertexBuffer(field.location, buffer.handle);\n }\n }\n }\n */\n }\n}\n"],"mappings":";AAGA,SAAgBA,cAAc,EAAuBC,IAAI,EAAEC,GAAG,EAAEC,aAAa,QAAO,eAAe;AAAC,SAC5FC,yCAAyC;AAAA,SACzCC,sBAAsB;AAAA,SACtBC,YAAY;AAAA,SACZC,qBAAqB,EAAE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O,CAACa,aACV,CAAC;IACH;EACF;EAEAN,oBAAoBA,CAACN,gBAAkC,EAAE;IACvD,IAAI,IAAI,CAACnC,YAAY,EAAE;MACrBmC,gBAAgB,CAAChE,MAAM,CAAC2B,cAAc,CAAC,IAAI,CAACE,YAAY,CAAC7B,MAAM,EAAE,IAAI,CAAC6B,YAAY,CAAC/B,KAAK,CAACgF,SAAS,CAAC;IACrG;IAEA,MAAM1B,OAAO,GAAG,IAAI,CAACN,WAAW,CAAC,CAAC;IAClC,KAAK,IAAIiC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG3B,OAAO,CAACvC,MAAM,EAAE,EAAEkE,CAAC,EAAE;MACvC,MAAM9C,MAAM,GAAG9C,IAAI,CAAeiE,OAAO,CAAC2B,CAAC,CAAC,CAAC;MAC7C,IAAI,CAAC9C,MAAM,EAAE;QACX,MAAM+C,SAAS,GAAG,IAAI,CAAClF,KAAK,CAACS,MAAM,CAACwB,UAAU,CAACkD,IAAI,CAChDD,SAAS,IAAKA,SAAS,CAACE,QAAQ,KAAKH,CACxC,CAAC;QACD,MAAM,IAAI3C,KAAK,sCAAAd,MAAA,CACwB,CAAA0D,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEhD,IAAI,KAAI,EAAE,kBAAAV,MAAA,CAAe,IAAI,CAACxB,KAAK,CAACK,EAAE,MACxF,CAAC;MACH;MACA6D,gBAAgB,CAAChE,MAAM,CAACmF,eAAe,CAACJ,CAAC,EAAE9C,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","_defineProperty","handle","createHandle","label","id","vs","fs","_bufferSlots","shaderLayout","bufferLayout","_buffers","Array","Object","keys","length","fill","_bindGroupLayout","getBindGroupLayout","descriptor","_getRenderPipelineDescriptor","renderPipeline","createRenderPipeline","groupCollapsed","concat","JSON","stringify","groupEnd","destroy","setIndexBuffer","indexBuffer","_indexBuffer","setAttributes","attributes","name","buffer","entries","bufferIndex","Error","setConstantAttributes","setBindings","bindings","assign","_bindGroup","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,sBAAs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