@luma.gl/webgpu 9.2.6 → 9.3.0-alpha.10

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 (137) hide show
  1. package/dist/adapter/helpers/cpu-hotspot-profiler.d.ts +54 -0
  2. package/dist/adapter/helpers/cpu-hotspot-profiler.d.ts.map +1 -0
  3. package/dist/adapter/helpers/cpu-hotspot-profiler.js +26 -0
  4. package/dist/adapter/helpers/cpu-hotspot-profiler.js.map +1 -0
  5. package/dist/adapter/helpers/generate-mipmaps-webgpu.d.ts +7 -0
  6. package/dist/adapter/helpers/generate-mipmaps-webgpu.d.ts.map +1 -0
  7. package/dist/adapter/helpers/generate-mipmaps-webgpu.js +490 -0
  8. package/dist/adapter/helpers/generate-mipmaps-webgpu.js.map +1 -0
  9. package/dist/adapter/helpers/get-bind-group.d.ts +4 -6
  10. package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
  11. package/dist/adapter/helpers/get-bind-group.js +39 -32
  12. package/dist/adapter/helpers/get-bind-group.js.map +1 -1
  13. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +3 -1
  14. package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
  15. package/dist/adapter/helpers/get-vertex-buffer-layout.js +17 -12
  16. package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
  17. package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
  18. package/dist/adapter/helpers/webgpu-parameters.js +1 -0
  19. package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
  20. package/dist/adapter/resources/webgpu-buffer.d.ts +7 -0
  21. package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
  22. package/dist/adapter/resources/webgpu-buffer.js +58 -15
  23. package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
  24. package/dist/adapter/resources/webgpu-command-buffer.js +1 -1
  25. package/dist/adapter/resources/webgpu-command-buffer.js.map +1 -1
  26. package/dist/adapter/resources/webgpu-command-encoder.d.ts +7 -16
  27. package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
  28. package/dist/adapter/resources/webgpu-command-encoder.js +89 -32
  29. package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
  30. package/dist/adapter/resources/webgpu-compute-pass.d.ts +3 -3
  31. package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
  32. package/dist/adapter/resources/webgpu-compute-pass.js +30 -12
  33. package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
  34. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +7 -9
  35. package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
  36. package/dist/adapter/resources/webgpu-compute-pipeline.js +30 -17
  37. package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
  38. package/dist/adapter/resources/webgpu-fence.d.ts +13 -0
  39. package/dist/adapter/resources/webgpu-fence.d.ts.map +1 -0
  40. package/dist/adapter/resources/webgpu-fence.js +33 -0
  41. package/dist/adapter/resources/webgpu-fence.js.map +1 -0
  42. package/dist/adapter/resources/webgpu-framebuffer.d.ts +6 -0
  43. package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
  44. package/dist/adapter/resources/webgpu-framebuffer.js +16 -0
  45. package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
  46. package/dist/adapter/resources/webgpu-pipeline-layout.d.ts +1 -1
  47. package/dist/adapter/resources/webgpu-pipeline-layout.d.ts.map +1 -1
  48. package/dist/adapter/resources/webgpu-pipeline-layout.js +11 -18
  49. package/dist/adapter/resources/webgpu-pipeline-layout.js.map +1 -1
  50. package/dist/adapter/resources/webgpu-query-set.d.ts +33 -4
  51. package/dist/adapter/resources/webgpu-query-set.d.ts.map +1 -1
  52. package/dist/adapter/resources/webgpu-query-set.js +145 -4
  53. package/dist/adapter/resources/webgpu-query-set.js.map +1 -1
  54. package/dist/adapter/resources/webgpu-render-pass.d.ts +6 -3
  55. package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
  56. package/dist/adapter/resources/webgpu-render-pass.js +78 -34
  57. package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
  58. package/dist/adapter/resources/webgpu-render-pipeline.d.ts +14 -10
  59. package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
  60. package/dist/adapter/resources/webgpu-render-pipeline.js +56 -35
  61. package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
  62. package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
  63. package/dist/adapter/resources/webgpu-sampler.js +4 -0
  64. package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
  65. package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
  66. package/dist/adapter/resources/webgpu-shader.js +17 -1
  67. package/dist/adapter/resources/webgpu-shader.js.map +1 -1
  68. package/dist/adapter/resources/webgpu-texture-view.d.ts +6 -0
  69. package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -1
  70. package/dist/adapter/resources/webgpu-texture-view.js +47 -11
  71. package/dist/adapter/resources/webgpu-texture-view.js.map +1 -1
  72. package/dist/adapter/resources/webgpu-texture.d.ts +25 -3
  73. package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
  74. package/dist/adapter/resources/webgpu-texture.js +211 -43
  75. package/dist/adapter/resources/webgpu-texture.js.map +1 -1
  76. package/dist/adapter/resources/webgpu-vertex-array.js +1 -1
  77. package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -1
  78. package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
  79. package/dist/adapter/webgpu-adapter.js +34 -34
  80. package/dist/adapter/webgpu-adapter.js.map +1 -1
  81. package/dist/adapter/webgpu-canvas-context.d.ts +6 -3
  82. package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
  83. package/dist/adapter/webgpu-canvas-context.js +90 -30
  84. package/dist/adapter/webgpu-canvas-context.js.map +1 -1
  85. package/dist/adapter/webgpu-device.d.ts +12 -2
  86. package/dist/adapter/webgpu-device.d.ts.map +1 -1
  87. package/dist/adapter/webgpu-device.js +173 -16
  88. package/dist/adapter/webgpu-device.js.map +1 -1
  89. package/dist/adapter/webgpu-presentation-context.d.ts +25 -0
  90. package/dist/adapter/webgpu-presentation-context.d.ts.map +1 -0
  91. package/dist/adapter/webgpu-presentation-context.js +144 -0
  92. package/dist/adapter/webgpu-presentation-context.js.map +1 -0
  93. package/dist/dist.dev.js +8070 -547
  94. package/dist/dist.min.js +169 -6
  95. package/dist/index.cjs +1929 -410
  96. package/dist/index.cjs.map +4 -4
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +2 -0
  100. package/dist/index.js.map +1 -1
  101. package/dist/wgsl/get-shader-layout-wgsl.d.ts +8 -0
  102. package/dist/wgsl/get-shader-layout-wgsl.d.ts.map +1 -0
  103. package/dist/wgsl/get-shader-layout-wgsl.js +144 -0
  104. package/dist/wgsl/get-shader-layout-wgsl.js.map +1 -0
  105. package/package.json +6 -5
  106. package/src/adapter/helpers/cpu-hotspot-profiler.ts +70 -0
  107. package/src/adapter/helpers/generate-mipmaps-webgpu.ts +583 -0
  108. package/src/adapter/helpers/get-bind-group.ts +52 -46
  109. package/src/adapter/helpers/get-vertex-buffer-layout.ts +31 -12
  110. package/src/adapter/helpers/webgpu-parameters.ts +2 -0
  111. package/src/adapter/resources/webgpu-buffer.ts +61 -15
  112. package/src/adapter/resources/webgpu-command-buffer.ts +1 -1
  113. package/src/adapter/resources/webgpu-command-encoder.ts +129 -50
  114. package/src/adapter/resources/webgpu-compute-pass.ts +48 -13
  115. package/src/adapter/resources/webgpu-compute-pipeline.ts +49 -18
  116. package/src/adapter/resources/webgpu-fence.ts +38 -0
  117. package/src/adapter/resources/webgpu-framebuffer.ts +21 -0
  118. package/src/adapter/resources/webgpu-pipeline-layout.ts +18 -17
  119. package/src/adapter/resources/webgpu-query-set.ts +185 -9
  120. package/src/adapter/resources/webgpu-render-pass.ts +92 -40
  121. package/src/adapter/resources/webgpu-render-pipeline.ts +83 -44
  122. package/src/adapter/resources/webgpu-sampler.ts +5 -0
  123. package/src/adapter/resources/webgpu-shader.ts +16 -1
  124. package/src/adapter/resources/webgpu-texture-view.ts +51 -11
  125. package/src/adapter/resources/webgpu-texture.ts +281 -101
  126. package/src/adapter/resources/webgpu-vertex-array.ts +1 -1
  127. package/src/adapter/webgpu-adapter.ts +40 -42
  128. package/src/adapter/webgpu-canvas-context.ts +107 -40
  129. package/src/adapter/webgpu-device.ts +231 -21
  130. package/src/adapter/webgpu-presentation-context.ts +180 -0
  131. package/src/index.ts +3 -0
  132. package/src/wgsl/get-shader-layout-wgsl.ts +165 -0
  133. package/dist/adapter/helpers/accessor-to-format.d.ts +0 -1
  134. package/dist/adapter/helpers/accessor-to-format.d.ts.map +0 -1
  135. package/dist/adapter/helpers/accessor-to-format.js +0 -105
  136. package/dist/adapter/helpers/accessor-to-format.js.map +0 -1
  137. package/src/adapter/helpers/accessor-to-format.ts +0 -104
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Internal WebGPU CPU hotspot profiler helpers.
3
+ *
4
+ * Keep the profiler key and accessors localized here so the adapter-level
5
+ * instrumentation can be reduced or removed without touching every call site.
6
+ */
7
+ export declare const CPU_HOTSPOT_PROFILER_MODULE = "cpu-hotspot-profiler";
8
+ export declare const CPU_HOTSPOT_SUBMIT_REASON = "cpu-hotspot-submit-reason";
9
+ export type CpuHotspotProfiler = {
10
+ enabled?: boolean;
11
+ framebufferAcquireCount?: number;
12
+ framebufferAcquireTimeMs?: number;
13
+ currentTextureAcquireCount?: number;
14
+ currentTextureAcquireTimeMs?: number;
15
+ activeDefaultFramebufferAcquireDepth?: number;
16
+ defaultFramebufferRenderPassCount?: number;
17
+ explicitFramebufferRenderPassCount?: number;
18
+ renderPassSetupCount?: number;
19
+ renderPassSetupTimeMs?: number;
20
+ renderPassDescriptorAssemblyCount?: number;
21
+ renderPassDescriptorAssemblyTimeMs?: number;
22
+ renderPassBeginCount?: number;
23
+ renderPassBeginTimeMs?: number;
24
+ submitCount?: number;
25
+ submitTimeMs?: number;
26
+ queueSubmitCount?: number;
27
+ queueSubmitTimeMs?: number;
28
+ submitResolveKickoffCount?: number;
29
+ submitResolveKickoffTimeMs?: number;
30
+ commandBufferDestroyCount?: number;
31
+ commandBufferDestroyTimeMs?: number;
32
+ defaultSubmitCount?: number;
33
+ defaultSubmitTimeMs?: number;
34
+ queryReadbackSubmitCount?: number;
35
+ queryReadbackSubmitTimeMs?: number;
36
+ errorScopePushCount?: number;
37
+ errorScopePopCount?: number;
38
+ errorScopeTimeMs?: number;
39
+ textureViewReinitializeCount?: number;
40
+ textureViewReinitializeTimeMs?: number;
41
+ };
42
+ type UserDataOwner = {
43
+ userData: Record<string, unknown>;
44
+ };
45
+ /** Returns the enabled profiler payload attached to a WebGPU userData owner. */
46
+ export declare function getCpuHotspotProfiler(owner: UserDataOwner): CpuHotspotProfiler | null;
47
+ /** Returns the optional submit reason tag used to split submit timing buckets. */
48
+ export declare function getCpuHotspotSubmitReason(owner: UserDataOwner): string | null;
49
+ /** Updates the optional submit reason tag used by the profiler. */
50
+ export declare function setCpuHotspotSubmitReason(owner: UserDataOwner, submitReason: string | undefined): void;
51
+ /** Shared timestamp helper for low-overhead CPU-side instrumentation. */
52
+ export declare function getTimestamp(): number;
53
+ export {};
54
+ //# sourceMappingURL=cpu-hotspot-profiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu-hotspot-profiler.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/cpu-hotspot-profiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,wBAAwB,CAAC,EAAE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ChF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,kBAAkB,GAAG,IAAI,CAGrF;AAED,kFAAkF;AAClF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAE7E;AAED,mEAAmE;AACnE,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,aAAa,EACpB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,IAAI,CAEN;AAED,yEAAyE;AACzE,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Internal WebGPU CPU hotspot profiler helpers.
3
+ *
4
+ * Keep the profiler key and accessors localized here so the adapter-level
5
+ * instrumentation can be reduced or removed without touching every call site.
6
+ */
7
+ export const CPU_HOTSPOT_PROFILER_MODULE = 'cpu-hotspot-profiler';
8
+ export const CPU_HOTSPOT_SUBMIT_REASON = 'cpu-hotspot-submit-reason';
9
+ /** Returns the enabled profiler payload attached to a WebGPU userData owner. */
10
+ export function getCpuHotspotProfiler(owner) {
11
+ const profiler = owner.userData[CPU_HOTSPOT_PROFILER_MODULE];
12
+ return profiler?.enabled ? profiler : null;
13
+ }
14
+ /** Returns the optional submit reason tag used to split submit timing buckets. */
15
+ export function getCpuHotspotSubmitReason(owner) {
16
+ return owner.userData[CPU_HOTSPOT_SUBMIT_REASON] || null;
17
+ }
18
+ /** Updates the optional submit reason tag used by the profiler. */
19
+ export function setCpuHotspotSubmitReason(owner, submitReason) {
20
+ owner.userData[CPU_HOTSPOT_SUBMIT_REASON] = submitReason;
21
+ }
22
+ /** Shared timestamp helper for low-overhead CPU-side instrumentation. */
23
+ export function getTimestamp() {
24
+ return globalThis.performance?.now?.() ?? Date.now();
25
+ }
26
+ //# sourceMappingURL=cpu-hotspot-profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu-hotspot-profiler.js","sourceRoot":"","sources":["../../../src/adapter/helpers/cpu-hotspot-profiler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAwCrE,gFAAgF;AAChF,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,2BAA2B,CAAmC,CAAC;IAC/F,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,yBAAyB,CAAC,KAAoB;IAC5D,OAAQ,KAAK,CAAC,QAAQ,CAAC,yBAAyB,CAAwB,IAAI,IAAI,CAAC;AACnF,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,yBAAyB,CACvC,KAAoB,EACpB,YAAgC;IAEhC,KAAK,CAAC,QAAQ,CAAC,yBAAyB,CAAC,GAAG,YAAY,CAAC;AAC3D,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Texture } from '@luma.gl/core';
2
+ import type { WebGPUDevice } from "../webgpu-device.js";
3
+ /**
4
+ * Generates mip levels from level 0 to the last mip for an existing WebGPU texture.
5
+ */
6
+ export declare function generateMipmapsWebGPU(device: WebGPUDevice, texture: Texture): void;
7
+ //# sourceMappingURL=generate-mipmaps-webgpu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-mipmaps-webgpu.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/generate-mipmaps-webgpu.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,OAAO,EAQR,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AA4CnD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAkBlF"}
@@ -0,0 +1,490 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { Buffer, textureFormatDecoder } from '@luma.gl/core';
5
+ const RENDER_DIMENSIONS = [
6
+ '2d',
7
+ '2d-array',
8
+ 'cube',
9
+ 'cube-array'
10
+ ];
11
+ const WORKGROUP_SIZE = {
12
+ x: 4,
13
+ y: 4,
14
+ z: 4
15
+ };
16
+ const RENDER_SOURCE_SAMPLER_LAYOUT = {
17
+ type: 'sampler',
18
+ name: 'sourceSampler',
19
+ group: 0,
20
+ location: 0
21
+ };
22
+ const COMPUTE_SOURCE_TEXTURE_LAYOUT = {
23
+ type: 'texture',
24
+ name: 'sourceTexture',
25
+ group: 0,
26
+ location: 0,
27
+ viewDimension: '3d',
28
+ sampleType: 'float'
29
+ };
30
+ const COMPUTE_UNIFORMS_LAYOUT = {
31
+ type: 'uniform',
32
+ name: 'uniforms',
33
+ group: 0,
34
+ location: 2
35
+ };
36
+ /**
37
+ * Generates mip levels from level 0 to the last mip for an existing WebGPU texture.
38
+ */
39
+ export function generateMipmapsWebGPU(device, texture) {
40
+ if (texture.mipLevels <= 1) {
41
+ return;
42
+ }
43
+ if (texture.dimension === '3d') {
44
+ generateMipmaps3D(device, texture);
45
+ return;
46
+ }
47
+ if (RENDER_DIMENSIONS.includes(texture.dimension)) {
48
+ generateMipmapsRender(device, texture);
49
+ return;
50
+ }
51
+ throw new Error(`Cannot generate mipmaps for texture dimension "${texture.dimension}" with WebGPU.`);
52
+ }
53
+ function generateMipmapsRender(device, texture) {
54
+ validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');
55
+ const colorAttachmentFormat = getColorAttachmentFormat(texture.format, 'render', texture.dimension);
56
+ const viewDimension = texture.dimension;
57
+ const shaderSource = getRenderMipmapWGSL(viewDimension);
58
+ const sampler = device.createSampler({ minFilter: 'linear', magFilter: 'linear' });
59
+ const uniformsBuffer = device.createBuffer({
60
+ byteLength: 16,
61
+ usage: Buffer.UNIFORM | Buffer.COPY_DST
62
+ });
63
+ const uniformValues = new Uint32Array(1);
64
+ const sourceTextureLayout = {
65
+ type: 'texture',
66
+ name: 'sourceTexture',
67
+ group: 0,
68
+ location: 1,
69
+ viewDimension,
70
+ sampleType: 'float'
71
+ };
72
+ const uniformsLayout = {
73
+ type: 'uniform',
74
+ name: 'uniforms',
75
+ group: 0,
76
+ location: 2
77
+ };
78
+ const renderShaderLayout = {
79
+ attributes: [],
80
+ bindings: [RENDER_SOURCE_SAMPLER_LAYOUT, sourceTextureLayout, uniformsLayout]
81
+ };
82
+ const vertexShader = device.createShader({
83
+ id: 'mipmap-generation-render-vs',
84
+ source: shaderSource,
85
+ language: 'wgsl',
86
+ stage: 'vertex'
87
+ });
88
+ const fragmentShader = device.createShader({
89
+ id: 'mipmap-generation-render-fs',
90
+ source: shaderSource,
91
+ language: 'wgsl',
92
+ stage: 'fragment'
93
+ });
94
+ const renderPipeline = device.createRenderPipeline({
95
+ id: `mipmap-generation-render:${texture.dimension}:${texture.format}`,
96
+ vs: vertexShader,
97
+ fs: fragmentShader,
98
+ shaderLayout: renderShaderLayout,
99
+ colorAttachmentFormats: [colorAttachmentFormat],
100
+ topology: 'triangle-list'
101
+ });
102
+ let sourceWidth = texture.width;
103
+ let sourceHeight = texture.height;
104
+ const layerCount = texture.dimension === '2d' ? 1 : texture.depth;
105
+ function renderMipmapLayer(sourceView, baseMipLevel, baseArrayLayer, destinationWidth, destinationHeight) {
106
+ uniformValues[0] = baseArrayLayer;
107
+ uniformsBuffer.write(uniformValues);
108
+ const destinationView = texture.createView({
109
+ dimension: '2d',
110
+ baseMipLevel,
111
+ mipLevelCount: 1,
112
+ baseArrayLayer,
113
+ arrayLayerCount: 1
114
+ });
115
+ const framebuffer = device.createFramebuffer({
116
+ colorAttachments: [destinationView]
117
+ });
118
+ const renderPass = device.beginRenderPass({
119
+ id: `mipmap-generation:${texture.format}:${baseMipLevel}:${baseArrayLayer}`,
120
+ framebuffer
121
+ });
122
+ try {
123
+ renderPass.setPipeline(renderPipeline);
124
+ renderPass.setBindings({
125
+ sourceSampler: sampler,
126
+ sourceTexture: sourceView,
127
+ uniforms: uniformsBuffer
128
+ });
129
+ renderPass.setParameters({
130
+ viewport: [0, 0, destinationWidth, destinationHeight, 0, 1],
131
+ scissorRect: [0, 0, destinationWidth, destinationHeight]
132
+ });
133
+ renderPass.draw({ vertexCount: 3 });
134
+ renderPass.end();
135
+ device.submit();
136
+ }
137
+ finally {
138
+ destinationView.destroy();
139
+ framebuffer.destroy();
140
+ }
141
+ }
142
+ try {
143
+ for (let baseMipLevel = 1; baseMipLevel < texture.mipLevels; ++baseMipLevel) {
144
+ validateFormatCapabilities(device, texture, ['render', 'filter'], 'render');
145
+ const sourceMipLevel = baseMipLevel - 1;
146
+ const destinationWidth = Math.max(1, sourceWidth >> 1);
147
+ const destinationHeight = Math.max(1, sourceHeight >> 1);
148
+ const sourceView = texture.createView({
149
+ dimension: viewDimension,
150
+ baseMipLevel: sourceMipLevel,
151
+ mipLevelCount: 1,
152
+ baseArrayLayer: 0,
153
+ arrayLayerCount: texture.depth
154
+ });
155
+ try {
156
+ for (let baseArrayLayer = 0; baseArrayLayer < layerCount; ++baseArrayLayer) {
157
+ renderMipmapLayer(sourceView, baseMipLevel, baseArrayLayer, destinationWidth, destinationHeight);
158
+ }
159
+ }
160
+ finally {
161
+ sourceView.destroy();
162
+ }
163
+ sourceWidth = destinationWidth;
164
+ sourceHeight = destinationHeight;
165
+ }
166
+ }
167
+ finally {
168
+ renderPipeline.destroy();
169
+ vertexShader.destroy();
170
+ fragmentShader.destroy();
171
+ sampler.destroy();
172
+ uniformsBuffer.destroy();
173
+ }
174
+ }
175
+ function getColorAttachmentFormat(format, path, dimension) {
176
+ if (textureFormatDecoder.isColor(format)) {
177
+ return format;
178
+ }
179
+ throw new Error(`Cannot run ${path} mipmap generation for ${dimension} texture with format "${format}". ` +
180
+ `Only color textures can be used for this operation. ` +
181
+ `Required capabilities: color. ` +
182
+ `Actual capabilities: color=false.`);
183
+ }
184
+ function generateMipmaps3D(device, texture) {
185
+ validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');
186
+ const format = getColorAttachmentFormat(texture.format, 'compute', texture.dimension);
187
+ const shaderSource = get3DComputeMipmapWGSL(format);
188
+ const destinationTextureLayout = {
189
+ type: 'storage',
190
+ name: 'destinationTexture',
191
+ group: 0,
192
+ location: 1,
193
+ format,
194
+ viewDimension: '3d',
195
+ access: 'write-only'
196
+ };
197
+ const computeShaderLayout = {
198
+ bindings: [COMPUTE_SOURCE_TEXTURE_LAYOUT, destinationTextureLayout, COMPUTE_UNIFORMS_LAYOUT]
199
+ };
200
+ const computeShader = device.createShader({
201
+ id: 'mipmap-generation-compute',
202
+ source: shaderSource,
203
+ language: 'wgsl',
204
+ stage: 'compute'
205
+ });
206
+ const computePipeline = device.createComputePipeline({
207
+ id: `mipmap-generation-compute:${texture.format}`,
208
+ shader: computeShader,
209
+ shaderLayout: computeShaderLayout
210
+ });
211
+ const uniformsBuffer = device.createBuffer({
212
+ byteLength: 32,
213
+ usage: Buffer.UNIFORM | Buffer.COPY_DST
214
+ });
215
+ const uniformValues = new Uint32Array(8);
216
+ let sourceWidth = texture.width;
217
+ let sourceHeight = texture.height;
218
+ let sourceDepth = texture.depth;
219
+ try {
220
+ for (let destinationMipLevel = 1; destinationMipLevel < texture.mipLevels; ++destinationMipLevel) {
221
+ validateFormatCapabilities(device, texture, ['filter', 'store'], 'compute');
222
+ const destinationWidth = Math.max(1, sourceWidth >> 1);
223
+ const destinationHeight = Math.max(1, sourceHeight >> 1);
224
+ const destinationDepth = Math.max(1, sourceDepth >> 1);
225
+ uniformValues[0] = sourceWidth;
226
+ uniformValues[1] = sourceHeight;
227
+ uniformValues[2] = sourceDepth;
228
+ uniformValues[3] = destinationWidth;
229
+ uniformValues[4] = destinationHeight;
230
+ uniformValues[5] = destinationDepth;
231
+ uniformValues[6] = 0;
232
+ uniformsBuffer.write(uniformValues);
233
+ const sourceView = texture.createView({
234
+ dimension: '3d',
235
+ baseMipLevel: destinationMipLevel - 1,
236
+ mipLevelCount: 1,
237
+ baseArrayLayer: 0,
238
+ arrayLayerCount: 1
239
+ });
240
+ const destinationView = texture.createView({
241
+ dimension: '3d',
242
+ baseMipLevel: destinationMipLevel,
243
+ mipLevelCount: 1,
244
+ baseArrayLayer: 0,
245
+ arrayLayerCount: 1
246
+ });
247
+ computePipeline.setBindings({
248
+ sourceTexture: sourceView,
249
+ destinationTexture: destinationView,
250
+ uniforms: uniformsBuffer
251
+ });
252
+ try {
253
+ const workgroupsX = Math.ceil(destinationWidth / WORKGROUP_SIZE.x);
254
+ const workgroupsY = Math.ceil(destinationHeight / WORKGROUP_SIZE.y);
255
+ const workgroupsZ = Math.ceil(destinationDepth / WORKGROUP_SIZE.z);
256
+ const computePass = device.beginComputePass({});
257
+ computePass.setPipeline(computePipeline);
258
+ computePass.dispatch(workgroupsX, workgroupsY, workgroupsZ);
259
+ computePass.end();
260
+ device.submit();
261
+ }
262
+ finally {
263
+ sourceView.destroy();
264
+ destinationView.destroy();
265
+ }
266
+ sourceWidth = destinationWidth;
267
+ sourceHeight = destinationHeight;
268
+ sourceDepth = destinationDepth;
269
+ }
270
+ }
271
+ finally {
272
+ computePipeline.destroy();
273
+ computeShader.destroy();
274
+ uniformsBuffer.destroy();
275
+ }
276
+ }
277
+ function validateFormatCapabilities(device, texture, requiredCapabilities, path) {
278
+ const { format, dimension } = texture;
279
+ const capabilities = device.getTextureFormatCapabilities(format);
280
+ const missingCapabilities = requiredCapabilities.filter(capability => !capabilities[capability]);
281
+ if (missingCapabilities.length > 0) {
282
+ const required = requiredCapabilities.join(' + ');
283
+ const actual = requiredCapabilities
284
+ .map(capability => `${capability}=${capabilities[capability]}`)
285
+ .join(', ');
286
+ throw new Error(`Cannot run ${path} mipmap generation for ${dimension} texture with format "${format}". ` +
287
+ `Required capabilities: ${required}. ` +
288
+ `Actual capabilities: ${actual}.`);
289
+ }
290
+ }
291
+ function getSourceTextureType(dimension) {
292
+ switch (dimension) {
293
+ case '2d':
294
+ return 'texture_2d<f32>';
295
+ case '2d-array':
296
+ return 'texture_2d_array<f32>';
297
+ case 'cube':
298
+ return 'texture_cube<f32>';
299
+ case 'cube-array':
300
+ return 'texture_cube_array<f32>';
301
+ default:
302
+ throw new Error(`Unsupported render dimension "${dimension}" for mipmap generation.`);
303
+ }
304
+ }
305
+ function getRenderMipmapWGSL(dimension) {
306
+ const sourceSnippet = getRenderMipmapSampleSnippet(dimension);
307
+ return `
308
+ struct MipmapUniforms {
309
+ sourceLayer: u32,
310
+ };
311
+
312
+ fn _touchUniform(uniforms: MipmapUniforms) {
313
+ let unusedSourceLayer = uniforms.sourceLayer;
314
+ }
315
+
316
+ const faceMat = array(
317
+ mat3x3f(
318
+ 0.0, 0.0, -2.0,
319
+ 0.0, -2.0, 0.0,
320
+ 1.0, 1.0, 1.0
321
+ ), // pos-x
322
+ mat3x3f(
323
+ 0.0, 0.0, 2.0,
324
+ 0.0, -2.0, 0.0,
325
+ -1.0, 1.0, -1.0
326
+ ), // neg-x
327
+ mat3x3f(
328
+ 2.0, 0.0, 0.0,
329
+ 0.0, 0.0, 2.0,
330
+ -1.0, 1.0, -1.0
331
+ ), // pos-y
332
+ mat3x3f(
333
+ 2.0, 0.0, 0.0,
334
+ 0.0, 0.0, -2.0,
335
+ -1.0, -1.0, 1.0
336
+ ), // neg-y
337
+ mat3x3f(
338
+ 2.0, 0.0, 0.0,
339
+ 0.0, -2.0, 0.0,
340
+ -1.0, 1.0, 1.0
341
+ ), // pos-z
342
+ mat3x3f(
343
+ -2.0, 0.0, 0.0,
344
+ 0.0, -2.0, 0.0,
345
+ 1.0, 1.0, -1.0
346
+ ) // neg-z
347
+ );
348
+
349
+ struct FragmentInputs {
350
+ @builtin(position) position: vec4f,
351
+ @location(0) texcoord: vec2f
352
+ };
353
+
354
+ struct VertexOutput {
355
+ @builtin(position) position: vec4f,
356
+ @location(0) texcoord: vec2f
357
+ };
358
+
359
+ @group(0) @binding(0) var sourceSampler: sampler;
360
+ @group(0) @binding(1) var sourceTexture: ${getSourceTextureType(dimension)};
361
+ @group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;
362
+
363
+ @vertex
364
+ fn vertexMain(
365
+ @builtin(vertex_index) vertexIndex: u32
366
+ ) -> VertexOutput {
367
+ const positions = array(
368
+ vec2f(-1.0, -1.0),
369
+ vec2f(-1.0, 3.0),
370
+ vec2f( 3.0, -1.0)
371
+ );
372
+
373
+ let xy = positions[vertexIndex];
374
+ return VertexOutput(
375
+ vec4f(xy, 0.0, 1.0),
376
+ xy * vec2f(0.5, -0.5) + vec2f(0.5)
377
+ );
378
+ }
379
+
380
+ @fragment
381
+ fn fragmentMain(fsInput: VertexOutput) -> @location(0) vec4f {
382
+ _touchUniform(uniforms);
383
+ return ${sourceSnippet};
384
+ }
385
+ `;
386
+ }
387
+ function getRenderMipmapSampleSnippet(dimension) {
388
+ const layer = 'uniforms.sourceLayer';
389
+ switch (dimension) {
390
+ case '2d':
391
+ return 'textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, 0.0)';
392
+ case '2d-array':
393
+ return ('textureSampleLevel(sourceTexture, sourceSampler, fsInput.texcoord, ' +
394
+ `i32(${layer}), 0.0)`);
395
+ case 'cube':
396
+ return ('textureSampleLevel(sourceTexture, sourceSampler, ' +
397
+ `faceMat[i32(${layer})] * vec3f(fract(fsInput.texcoord), 1.0), 0.0)`);
398
+ case 'cube-array':
399
+ return ('textureSampleLevel(sourceTexture, sourceSampler, ' +
400
+ `faceMat[i32(${layer} % 6u)] * vec3f(fract(fsInput.texcoord), 1.0), ` +
401
+ `i32(${layer} / 6u), 0.0)`);
402
+ default:
403
+ throw new Error(`Unsupported render dimension "${dimension}" for mipmap generation.`);
404
+ }
405
+ }
406
+ function get3DComputeMipmapWGSL(format) {
407
+ return `
408
+ struct MipmapUniforms {
409
+ sourceWidth: u32,
410
+ sourceHeight: u32,
411
+ sourceDepth: u32,
412
+ destinationWidth: u32,
413
+ destinationHeight: u32,
414
+ destinationDepth: u32,
415
+ padding: u32,
416
+ };
417
+
418
+ @group(0) @binding(0) var sourceTexture: texture_3d<f32>;
419
+ @group(0) @binding(1) var destinationTexture: texture_storage_3d<${format}, write>;
420
+ @group(0) @binding(2) var<uniform> uniforms: MipmapUniforms;
421
+
422
+ @compute @workgroup_size(${WORKGROUP_SIZE.x}, ${WORKGROUP_SIZE.y}, ${WORKGROUP_SIZE.z})
423
+ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
424
+ if (
425
+ id.x >= uniforms.destinationWidth ||
426
+ id.y >= uniforms.destinationHeight ||
427
+ id.z >= uniforms.destinationDepth
428
+ ) {
429
+ return;
430
+ }
431
+
432
+ let sourceBase = id * 2u;
433
+ let sourceX0 = min(sourceBase.x, uniforms.sourceWidth - 1u);
434
+ let sourceY0 = min(sourceBase.y, uniforms.sourceHeight - 1u);
435
+ let sourceZ0 = min(sourceBase.z, uniforms.sourceDepth - 1u);
436
+
437
+ let sourceX1 = min(sourceBase.x + 1u, uniforms.sourceWidth - 1u);
438
+ let sourceY1 = min(sourceBase.y + 1u, uniforms.sourceHeight - 1u);
439
+ let sourceZ1 = min(sourceBase.z + 1u, uniforms.sourceDepth - 1u);
440
+
441
+ var sum = textureLoad(
442
+ sourceTexture,
443
+ vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ0)),
444
+ 0
445
+ );
446
+ sum += textureLoad(
447
+ sourceTexture,
448
+ vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ0)),
449
+ 0
450
+ );
451
+ sum += textureLoad(
452
+ sourceTexture,
453
+ vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ0)),
454
+ 0
455
+ );
456
+ sum += textureLoad(
457
+ sourceTexture,
458
+ vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ0)),
459
+ 0
460
+ );
461
+ sum += textureLoad(
462
+ sourceTexture,
463
+ vec3<i32>(i32(sourceX0), i32(sourceY0), i32(sourceZ1)),
464
+ 0
465
+ );
466
+ sum += textureLoad(
467
+ sourceTexture,
468
+ vec3<i32>(i32(sourceX1), i32(sourceY0), i32(sourceZ1)),
469
+ 0
470
+ );
471
+ sum += textureLoad(
472
+ sourceTexture,
473
+ vec3<i32>(i32(sourceX0), i32(sourceY1), i32(sourceZ1)),
474
+ 0
475
+ );
476
+ sum += textureLoad(
477
+ sourceTexture,
478
+ vec3<i32>(i32(sourceX1), i32(sourceY1), i32(sourceZ1)),
479
+ 0
480
+ );
481
+
482
+ textureStore(
483
+ destinationTexture,
484
+ vec3<i32>(i32(id.x), i32(id.y), i32(id.z)),
485
+ vec4<f32>(sum.xyz / 8.0, sum.w / 8.0)
486
+ );
487
+ }
488
+ `;
489
+ }
490
+ //# sourceMappingURL=generate-mipmaps-webgpu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-mipmaps-webgpu.js","sourceRoot":"","sources":["../../../src/adapter/helpers/generate-mipmaps-webgpu.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAepC,OAAO,EAAC,MAAM,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAS3D,MAAM,iBAAiB,GAA8C;IACnE,IAAI;IACJ,UAAU;IACV,MAAM;IACN,YAAY;CACb,CAAC;AAEF,MAAM,cAAc,GAAG;IACrB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;CACI,CAAC;AAEX,MAAM,4BAA4B,GAAyB;IACzD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,6BAA6B,GAAyB;IAC1D,IAAI,E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AiC,SAAS,0BAA0B,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,MAA0B;IACxD,OAAO;;;;;;;;;;;;mEAY0D,MAAM;;;2BAG9C,cAAc,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEpF,CAAC;AACF,CAAC"}
@@ -1,14 +1,12 @@
1
- import type { ComputeShaderLayout, BindingDeclaration, Binding } from '@luma.gl/core';
1
+ import type { Bindings, ComputeShaderLayout, ShaderLayout } from '@luma.gl/core';
2
+ import type { WebGPUDevice } from "../webgpu-device.js";
2
3
  /**
3
4
  * Create a WebGPU "bind group layout" from an array of luma.gl bindings
4
5
  * @note bind groups can be automatically generated by WebGPU.
5
6
  */
