@luma.gl/webgpu 9.3.0-alpha.6 → 9.3.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.
- package/dist/adapter/helpers/get-bind-group.d.ts +3 -6
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +11 -14
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts +3 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +17 -12
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.d.ts.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +1 -0
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +3 -13
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +68 -29
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.d.ts +3 -3
- package/dist/adapter/resources/webgpu-compute-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +17 -7
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +7 -9
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +26 -29
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-fence.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-fence.js +9 -1
- package/dist/adapter/resources/webgpu-fence.js.map +1 -1
- package/dist/adapter/resources/webgpu-pipeline-layout.d.ts +1 -1
- package/dist/adapter/resources/webgpu-pipeline-layout.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-pipeline-layout.js +10 -16
- package/dist/adapter/resources/webgpu-pipeline-layout.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +4 -4
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +10 -10
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +10 -9
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +48 -38
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +17 -1
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +8 -1
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +35 -43
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +6 -2
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +60 -18
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +508 -311
- package/dist/dist.min.js +13 -13
- package/dist/index.cjs +439 -319
- package/dist/index.cjs.map +4 -4
- package/dist/wgsl/get-shader-layout-wgsl.d.ts.map +1 -1
- package/dist/wgsl/get-shader-layout-wgsl.js +8 -0
- package/dist/wgsl/get-shader-layout-wgsl.js.map +1 -1
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +18 -27
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +31 -12
- package/src/adapter/helpers/webgpu-parameters.ts +2 -0
- package/src/adapter/resources/webgpu-command-encoder.ts +99 -46
- package/src/adapter/resources/webgpu-compute-pass.ts +35 -8
- package/src/adapter/resources/webgpu-compute-pipeline.ts +43 -30
- package/src/adapter/resources/webgpu-fence.ts +11 -3
- package/src/adapter/resources/webgpu-pipeline-layout.ts +16 -14
- package/src/adapter/resources/webgpu-render-pass.ts +18 -14
- package/src/adapter/resources/webgpu-render-pipeline.ts +68 -46
- package/src/adapter/resources/webgpu-shader.ts +16 -1
- package/src/adapter/resources/webgpu-texture.ts +61 -44
- package/src/adapter/webgpu-device.ts +101 -25
- package/src/wgsl/get-shader-layout-wgsl.ts +9 -0
- package/dist/adapter/helpers/accessor-to-format.d.ts +0 -1
- package/dist/adapter/helpers/accessor-to-format.d.ts.map +0 -1
- package/dist/adapter/helpers/accessor-to-format.js +0 -105
- package/dist/adapter/helpers/accessor-to-format.js.map +0 -1
- package/src/adapter/helpers/accessor-to-format.ts +0 -104
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shader-layout-wgsl.d.ts","sourceRoot":"","sources":["../../src/wgsl/get-shader-layout-wgsl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,YAAY,EAA4B,MAAM,eAAe,CAAC;AAG3F;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"get-shader-layout-wgsl.d.ts","sourceRoot":"","sources":["../../src/wgsl/get-shader-layout-wgsl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,YAAY,EAA4B,MAAM,eAAe,CAAC;AAG3F;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAgFpE"}
|
|
@@ -36,6 +36,14 @@ export function getShaderLayoutFromWGSL(source) {
|
|
|
36
36
|
members
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
for (const storageBuffer of parsedWGSL.storage) {
|
|
40
|
+
shaderLayout.bindings.push({
|
|
41
|
+
type: storageBuffer.access === 'read' ? 'read-only-storage' : 'storage',
|
|
42
|
+
name: storageBuffer.name,
|
|
43
|
+
group: storageBuffer.group,
|
|
44
|
+
location: storageBuffer.binding
|
|
45
|
+
});
|
|
46
|
+
}
|
|
39
47
|
for (const texture of parsedWGSL.textures) {
|
|
40
48
|
const bindingDeclaration = {
|
|
41
49
|
type: 'texture',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shader-layout-wgsl.js","sourceRoot":"","sources":["../../src/wgsl/get-shader-layout-wgsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAA0D,GAAG,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAyB,WAAW,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAc;IACpD,MAAM,YAAY,GAAiB,EAAC,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAC,CAAC;IAElE,IAAI,UAAuB,CAAC;IAC5B,IAAI,CAAC;QACH,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,mBAAmB;QACnB,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YACpD,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;aAC9B,CAAC,CAAC;QACL,CAAC;QAED,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;YACzB,IAAI,EAAE,S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K,KAAK,EAAE,CAAC;QAC/B,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,OAAO,CAAC,CAAC,mBAAmB;IAC3C,CAAC;IAED,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,YAAY,EAAC,CAAC;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgpu",
|
|
3
|
-
"version": "9.3.0-alpha.
|
|
3
|
+
"version": "9.3.0-alpha.9",
|
|
4
4
|
"description": "WebGPU adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@luma.gl/core": "9.
|
|
40
|
+
"@luma.gl/core": "9.3.0-alpha.6"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@probe.gl/env": "^4.1.1",
|
|
44
44
|
"@webgpu/types": "^0.1.69",
|
|
45
45
|
"wgsl_reflect": "^1.2.3"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "737b0f752b3f8a6ae920b394d5ca028427275b37"
|
|
48
48
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import {Buffer, Sampler, Texture, TextureView, log} from '@luma.gl/core';
|
|
5
|
+
import type {Binding, Bindings, ComputeShaderLayout, ShaderLayout} from '@luma.gl/core';
|
|
6
|
+
import {Buffer, Sampler, Texture, TextureView, getShaderLayoutBinding, log} from '@luma.gl/core';
|
|
7
7
|
import type {WebGPUDevice} from '../webgpu-device';
|
|
8
8
|
import type {WebGPUBuffer} from '../resources/webgpu-buffer';
|
|
9
9
|
import type {WebGPUSampler} from '../resources/webgpu-sampler';
|
|
@@ -17,7 +17,7 @@ import type {WebGPUTextureView} from '../resources/webgpu-texture-view';
|
|
|
17
17
|
export function makeBindGroupLayout(
|
|
18
18
|
device: GPUDevice,
|
|
19
19
|
layout: GPUBindGroupLayout,
|
|
20
|
-
bindings:
|
|
20
|
+
bindings: Bindings
|
|
21
21
|
): GPUBindGroupLayout {
|
|
22
22
|
throw new Error('not implemented');
|
|
23
23
|
// return device.createBindGroupLayout({
|
|
@@ -32,10 +32,14 @@ export function makeBindGroupLayout(
|
|
|
32
32
|
export function getBindGroup(
|
|
33
33
|
device: WebGPUDevice,
|
|
34
34
|
bindGroupLayout: GPUBindGroupLayout,
|
|
35
|
-
shaderLayout: ComputeShaderLayout,
|
|
36
|
-
bindings:
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
shaderLayout: ShaderLayout | ComputeShaderLayout,
|
|
36
|
+
bindings: Bindings,
|
|
37
|
+
group: number
|
|
38
|
+
): GPUBindGroup | null {
|
|
39
|
+
const entries = getBindGroupEntries(bindings, shaderLayout, group);
|
|
40
|
+
if (entries.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
39
43
|
device.pushErrorScope('validation');
|
|
40
44
|
const bindGroup = device.handle.createBindGroup({
|
|
41
45
|
layout: bindGroupLayout,
|
|
@@ -47,29 +51,14 @@ export function getBindGroup(
|
|
|
47
51
|
return bindGroup;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
export function getShaderLayoutBinding(
|
|
51
|
-
shaderLayout: ComputeShaderLayout,
|
|
52
|
-
bindingName: string,
|
|
53
|
-
options?: {ignoreWarnings?: boolean}
|
|
54
|
-
): BindingDeclaration | null {
|
|
55
|
-
const bindingLayout = shaderLayout.bindings.find(
|
|
56
|
-
binding =>
|
|
57
|
-
binding.name === bindingName ||
|
|
58
|
-
`${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase()
|
|
59
|
-
);
|
|
60
|
-
if (!bindingLayout && !options?.ignoreWarnings) {
|
|
61
|
-
log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
62
|
-
}
|
|
63
|
-
return bindingLayout || null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
54
|
/**
|
|
67
55
|
* @param bindings
|
|
68
56
|
* @returns
|
|
69
57
|
*/
|
|
70
58
|
function getBindGroupEntries(
|
|
71
|
-
bindings:
|
|
72
|
-
shaderLayout: ComputeShaderLayout
|
|
59
|
+
bindings: Bindings,
|
|
60
|
+
shaderLayout: ShaderLayout | ComputeShaderLayout,
|
|
61
|
+
group: number
|
|
73
62
|
): GPUBindGroupEntry[] {
|
|
74
63
|
const entries: GPUBindGroupEntry[] = [];
|
|
75
64
|
|
|
@@ -81,7 +70,7 @@ function getBindGroupEntries(
|
|
|
81
70
|
|
|
82
71
|
// Mirror the WebGL path: when both `foo` and `fooUniforms` exist in the bindings map,
|
|
83
72
|
// prefer the exact shader binding name and ignore the alias entry.
|
|
84
|
-
if (!isShadowedAlias) {
|
|
73
|
+
if (!isShadowedAlias && bindingLayout?.group === group) {
|
|
85
74
|
const entry = bindingLayout
|
|
86
75
|
? getBindGroupEntry(value, bindingLayout.location, undefined, bindingName)
|
|
87
76
|
: null;
|
|
@@ -95,7 +84,9 @@ function getBindGroupEntries(
|
|
|
95
84
|
ignoreWarnings: true
|
|
96
85
|
});
|
|
97
86
|
const samplerEntry = samplerBindingLayout
|
|
98
|
-
?
|
|
87
|
+
? samplerBindingLayout.group === group
|
|
88
|
+
? getBindGroupEntry(value, samplerBindingLayout.location, {sampler: true}, bindingName)
|
|
89
|
+
: null
|
|
99
90
|
: null;
|
|
100
91
|
if (samplerEntry) {
|
|
101
92
|
entries.push(samplerEntry);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';
|
|
6
|
-
import {log,
|
|
6
|
+
import {log, vertexFormatDecoder} from '@luma.gl/core';
|
|
7
7
|
// import {getAttributeInfosFromLayouts} from '@luma.gl/core';
|
|
8
8
|
|
|
9
9
|
/** Throw error on any WebGL-only vertex formats */
|
|
@@ -23,10 +23,12 @@ function getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {
|
|
|
23
23
|
*/
|
|
24
24
|
export function getVertexBufferLayout(
|
|
25
25
|
shaderLayout: ShaderLayout,
|
|
26
|
-
bufferLayout: BufferLayout[]
|
|
26
|
+
bufferLayout: BufferLayout[],
|
|
27
|
+
options?: {pipelineId?: string}
|
|
27
28
|
): GPUVertexBufferLayout[] {
|
|
28
29
|
const vertexBufferLayouts: GPUVertexBufferLayout[] = [];
|
|
29
30
|
const usedAttributes = new Set<string>();
|
|
31
|
+
const shaderAttributes = shaderLayout.attributes || [];
|
|
30
32
|
|
|
31
33
|
// First handle any buffers mentioned in `bufferLayout`
|
|
32
34
|
for (const mapping of bufferLayout) {
|
|
@@ -44,7 +46,12 @@ export function getVertexBufferLayout(
|
|
|
44
46
|
// const arrayStride = mapping.byteStride; TODO
|
|
45
47
|
for (const attributeMapping of mapping.attributes) {
|
|
46
48
|
const attributeName = attributeMapping.attribute;
|
|
47
|
-
const attributeLayout = findAttributeLayout(
|
|
49
|
+
const attributeLayout = findAttributeLayout(
|
|
50
|
+
shaderLayout,
|
|
51
|
+
attributeName,
|
|
52
|
+
usedAttributes,
|
|
53
|
+
options
|
|
54
|
+
);
|
|
48
55
|
|
|
49
56
|
// @ts-ignore
|
|
50
57
|
const location: number = attributeLayout?.location;
|
|
@@ -59,15 +66,20 @@ export function getVertexBufferLayout(
|
|
|
59
66
|
shaderLocation: location
|
|
60
67
|
});
|
|
61
68
|
|
|
62
|
-
byteStride += getVertexFormatInfo(format).byteLength;
|
|
69
|
+
byteStride += vertexFormatDecoder.getVertexFormatInfo(format).byteLength;
|
|
63
70
|
}
|
|
64
71
|
// non-interleaved mapping (just set offset and stride)
|
|
65
72
|
} else {
|
|
66
|
-
const attributeLayout = findAttributeLayout(
|
|
73
|
+
const attributeLayout = findAttributeLayout(
|
|
74
|
+
shaderLayout,
|
|
75
|
+
mapping.name,
|
|
76
|
+
usedAttributes,
|
|
77
|
+
options
|
|
78
|
+
);
|
|
67
79
|
if (!attributeLayout) {
|
|
68
80
|
continue; // eslint-disable-line no-continue
|
|
69
81
|
}
|
|
70
|
-
byteStride = getVertexFormatInfo(format).byteLength;
|
|
82
|
+
byteStride = vertexFormatDecoder.getVertexFormatInfo(format).byteLength;
|
|
71
83
|
|
|
72
84
|
stepMode =
|
|
73
85
|
attributeLayout.stepMode ||
|
|
@@ -89,10 +101,10 @@ export function getVertexBufferLayout(
|
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
// Add any non-mapped attributes - TODO - avoid hardcoded types
|
|
92
|
-
for (const attribute of
|
|
104
|
+
for (const attribute of shaderAttributes) {
|
|
93
105
|
if (!usedAttributes.has(attribute.name)) {
|
|
94
106
|
vertexBufferLayouts.push({
|
|
95
|
-
arrayStride: getVertexFormatInfo('float32x3').byteLength,
|
|
107
|
+
arrayStride: vertexFormatDecoder.getVertexFormatInfo('float32x3').byteLength,
|
|
96
108
|
stepMode:
|
|
97
109
|
attribute.stepMode || (attribute.name.startsWith('instance') ? 'instance' : 'vertex'),
|
|
98
110
|
attributes: [
|
|
@@ -124,6 +136,7 @@ export function getBufferSlots(
|
|
|
124
136
|
bufferLayout: BufferLayout[]
|
|
125
137
|
): Record<string, number> {
|
|
126
138
|
const usedAttributes = new Set<string>();
|
|
139
|
+
const shaderAttributes = shaderLayout.attributes || [];
|
|
127
140
|
let bufferSlot = 0;
|
|
128
141
|
const bufferSlots: Record<string, number> = {};
|
|
129
142
|
|
|
@@ -142,7 +155,7 @@ export function getBufferSlots(
|
|
|
142
155
|
}
|
|
143
156
|
|
|
144
157
|
// Add any non-mapped attributes
|
|
145
|
-
for (const attribute of
|
|
158
|
+
for (const attribute of shaderAttributes) {
|
|
146
159
|
if (!usedAttributes.has(attribute.name)) {
|
|
147
160
|
bufferSlots[attribute.name] = bufferSlot++;
|
|
148
161
|
}
|
|
@@ -159,11 +172,17 @@ export function getBufferSlots(
|
|
|
159
172
|
function findAttributeLayout(
|
|
160
173
|
shaderLayout: ShaderLayout,
|
|
161
174
|
name: string,
|
|
162
|
-
attributeNames?: Set<string
|
|
175
|
+
attributeNames?: Set<string>,
|
|
176
|
+
options?: {pipelineId?: string}
|
|
163
177
|
): AttributeDeclaration | null {
|
|
164
|
-
const attribute = shaderLayout.attributes
|
|
178
|
+
const attribute = shaderLayout.attributes?.find(attribute_ => attribute_.name === name);
|
|
165
179
|
if (!attribute) {
|
|
166
|
-
|
|
180
|
+
const pipelineContext = options?.pipelineId
|
|
181
|
+
? `RenderPipeline(${options.pipelineId})`
|
|
182
|
+
: 'RenderPipeline';
|
|
183
|
+
log.warn(
|
|
184
|
+
`${pipelineContext}: Ignoring "${name}" attribute, since it is not present in shader layout.`
|
|
185
|
+
)();
|
|
167
186
|
return null;
|
|
168
187
|
}
|
|
169
188
|
if (attributeNames) {
|
|
@@ -65,6 +65,8 @@ export const PARAMETER_TABLE: Record<keyof Parameters, Function> = {
|
|
|
65
65
|
depthStencil.format = value;
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
+
clearDepth: notSupported,
|
|
69
|
+
|
|
68
70
|
depthBias: (_: keyof Parameters, value: any, descriptor: GPURenderPipelineDescriptor) => {
|
|
69
71
|
const depthStencil = addDepthStencil(descriptor);
|
|
70
72
|
depthStencil.depthBias = value;
|
|
@@ -6,10 +6,11 @@ import type {
|
|
|
6
6
|
CommandBufferProps,
|
|
7
7
|
RenderPassProps,
|
|
8
8
|
ComputePassProps,
|
|
9
|
+
CopyBufferToTextureOptions,
|
|
9
10
|
CopyTextureToTextureOptions,
|
|
10
11
|
CopyTextureToBufferOptions
|
|
11
12
|
} from '@luma.gl/core';
|
|
12
|
-
import {CommandEncoder, CommandEncoderProps, Buffer
|
|
13
|
+
import {CommandEncoder, CommandEncoderProps, Buffer} from '@luma.gl/core';
|
|
13
14
|
import {WebGPUDevice} from '../webgpu-device';
|
|
14
15
|
import {WebGPUCommandBuffer} from './webgpu-command-buffer';
|
|
15
16
|
import {WebGPUBuffer} from './webgpu-buffer';
|
|
@@ -58,18 +59,25 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
58
59
|
* @todo need to support a "Framebuffer" equivalent (aka preconfigured RenderPassDescriptors?).
|
|
59
60
|
*/
|
|
60
61
|
beginRenderPass(props: RenderPassProps = {}): WebGPURenderPass {
|
|
61
|
-
return new WebGPURenderPass(
|
|
62
|
+
return new WebGPURenderPass(
|
|
63
|
+
this.device,
|
|
64
|
+
this._applyTimeProfilingToPassProps(props),
|
|
65
|
+
this.handle
|
|
66
|
+
);
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
beginComputePass(props: ComputePassProps = {}): WebGPUComputePass {
|
|
65
|
-
return new WebGPUComputePass(
|
|
70
|
+
return new WebGPUComputePass(
|
|
71
|
+
this.device,
|
|
72
|
+
this._applyTimeProfilingToPassProps(props),
|
|
73
|
+
this.handle
|
|
74
|
+
);
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
69
78
|
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
70
79
|
|
|
71
|
-
copyBufferToBuffer(options:
|
|
72
|
-
{
|
|
80
|
+
copyBufferToBuffer(options: {
|
|
73
81
|
sourceBuffer: Buffer;
|
|
74
82
|
sourceOffset?: number;
|
|
75
83
|
destinationBuffer: Buffer;
|
|
@@ -77,74 +85,119 @@ export class WebGPUCommandEncoder extends CommandEncoder {
|
|
|
77
85
|
size?: number;
|
|
78
86
|
}): void {
|
|
79
87
|
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;
|
|
80
|
-
const
|
|
88
|
+
const webgpuDestinationBuffer = options.destinationBuffer as WebGPUBuffer;
|
|
81
89
|
this.handle.copyBufferToBuffer(
|
|
82
90
|
webgpuSourceBuffer.handle,
|
|
83
91
|
options.sourceOffset ?? 0,
|
|
84
|
-
|
|
92
|
+
webgpuDestinationBuffer.handle,
|
|
85
93
|
options.destinationOffset ?? 0,
|
|
86
94
|
options.size ?? 0
|
|
87
95
|
);
|
|
88
96
|
}
|
|
89
97
|
|
|
90
|
-
copyBufferToTexture(options:
|
|
91
|
-
{
|
|
92
|
-
sourceBuffer: Buffer;
|
|
93
|
-
offset?: number;
|
|
94
|
-
bytesPerRow: number;
|
|
95
|
-
rowsPerImage: number;
|
|
96
|
-
|
|
97
|
-
destinationTexture: Texture;
|
|
98
|
-
mipLevel?: number;
|
|
99
|
-
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
100
|
-
|
|
101
|
-
origin?: number[] | [number, number, number];
|
|
102
|
-
extent?: number[] | [number, number, number];
|
|
103
|
-
}): void {
|
|
98
|
+
copyBufferToTexture(options: CopyBufferToTextureOptions): void {
|
|
104
99
|
const webgpuSourceBuffer = options.sourceBuffer as WebGPUBuffer;
|
|
105
|
-
const
|
|
100
|
+
const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;
|
|
101
|
+
const copyOrigin = options.origin ?? [0, 0, 0];
|
|
102
|
+
const copySize = options.size;
|
|
106
103
|
this.handle.copyBufferToTexture(
|
|
107
104
|
{
|
|
108
105
|
buffer: webgpuSourceBuffer.handle,
|
|
109
|
-
offset: options.
|
|
106
|
+
offset: options.byteOffset ?? 0,
|
|
110
107
|
bytesPerRow: options.bytesPerRow,
|
|
111
108
|
rowsPerImage: options.rowsPerImage
|
|
112
109
|
},
|
|
113
110
|
{
|
|
114
|
-
texture:
|
|
111
|
+
texture: webgpuDestinationTexture.handle,
|
|
115
112
|
mipLevel: options.mipLevel ?? 0,
|
|
116
|
-
origin:
|
|
117
|
-
|
|
113
|
+
origin: {
|
|
114
|
+
x: copyOrigin[0] ?? 0,
|
|
115
|
+
y: copyOrigin[1] ?? 0,
|
|
116
|
+
z: copyOrigin[2] ?? 0
|
|
117
|
+
},
|
|
118
|
+
aspect: options.aspect
|
|
118
119
|
},
|
|
119
120
|
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
depthOrArrayLayers: options.extent?.[2]
|
|
121
|
+
width: copySize[0],
|
|
122
|
+
height: copySize[1],
|
|
123
|
+
depthOrArrayLayers: copySize[2]
|
|
124
124
|
}
|
|
125
125
|
);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
copyTextureToBuffer(options: CopyTextureToBufferOptions): void {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
const {
|
|
130
|
+
sourceTexture,
|
|
131
|
+
destinationBuffer,
|
|
132
|
+
origin = [0, 0, 0],
|
|
133
|
+
byteOffset = 0,
|
|
134
|
+
width,
|
|
135
|
+
height,
|
|
136
|
+
depthOrArrayLayers,
|
|
137
|
+
mipLevel,
|
|
138
|
+
aspect
|
|
139
|
+
} = options;
|
|
140
|
+
const webgpuSourceTexture = sourceTexture as WebGPUTexture;
|
|
141
|
+
webgpuSourceTexture.copyToBuffer(
|
|
142
|
+
this.handle,
|
|
143
|
+
{
|
|
144
|
+
x: origin[0] ?? 0,
|
|
145
|
+
y: origin[1] ?? 0,
|
|
146
|
+
z: origin[2] ?? 0,
|
|
147
|
+
width,
|
|
148
|
+
height,
|
|
149
|
+
depthOrArrayLayers,
|
|
150
|
+
mipLevel,
|
|
151
|
+
aspect,
|
|
152
|
+
byteOffset,
|
|
153
|
+
bytesPerRow: options.bytesPerRow,
|
|
154
|
+
rowsPerImage: options.rowsPerImage
|
|
155
|
+
},
|
|
156
|
+
destinationBuffer
|
|
157
|
+
);
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
copyTextureToTexture(options: CopyTextureToTextureOptions): void {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
const webgpuSourceTexture = options.sourceTexture as WebGPUTexture;
|
|
162
|
+
const webgpuDestinationTexture = options.destinationTexture as WebGPUTexture;
|
|
163
|
+
const sourceRegion = webgpuSourceTexture._normalizeTextureReadOptions({
|
|
164
|
+
x: options.origin?.[0] ?? 0,
|
|
165
|
+
y: options.origin?.[1] ?? 0,
|
|
166
|
+
z: options.origin?.[2] ?? 0,
|
|
167
|
+
width: options.width,
|
|
168
|
+
height: options.height,
|
|
169
|
+
depthOrArrayLayers: options.depthOrArrayLayers,
|
|
170
|
+
mipLevel: options.mipLevel ?? 0,
|
|
171
|
+
aspect: options.aspect ?? 'all'
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
this.handle.copyTextureToTexture(
|
|
175
|
+
{
|
|
176
|
+
texture: webgpuSourceTexture.handle,
|
|
177
|
+
mipLevel: sourceRegion.mipLevel,
|
|
178
|
+
origin: {
|
|
179
|
+
x: sourceRegion.x,
|
|
180
|
+
y: sourceRegion.y,
|
|
181
|
+
z: sourceRegion.z
|
|
182
|
+
},
|
|
183
|
+
aspect: sourceRegion.aspect
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
texture: webgpuDestinationTexture.handle,
|
|
187
|
+
mipLevel: options.destinationMipLevel ?? 0,
|
|
188
|
+
origin: {
|
|
189
|
+
x: options.destinationOrigin?.[0] ?? 0,
|
|
190
|
+
y: options.destinationOrigin?.[1] ?? 0,
|
|
191
|
+
z: options.destinationOrigin?.[2] ?? 0
|
|
192
|
+
},
|
|
193
|
+
aspect: options.destinationAspect ?? sourceRegion.aspect
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
width: sourceRegion.width,
|
|
197
|
+
height: sourceRegion.height,
|
|
198
|
+
depthOrArrayLayers: sourceRegion.depthOrArrayLayers
|
|
199
|
+
}
|
|
200
|
+
);
|
|
148
201
|
}
|
|
149
202
|
|
|
150
203
|
override pushDebugGroup(groupLabel: string): void {
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ComputePass,
|
|
7
|
+
ComputePassProps,
|
|
8
|
+
ComputePipeline,
|
|
9
|
+
Buffer,
|
|
10
|
+
Bindings,
|
|
11
|
+
BindingsByGroup,
|
|
12
|
+
_getDefaultBindGroupFactory
|
|
13
|
+
} from '@luma.gl/core';
|
|
6
14
|
import {WebGPUDevice} from '../webgpu-device';
|
|
7
15
|
import {WebGPUBuffer} from './webgpu-buffer';
|
|
8
16
|
import {WebGPUComputePipeline} from './webgpu-compute-pipeline';
|
|
@@ -14,7 +22,11 @@ export class WebGPUComputePass extends ComputePass {
|
|
|
14
22
|
|
|
15
23
|
_webgpuPipeline: WebGPUComputePipeline | null = null;
|
|
16
24
|
|
|
17
|
-
constructor(
|
|
25
|
+
constructor(
|
|
26
|
+
device: WebGPUDevice,
|
|
27
|
+
props: ComputePassProps = {},
|
|
28
|
+
commandEncoder: GPUCommandEncoder = device.commandEncoder.handle
|
|
29
|
+
) {
|
|
18
30
|
super(device, props);
|
|
19
31
|
this.device = device;
|
|
20
32
|
const {props: computePassProps} = this;
|
|
@@ -35,7 +47,7 @@ export class WebGPUComputePass extends ComputePass {
|
|
|
35
47
|
|
|
36
48
|
this.handle =
|
|
37
49
|
this.props.handle ||
|
|
38
|
-
|
|
50
|
+
commandEncoder.beginComputePass({
|
|
39
51
|
label: this.props.id,
|
|
40
52
|
timestampWrites
|
|
41
53
|
});
|
|
@@ -58,17 +70,32 @@ export class WebGPUComputePass extends ComputePass {
|
|
|
58
70
|
const wgpuPipeline = pipeline as WebGPUComputePipeline;
|
|
59
71
|
this.handle.setPipeline(wgpuPipeline.handle);
|
|
60
72
|
this._webgpuPipeline = wgpuPipeline;
|
|
61
|
-
this.
|
|
73
|
+
const bindGroups = _getDefaultBindGroupFactory(this.device).getBindGroups(
|
|
74
|
+
this._webgpuPipeline,
|
|
75
|
+
this._webgpuPipeline._getBindingsByGroupWebGPU(),
|
|
76
|
+
this._webgpuPipeline._getBindGroupCacheKeysWebGPU()
|
|
77
|
+
);
|
|
78
|
+
for (const [group, bindGroup] of Object.entries(bindGroups)) {
|
|
79
|
+
if (bindGroup) {
|
|
80
|
+
this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
/**
|
|
65
86
|
* Sets an array of bindings (uniform buffers, samplers, textures, ...)
|
|
66
87
|
* TODO - still some API confusion - does this method go here or on the pipeline?
|
|
67
88
|
*/
|
|
68
|
-
setBindings(bindings:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
setBindings(bindings: Bindings | BindingsByGroup): void {
|
|
90
|
+
const bindGroups =
|
|
91
|
+
(this._webgpuPipeline &&
|
|
92
|
+
_getDefaultBindGroupFactory(this.device).getBindGroups(this._webgpuPipeline, bindings)) ||
|
|
93
|
+
{};
|
|
94
|
+
for (const [group, bindGroup] of Object.entries(bindGroups)) {
|
|
95
|
+
if (bindGroup) {
|
|
96
|
+
this.handle.setBindGroup(Number(group), bindGroup as GPUBindGroup);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
72
99
|
}
|
|
73
100
|
|
|
74
101
|
/**
|
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
ComputePipeline,
|
|
7
|
+
ComputePipelineProps,
|
|
8
|
+
Bindings,
|
|
9
|
+
BindingsByGroup,
|
|
10
|
+
_getDefaultBindGroupFactory,
|
|
11
|
+
normalizeBindingsByGroup
|
|
12
|
+
} from '@luma.gl/core';
|
|
7
13
|
import {WebGPUDevice} from '../webgpu-device';
|
|
8
14
|
import {WebGPUShader} from './webgpu-shader';
|
|
9
15
|
|
|
10
|
-
const
|
|
16
|
+
const EMPTY_BIND_GROUPS: BindingsByGroup = {};
|
|
11
17
|
|
|
12
18
|
// COMPUTE PIPELINE
|
|
13
19
|
|
|
@@ -16,11 +22,8 @@ export class WebGPUComputePipeline extends ComputePipeline {
|
|
|
16
22
|
readonly device: WebGPUDevice;
|
|
17
23
|
readonly handle: GPUComputePipeline;
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
private _bindGroup: GPUBindGroup | null = null;
|
|
22
|
-
/** For internal use to create BindGroups */
|
|
23
|
-
private _bindings: Record<string, Binding>;
|
|
25
|
+
private _bindingsByGroup: BindingsByGroup;
|
|
26
|
+
private _bindGroupCacheKeysByGroup: Partial<Record<number, object>>;
|
|
24
27
|
|
|
25
28
|
constructor(device: WebGPUDevice, props: ComputePipelineProps) {
|
|
26
29
|
super(device, props);
|
|
@@ -40,41 +43,51 @@ export class WebGPUComputePipeline extends ComputePipeline {
|
|
|
40
43
|
layout: 'auto'
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
this.
|
|
46
|
+
this._bindingsByGroup = EMPTY_BIND_GROUPS;
|
|
47
|
+
this._bindGroupCacheKeysByGroup = {};
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* @todo Use renderpass.setBindings() ?
|
|
48
52
|
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
49
53
|
*/
|
|
50
|
-
setBindings(bindings:
|
|
51
|
-
|
|
52
|
-
for (const [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
setBindings(bindings: Bindings | BindingsByGroup): void {
|
|
55
|
+
const nextBindingsByGroup = normalizeBindingsByGroup(this.shaderLayout, bindings);
|
|
56
|
+
for (const [groupKey, groupBindings] of Object.entries(nextBindingsByGroup)) {
|
|
57
|
+
const group = Number(groupKey);
|
|
58
|
+
for (const [name, binding] of Object.entries(groupBindings || {})) {
|
|
59
|
+
const currentGroupBindings = this._bindingsByGroup[group] || {};
|
|
60
|
+
if (currentGroupBindings[name] !== binding) {
|
|
61
|
+
if (
|
|
62
|
+
!this._bindingsByGroup[group] ||
|
|
63
|
+
this._bindingsByGroup[group] === currentGroupBindings
|
|
64
|
+
) {
|
|
65
|
+
this._bindingsByGroup[group] = {...currentGroupBindings};
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
this._bindingsByGroup[group][name] = binding;
|
|
68
|
+
this._bindGroupCacheKeysByGroup[group] = {};
|
|
59
69
|
}
|
|
60
|
-
this._bindings[name] = binding;
|
|
61
70
|
}
|
|
62
71
|
}
|
|
63
|
-
if (bindingsChanged) {
|
|
64
|
-
this._bindGroup = null;
|
|
65
|
-
}
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
_getBindGroups(
|
|
75
|
+
bindings?: Bindings | BindingsByGroup,
|
|
76
|
+
bindGroupCacheKeys?: Partial<Record<number, object>>
|
|
77
|
+
): Partial<Record<number, unknown>> {
|
|
78
|
+
const hasExplicitBindings = Boolean(bindings);
|
|
79
|
+
return _getDefaultBindGroupFactory(this.device).getBindGroups(
|
|
80
|
+
this,
|
|
81
|
+
hasExplicitBindings ? bindings : this._bindingsByGroup,
|
|
82
|
+
hasExplicitBindings ? bindGroupCacheKeys : this._bindGroupCacheKeysByGroup
|
|
83
|
+
);
|
|
84
|
+
}
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
getBindGroup(this.device, this._bindGroupLayout, this.shaderLayout, this._bindings);
|
|
86
|
+
_getBindingsByGroupWebGPU(): BindingsByGroup {
|
|
87
|
+
return this._bindingsByGroup;
|
|
88
|
+
}
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
_getBindGroupCacheKeysWebGPU(): Partial<Record<number, object>> {
|
|
91
|
+
return this._bindGroupCacheKeysByGroup;
|
|
79
92
|
}
|
|
80
93
|
}
|