@luma.gl/webgpu 9.0.0-alpha.7 → 9.0.0-alpha.9

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 (46) hide show
  1. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  2. package/dist/adapter/helpers/webgpu-parameters.js +47 -38
  3. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  4. package/dist/adapter/resources/webgpu-buffer.d.ts +0 -1
  5. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  6. package/dist/adapter/resources/webgpu-buffer.js +0 -4
  7. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  8. package/dist/adapter/resources/webgpu-command-encoder.d.ts +0 -1
  9. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  10. package/dist/adapter/resources/webgpu-command-encoder.js +7 -7
  11. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  12. package/dist/adapter/resources/webgpu-compute-pass.d.ts +1 -1
  13. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  14. package/dist/adapter/resources/webgpu-compute-pass.js +5 -3
  15. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  16. package/dist/adapter/resources/webgpu-framebuffer.d.ts +1 -1
  17. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  18. package/dist/adapter/resources/webgpu-framebuffer.js +1 -1
  19. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  20. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  21. package/dist/adapter/resources/webgpu-render-pass.js +9 -3
  22. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  23. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  24. package/dist/adapter/resources/webgpu-render-pipeline.js +13 -3
  25. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  26. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  27. package/dist/adapter/resources/webgpu-texture.js +2 -2
  28. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  29. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  30. package/dist/adapter/webgpu-canvas-context.js +2 -2
  31. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  32. package/dist/adapter/webgpu-device.d.ts +6 -6
  33. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  34. package/dist/adapter/webgpu-device.js +31 -14
  35. package/dist/adapter/webgpu-device.js.map +1 -1
  36. package/package.json +3 -3
  37. package/src/adapter/helpers/webgpu-parameters.ts +48 -45
  38. package/src/adapter/resources/webgpu-buffer.ts +0 -4
  39. package/src/adapter/resources/webgpu-command-encoder.ts +8 -7
  40. package/src/adapter/resources/webgpu-compute-pass.ts +2 -2
  41. package/src/adapter/resources/webgpu-framebuffer.ts +1 -1
  42. package/src/adapter/resources/webgpu-render-pass.ts +6 -3
  43. package/src/adapter/resources/webgpu-render-pipeline.ts +13 -4
  44. package/src/adapter/resources/webgpu-texture.ts +3 -2
  45. package/src/adapter/webgpu-canvas-context.ts +2 -2
  46. package/src/adapter/webgpu-device.ts +44 -32
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAWxC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAqJ9D,CAAC;AA8BF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
1
+ {"version":3,"file":"webgpu-parameters.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAYxC;;;GAGG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAqJ9D,CAAC;AA8BF,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,2BAA2B,EAC/C,UAAU,GAAE,UAAe,GAC1B,IAAI,CAIN"}
@@ -4,66 +4,69 @@ function addDepthStencil(descriptor) {
4
4
  stencilFront: {},
5
5
  stencilBack: {}
6
6
  };
7
+ return descriptor.depthStencil;
7
8
  }
8
9
 