6
- export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Binding[]): GPUBindGroupLayout;
7
+ export declare function makeBindGroupLayout(device: GPUDevice, layout: GPUBindGroupLayout, bindings: Bindings): GPUBindGroupLayout;
7
8
  /**
8
9
  * Create a WebGPU "bind group" from an array of luma.gl bindings
9
10
  */
10
- export declare function getBindGroup(device: GPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ComputeShaderLayout, bindings: Record<string, Binding>): GPUBindGroup;
11
- export declare function getShaderLayoutBinding(shaderLayout: ComputeShaderLayout, bindingName: string, options?: {
12
- ignoreWarnings?: boolean;
13
- }): BindingDeclaration | null;
11
+ export declare function getBindGroup(device: WebGPUDevice, bindGroupLayout: GPUBindGroupLayout, shaderLayout: ShaderLayout | ComputeShaderLayout, bindings: Bindings, group: number): GPUBindGroup | null;
14
12
  //# sourceMappingURL=get-bind-group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAMpF;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,EAAE,GAClB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,mBAAmB,EACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,YAAY,CAad;AAED,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,mBAAmB,EACjC,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAC,GACnC,kBAAkB,GAAG,IAAI,CAU3B"}
1
+ {"version":3,"file":"get-bind-group.d.ts","sourceRoot":"","sources":["../../../src/adapter/helpers/get-bind-group.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAU,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAExF,OAAO,KAAK,EAAC,YAAY,EAAC,4BAAyB;AAMnD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,QAAQ,GACjB,kBAAkB,CAMpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,kBAAkB,EACnC,YAAY,EAAE,YAAY,GAAG,mBAAmB,EAChD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,GACZ,YAAY,GAAG,IAAI,CAcrB"}