9
10
  export const PARAMETER_TABLE = {
10
11
  cullMode: (parameter, value, descriptor) => {
12
+ descriptor.primitive = descriptor.primitive || {};
11
13
  descriptor.primitive.cullMode = value;
12
14
  },
13
15
  frontFace: (parameter, value, descriptor) => {
16
+ descriptor.primitive = descriptor.primitive || {};
14
17
  descriptor.primitive.frontFace = value;
15
18
  },
16
19
  depthWriteEnabled: (parameter, value, descriptor) => {
17
- addDepthStencil(descriptor);
18
- descriptor.depthStencil.depthWriteEnabled = value;
20
+ const depthStencil = addDepthStencil(descriptor);
21
+ depthStencil.depthWriteEnabled = value;
19
22
  },
20
23
  depthCompare: (parameter, value, descriptor) => {
21
- addDepthStencil(descriptor);
22
- descriptor.depthStencil.depthCompare = value;
24
+ const depthStencil = addDepthStencil(descriptor);
25
+ depthStencil.depthCompare = value;
23
26
  },
24
27
  depthFormat: (parameter, value, descriptor) => {
25
- addDepthStencil(descriptor);
26
- descriptor.depthStencil.format = value;
28
+ const depthStencil = addDepthStencil(descriptor);
29
+ depthStencil.format = value;
27
30
  },
28
31
  depthBias: (parameter, value, descriptor) => {
29
- addDepthStencil(descriptor);
30
- descriptor.depthStencil.depthBias = value;
32
+ const depthStencil = addDepthStencil(descriptor);
33
+ depthStencil.depthBias = value;
31
34
  },
32
35
  depthBiasSlopeScale: (parameter, value, descriptor) => {
33
- addDepthStencil(descriptor);
34
- descriptor.depthStencil.depthBiasSlopeScale = value;
36
+ const depthStencil = addDepthStencil(descriptor);
37
+ depthStencil.depthBiasSlopeScale = value;
35
38
  },
36
39
  depthBiasClamp: (parameter, value, descriptor) => {
37
- addDepthStencil(descriptor);
38
- descriptor.depthStencil.depthBiasClamp = value;
40
+ const depthStencil = addDepthStencil(descriptor);
41
+ depthStencil.depthBiasClamp = value;
39
42
  },
40
43
  stencilReadMask: (parameter, value, descriptor) => {
41
- addDepthStencil(descriptor);
42
- descriptor.depthStencil.stencilReadMask = value;
44
+ const depthStencil = addDepthStencil(descriptor);
45
+ depthStencil.stencilReadMask = value;
43
46
  },
44
47
  stencilWriteMask: (parameter, value, descriptor) => {
45
- addDepthStencil(descriptor);
46
- descriptor.depthStencil.stencilWriteMask = value;
48
+ const depthStencil = addDepthStencil(descriptor);
49
+ depthStencil.stencilWriteMask = value;
47
50
  },
48
51
  stencilCompare: (parameter, value, descriptor) => {
49
- addDepthStencil(descriptor);
50
- descriptor.depthStencil.stencilFront.compare = value;
51
- descriptor.depthStencil.stencilBack.compare = value;
52
+ const depthStencil = addDepthStencil(descriptor);
53
+ depthStencil.stencilFront.compare = value;
54
+ depthStencil.stencilBack.compare = value;
52
55
  },
53
56
  stencilPassOperation: (parameter, value, descriptor) => {
54
- addDepthStencil(descriptor);
55
- descriptor.depthStencil.stencilFront.passOp = value;
56
- descriptor.depthStencil.stencilBack.passOp = value;
57
+ const depthStencil = addDepthStencil(descriptor);
58
+ depthStencil.stencilFront.passOp = value;
59
+ depthStencil.stencilBack.passOp = value;
57
60
  },
58
61
  stencilFailOperation: (parameter, value, descriptor) => {
59
- addDepthStencil(descriptor);
60
- descriptor.depthStencil.stencilFront.failOp = value;
61
- descriptor.depthStencil.stencilBack.failOp = value;
62
+ const depthStencil = addDepthStencil(descriptor);
63
+ depthStencil.stencilFront.failOp = value;
64
+ depthStencil.stencilBack.failOp = value;
62
65
  },
63
66
  stencilDepthFailOperation: (parameter, value, descriptor) => {
64
- addDepthStencil(descriptor);
65
- descriptor.depthStencil.stencilFront.depthFailOp = value;
66
- descriptor.depthStencil.stencilBack.depthFailOp = value;
67
+ const depthStencil = addDepthStencil(descriptor);
68
+ depthStencil.stencilFront.depthFailOp = value;
69
+ depthStencil.stencilBack.depthFailOp = value;
67
70
  },
68
71
  sampleCount: (parameter, value, descriptor) => {
69
72
  descriptor.multisample = descriptor.multisample || {};
@@ -78,16 +81,12 @@ export const PARAMETER_TABLE = {
78
81
  descriptor.multisample.alphaToCoverageEnabled = value;
79
82
  },
80
83
  colorMask: (parameter, value, descriptor) => {
81
- addColorState(descriptor);
82
- const targets = descriptor.fragment.targets;
84
+ const targets = addColorState(descriptor);
83
85
  targets[0].writeMask = value;
84
86
  },
85
87
  blendColorOperation: (parameter, value, descriptor) => {
86
- addColorState(descriptor);
87
- const targets = descriptor.fragment.targets;
88
- targets[0].blend = targets[0].blend || {};
89
- targets[0].blend.color = targets[0].blend.color || {};
90
- targets[0].blend.color.operation = value;
88
+ const targets = addColorState(descriptor);
89
+ const target = targets[0];
91
90
  }
92
91
  };
93
92
  const DEFAULT_PIPELINE_DESCRIPTOR = {
@@ -125,10 +124,20 @@ function setParameters(pipelineDescriptor, parameters) {
125
124
  }
126
125
 
127
126
  function addColorState(descriptor) {
128
- descriptor.fragment.targets = descriptor.fragment.targets || [];
127
+ var _descriptor$fragment, _descriptor$fragment2, _descriptor$fragment3, _descriptor$fragment4, _descriptor$fragment5;
129
128
 
130
- if (descriptor.fragment.targets.length === 0) {
131
- descriptor.fragment.targets.push({});
129
+ descriptor.fragment.targets = ((_descriptor$fragment = descriptor.fragment) === null || _descriptor$fragment === void 0 ? void 0 : _descriptor$fragment.targets) || [];
130
+
131
+ if (!Array.isArray((_descriptor$fragment2 = descriptor.fragment) === null || _descriptor$fragment2 === void 0 ? void 0 : _descriptor$fragment2.targets)) {
132
+ throw new Error('colorstate');
132
133
  }
134
+
135
+ if (((_descriptor$fragment3 = descriptor.fragment) === null || _descriptor$fragment3 === void 0 ? void 0 : (_descriptor$fragment4 = _descriptor$fragment3.targets) === null || _descriptor$fragment4 === void 0 ? void 0 : _descriptor$fragment4.length) === 0) {
136
+ var _descriptor$fragment$;
137
+
138
+ (_descriptor$fragment$ = descriptor.fragment.targets) === null || _descriptor$fragment$ === void 0 ? void 0 : _descriptor$fragment$.push({});
139
+ }
140
+
141
+ return (_descriptor$fragment5 = descriptor.fragment) === null || _descriptor$fragment5 === void 0 ? void 0 : _descriptor$fragment5.targets;
133
142
  }
134
143
  //# sourceMappingURL=webgpu-parameters.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","depthWriteEnabled","depthCompare","depthFormat","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","compare","stencilPassOperation","passOp","stencilFailOperation","failOp","stencilDepthFailOperation","depthFailOp","sampleCount","multisample","count","sampleMask","mask","sampleAlphaToCoverageEnabled","alphaToCoverageEnabled","colorMask","addColorState","targets","fragment","writeMask","blendColorOperation","blend","color","operation","DEFAULT_PIPELINE_DESCRIPTOR","topology","vertex","module","undefined","entryPoint","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","Object","assign","setParameters","key","entries","setterFunction","Error","length","push"],"mappings":"AAEA,SAASA,eAAT,CAAyBC,UAAzB,EAAwE;AACtEA,EAAAA,UAAU,CAACC,YAAX,GAA0BD,UAAU,CAACC,YAAX,IAA2B;AAEnDC,IAAAA,MAAM,EAAE,aAF2C;AAGnDC,IAAAA,YAAY,EAAE,EAHqC;AAInDC,IAAAA,WAAW,EAAE;AAJsC,GAArD;AAMD;;AAOD,OAAO,MAAMC,eAAmD,GAAG;AAGjEC,EAAAA,QAAQ,EAAE,CAACC,SAAD,EAA8BC,KAA9B,EAA0CR,UAA1C,KAAsF;AAC9FA,IAAAA,UAAU,CAACS,SAAX,CAAqBH,QAArB,GAAgCE,KAAhC;AACD,GALgE;AAOjEE,EAAAA,SAAS,EAAE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J;AAAiC,OAAGO;AAApC,GAAlC;AACAI,EAAAA,aAAa,CAACJ,kBAAD,EAAqBC,UAArB,CAAb;AACD;;AAGD,SAASG,aAAT,CACEJ,kBADF,EAEEC,UAFF,EAGQ;AACN,OAAK,MAAM,CAACI,GAAD,EAAM/C,KAAN,CAAX,IAA2B4C,MAAM,CAACI,OAAP,CAAeL,UAAf,CAA3B,EAAuD;AACrD,UAAMM,cAAc,GAAGpD,eAAe,CAACkD,GAAD,CAAtC;;AACA,QAAI,CAACE,cAAL,EAAqB;AACnB,YAAM,IAAIC,KAAJ,6BAA+BH,GAA/B,EAAN;AACD;;AACDE,IAAAA,cAAc,CAACF,GAAD,EAAM/C,KAAN,EAAa0C,kBAAb,CAAd;AACD;AACF;;AAED,SAASf,aAAT,CAAuBnC,UAAvB,EAAsE;AACpEA,EAAAA,UAAU,CAACqC,QAAX,CAAoBD,OAApB,GAA8BpC,UAAU,CAACqC,QAAX,CAAoBD,OAApB,IAA+B,EAA7D;;AAEA,MAAIpC,UAAU,CAACqC,QAAX,CAAoBD,OAApB,CAA4BuB,MAA5B,KAAuC,CAA3C,EAA8C;AAE5C3D,IAAAA,UAAU,CAACqC,QAAX,CAAoBD,OAApB,CAA4BwB,IAA5B,CAAiC,EAAjC;AACD;AACF","sourcesContent":["import {Parameters} from '@luma.gl/api';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): void {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {}\n };\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.cullMode = value;\n },\n\n frontFace: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.depthWriteEnabled = value;\n },\n\n depthCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.depthCompare = value;\n },\n\n depthFormat: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.format = value;\n },\n\n depthBias: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilFront.compare = value;\n descriptor.depthStencil.stencilBack.compare = value;\n },\n\n stencilPassOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilFront.passOp = value;\n descriptor.depthStencil.stencilBack.passOp = value;\n },\n\n stencilFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilFront.failOp = value;\n descriptor.depthStencil.stencilBack.failOp = value;\n },\n\n stencilDepthFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addDepthStencil(descriptor);\n descriptor.depthStencil.stencilFront.depthFailOp = value;\n descriptor.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 addColorState(descriptor);\n const targets = descriptor.fragment.targets as GPUColorTargetState[];\n targets[0].writeMask = value;\n },\n\n blendColorOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n const targets = descriptor.fragment.targets as GPUColorTargetState[];\n // @ts-expect-error\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.operation = value;\n }\n\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n\n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n\n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n\n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n\n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n }\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\n\nfunction addColorState(descriptor: GPURenderPipelineDescriptor): void {\n descriptor.fragment.targets = descriptor.fragment.targets || [];\n // @ts-expect-error\n if (descriptor.fragment.targets.length === 0) {\n // @ts-expect-error\n descriptor.fragment.targets.push({});\n }\n}\n"],"file":"webgpu-parameters.js"}
1
+ {"version":3,"sources":["../../../src/adapter/helpers/webgpu-parameters.ts"],"names":["addDepthStencil","descriptor","depthStencil","format","stencilFront","stencilBack","PARAMETER_TABLE","cullMode","parameter","value","primitive","frontFace","depthWriteEnabled","depthCompare","depthFormat","depthBias","depthBiasSlopeScale","depthBiasClamp","stencilReadMask","stencilWriteMask","stencilCompare","compare","stencilPassOperation","passOp","stencilFailOperation","failOp","stencilDepthFailOperation","depthFailOp","sampleCount","multisample","count","sampleMask","mask","sampleAlphaToCoverageEnabled","alphaToCoverageEnabled","colorMask","targets","addColorState","writeMask","blendColorOperation","target","DEFAULT_PIPELINE_DESCRIPTOR","topology","vertex","module","undefined","entryPoint","fragment","applyParametersToRenderPipelineDescriptor","pipelineDescriptor","parameters","Object","assign","setParameters","key","entries","setterFunction","Error","Array","isArray","length","push"],"mappings":"AAEA,SAASA,eAAT,CAAyBC,UAAzB,EAAwF;AACtFA,EAAAA,UAAU,CAACC,YAAX,GAA0BD,UAAU,CAACC,YAAX,IAA2B;AAEnDC,IAAAA,MAAM,EAAE,aAF2C;AAGnDC,IAAAA,YAAY,EAAE,EAHqC;AAInDC,IAAAA,WAAW,EAAE;AAJsC,GAArD;AAMA,SAAOJ,UAAU,CAACC,YAAlB;AACD;;AAOD,OAAO,MAAMI,eAAmD,GAAG;AAGjEC,EAAAA,QAAQ,EAAE,CAACC,SAAD,EAA8BC,KAA9B,EAA0CR,UAA1C,KAAsF;AAC9FA,IAAAA,UAAU,CAACS,SAAX,GAAuBT,UAAU,CAACS,SAAX,IAAwB,EAA/C;AACAT,IAAAA,UAAU,CAACS,SAAX,CAAqBH,QAArB,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A/B,EAAN;AACD;;AACDE,IAAAA,cAAc,CAACF,GAAD,EAAM7C,KAAN,EAAawC,kBAAb,CAAd;AACD;AACF;;AAED,SAASZ,aAAT,CAAuBpC,UAAvB,EAAuF;AAAA;;AACrFA,EAAAA,UAAU,CAAC8C,QAAX,CAAqBX,OAArB,GAA+B,yBAAAnC,UAAU,CAAC8C,QAAX,8EAAqBX,OAArB,KAAgC,EAA/D;;AACA,MAAI,CAACsB,KAAK,CAACC,OAAN,0BAAc1D,UAAU,CAAC8C,QAAzB,0DAAc,sBAAqBX,OAAnC,CAAL,EAAkD;AAChD,UAAM,IAAIqB,KAAJ,CAAU,YAAV,CAAN;AACD;;AACD,MAAI,0BAAAxD,UAAU,CAAC8C,QAAX,yGAAqBX,OAArB,gFAA8BwB,MAA9B,MAAyC,CAA7C,EAAgD;AAAA;;AAC9C,6BAAA3D,UAAU,CAAC8C,QAAX,CAAoBX,OAApB,gFAA6ByB,IAA7B,CAAkC,EAAlC;AACD;;AACD,kCAAO5D,UAAU,CAAC8C,QAAlB,0DAAO,sBAAqBX,OAA5B;AACD","sourcesContent":["import {Parameters} from '@luma.gl/api';\n\nfunction addDepthStencil(descriptor: GPURenderPipelineDescriptor): GPUDepthStencilState {\n descriptor.depthStencil = descriptor.depthStencil || {\n // required, set something\n format: 'depth24plus',\n stencilFront: {},\n stencilBack: {}\n };\n return descriptor.depthStencil;\n}\n\n/**\n * Supports for luma.gl's flat parameter space\n * Populates the corresponding sub-objects in a GPURenderPipelineDescriptor\n */\n// @ts-expect-error\nexport const PARAMETER_TABLE: Record<keyof Parameters, Function> = {\n // RASTERIZATION PARAMETERS\n\n cullMode: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.cullMode = value;\n },\n\n frontFace: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.primitive = descriptor.primitive || {};\n descriptor.primitive.frontFace = value;\n },\n\n // DEPTH\n\n depthWriteEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthWriteEnabled = value;\n },\n\n depthCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthCompare = value;\n },\n\n depthFormat: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.format = value;\n },\n\n depthBias: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBias = value;\n },\n\n depthBiasSlopeScale: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasSlopeScale = value;\n },\n\n depthBiasClamp: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.depthBiasClamp = value;\n },\n\n // STENCIL\n\n stencilReadMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilReadMask = value;\n },\n\n stencilWriteMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilWriteMask = value;\n },\n\n stencilCompare: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.compare = value;\n depthStencil.stencilBack!.compare = value;\n },\n\n stencilPassOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.passOp = value;\n depthStencil.stencilBack!.passOp = value;\n },\n\n stencilFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.failOp = value;\n depthStencil.stencilBack!.failOp = value;\n },\n\n stencilDepthFailOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const depthStencil = addDepthStencil(descriptor);\n depthStencil.stencilFront!.depthFailOp = value;\n depthStencil.stencilBack!.depthFailOp = value;\n },\n\n // MULTISAMPLE\n\n sampleCount: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.count = value;\n },\n\n sampleMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.mask = value;\n },\n\n sampleAlphaToCoverageEnabled: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n descriptor.multisample = descriptor.multisample || {};\n descriptor.multisample.alphaToCoverageEnabled = value;\n },\n\n // COLOR\n\n colorMask: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n targets[0].writeMask = value;\n },\n\n blendColorOperation: (parameter: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {\n const targets = addColorState(descriptor);\n const target = targets[0];\n // const blend: GPUBlendState = target.blend || {color: {alpha: 0}};\n // blend.color = blend.color || {};\n // target.blend.color.operation = value;\n }\n\n /*\n blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.srcTarget = value;\n },\n\n blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.color = targets[0].blend.color || {};\n targets[0].blend.color.dstTarget = value;\n },\n\n blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.operation = value;\n },\n\n blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.srcTarget = value;\n },\n\n blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {\n addColorState(descriptor);\n targets[0].blend = targets[0].blend || {};\n targets[0].blend.alpha = targets[0].blend.alpha || {};\n targets[0].blend.alpha.dstTarget = value;\n },\n */\n};\n\nconst DEFAULT_PIPELINE_DESCRIPTOR: GPURenderPipelineDescriptor = {\n // depthStencil: {\n // stencilFront: {},\n // stencilBack: {},\n // // depthWriteEnabled: true,\n // // depthCompare: 'less',\n // // format: 'depth24plus-stencil8',\n // },\n\n primitive: {\n cullMode: 'back',\n topology: 'triangle-list'\n },\n\n vertex: {\n module: undefined!,\n entryPoint: 'main'\n },\n\n fragment: {\n module: undefined!,\n entryPoint: 'main',\n targets: [\n // { format: props.color0Format || 'bgra8unorm' }\n ]\n }\n};\n\nexport function applyParametersToRenderPipelineDescriptor(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters = {}\n): void {\n // Apply defaults\n Object.assign(pipelineDescriptor, {...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor});\n setParameters(pipelineDescriptor, parameters);\n}\n\n// Apply any supplied parameters\nfunction setParameters(\n pipelineDescriptor: GPURenderPipelineDescriptor,\n parameters: Parameters\n): void {\n for (const [key, value] of Object.entries(parameters)) {\n const setterFunction = PARAMETER_TABLE[key as keyof Parameters];\n if (!setterFunction) {\n throw new Error(`Illegal parameter ${key}`);\n }\n setterFunction(key, value, pipelineDescriptor);\n }\n}\n\nfunction addColorState(descriptor: GPURenderPipelineDescriptor): GPUColorTargetState[] {\n descriptor.fragment!.targets = descriptor.fragment?.targets || [];\n if (!Array.isArray(descriptor.fragment?.targets)) {\n throw new Error('colorstate');\n }\n if (descriptor.fragment?.targets?.length === 0) {\n descriptor.fragment.targets?.push({});\n }\n return descriptor.fragment?.targets as GPUColorTargetState[];\n}\n"],"file":"webgpu-parameters.js"}
@@ -6,7 +6,6 @@ export default class WebGPUBuffer extends Buffer {
6
6
  readonly handle: GPUBuffer;
7
7
  readonly byteLength: number;
8
8
  constructor(device: WebGPUDevice, props: BufferProps);
9
- protected createHandle(mapBuffer: boolean): GPUBuffer;
10
9
  destroy(): void;
11
10
  write(data: ArrayBufferView, byteOffset?: number): void;
12
11
  readAsync(byteOffset?: number, byteLength?: number): Promise<ArrayBuffer>;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAyBpD,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS;IAIrD,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmBnG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
1
+ {"version":3,"file":"webgpu-buffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAS,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAMjD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,MAAM;IAC9C,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW;IAyBpD,OAAO,IAAI,IAAI;IAKf,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,SAAI;IAUrC,SAAS,CAAC,UAAU,GAAE,MAAU,EAAE,UAAU,GAAE,MAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmBnG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxE,cAAc,CAAC,MAAM,GAAE,MAAU,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW;IAI9D,KAAK,IAAI,IAAI;CAGd"}
@@ -36,10 +36,6 @@ export default class WebGPUBuffer extends Buffer {
36
36
  }
37
37
  }
38
38
 
39
- createHandle(mapBuffer) {
40
- return;
41
- }
42
-
43
39
  destroy() {
44
40
  this.handle.destroy();
45
41
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":["Buffer","getByteLength","props","byteLength","data","WebGPUBuffer","constructor","device","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","createHandle","destroy","write","byteOffset","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"mappings":";AACA,SAAQA,MAAR,QAA0C,cAA1C;;AAGA,SAASC,aAAT,CAAuBC,KAAvB,EAAmD;AAAA;;AACjD,SAAOA,KAAK,CAACC,UAAN,oBAAoBD,KAAK,CAACE,IAA1B,gDAAoB,YAAYD,UAAhC,KAA8C,CAArD;AACD;;AAED,eAAe,MAAME,YAAN,SAA2BL,MAA3B,CAAkC;AAK/CM,EAAAA,WAAW,CAACC,MAAD,EAAuBL,KAAvB,EAA2C;AACpD,UAAMK,MAAN,EAAcL,KAAd;;AADoD;;AAAA;;AAAA;;AAEpD,SAAKK,MAAL,GAAcA,MAAd;AAEA,SAAKJ,UAAL,GAAkBF,aAAa,CAACC,KAAD,CAA/B;AACA,UAAMM,SAAS,GAAGC,OAAO,CAACP,KAAK,CAACE,IAAP,CAAzB;AAEA,SAAKM,MAAL,GAAc,KAAKR,KAAL,CAAWQ,MAAX,IAAqB,KAAKH,MAAL,CAAYG,MAAZ,CAAmBC,YAAnB,CAAgC;AACjEC,MAAAA,IAAI,EAAE,KAAKT,UADsD;AAGjEU,MAAAA,KAAK,EAAE,KAAKX,KAAL,CAAWW,KAAX,IAAqBC,cAAc,CAACC,MAAf,GAAwBD,cAAc,CAACE,QAHF;AAIjEC,MAAAA,gBAAgB,EAAE,KAAKf,KAAL,CAAWe,gBAAX,IAA+BT,SAJgB;AAKj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AAGA,UAAMN,UAAU,CAACpB,MAAX,CAAkB2B,QAAlB,CAA2BC,UAAU,CAACC,IAAtC,EAA4Cd,UAA5C,EAAwDtB,UAAxD,CAAN;AACA,UAAMqC,WAAW,GAAGV,UAAU,CAACpB,MAAX,CAAkB+B,cAAlB,GAAmCC,KAAnC,CAAyC,CAAzC,CAApB;AACAZ,IAAAA,UAAU,CAACpB,MAAX,CAAkBW,KAAlB;AACAS,IAAAA,UAAU,CAACP,OAAX;AAEA,WAAOiB,WAAP;AACD;;AAEDpB,EAAAA,YAAY,CAAauB,UAAb,EAA2C;AACrD,UAAMH,WAAW,GAAG,KAAK9B,MAAL,CAAY+B,cAAZ,EAApB;AAEA,QAAIE,UAAU,CAACrC,WAAf,CAA2BkC,WAA3B,EAAwCI,GAAxC,CAA4CD,UAA5C;AACD;;AAIDN,EAAAA,QAAQ,CAACQ,IAAD,EAAeC,MAAc,GAAG,CAAhC,EAAmClC,IAAnC,EAAiE;AACvE,WAAO,KAAKF,MAAL,CAAY2B,QAAZ,CAAqBQ,IAArB,EAA2BC,MAA3B,EAAmClC,IAAnC,CAAP;AACD;;AAED6B,EAAAA,cAAc,CAACK,MAAc,GAAG,CAAlB,EAAqBlC,IAArB,EAAiD;AAC7D,WAAO,KAAKF,MAAL,CAAY+B,cAAZ,CAA2BK,MAA3B,EAAmClC,IAAnC,CAAP;AACD;;AAEDS,EAAAA,KAAK,GAAS;AACZ,SAAKX,MAAL,CAAYW,KAAZ;AACD;;AAtF8C","sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps, assert} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n protected createHandle(mapBuffer: boolean): GPUBuffer {\n return\n }\n\n destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"file":"webgpu-buffer.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-buffer.ts"],"names":["Buffer","getByteLength","props","byteLength","data","WebGPUBuffer","constructor","device","mapBuffer","Boolean","handle","createBuffer","size","usage","GPUBufferUsage","VERTEX","COPY_DST","mappedAtCreation","label","id","_writeMapped","unmap","destroy","write","byteOffset","queue","writeBuffer","buffer","readAsync","tempBuffer","MAP_READ","commandEncoder","createCommandEncoder","copyBufferToBuffer","submit","finish","mapAsync","GPUMapMode","READ","arrayBuffer","getMappedRange","slice","typedArray","set","mode","offset"],"mappings":";AACA,SAAQA,MAAR,QAA0C,cAA1C;;AAGA,SAASC,aAAT,CAAuBC,KAAvB,EAAmD;AAAA;;AACjD,SAAOA,KAAK,CAACC,UAAN,oBAAoBD,KAAK,CAACE,IAA1B,gDAAoB,YAAYD,UAAhC,KAA8C,CAArD;AACD;;AAED,eAAe,MAAME,YAAN,SAA2BL,MAA3B,CAAkC;AAK/CM,EAAAA,WAAW,CAACC,MAAD,EAAuBL,KAAvB,EAA2C;AACpD,UAAMK,MAAN,EAAcL,KAAd;;AADoD;;AAAA;;AAAA;;AAEpD,SAAKK,MAAL,GAAcA,MAAd;AAEA,SAAKJ,UAAL,GAAkBF,aAAa,CAACC,KAAD,CAA/B;AACA,UAAMM,SAAS,GAAGC,OAAO,CAACP,KAAK,CAACE,IAAP,CAAzB;AAEA,SAAKM,MAAL,GAAc,KAAKR,KAAL,CAAWQ,MAAX,IAAqB,KAAKH,MAAL,CAAYG,MAAZ,CAAmBC,YAAnB,CAAgC;AACjEC,MAAAA,IAAI,EAAE,KAAKT,UADsD;AAGjEU,MAAAA,KAAK,EAAE,KAAKX,KAAL,CAAWW,KAAX,IAAqBC,cAAc,CAACC,MAAf,GAAw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AAzB,CAAgC,CAACH,cAAc,CAACI,MAAf,EAAD,CAAhC;AAGA,UAAMN,UAAU,CAACnB,MAAX,CAAkB0B,QAAlB,CAA2BC,UAAU,CAACC,IAAtC,EAA4Cd,UAA5C,EAAwDrB,UAAxD,CAAN;AACA,UAAMoC,WAAW,GAAGV,UAAU,CAACnB,MAAX,CAAkB8B,cAAlB,GAAmCC,KAAnC,CAAyC,CAAzC,CAApB;AACAZ,IAAAA,UAAU,CAACnB,MAAX,CAAkBW,KAAlB;AACAQ,IAAAA,UAAU,CAACP,OAAX;AAEA,WAAOiB,WAAP;AACD;;AAEDnB,EAAAA,YAAY,CAAasB,UAAb,EAA2C;AACrD,UAAMH,WAAW,GAAG,KAAK7B,MAAL,CAAY8B,cAAZ,EAApB;AAEA,QAAIE,UAAU,CAACpC,WAAf,CAA2BiC,WAA3B,EAAwCI,GAAxC,CAA4CD,UAA5C;AACD;;AAIDN,EAAAA,QAAQ,CAACQ,IAAD,EAAeC,MAAc,GAAG,CAAhC,EAAmCjC,IAAnC,EAAiE;AACvE,WAAO,KAAKF,MAAL,CAAY0B,QAAZ,CAAqBQ,IAArB,EAA2BC,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAED4B,EAAAA,cAAc,CAACK,MAAc,GAAG,CAAlB,EAAqBjC,IAArB,EAAiD;AAC7D,WAAO,KAAKF,MAAL,CAAY8B,cAAZ,CAA2BK,MAA3B,EAAmCjC,IAAnC,CAAP;AACD;;AAEDS,EAAAA,KAAK,GAAS;AACZ,SAAKX,MAAL,CAAYW,KAAZ;AACD;;AAlF8C","sourcesContent":["// WEBGPU Buffer implementation\nimport {Buffer, BufferProps, assert} from '@luma.gl/api';\nimport type WebGPUDevice from '../webgpu-device';\n\nfunction getByteLength(props: BufferProps): number {\n return props.byteLength || props.data?.byteLength || 0;\n}\n\nexport default class WebGPUBuffer extends Buffer {\n readonly device: WebGPUDevice;\n readonly handle: GPUBuffer;\n readonly byteLength: number;\n\n constructor(device: WebGPUDevice, props: BufferProps) {\n super(device, props);\n this.device = device;\n\n this.byteLength = getByteLength(props);\n const mapBuffer = Boolean(props.data);\n\n this.handle = this.props.handle || this.device.handle.createBuffer({\n size: this.byteLength,\n // usage defaults to vertex\n usage: this.props.usage || (GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST),\n mappedAtCreation: this.props.mappedAtCreation || mapBuffer,\n label: this.props.id\n });\n\n if (props.data) {\n this._writeMapped(props.data);\n // this.handle.writeAsync({data: props.data, map: false, unmap: false});\n }\n\n if (mapBuffer && !props.mappedAtCreation) {\n this.handle.unmap();\n }\n }\n\n destroy(): void {\n this.handle.destroy();\n }\n\n // WebGPU provides multiple ways to write a buffer...\n write(data: ArrayBufferView, byteOffset = 0) {\n this.device.handle.queue.writeBuffer(\n this.handle,\n byteOffset,\n data.buffer,\n data.byteOffset,\n data.byteLength\n );\n }\n\n async readAsync(byteOffset: number = 0, byteLength: number = this.byteLength): Promise<ArrayBuffer> {\n // We need MAP_READ flag, but only COPY_DST buffers can have MAP_READ flag, so we need to create a temp buffer\n const tempBuffer = new WebGPUBuffer(this.device, {usage: Buffer.MAP_READ | Buffer.COPY_DST, byteLength});\n\n // Now do a GPU-side copy into the temp buffer we can actually read.\n // TODO - we are spinning up an independent command queue here, what does this mean\n const commandEncoder = this.device.handle.createCommandEncoder();\n commandEncoder.copyBufferToBuffer(this.handle, byteOffset, tempBuffer.handle, 0, byteLength);\n this.device.handle.queue.submit([commandEncoder.finish()]);\n\n // Map the temp buffer and read the data.\n await tempBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);\n const arrayBuffer = tempBuffer.handle.getMappedRange().slice(0);\n tempBuffer.handle.unmap();\n tempBuffer.destroy();\n\n return arrayBuffer;\n }\n\n _writeMapped<TypedArray>(typedArray: TypedArray): void {\n const arrayBuffer = this.handle.getMappedRange();\n // @ts-expect-error\n new typedArray.constructor(arrayBuffer).set(typedArray);\n }\n\n // WEBGPU API\n\n mapAsync(mode: number, offset: number = 0, size?: number): Promise<void> {\n return this.handle.mapAsync(mode, offset, size);\n }\n\n getMappedRange(offset: number = 0, size?: number): ArrayBuffer {\n return this.handle.getMappedRange(offset, size);\n }\n\n unmap(): void {\n this.handle.unmap();\n }\n}\n"],"file":"webgpu-buffer.js"}
@@ -5,7 +5,6 @@ export default class WebGPUCommandEncoder extends CommandEncoder {
5
5
  readonly device: WebGPUDevice;
6
6
  readonly handle: GPUCommandEncoder;
7
7
  constructor(device: WebGPUDevice, props: CommandEncoderProps);
8
- protected createHandle(): GPUCommandEncoder;
9
8
  destroy(): void;
10
9
  finish(options?: {
11
10
  id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-command-encoder.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAkB,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACxG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB;IAO5D,SAAS,CAAC,YAAY,IAAI,iBAAiB;IAM3C,OAAO;IAEP,MAAM,CAAC,OAAO,CAAC,EAAE;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,gBAAgB;IAOjD,kBAAkB,CAAC,OAAO,EAAE;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,GAAG,IAAI;IAUR,mBAAmB,CAAC,OAAO,EAAE;QAC3B,MAA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xC,aAAa,IAAI,IAAI;IAIrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAa7C"}
@@ -9,14 +9,10 @@ export default class WebGPUCommandEncoder extends CommandEncoder {
9
9
  _defineProperty(this, "handle", void 0);
10
10
 
11
11
  this.device = device;
12
- this.handle = this.handle || this.createHandle();
13
- this.handle.label = this.props.id;
14
- }
15
-
16
- createHandle() {
17
- return this.device.handle.createCommandEncoder({
12
+ this.handle = props.handle || this.device.handle.createCommandEncoder({
18
13
  measureExecutionTime: this.props.measureExecutionTime
19
14
  });
15
+ this.handle.label = this.props.id;
20
16
  }
21
17
 
22
18
  destroy() {}
@@ -43,7 +39,11 @@ export default class WebGPUCommandEncoder extends CommandEncoder {
43
39
  texture: cast(options.destination).handle,
44
40
  mipLevel: (_options$mipLevel = options.mipLevel) !== null && _options$mipLevel !== void 0 ? _options$mipLevel : 0,
45
41
  origin: (_options$origin = options.origin) !== null && _options$origin !== void 0 ? _options$origin : {}
46
- }, options.extent);
42
+ }, {
43
+ width: options.extent[0],
44
+ height: options.extent[1],
45
+ depthOrArrayLayers: options.extent[2]
46
+ });
47
47
  }
48
48
 
49
49
  copyTextureToBuffer(options) {}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","handle","createHandle","label","id","createCommandEncoder","measureExecutionTime","destroy","finish","options","copyBufferToBuffer","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","extent","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,EAA8EC,IAA9E,QAAyF,cAAzF;AAKA,eAAe,MAAMC,oBAAN,SAAmCF,cAAnC,CAAkD;AAI/DG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC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,CAAJ,CAAyCZ,MADpD;AAEEqB,MAAAA,QAAQ,uBAAEb,OAAO,CAACa,QAAV,iEAAsB,CAFhC;AAGEC,MAAAA,MAAM,qBAAEd,OAAO,CAACc,MAAV,6DAAoB;AAH5B,KAPF,EAaEd,OAAO,CAACe,MAbV;AAeD;;AAEDC,EAAAA,mBAAmB,CAAChB,OAAD,EAIV,CAAE;;AAEXiB,EAAAA,oBAAoB,CAACjB,OAAD,EAIX,CAAE;;AAEXkB,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK3B,MAAL,CAAY0B,cAAZ,CAA2BC,UAA3B;AACD;;AAEDC,EAAAA,aAAa,GAAS;AACpB,SAAK5B,MAAL,CAAY4B,aAAZ;AACD;;AAEDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK9B,MAAL,CAAY6B,iBAAZ,CAA8BC,WAA9B;AACD;;AA9F8D","sourcesContent":["import {CommandEncoder, CommandEncoderProps, RenderPipeline, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = this.handle || this.createHandle();\n this.handle.label = this.props.id;\n }\n\n protected createHandle(): GPUCommandEncoder {\n return this.device.handle.createCommandEncoder({\n measureExecutionTime: this.props.measureExecutionTime\n });\n }\n\n destroy() {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n options.extent // default depth?\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"file":"webgpu-command-encoder.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-command-encoder.ts"],"names":["CommandEncoder","cast","WebGPUCommandEncoder","constructor","device","props","handle","createCommandEncoder","measureExecutionTime","label","id","destroy","finish","options","copyBufferToBuffer","source","sourceOffset","destination","destinationOffset","size","copyBufferToTexture","buffer","offset","bytesPerRow","rowsPerImage","texture","mipLevel","origin","width","extent","height","depthOrArrayLayers","copyTextureToBuffer","copyTextureToTexture","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,cAAR,EAA8EC,IAA9E,QAAyF,cAAzF;AAKA,eAAe,MAAMC,oBAAN,SAAmCF,cAAnC,CAAkD;AAI/DG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAmD;AAC5D,UAAMA,KAAN;;AAD4D;;AAAA;;AAE5D,SAAKD,MAAL,GAAcA,MAAd;AACA,SAAKE,MAAL,GAAcD,KAAK,CAACC,MAAN,IAAgB,KAAKF,MAAL,CAAYE,MAAZ,CAAmBC,oBAAnB,CAAwC;AACpEC,MAAAA,oBAAoB,EAAE,KAAKH,KAAL,CAAWG;AADmC,KAAxC,CAA9B;AAGA,SAAKF,MAAL,CAAYG,KAAZ,GAAoB,KAAKJ,KAAL,CAAWK,EAA/B;AACD;;AAEDC,EAAAA,OAAO,GAAG,CAAE;;AAEZC,EAAAA,MAAM,CAACC,OAAD,EAA4C;AAChD,WAAO,KAAKD,MAAL,CAAYC,OAAZ,CAAP;AACD;;AAKDC,EAAAA,kBAAkB,CAACD,OAAD,EAMT;AAAA;;AACP,SAAKP,MAAL,CAAYQ,kBAAZ,CACEb,IAAI,CAAeY,OAAO,CAACE,MAAvB,CAAJ,CAAmCT,MADrC,2BAEEO,OAAO,CAACG,YAFV,yEAE0B,CAF1B,EAGEf,IAAI,CAAeY,OAAO,CAACI,WAAvB,CAAJ,CAAwCX,MAH1C,2BAIEO,OAAO,CAACK,iBAJV,yEAI+B,CAJ/B,mBAKEL,OAAO,CAACM,IALV,yDAKkB,CALlB;AAOD;;AAEDC,EAAAA,mBAAmB,CAACP,OAAD,EAYV;AAAA;;AACP,SAAKP,MAAL,CAAYc,mBAAZ,CACE;AACEC,MAAAA,MAAM,EAAEpB,IAAI,CAAeY,OAAO,CAACE,MAAvB,CAAJ,CAAmCT,MAD7C;AAEEgB,MAAAA,MAAM,qBAAET,OAAO,CAACS,MAAV,6DAAoB,CAF5B;AAGEC,MAAAA,WAAW,EAAEV,OAAO,CAACU,WAHvB;AAIEC,MAAAA,YAAY,EAAEX,OAAO,CAACW;AAJxB,KADF,EAOE;AACEC,MAAAA,OAAO,EAAExB,IAAI,CAAgBY,OAAO,CAACI,WAAxB,CAAJ,CAAyCX,MADpD;AAEEoB,MAAAA,QAAQ,uBAAEb,OAAO,CAACa,QAAV,iEAAsB,CAFhC;AAGEC,MAAAA,MAAM,qBAAEd,OAAO,CAACc,MAAV,6DAAoB;AAH5B,KAPF,EAaE;AAEEC,MAAAA,KAAK,EAAEf,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAFT;AAGEC,MAAAA,MAAM,EAAEjB,OAAO,CAACgB,MAAR,CAAgB,CAAhB,CAHV;AAIEE,MAAAA,kBAAkB,EAAElB,OAAO,CAACgB,MAAR,CAAgB,CAAhB;AAJtB,KAbF;AAoBD;;AAEDG,EAAAA,mBAAmB,CAACnB,OAAD,EAIV,CAAE;;AAEXoB,EAAAA,oBAAoB,CAACpB,OAAD,EAIX,CAAE;;AAEXqB,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK7B,MAAL,CAAY4B,cAAZ,CAA2BC,UAA3B;AACD;;AAEDC,EAAAA,aAAa,GAAS;AACpB,SAAK9B,MAAL,CAAY8B,aAAZ;AACD;;AAEDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAKhC,MAAL,CAAY+B,iBAAZ,CAA8BC,WAA9B;AACD;;AA/F8D","sourcesContent":["import {CommandEncoder, CommandEncoderProps, RenderPipeline, Buffer, Texture, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WEBGPUBuffer from './webgpu-buffer';\nimport WebGPUTexture from './webgpu-texture';\n\nexport default class WebGPUCommandEncoder extends CommandEncoder {\n readonly device: WebGPUDevice;\n readonly handle: GPUCommandEncoder;\n\n constructor(device: WebGPUDevice, props: CommandEncoderProps) {\n super(props);\n this.device = device;\n this.handle = props.handle || this.device.handle.createCommandEncoder({\n measureExecutionTime: this.props.measureExecutionTime\n });\n this.handle.label = this.props.id;\n }\n\n destroy() {}\n\n finish(options?: {id?: string}): GPUCommandBuffer {\n return this.finish(options);\n }\n\n // beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;\n // beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;\n\n copyBufferToBuffer(options: {\n source: Buffer,\n sourceOffset?: number,\n destination: Buffer,\n destinationOffset?: number,\n size?: number\n }): void {\n this.handle.copyBufferToBuffer(\n cast<WEBGPUBuffer>(options.source).handle,\n options.sourceOffset ?? 0,\n cast<WEBGPUBuffer>(options.destination).handle,\n options.destinationOffset ?? 0,\n options.size ?? 0\n );\n }\n\n copyBufferToTexture(options: {\n source: Buffer,\n offset?: number,\n bytesPerRow: number,\n rowsPerImage: number,\n\n destination: Texture,\n mipLevel?: number;\n aspect?: 'all' | 'stencil-only' | 'depth-only',\n\n origin?: number[] | [number, number, number],\n extent?: number[] | [number, number, number]\n }): void {\n this.handle.copyBufferToTexture(\n {\n buffer: cast<WEBGPUBuffer>(options.source).handle,\n offset: options.offset ?? 0,\n bytesPerRow: options.bytesPerRow,\n rowsPerImage: options.rowsPerImage,\n },\n {\n texture: cast<WebGPUTexture>(options.destination).handle,\n mipLevel: options.mipLevel ?? 0,\n origin: options.origin ?? {},\n // aspect: options.aspect\n },\n {\n // TODO exclamation mark hack\n width: options.extent![0],\n height: options.extent![1],\n depthOrArrayLayers: options.extent![2]\n }\n );\n }\n\n copyTextureToBuffer(options: {\n source: GPUImageCopyTexture,\n destination: GPUImageCopyBuffer,\n copySize: GPUExtent3D\n }): void {}\n\n copyTextureToTexture(options: {\n source: GPUImageCopyTexture ,\n destination: GPUImageCopyTexture,\n copySize: GPUExtent3D\n }): void {}\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: Query, queryIndex: number): void {}\n\n // resolveQuerySet(options: {\n // querySet: GPUQuerySet,\n // firstQuery: number,\n // queryCount: number,\n // destination: Buffer,\n // destinationOffset?: number;\n // }): void;\n}"],"file":"webgpu-command-encoder.js"}
@@ -4,7 +4,7 @@ import WebGPUDevice from '../webgpu-device';
4
4
  export default class WebGPUComputePass extends ComputePass {
5
5
  readonly device: WebGPUDevice;
6
6
  readonly handle: GPUComputePassEncoder;
7
- _bindGroupLayout: GPUBindGroupLayout;
7
+ _bindGroupLayout: GPUBindGroupLayout | null;
8
8
  constructor(device: WebGPUDevice, props: ComputePassProps);
9
9
  /** @note no WebGPU destroy method, just gc */
10
10
  destroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-compute-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAO,MAAM,cAAc,CAAC;AACnG,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAK5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,CAAC;gBAEzB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAUzD,8CAA8C;IAC9C,OAAO;IAEP,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAM5C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,GAA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AI1E,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAO7C"}
@@ -2,18 +2,20 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { ComputePass, cast } from '@luma.gl/api';
3
3
  export default class WebGPUComputePass extends ComputePass {
4
4
  constructor(device, props) {
5
+ var _device$commandEncode;
6
+
5
7
  super(device, props);
6
8
 
7
9
  _defineProperty(this, "device", void 0);
8
10
 
9
11
  _defineProperty(this, "handle", void 0);
10
12
 
11
- _defineProperty(this, "_bindGroupLayout", void 0);
13
+ _defineProperty(this, "_bindGroupLayout", null);
12
14
 
13
15
  this.device = device;
14
- this.handle = this.props.handle || device.commandEncoder.beginComputePass({
16
+ this.handle = this.props.handle || ((_device$commandEncode = device.commandEncoder) === null || _device$commandEncode === void 0 ? void 0 : _device$commandEncode.beginComputePass({
15
17
  label: this.props.id
16
- });
18
+ }));
17
19
  }
18
20
 
19
21
  destroy() {}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","handle","commandEncoder","beginComputePass","label","id","destroy","endPass","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchIndirect","indirectBuffer","indirectOffset","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,WAAR,EAAyEC,IAAzE,QAAoF,cAApF;AAMA,eAAe,MAAMC,iBAAN,SAAgCF,WAAhC,CAA4C;AAKzDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA;;AAAA;;AAEzD,SAAKD,MAAL,GAAcA,MAAd;AAEA,SAAKE,MAAL,GAAc,KA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l/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatch(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"file":"webgpu-compute-pass.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-compute-pass.ts"],"names":["ComputePass","cast","WebGPUComputePass","constructor","device","props","handle","commandEncoder","beginComputePass","label","id","destroy","endPass","setPipeline","pipeline","wgpuPipeline","_bindGroupLayout","_getBindGroupLayout","setBindings","bindings","Error","dispatch","x","y","z","dispatchIndirect","indirectBuffer","indirectOffset","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AAAA,SAAQA,WAAR,EAAyEC,IAAzE,QAAoF,cAApF;AAMA,eAAe,MAAMC,iBAAN,SAAgCF,WAAhC,CAA4C;AAKzDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AAAA;;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA;;AAAA,8CAFb,IAEa;;AAEzD,SAAKD,MAAL,GAAcA,MAAd;AAEA,SAAKE,MAAL,GAAc,KAAKD,KAAL,CAAWC,MAAX,8BAAqBF,MAAM,CAACG,cAA5B,0DAAqB,sBAAuBC,gBAAvB,CAAwC;AACzEC,MAAAA,KAAK,EAAE,KAAKJ,KAAL,CAAWK;AADuD,KAAxC,CAArB,CAAd;AAID;;AAGDC,EAAAA,OAAO,GAAG,CAAE;;AAEZC,EAAAA,OAAO,GAAS;AACd,SAAKN,MAAL,CAAYM,OAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAkC;AAC3C,UAAMC,YAAY,GAAGd,IAAI,CAAwBa,QAAxB,CAAzB;AACA,SAAKR,MAAL,CAAYO,WAAZ,CAAwBE,YAAY,CAACT,MAArC;AACA,SAAKU,gBAAL,GAAwBD,YAAY,CAACE,mBAAb,EAAxB;AACD;;AAGDC,EAAAA,WAAW,CAACC,QAAD,EAA4B;AACrC,UAAM,IAAIC,KAAJ,CAAU,QAAV,CAAN;AAGD;;AAQDC,EAAAA,QAAQ,CAACC,CAAD,EAAYC,CAAZ,EAAwBC,CAAxB,EAA0C;AAChD,SAAKlB,MAAL,CAAYe,QAAZ,CAAqBC,CAArB,EAAwBC,CAAxB,EAA2BC,CAA3B;AACD;;AAODC,EAAAA,gBAAgB,CAACC,cAAD,EAAyBC,cAAsB,GAAG,CAAlD,EAA2D;AACzE,SAAKrB,MAAL,CAAYmB,gBAAZ,CAA6BxB,IAAI,CAAeyB,cAAf,CAAJ,CAAmCpB,MAAhE,EAAwEqB,cAAxE;AACD;;AAEDC,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAKvB,MAAL,CAAYsB,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAKxB,MAAL,CAAYwB,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK1B,MAAL,CAAYyB,iBAAZ,CAA8BC,WAA9B;AACD;;AA9DwD","sourcesContent":["import {ComputePass, ComputePassProps, ComputePipeline, Buffer, Binding, cast} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPUComputePipeline from './webgpu-compute-pipeline';\n\nexport default class WebGPUComputePass extends ComputePass {\n readonly device: WebGPUDevice;\n readonly handle: GPUComputePassEncoder;\n _bindGroupLayout: GPUBindGroupLayout | null = null;\n\n constructor(device: WebGPUDevice, props: ComputePassProps) {\n super(device, props);\n this.device = device;\n\n this.handle = this.props.handle || device.commandEncoder?.beginComputePass({\n label: this.props.id,\n // timestampWrites?: GPUComputePassTimestampWrites;\n });\n }\n\n /** @note no WebGPU destroy method, just gc */\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: ComputePipeline): void {\n const wgpuPipeline = cast<WebGPUComputePipeline>(pipeline);\n this.handle.setPipeline(wgpuPipeline.handle);\n this._bindGroupLayout = wgpuPipeline._getBindGroupLayout();\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Binding[]): void {\n throw new Error('fix me');\n // const bindGroup = getBindGroup(this.device.handle, this._bindGroupLayout, this.props.bindings);\n // this.handle.setBindGroup(0, bindGroup);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param x X dimension of the grid of workgroups to dispatch.\n * @param y Y dimension of the grid of workgroups to dispatch.\n * @param z Z dimension of the grid of workgroups to dispatch.\n */\n dispatch(x: number, y?: number, z?: number): void {\n this.handle.dispatch(x, y, z);\n }\n\n /**\n * Dispatch work to be performed with the current ComputePipeline.\n * @param indirectBuffer buffer must be a tightly packed block of three 32-bit unsigned integer values (12 bytes total), given in the same order as the arguments for dispatch()\n * @param indirectOffset\n */\n dispatchIndirect(indirectBuffer: Buffer, indirectOffset: number = 0): void {\n this.handle.dispatchIndirect(cast<WebGPUBuffer>(indirectBuffer).handle, indirectOffset);\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n}\n"],"file":"webgpu-compute-pass.js"}
@@ -10,7 +10,7 @@ import WebGPUTexture from './webgpu-texture';
10
10
  export default class WebGPUFramebuffer extends Framebuffer {
11
11
  readonly device: WebGPUDevice;
12
12
  colorAttachments: WebGPUTexture[];
13
- depthStencilAttachment: WebGPUTexture;
13
+ depthStencilAttachment: WebGPUTexture | null;
14
14
  /** Partial render pass descriptor. Used by WebGPURenderPass */
15
15
  renderPassDescriptor: {
16
16
  colorAttachments: GPURenderPassColorAttachment[];
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAC,WAAW,EAAU,MAAM,cAAc,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAM7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,gBAAgB,EAAE,aAAa,EAAE,CAAM;IACvC,sBAAsB,EAAE,aAAa,CAAC;IAEtC,+DAA+D;IAC/D,oBAAoB,EAAE;QACpB,gBAAgB,EAAE,4BAA4B,EAAE,CAAC;QACjD,sBAAsB,CAAC,EAAE,mCAAmC,CAAC;KAC9D,CAEC;gBAEU,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAgCzD,mCAAmC;IACnC,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,kBAAkB;IAkB1B;;;OAGG;IACF,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAiBnE"}
1
+ {"version":3,"file":"webgpu-framebuffer.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAC,WAAW,EAAU,MAAM,cAAc,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAM7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,WAAW;IACxD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,gBAAgB,EAAE,aAAa,EAAE,CAAM;IACvC,sBAAsB,EAAE,aAAa,GAAG,IAAI,CAAQ;IAEpD,+DAA+D;IAC/D,oBAAoB,EAAE;QACpB,gBAAgB,EAAE,4BAA4B,EAAE,CAAC;QACjD,sBAAsB,CAAC,EAAE,mCAAmC,CAAC;KAC9D,CAEC;gBAEU,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAgCzD,mCAAmC;IACnC,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,kBAAkB;IAkB1B;;;OAGG;IACF,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAiBnE"}
@@ -10,7 +10,7 @@ export default class WebGPUFramebuffer extends Framebuffer {
10
10
 
11
11
  _defineProperty(this, "colorAttachments", []);
12
12
 
13
- _defineProperty(this, "depthStencilAttachment", void 0);
13
+ _defineProperty(this, "depthStencilAttachment", null);
14
14
 
15
15
  _defineProperty(this, "renderPassDescriptor", {
16
16
  colorAttachments: []
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":["Framebuffer","Texture","WEBGPUTexture","MAX_COLOR_ATTACHMENTS","WebGPUFramebuffer","constructor","device","props","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthLoadValue","depthStoreOp","stencilLoadValue","stencilStoreOp","length","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"mappings":";AACA,SAAQA,WAAR,EAAqBC,OAArB,QAAmC,cAA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ACjE,SAAK,IAAIM,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,KAAK3B,gBAAL,CAAsBc,MAA1C,EAAkD,EAAEa,CAApD,EAAuD;AACrD,UAAI,KAAK3B,gBAAL,CAAsB2B,CAAtB,CAAJ,EAA8B;AAC5B,cAAMC,cAAc,GAAG,KAAK9B,MAAL,CAAYmB,cAAZ,CAA2B,EAAC,GAAG,KAAKjB,gBAAL,CAAsB2B,CAAtB,EAAyB5B,KAA7B;AAAoCqB,UAAAA,KAApC;AAA2CC,UAAAA;AAA3C,SAA3B,CAAvB;;AACA,aAAKrB,gBAAL,CAAsB2B,CAAtB,EAAyBE,OAAzB;AACA,aAAK7B,gBAAL,CAAsB2B,CAAtB,IAA2BC,cAA3B;AACA,aAAKtB,oBAAL,CAA0BN,gBAA1B,CAA2C2B,CAA3C,EAA8CpB,IAA9C,GAAqDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAArD;AACD;AACF;;AAED,QAAI,KAAKR,sBAAT,EAAiC;AAC9B,YAAM2B,cAAc,GAAG,KAAK9B,MAAL,CAAYmB,cAAZ,CAA2B,EAAC,GAAG,KAAKhB,sBAAL,CAA4BF,KAAhC;AAAuCqB,QAAAA,KAAvC;AAA8CC,QAAAA;AAA9C,OAA3B,CAAvB;;AACA,WAAKpB,sBAAL,CAA4B4B,OAA5B;AACA,WAAK5B,sBAAL,GAA8B2B,cAA9B;AACA,WAAKtB,oBAAL,CAA0BL,sBAA1B,CAAiDM,IAAjD,GAAwDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAAxD;AACF;AACF;;AAvGwD","sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\nconst MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthLoadValue: 1.0,\n depthStoreOp: 'store',\n stencilLoadValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"file":"webgpu-framebuffer.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-framebuffer.ts"],"names":["Framebuffer","Texture","WEBGPUTexture","MAX_COLOR_ATTACHMENTS","WebGPUFramebuffer","constructor","device","props","colorAttachments","depthStencilAttachment","createDepthStencilTexture","map","colorAttachment","createColorTexture","renderPassDescriptor","view","handle","createView","depthLoadValue","depthStoreOp","stencilLoadValue","stencilStoreOp","length","loadValue","storeOp","_createTexture","id","format","width","height","usage","RENDER_ATTACHMENT","Error","texture","_resizeAttachments","i","resizedTexture","destroy"],"mappings":";AACA,SAAQA,WAAR,EAAqBC,OAArB,QAAmC,cAAnC;AAGA,OAAOC,aAAP,MAA0B,kBAA1B;AAKA,MAAMC,qBAAqB,GAAG,CAA9B;AAMA,eAAe,MAAMC,iBAAN,SAAgCJ,WAAhC,CAA4C;AAczDK,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAvB,EAAgD;AACzD,UAAMD,MAAN,EAAcC,KAAd;;AADyD;;AAAA,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AL,CAAYmB,cAAZ,CAA2B,EAAC,GAAG,KAAKjB,gBAAL,CAAsB2B,CAAtB,EAAyB5B,KAA7B;AAAoCqB,UAAAA,KAApC;AAA2CC,UAAAA;AAA3C,SAA3B,CAAvB;;AACA,aAAKrB,gBAAL,CAAsB2B,CAAtB,EAAyBE,OAAzB;AACA,aAAK7B,gBAAL,CAAsB2B,CAAtB,IAA2BC,cAA3B;AACA,aAAKtB,oBAAL,CAA0BN,gBAA1B,CAA2C2B,CAA3C,EAA8CpB,IAA9C,GAAqDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAArD;AACD;AACF;;AAED,QAAI,KAAKR,sBAAT,EAAiC;AAC9B,YAAM2B,cAAc,GAAG,KAAK9B,MAAL,CAAYmB,cAAZ,CAA2B,EAAC,GAAG,KAAKhB,sBAAL,CAA4BF,KAAhC;AAAuCqB,QAAAA,KAAvC;AAA8CC,QAAAA;AAA9C,OAA3B,CAAvB;;AACA,WAAKpB,sBAAL,CAA4B4B,OAA5B;AACA,WAAK5B,sBAAL,GAA8B2B,cAA9B;AACA,WAAKtB,oBAAL,CAA0BL,sBAA1B,CAAiDM,IAAjD,GAAwDqB,cAAc,CAACpB,MAAf,CAAsBC,UAAtB,EAAxD;AACF;AACF;;AAvGwD","sourcesContent":["import type {FramebufferProps, ColorTextureFormat} from '@luma.gl/api';\nimport {Framebuffer, Texture} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\n// import WebGPUCanvasContext from '../webgpu-canvas-context';\nimport WEBGPUTexture from './webgpu-texture';\nimport WebGPUTexture from './webgpu-texture';\n\n// const DEFAULT_DEPTH_STENCIL_FORMAT: DepthStencilTextureFormat = 'depth24plus';\n\nconst MAX_COLOR_ATTACHMENTS = 8;\n\n/**\n * Create new textures with correct size for all attachments. \n * @note resize() destroys existing textures (if size has changed). \n */\nexport default class WebGPUFramebuffer extends Framebuffer {\n readonly device: WebGPUDevice;\n\n colorAttachments: WebGPUTexture[] = [];\n depthStencilAttachment: WebGPUTexture | null = null;\n\n /** Partial render pass descriptor. Used by WebGPURenderPass */\n renderPassDescriptor: {\n colorAttachments: GPURenderPassColorAttachment[];\n depthStencilAttachment?: GPURenderPassDepthStencilAttachment;\n } = {\n colorAttachments: []\n };\n\n constructor(device: WebGPUDevice, props: FramebufferProps) {\n super(device, props);\n this.device = device;\n\n if (props.depthStencilAttachment) {\n this.depthStencilAttachment = this.createDepthStencilTexture(props);\n }\n\n if (props.colorAttachments) {\n this.colorAttachments = props.colorAttachments.map(colorAttachment => this.createColorTexture(this.props, colorAttachment));\n }\n\n if (this.depthStencilAttachment) {\n this.renderPassDescriptor.depthStencilAttachment = {\n view: this.depthStencilAttachment.handle.createView(),\n // Add default clear values\n depthLoadValue: 1.0,\n depthStoreOp: 'store',\n stencilLoadValue: 0,\n stencilStoreOp: 'store',\n }\n }\n\n if (this.colorAttachments.length > 0) {\n this.renderPassDescriptor.colorAttachments = this.colorAttachments.map(colorAttachment => ({\n view: colorAttachment.handle.createView(),\n loadValue: [0.0, 0.0, 0.0, 0.0],\n storeOp: 'store'\n }));\n }\n }\n\n /** Create depth stencil texture */\n private createDepthStencilTexture(props: FramebufferProps): WEBGPUTexture {\n if (props.depthStencilAttachment instanceof WEBGPUTexture) {\n return props.depthStencilAttachment;\n }\n\n if (typeof props.depthStencilAttachment === 'string') {\n return this.device._createTexture({\n id: 'depth-stencil-attachment',\n format: props.depthStencilAttachment,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n private createColorTexture(props: FramebufferProps, texture: Texture | ColorTextureFormat): WEBGPUTexture {\n if (texture instanceof WEBGPUTexture) {\n return texture;\n }\n\n if (typeof texture === 'string') {\n return this.device._createTexture({\n id: 'color-attachment',\n format: texture,\n width: props.width,\n height: props.height,\n usage: Texture.RENDER_ATTACHMENT\n });\n }\n\n throw new Error('type');\n }\n\n /**\n * Create new textures with correct size for all attachments.\n * @note destroys existing textures.\n */\n protected _resizeAttachments(width: number, height: number): void {\n for (let i = 0; i < this.colorAttachments.length; ++i) {\n if (this.colorAttachments[i]) {\n const resizedTexture = this.device._createTexture({...this.colorAttachments[i].props, width, height})\n this.colorAttachments[i].destroy();\n this.colorAttachments[i] = resizedTexture;\n this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();\n }\n }\n\n if (this.depthStencilAttachment) {\n const resizedTexture = this.device._createTexture({...this.depthStencilAttachment.props, width, height})\n this.depthStencilAttachment.destroy();\n this.depthStencilAttachment = resizedTexture;\n this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();\n }\n }\n}\n"],"file":"webgpu-framebuffer.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pass.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,cAAc,EAAY,MAAM,cAAc,CAAC;AAC3E,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAG5C,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU;IACtD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAEtC,sBAAsB;IACtB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAQ;gBAEjC,MAAM,EAAE,YAAY,EAAE,KAAK,GAAE,eAAoB;IAU7D,OAAO;IAEP,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKpD,cAAc,CACZ,MAAM,EAAE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IAAI,CAAQ;gBAEjC,MAAM,EAAE,YAAY,EAAE,KAAK,GAAE,eAAoB;IAU7D,OAAO;IAEP,OAAO,IAAI,IAAI;IAIf,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,2EAA2E;IAC3E,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAQpD,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,MAAM,GAAE,MAAU,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAIP,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAU,GAAG,IAAI;IAIvE,IAAI,CAAC,OAAO,EAAE;QACZ,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;IAmBR,YAAY,IAAI,IAAI;IAKpB,aAAa,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAwBrD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAGxC,aAAa,IAAI,IAAI;IAGrB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAW7C"}
@@ -29,8 +29,14 @@ export default class WebGPURenderPass extends RenderPass {
29
29
  }
30
30
 
31
31
  setBindings(bindings) {
32
- this.pipeline.setBindings(bindings);
33
- this.handle.setBindGroup(0, this.pipeline._getBindGroup());
32
+ var _this$pipeline, _this$pipeline2;
33
+
34
+ (_this$pipeline = this.pipeline) === null || _this$pipeline === void 0 ? void 0 : _this$pipeline.setBindings(bindings);
35
+ const bindGroup = (_this$pipeline2 = this.pipeline) === null || _this$pipeline2 === void 0 ? void 0 : _this$pipeline2._getBindGroup();
36
+
37
+ if (bindGroup) {
38
+ this.handle.setBindGroup(0, bindGroup);
39
+ }
34
40
  }
35
41
 
36
42
  setIndexBuffer(buffer, indexFormat, offset = 0, size) {
@@ -45,7 +51,7 @@ export default class WebGPURenderPass extends RenderPass {
45
51
  if (options.indexCount) {
46
52
  this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
47
53
  } else {
48
- this.handle.draw(options.vertexCount, options.instanceCount, options.firstIndex, options.firstInstance);
54
+ this.handle.draw(options.vertexCount || 0, options.instanceCount, options.firstIndex, options.firstInstance);
49
55
  }
50
56
  }
51
57
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","endPass","setPipeline","pipeline","setBindings","bindings","setBindGroup","_getBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AACA,SAAgBA,UAAhB,EAA4CC,IAA5C,QAA4D,cAA5D;AAMA,eAAe,MAAMC,gBAAN,SAA+BF,UAA/B,CAA0C;AAOvDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAsB,GAAG,EAAhD,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA,sCAFvB,IAEuB;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,UAAME,WAAW,GAAGD,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,EAA2B;AACvC,SAAKzC,MAAL,CAAYwC,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAK1C,MAAL,CAAY0C,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK5C,MAAL,CAAY2C,iBAAZ,CAA8BC,WAA9B;AACD;;AA/GsD","sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast, log} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline.setBindings(bindings);\n this.handle.setBindGroup(0, this.pipeline._getBindGroup());\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,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"file":"webgpu-render-pass.js"}
1
+ {"version":3,"sources":["../../../src/adapter/resources/webgpu-render-pass.ts"],"names":["RenderPass","cast","WebGPURenderPass","constructor","device","props","framebuffer","canvasContext","getCurrentFramebuffer","renderPassDescriptor","handle","commandEncoder","beginRenderPass","label","id","destroy","endPass","setPipeline","pipeline","setBindings","bindings","bindGroup","_getBindGroup","setBindGroup","setIndexBuffer","buffer","indexFormat","offset","size","setVertexBuffer","slot","draw","options","indexCount","drawIndexed","instanceCount","firstIndex","baseVertex","firstInstance","vertexCount","drawIndirect","setParameters","parameters","blendConstant","stencilReference","scissorRect","viewport","setBlendConstant","setStencilReference","setScissorRect","setViewport","pushDebugGroup","groupLabel","popDebugGroup","insertDebugMarker","markerLabel"],"mappings":";AACA,SAAgBA,UAAhB,EAA4CC,IAA5C,QAA4D,cAA5D;AAMA,eAAe,MAAMC,gBAAN,SAA+BF,UAA/B,CAA0C;AAOvDG,EAAAA,WAAW,CAACC,MAAD,EAAuBC,KAAsB,GAAG,EAAhD,EAAoD;AAC7D,UAAMD,MAAN,EAAcC,KAAd;;AAD6D;;AAAA;;AAAA,sCAFvB,IAEuB;;AAE7D,SAAKD,MAAL,GAAcA,MAAd;AACA,UAAME,WAAW,GAAGD,KAAK,CAACC,WAAN,IAAqBF,MAAM,CAACG,aAAP,CAAqBC,qBAArB,EAAzC;AAEA,UAAMC,oBAAoB,GAAGH,WAAW,CAACG,oBAAzC;AACA,SAAKC,MAAL,GAAc,KAAKL,KAAL,CAAWK,MAAX,IAAqBN,MAAM,CAACO,cAAP,CAAsBC,eAAtB,CAAsCH,oBAAtC,CAAnC;AACA,SAAKC,MAAL,CAAYG,KAAZ,GAAoB,KAAKR,KAAL,CAAWS,EAA/B;AACD;;AAEDC,EAAAA,OAAO,GAAG,CAAE;;AAEZC,EAAAA,OAAO,GAAS;AACd,SAAKN,MAAL,CAAYM,OAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAiC;AAC1C,SAAKA,QAAL,GAAgBjB,IAAI,C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AS,CAGpB;;AAEDC,EAAAA,aAAa,CAACC,UAAD,EAAyC;AACpD,UAAM;AAACC,MAAAA,aAAD;AAAgBC,MAAAA,gBAAhB;AAAkCC,MAAAA,WAAlC;AAA+CC,MAAAA;AAA/C,QAA2DJ,UAAjE;;AACA,QAAIC,aAAJ,EAAmB;AACjB,WAAKjC,MAAL,CAAYqC,gBAAZ,CAA6BJ,aAA7B;AACD;;AACD,QAAIC,gBAAJ,EAAsB;AACpB,WAAKlC,MAAL,CAAYsC,mBAAZ,CAAgCJ,gBAAhC;AACD;;AACD,QAAIC,WAAJ,EAAiB;AACf,WAAKnC,MAAL,CAAYuC,cAAZ,CAA2BJ,WAAW,CAAC,CAAD,CAAtC,EAA2CA,WAAW,CAAC,CAAD,CAAtD,EAA2DA,WAAW,CAAC,CAAD,CAAtE,EAA2EA,WAAW,CAAC,CAAD,CAAtF;AACD;;AAED,QAAIC,QAAJ,EAAc;AACZ,WAAKpC,MAAL,CAAYwC,WAAZ,CACEJ,QAAQ,CAAC,CAAD,CADV,EAEEA,QAAQ,CAAC,CAAD,CAFV,EAGEA,QAAQ,CAAC,CAAD,CAHV,EAIEA,QAAQ,CAAC,CAAD,CAJV,EAKEA,QAAQ,CAAC,CAAD,CALV,EAMEA,QAAQ,CAAC,CAAD,CANV;AAQD;AACF;;AAEDK,EAAAA,cAAc,CAACC,UAAD,EAA2B;AACvC,SAAK1C,MAAL,CAAYyC,cAAZ,CAA2BC,UAA3B;AACD;;AACDC,EAAAA,aAAa,GAAS;AACpB,SAAK3C,MAAL,CAAY2C,aAAZ;AACD;;AACDC,EAAAA,iBAAiB,CAACC,WAAD,EAA4B;AAC3C,SAAK7C,MAAL,CAAY4C,iBAAZ,CAA8BC,WAA9B;AACD;;AAlHsD","sourcesContent":["import type {RenderPassProps, RenderPassParameters, Binding} from '@luma.gl/api';\nimport {Buffer, RenderPass, RenderPipeline, cast, log} from '@luma.gl/api';\nimport WebGPUDevice from '../webgpu-device';\nimport WebGPUBuffer from './webgpu-buffer';\n// import WebGPUCommandEncoder from './webgpu-command-encoder';\nimport WebGPURenderPipeline from './webgpu-render-pipeline';\n\nexport default class WebGPURenderPass extends RenderPass {\n readonly device: WebGPUDevice;\n readonly handle: GPURenderPassEncoder;\n\n /** Active pipeline */\n pipeline: WebGPURenderPipeline | null = null;\n\n constructor(device: WebGPUDevice, props: RenderPassProps = {}) {\n super(device, props);\n this.device = device;\n const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();\n // @ts-expect-error\n const renderPassDescriptor = framebuffer.renderPassDescriptor;\n this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);\n this.handle.label = this.props.id;\n }\n\n destroy() {}\n\n endPass(): void {\n this.handle.endPass();\n }\n\n setPipeline(pipeline: RenderPipeline): void {\n this.pipeline = cast<WebGPURenderPipeline>(pipeline);\n this.handle.setPipeline(this.pipeline.handle);\n }\n\n /** Sets an array of bindings (uniform buffers, samplers, textures, ...) */\n setBindings(bindings: Record<string, Binding>): void {\n this.pipeline?.setBindings(bindings);\n const bindGroup = this.pipeline?._getBindGroup();\n if (bindGroup) {\n this.handle.setBindGroup(0, bindGroup);\n }\n }\n\n setIndexBuffer(\n buffer: Buffer,\n indexFormat: GPUIndexFormat,\n offset: number = 0,\n size?: number\n ): void {\n this.handle.setIndexBuffer(cast<WebGPUBuffer>(buffer).handle, indexFormat, offset, size);\n }\n\n setVertexBuffer(slot: number, buffer: Buffer, offset: number = 0): void {\n this.handle.setVertexBuffer(slot, cast<WebGPUBuffer>(buffer).handle, offset);\n }\n\n draw(options: {\n vertexCount?: number;\n indexCount?: number;\n instanceCount?: number;\n firstVertex?: number;\n firstIndex?: number;\n firstInstance?: number;\n baseVertex?: number;\n }): void {\n if (options.indexCount) {\n this.handle.drawIndexed(\n options.indexCount,\n options.instanceCount,\n options.firstIndex,\n options.baseVertex,\n options.firstInstance\n );\n } else {\n this.handle.draw(\n options.vertexCount || 0,\n options.instanceCount,\n options.firstIndex,\n options.firstInstance\n );\n }\n }\n\n drawIndirect(): void {\n // drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n // drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;\n }\n\n setParameters(parameters: RenderPassParameters): void {\n const {blendConstant, stencilReference, scissorRect, viewport} = parameters;\n if (blendConstant) {\n this.handle.setBlendConstant(blendConstant);\n }\n if (stencilReference) {\n this.handle.setStencilReference(stencilReference);\n }\n if (scissorRect) {\n this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);\n }\n // TODO - explain how 3 dimensions vs 2 in WebGL works.\n if (viewport) {\n this.handle.setViewport(\n viewport[0],\n viewport[1],\n viewport[2],\n viewport[3],\n viewport[4],\n viewport[5]\n );\n }\n }\n\n pushDebugGroup(groupLabel: string): void {\n this.handle.pushDebugGroup(groupLabel);\n }\n popDebugGroup(): void {\n this.handle.popDebugGroup();\n }\n insertDebugMarker(markerLabel: string): void {\n this.handle.insertDebugMarker(markerLabel);\n }\n\n // writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;\n // beginOcclusionQuery(queryIndex: number): void;\n // endOcclusionQuery(): void;\n // beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n // endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;\n\n // executeBundles(bundles: Iterable<GPURenderBundle>): void;\n}\n"],"file":"webgpu-render-pass.js"}
@@ -1 +1 @@
1
- {"version":3,"file":"webgpu-render-pipeline.d.ts","sourceRoot":"","sources":["../../../src/adapter/resources/webgpu-render-pipeline.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAS,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AASnG,OAAO,KAAK,YAAY,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,YAAY,MAAM,iBAAiB,C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