@luma.gl/webgpu 9.1.9 → 9.2.0-alpha.2
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/accessor-to-format.js +1 -0
- package/dist/adapter/helpers/accessor-to-format.js.map +1 -1
- package/dist/adapter/helpers/get-bind-group.d.ts +3 -1
- package/dist/adapter/helpers/get-bind-group.d.ts.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +28 -10
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +5 -5
- 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 +89 -75
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.d.ts +13 -16
- package/dist/adapter/resources/webgpu-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +132 -93
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-buffer.d.ts +10 -0
- package/dist/adapter/resources/webgpu-command-buffer.d.ts.map +1 -0
- package/dist/adapter/resources/webgpu-command-buffer.js +18 -0
- package/dist/adapter/resources/webgpu-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgpu-command-encoder.d.ts +12 -5
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +28 -5
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts +2 -2
- package/dist/adapter/resources/webgpu-compute-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.d.ts +2 -2
- package/dist/adapter/resources/webgpu-external-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +3 -2
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +1 -0
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-pipeline-layout.d.ts +2 -2
- package/dist/adapter/resources/webgpu-pipeline-layout.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-pipeline-layout.js +5 -2
- package/dist/adapter/resources/webgpu-pipeline-layout.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +11 -6
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts +5 -4
- package/dist/adapter/resources/webgpu-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +33 -20
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +1 -1
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +7 -8
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture-view.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture-view.js +15 -10
- package/dist/adapter/resources/webgpu-texture-view.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +4 -37
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +97 -126
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.d.ts +2 -2
- package/dist/adapter/resources/webgpu-vertex-array.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-vertex-array.js +2 -2
- package/dist/adapter/resources/webgpu-vertex-array.js.map +1 -1
- package/dist/adapter/webgpu-adapter.d.ts +2 -3
- package/dist/adapter/webgpu-adapter.d.ts.map +1 -1
- package/dist/adapter/webgpu-adapter.js +54 -43
- package/dist/adapter/webgpu-adapter.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +7 -15
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +50 -72
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +16 -27
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +48 -65
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +1919 -1520
- package/dist/dist.min.js +6 -5
- package/dist/index.cjs +1749 -1397
- package/dist/index.cjs.map +4 -4
- package/package.json +3 -3
- package/src/adapter/helpers/get-bind-group.ts +31 -11
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +5 -5
- package/src/adapter/helpers/webgpu-parameters.ts +114 -102
- package/src/adapter/resources/webgpu-buffer.ts +163 -102
- package/src/adapter/resources/webgpu-command-buffer.ts +24 -0
- package/src/adapter/resources/webgpu-command-encoder.ts +34 -4
- package/src/adapter/resources/webgpu-compute-pass.ts +1 -1
- package/src/adapter/resources/webgpu-compute-pipeline.ts +2 -2
- package/src/adapter/resources/webgpu-external-texture.ts +2 -2
- package/src/adapter/resources/webgpu-framebuffer.ts +3 -2
- package/src/adapter/resources/webgpu-pipeline-layout.ts +8 -3
- package/src/adapter/resources/webgpu-render-pass.ts +11 -6
- package/src/adapter/resources/webgpu-render-pipeline.ts +39 -24
- package/src/adapter/resources/webgpu-sampler.ts +1 -1
- package/src/adapter/resources/webgpu-shader.ts +11 -8
- package/src/adapter/resources/webgpu-texture-view.ts +14 -8
- package/src/adapter/resources/webgpu-texture.ts +106 -186
- package/src/adapter/resources/webgpu-vertex-array.ts +2 -2
- package/src/adapter/webgpu-adapter.ts +72 -58
- package/src/adapter/webgpu-canvas-context.ts +62 -82
- package/src/adapter/webgpu-device.ts +66 -105
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
5
9
|
var __export = (target, all) => {
|
|
6
|
-
for (var
|
|
7
|
-
__defProp(target,
|
|
10
|
+
for (var name2 in all)
|
|
11
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
8
12
|
};
|
|
9
13
|
var __copyProps = (to, from, except, desc) => {
|
|
10
14
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -16,95 +20,154 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
20
|
};
|
|
17
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
22
|
|
|
19
|
-
// dist/index.js
|
|
20
|
-
var dist_exports = {};
|
|
21
|
-
__export(dist_exports, {
|
|
22
|
-
WebGPUBuffer: () => WebGPUBuffer,
|
|
23
|
-
WebGPUDevice: () => WebGPUDevice,
|
|
24
|
-
WebGPUSampler: () => WebGPUSampler,
|
|
25
|
-
WebGPUShader: () => WebGPUShader,
|
|
26
|
-
WebGPUTexture: () => WebGPUTexture,
|
|
27
|
-
webgpuAdapter: () => webgpuAdapter
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(dist_exports);
|
|
30
|
-
|
|
31
|
-
// dist/adapter/webgpu-adapter.js
|
|
32
|
-
var import_core20 = require("@luma.gl/core");
|
|
33
|
-
|
|
34
|
-
// dist/adapter/webgpu-device.js
|
|
35
|
-
var import_core19 = require("@luma.gl/core");
|
|
36
|
-
|
|
37
23
|
// dist/adapter/resources/webgpu-buffer.js
|
|
38
|
-
var import_core
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
24
|
+
var import_core, WebGPUBuffer;
|
|
25
|
+
var init_webgpu_buffer = __esm({
|
|
26
|
+
"dist/adapter/resources/webgpu-buffer.js"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
import_core = require("@luma.gl/core");
|
|
29
|
+
WebGPUBuffer = class extends import_core.Buffer {
|
|
30
|
+
device;
|
|
31
|
+
handle;
|
|
32
|
+
byteLength;
|
|
33
|
+
constructor(device, props) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
super(device, props);
|
|
36
|
+
this.device = device;
|
|
37
|
+
this.byteLength = props.byteLength || ((_a = props.data) == null ? void 0 : _a.byteLength) || 0;
|
|
38
|
+
const mappedAtCreation = Boolean(this.props.onMapped || props.data);
|
|
39
|
+
const size = Math.ceil(this.byteLength / 4) * 4;
|
|
40
|
+
this.device.pushErrorScope("out-of-memory");
|
|
41
|
+
this.device.pushErrorScope("validation");
|
|
42
|
+
this.handle = this.props.handle || this.device.handle.createBuffer({
|
|
43
|
+
label: this.props.id,
|
|
44
|
+
// usage defaults to vertex
|
|
45
|
+
usage: this.props.usage || GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
46
|
+
mappedAtCreation,
|
|
47
|
+
size
|
|
48
|
+
});
|
|
49
|
+
this.device.popErrorScope((error) => {
|
|
50
|
+
this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();
|
|
51
|
+
this.device.debug();
|
|
52
|
+
});
|
|
53
|
+
this.device.popErrorScope((error) => {
|
|
54
|
+
this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();
|
|
55
|
+
this.device.debug();
|
|
56
|
+
});
|
|
57
|
+
this.device.pushErrorScope("validation");
|
|
58
|
+
if (props.data || props.onMapped) {
|
|
59
|
+
try {
|
|
60
|
+
const arrayBuffer = this.handle.getMappedRange();
|
|
61
|
+
if (props.data) {
|
|
62
|
+
const typedArray = props.data;
|
|
63
|
+
new typedArray.constructor(arrayBuffer).set(typedArray);
|
|
64
|
+
} else {
|
|
65
|
+
(_b = props.onMapped) == null ? void 0 : _b.call(props, arrayBuffer, "mapped");
|
|
66
|
+
}
|
|
67
|
+
} finally {
|
|
68
|
+
this.handle.unmap();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
this.device.popErrorScope((error) => {
|
|
72
|
+
this.device.reportError(new Error(`${this} creation failed ${error.message}`), this)();
|
|
73
|
+
this.device.debug();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
destroy() {
|
|
77
|
+
var _a;
|
|
78
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
79
|
+
this.handle = null;
|
|
80
|
+
}
|
|
81
|
+
write(data, byteOffset = 0) {
|
|
82
|
+
const arrayBuffer = ArrayBuffer.isView(data) ? data.buffer : data;
|
|
83
|
+
const dataByteOffset = ArrayBuffer.isView(data) ? data.byteOffset : 0;
|
|
84
|
+
this.device.pushErrorScope("validation");
|
|
85
|
+
this.device.handle.queue.writeBuffer(this.handle, byteOffset, arrayBuffer, dataByteOffset, data.byteLength);
|
|
86
|
+
this.device.popErrorScope((error) => {
|
|
87
|
+
this.device.reportError(new Error(`${this}.write() ${error.message}`), this)();
|
|
88
|
+
this.device.debug();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async mapAndWriteAsync(callback, byteOffset = 0, byteLength = this.byteLength - byteOffset) {
|
|
92
|
+
const isMappable = (this.usage & import_core.Buffer.MAP_WRITE) !== 0;
|
|
93
|
+
const mappableBuffer = !isMappable ? this._getMappableBuffer(import_core.Buffer.MAP_WRITE | import_core.Buffer.COPY_SRC, 0, this.byteLength) : null;
|
|
94
|
+
const writeBuffer = mappableBuffer || this;
|
|
95
|
+
this.device.pushErrorScope("validation");
|
|
96
|
+
try {
|
|
97
|
+
await this.device.handle.queue.onSubmittedWorkDone();
|
|
98
|
+
await writeBuffer.handle.mapAsync(GPUMapMode.WRITE, byteOffset, byteLength);
|
|
99
|
+
const arrayBuffer = writeBuffer.handle.getMappedRange(byteOffset, byteLength);
|
|
100
|
+
await callback(arrayBuffer, "mapped");
|
|
101
|
+
writeBuffer.handle.unmap();
|
|
102
|
+
if (mappableBuffer) {
|
|
103
|
+
this._copyBuffer(mappableBuffer, byteOffset, byteLength);
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
this.device.popErrorScope((error) => {
|
|
107
|
+
this.device.reportError(new Error(`${this}.mapAndWriteAsync() ${error.message}`), this)();
|
|
108
|
+
this.device.debug();
|
|
109
|
+
});
|
|
110
|
+
mappableBuffer == null ? void 0 : mappableBuffer.destroy();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async readAsync(byteOffset = 0, byteLength = this.byteLength - byteOffset) {
|
|
114
|
+
return this.mapAndReadAsync((arrayBuffer) => new Uint8Array(arrayBuffer.slice(0)), byteOffset, byteLength);
|
|
115
|
+
}
|
|
116
|
+
async mapAndReadAsync(callback, byteOffset = 0, byteLength = this.byteLength - byteOffset) {
|
|
117
|
+
if (byteOffset % 8 !== 0 || byteLength % 4 !== 0) {
|
|
118
|
+
throw new Error("byteOffset must be multiple of 8 and byteLength multiple of 4");
|
|
119
|
+
}
|
|
120
|
+
if (byteOffset + byteLength > this.handle.size) {
|
|
121
|
+
throw new Error("Mapping range exceeds buffer size");
|
|
122
|
+
}
|
|
123
|
+
const isMappable = (this.usage & import_core.Buffer.MAP_READ) !== 0;
|
|
124
|
+
const mappableBuffer = !isMappable ? this._getMappableBuffer(import_core.Buffer.MAP_READ | import_core.Buffer.COPY_DST, 0, this.byteLength) : null;
|
|
125
|
+
const readBuffer = mappableBuffer || this;
|
|
126
|
+
this.device.pushErrorScope("validation");
|
|
127
|
+
try {
|
|
128
|
+
await this.device.handle.queue.onSubmittedWorkDone();
|
|
129
|
+
if (mappableBuffer) {
|
|
130
|
+
mappableBuffer._copyBuffer(this);
|
|
131
|
+
}
|
|
132
|
+
await readBuffer.handle.mapAsync(GPUMapMode.READ, byteOffset, byteLength);
|
|
133
|
+
const arrayBuffer = readBuffer.handle.getMappedRange(byteOffset, byteLength);
|
|
134
|
+
const result = await callback(arrayBuffer, "mapped");
|
|
135
|
+
readBuffer.handle.unmap();
|
|
136
|
+
return result;
|
|
137
|
+
} finally {
|
|
138
|
+
this.device.popErrorScope((error) => {
|
|
139
|
+
this.device.reportError(new Error(`${this}.mapAndReadAsync() ${error.message}`), this)();
|
|
140
|
+
this.device.debug();
|
|
141
|
+
});
|
|
142
|
+
mappableBuffer == null ? void 0 : mappableBuffer.destroy();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
readSyncWebGL(byteOffset, byteLength) {
|
|
146
|
+
throw new Error("Not implemented");
|
|
147
|
+
}
|
|
148
|
+
// INTERNAL METHODS
|
|
149
|
+
/**
|
|
150
|
+
* @todo - A small set of mappable buffers could be cached on the device,
|
|
151
|
+
* however this goes against the goal of keeping core as a thin GPU API layer.
|
|
152
|
+
*/
|
|
153
|
+
_getMappableBuffer(usage, byteOffset, byteLength) {
|
|
154
|
+
import_core.log.warn(`${this} is not readable, creating a temporary Buffer`);
|
|
155
|
+
const readableBuffer = new WebGPUBuffer(this.device, { usage, byteLength });
|
|
156
|
+
return readableBuffer;
|
|
157
|
+
}
|
|
158
|
+
_copyBuffer(sourceBuffer, byteOffset = 0, byteLength = this.byteLength) {
|
|
159
|
+
this.device.pushErrorScope("validation");
|
|
160
|
+
const commandEncoder = this.device.handle.createCommandEncoder();
|
|
161
|
+
commandEncoder.copyBufferToBuffer(sourceBuffer.handle, byteOffset, this.handle, byteOffset, byteLength);
|
|
162
|
+
this.device.handle.queue.submit([commandEncoder.finish()]);
|
|
163
|
+
this.device.popErrorScope((error) => {
|
|
164
|
+
this.device.reportError(new Error(`${this}._getReadableBuffer() ${error.message}`), this)();
|
|
165
|
+
this.device.debug();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
103
169
|
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// dist/adapter/resources/webgpu-texture.js
|
|
107
|
-
var import_core4 = require("@luma.gl/core");
|
|
170
|
+
});
|
|
108
171
|
|
|
109
172
|
// dist/adapter/helpers/convert-texture-format.js
|
|
110
173
|
function getWebGPUTextureFormat(format) {
|
|
@@ -113,266 +176,298 @@ function getWebGPUTextureFormat(format) {
|
|
|
113
176
|
}
|
|
114
177
|
return format;
|
|
115
178
|
}
|
|
179
|
+
var init_convert_texture_format = __esm({
|
|
180
|
+
"dist/adapter/helpers/convert-texture-format.js"() {
|
|
181
|
+
"use strict";
|
|
182
|
+
}
|
|
183
|
+
});
|
|
116
184
|
|
|
117
185
|
// dist/adapter/resources/webgpu-sampler.js
|
|
118
|
-
var import_core2
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
186
|
+
var import_core2, WebGPUSampler;
|
|
187
|
+
var init_webgpu_sampler = __esm({
|
|
188
|
+
"dist/adapter/resources/webgpu-sampler.js"() {
|
|
189
|
+
"use strict";
|
|
190
|
+
import_core2 = require("@luma.gl/core");
|
|
191
|
+
WebGPUSampler = class extends import_core2.Sampler {
|
|
192
|
+
device;
|
|
193
|
+
handle;
|
|
194
|
+
constructor(device, props) {
|
|
195
|
+
super(device, props);
|
|
196
|
+
this.device = device;
|
|
197
|
+
const samplerDescriptor = {
|
|
198
|
+
...this.props,
|
|
199
|
+
mipmapFilter: void 0
|
|
200
|
+
};
|
|
201
|
+
if (props.type !== "comparison-sampler") {
|
|
202
|
+
delete samplerDescriptor.compare;
|
|
203
|
+
}
|
|
204
|
+
if (props.mipmapFilter && props.mipmapFilter !== "none") {
|
|
205
|
+
samplerDescriptor.mipmapFilter = props.mipmapFilter;
|
|
206
|
+
}
|
|
207
|
+
this.handle = props.handle || this.device.handle.createSampler(samplerDescriptor);
|
|
208
|
+
this.handle.label = this.props.id;
|
|
209
|
+
}
|
|
210
|
+
destroy() {
|
|
211
|
+
this.handle = null;
|
|
212
|
+
}
|
|
128
213
|
};
|
|
129
|
-
if (props.type !== "comparison-sampler") {
|
|
130
|
-
delete samplerDescriptor.compare;
|
|
131
|
-
}
|
|
132
|
-
if (props.mipmapFilter && props.mipmapFilter !== "none") {
|
|
133
|
-
samplerDescriptor.mipmapFilter = props.mipmapFilter;
|
|
134
|
-
}
|
|
135
|
-
this.handle = this.handle || this.device.handle.createSampler(samplerDescriptor);
|
|
136
|
-
this.handle.label = this.props.id;
|
|
137
214
|
}
|
|
138
|
-
|
|
139
|
-
this.handle = null;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
215
|
+
});
|
|
142
216
|
|
|
143
217
|
// dist/adapter/resources/webgpu-texture-view.js
|
|
144
|
-
var import_core3
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
218
|
+
var import_core3, WebGPUTextureView;
|
|
219
|
+
var init_webgpu_texture_view = __esm({
|
|
220
|
+
"dist/adapter/resources/webgpu-texture-view.js"() {
|
|
221
|
+
"use strict";
|
|
222
|
+
import_core3 = require("@luma.gl/core");
|
|
223
|
+
WebGPUTextureView = class extends import_core3.TextureView {
|
|
224
|
+
device;
|
|
225
|
+
handle;
|
|
226
|
+
texture;
|
|
227
|
+
constructor(device, props) {
|
|
228
|
+
super(device, props);
|
|
229
|
+
this.device = device;
|
|
230
|
+
this.texture = props.texture;
|
|
231
|
+
this.device.pushErrorScope("validation");
|
|
232
|
+
this.handle = // props.handle ||
|
|
233
|
+
this.texture.handle.createView({
|
|
234
|
+
format: this.props.format || this.texture.format,
|
|
235
|
+
dimension: this.props.dimension || this.texture.dimension,
|
|
236
|
+
aspect: this.props.aspect,
|
|
237
|
+
baseMipLevel: this.props.baseMipLevel,
|
|
238
|
+
mipLevelCount: this.props.mipLevelCount,
|
|
239
|
+
baseArrayLayer: this.props.baseArrayLayer,
|
|
240
|
+
arrayLayerCount: this.props.arrayLayerCount
|
|
241
|
+
});
|
|
242
|
+
this.device.popErrorScope((error) => {
|
|
243
|
+
this.device.reportError(new Error(`TextureView constructor: ${error.message}`), this)();
|
|
244
|
+
this.device.debug();
|
|
245
|
+
});
|
|
246
|
+
this.handle.label = this.props.id;
|
|
247
|
+
}
|
|
248
|
+
destroy() {
|
|
249
|
+
this.handle = null;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
169
252
|
}
|
|
170
|
-
};
|
|
253
|
+
});
|
|
171
254
|
|
|
172
255
|
// dist/adapter/resources/webgpu-texture.js
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
"
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
256
|
+
var import_core4, WebGPUTexture;
|
|
257
|
+
var init_webgpu_texture = __esm({
|
|
258
|
+
"dist/adapter/resources/webgpu-texture.js"() {
|
|
259
|
+
"use strict";
|
|
260
|
+
import_core4 = require("@luma.gl/core");
|
|
261
|
+
init_convert_texture_format();
|
|
262
|
+
init_webgpu_sampler();
|
|
263
|
+
init_webgpu_texture_view();
|
|
264
|
+
WebGPUTexture = class extends import_core4.Texture {
|
|
265
|
+
device;
|
|
266
|
+
handle;
|
|
267
|
+
sampler;
|
|
268
|
+
view;
|
|
269
|
+
constructor(device, props) {
|
|
270
|
+
super(device, props);
|
|
271
|
+
this.device = device;
|
|
272
|
+
if (this.dimension === "cube") {
|
|
273
|
+
this.depth = 6;
|
|
274
|
+
}
|
|
275
|
+
this.device.pushErrorScope("out-of-memory");
|
|
276
|
+
this.device.pushErrorScope("validation");
|
|
277
|
+
this.handle = this.props.handle || this.device.handle.createTexture({
|
|
278
|
+
label: this.id,
|
|
279
|
+
size: {
|
|
280
|
+
width: this.width,
|
|
281
|
+
height: this.height,
|
|
282
|
+
depthOrArrayLayers: this.depth
|
|
283
|
+
},
|
|
284
|
+
usage: this.props.usage || import_core4.Texture.TEXTURE | import_core4.Texture.COPY_DST,
|
|
285
|
+
dimension: this.baseDimension,
|
|
286
|
+
format: getWebGPUTextureFormat(this.format),
|
|
287
|
+
mipLevelCount: this.mipLevels,
|
|
288
|
+
sampleCount: this.props.samples
|
|
289
|
+
});
|
|
290
|
+
this.device.popErrorScope((error) => {
|
|
291
|
+
this.device.reportError(new Error(`${this} constructor: ${error.message}`), this)();
|
|
292
|
+
this.device.debug();
|
|
293
|
+
});
|
|
294
|
+
this.device.popErrorScope((error) => {
|
|
295
|
+
this.device.reportError(new Error(`${this} out of memory: ${error.message}`), this)();
|
|
296
|
+
this.device.debug();
|
|
297
|
+
});
|
|
298
|
+
if (this.props.handle) {
|
|
299
|
+
this.handle.label ||= this.id;
|
|
300
|
+
this.width = this.handle.width;
|
|
301
|
+
this.height = this.handle.height;
|
|
302
|
+
}
|
|
303
|
+
this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler || {});
|
|
304
|
+
this.view = new WebGPUTextureView(this.device, {
|
|
305
|
+
...this.props,
|
|
306
|
+
texture: this,
|
|
307
|
+
mipLevelCount: this.mipLevels,
|
|
308
|
+
// Note: arrayLayerCount controls the view of array textures, but does not apply to 3d texture depths
|
|
309
|
+
arrayLayerCount: this.dimension !== "3d" ? this.depth : 1
|
|
310
|
+
});
|
|
311
|
+
this._initializeData(props.data);
|
|
211
312
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
flipY
|
|
284
|
-
},
|
|
285
|
-
// destination: GPUImageCopyTextureTagged
|
|
286
|
-
{
|
|
287
|
-
texture: this.handle,
|
|
288
|
-
origin: [x, y, z],
|
|
289
|
-
mipLevel,
|
|
290
|
-
aspect,
|
|
291
|
-
colorSpace,
|
|
292
|
-
premultipliedAlpha
|
|
293
|
-
},
|
|
294
|
-
// copySize: GPUExtent3D
|
|
295
|
-
[width, height, depth]
|
|
296
|
-
);
|
|
297
|
-
return { width, height };
|
|
313
|
+
destroy() {
|
|
314
|
+
var _a;
|
|
315
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
316
|
+
this.handle = null;
|
|
317
|
+
}
|
|
318
|
+
createView(props) {
|
|
319
|
+
return new WebGPUTextureView(this.device, { ...props, texture: this });
|
|
320
|
+
}
|
|
321
|
+
copyImageData(options_) {
|
|
322
|
+
const { width, height, depth } = this;
|
|
323
|
+
const options = this._normalizeCopyImageDataOptions(options_);
|
|
324
|
+
this.device.pushErrorScope("validation");
|
|
325
|
+
this.device.handle.queue.writeTexture(
|
|
326
|
+
// destination: GPUImageCopyTexture
|
|
327
|
+
{
|
|
328
|
+
// texture subresource
|
|
329
|
+
texture: this.handle,
|
|
330
|
+
mipLevel: options.mipLevel,
|
|
331
|
+
aspect: options.aspect,
|
|
332
|
+
// origin to write to
|
|
333
|
+
origin: [options.x, options.y, options.z]
|
|
334
|
+
},
|
|
335
|
+
// data
|
|
336
|
+
options.data,
|
|
337
|
+
// dataLayout: GPUImageDataLayout
|
|
338
|
+
{
|
|
339
|
+
offset: options.byteOffset,
|
|
340
|
+
bytesPerRow: options.bytesPerRow,
|
|
341
|
+
rowsPerImage: options.rowsPerImage
|
|
342
|
+
},
|
|
343
|
+
// size: GPUExtent3D - extents of the content to write
|
|
344
|
+
[width, height, depth]
|
|
345
|
+
);
|
|
346
|
+
this.device.popErrorScope((error) => {
|
|
347
|
+
this.device.reportError(new Error(`copyImageData: ${error.message}`), this)();
|
|
348
|
+
this.device.debug();
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
copyExternalImage(options_) {
|
|
352
|
+
const options = this._normalizeCopyExternalImageOptions(options_);
|
|
353
|
+
this.device.pushErrorScope("validation");
|
|
354
|
+
this.device.handle.queue.copyExternalImageToTexture(
|
|
355
|
+
// source: GPUImageCopyExternalImage
|
|
356
|
+
{
|
|
357
|
+
source: options.image,
|
|
358
|
+
origin: [options.sourceX, options.sourceY],
|
|
359
|
+
flipY: options.flipY
|
|
360
|
+
},
|
|
361
|
+
// destination: GPUImageCopyTextureTagged
|
|
362
|
+
{
|
|
363
|
+
texture: this.handle,
|
|
364
|
+
origin: [options.x, options.y, 0],
|
|
365
|
+
// options.depth],
|
|
366
|
+
mipLevel: options.mipLevel,
|
|
367
|
+
aspect: options.aspect,
|
|
368
|
+
colorSpace: options.colorSpace,
|
|
369
|
+
premultipliedAlpha: options.premultipliedAlpha
|
|
370
|
+
},
|
|
371
|
+
// copySize: GPUExtent3D
|
|
372
|
+
[options.width, options.height, 1]
|
|
373
|
+
);
|
|
374
|
+
this.device.popErrorScope((error) => {
|
|
375
|
+
this.device.reportError(new Error(`copyExternalImage: ${error.message}`), this)();
|
|
376
|
+
this.device.debug();
|
|
377
|
+
});
|
|
378
|
+
return { width: options.width, height: options.height };
|
|
379
|
+
}
|
|
380
|
+
generateMipmapsWebGL() {
|
|
381
|
+
import_core4.log.warn(`${this}: generateMipmaps not supported in WebGPU`)();
|
|
382
|
+
}
|
|
383
|
+
};
|
|
298
384
|
}
|
|
299
|
-
};
|
|
385
|
+
});
|
|
300
386
|
|
|
301
387
|
// dist/adapter/resources/webgpu-external-texture.js
|
|
302
|
-
var import_core5
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
388
|
+
var import_core5, WebGPUExternalTexture;
|
|
389
|
+
var init_webgpu_external_texture = __esm({
|
|
390
|
+
"dist/adapter/resources/webgpu-external-texture.js"() {
|
|
391
|
+
"use strict";
|
|
392
|
+
import_core5 = require("@luma.gl/core");
|
|
393
|
+
init_webgpu_sampler();
|
|
394
|
+
WebGPUExternalTexture = class extends import_core5.ExternalTexture {
|
|
395
|
+
device;
|
|
396
|
+
handle;
|
|
397
|
+
sampler;
|
|
398
|
+
constructor(device, props) {
|
|
399
|
+
super(device, props);
|
|
400
|
+
this.device = device;
|
|
401
|
+
this.handle = this.props.handle || this.device.handle.importExternalTexture({
|
|
402
|
+
source: props.source,
|
|
403
|
+
colorSpace: props.colorSpace
|
|
404
|
+
});
|
|
405
|
+
this.sampler = null;
|
|
406
|
+
}
|
|
407
|
+
destroy() {
|
|
408
|
+
this.handle = null;
|
|
409
|
+
}
|
|
410
|
+
/** Set default sampler */
|
|
411
|
+
setSampler(sampler) {
|
|
412
|
+
this.sampler = sampler instanceof WebGPUSampler ? sampler : new WebGPUSampler(this.device, sampler);
|
|
413
|
+
return this;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
323
416
|
}
|
|
324
|
-
};
|
|
417
|
+
});
|
|
325
418
|
|
|
326
419
|
// dist/adapter/resources/webgpu-shader.js
|
|
327
|
-
var import_core6
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
420
|
+
var import_core6, WebGPUShader;
|
|
421
|
+
var init_webgpu_shader = __esm({
|
|
422
|
+
"dist/adapter/resources/webgpu-shader.js"() {
|
|
423
|
+
"use strict";
|
|
424
|
+
import_core6 = require("@luma.gl/core");
|
|
425
|
+
WebGPUShader = class extends import_core6.Shader {
|
|
426
|
+
device;
|
|
427
|
+
handle;
|
|
428
|
+
constructor(device, props) {
|
|
429
|
+
super(device, props);
|
|
430
|
+
this.device = device;
|
|
431
|
+
const isGLSL = props.source.includes("#version");
|
|
432
|
+
if (this.props.language === "glsl" || isGLSL) {
|
|
433
|
+
throw new Error("GLSL shaders are not supported in WebGPU");
|
|
434
|
+
}
|
|
435
|
+
this.device.pushErrorScope("validation");
|
|
436
|
+
this.handle = this.props.handle || this.device.handle.createShaderModule({ code: props.source });
|
|
437
|
+
this.device.popErrorScope((error) => {
|
|
438
|
+
this.device.reportError(new Error(`${this} creation failed:
|
|
439
|
+
"${error.message}"`), this, this.props.source)();
|
|
440
|
+
this.device.debug();
|
|
441
|
+
});
|
|
442
|
+
this.handle.label = this.props.id;
|
|
443
|
+
this._checkCompilationError();
|
|
344
444
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return compilationInfo.messages;
|
|
445
|
+
get asyncCompilationStatus() {
|
|
446
|
+
return this.getCompilationInfo().then(() => this.compilationStatus);
|
|
447
|
+
}
|
|
448
|
+
async _checkCompilationError() {
|
|
449
|
+
const shaderLog = await this.getCompilationInfo();
|
|
450
|
+
const hasErrors = Boolean(shaderLog.find((msg) => msg.type === "error"));
|
|
451
|
+
this.compilationStatus = hasErrors ? "error" : "success";
|
|
452
|
+
this.debugShader();
|
|
453
|
+
if (this.compilationStatus === "error") {
|
|
454
|
+
this.device.reportError(new Error(`Shader compilation error`), this, shaderLog)();
|
|
455
|
+
this.device.debug();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
destroy() {
|
|
459
|
+
this.handle = null;
|
|
460
|
+
}
|
|
461
|
+
/** Returns compilation info for this shader */
|
|
462
|
+
async getCompilationInfo() {
|
|
463
|
+
const compilationInfo = await this.handle.getCompilationInfo();
|
|
464
|
+
return compilationInfo.messages;
|
|
465
|
+
}
|
|
466
|
+
};
|
|
368
467
|
}
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
// dist/adapter/resources/webgpu-render-pipeline.js
|
|
372
|
-
var import_core10 = require("@luma.gl/core");
|
|
468
|
+
});
|
|
373
469
|
|
|
374
470
|
// dist/adapter/helpers/webgpu-parameters.js
|
|
375
|
-
var import_core7 = require("@luma.gl/core");
|
|
376
471
|
function addDepthStencil(descriptor) {
|
|
377
472
|
descriptor.depthStencil = descriptor.depthStencil || {
|
|
378
473
|
// required, set something
|
|
@@ -393,157 +488,9 @@ function addDepthStencilBack(descriptor) {
|
|
|
393
488
|
const depthStencil = addDepthStencil(descriptor);
|
|
394
489
|
return depthStencil.stencilBack;
|
|
395
490
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
descriptor.primitive = descriptor.primitive || {};
|
|
400
|
-
descriptor.primitive.cullMode = value;
|
|
401
|
-
},
|
|
402
|
-
frontFace: (parameter, value, descriptor) => {
|
|
403
|
-
descriptor.primitive = descriptor.primitive || {};
|
|
404
|
-
descriptor.primitive.frontFace = value;
|
|
405
|
-
},
|
|
406
|
-
// DEPTH
|
|
407
|
-
depthWriteEnabled: (parameter, value, descriptor) => {
|
|
408
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
409
|
-
depthStencil.depthWriteEnabled = value;
|
|
410
|
-
},
|
|
411
|
-
depthCompare: (parameter, value, descriptor) => {
|
|
412
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
413
|
-
depthStencil.depthCompare = value;
|
|
414
|
-
},
|
|
415
|
-
depthFormat: (parameter, value, descriptor) => {
|
|
416
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
417
|
-
depthStencil.format = value;
|
|
418
|
-
},
|
|
419
|
-
depthBias: (parameter, value, descriptor) => {
|
|
420
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
421
|
-
depthStencil.depthBias = value;
|
|
422
|
-
},
|
|
423
|
-
depthBiasSlopeScale: (parameter, value, descriptor) => {
|
|
424
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
425
|
-
depthStencil.depthBiasSlopeScale = value;
|
|
426
|
-
},
|
|
427
|
-
depthBiasClamp: (parameter, value, descriptor) => {
|
|
428
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
429
|
-
depthStencil.depthBiasClamp = value;
|
|
430
|
-
},
|
|
431
|
-
// STENCIL
|
|
432
|
-
stencilReadMask: (parameter, value, descriptor) => {
|
|
433
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
434
|
-
depthStencil.stencilReadMask = value;
|
|
435
|
-
},
|
|
436
|
-
stencilWriteMask: (parameter, value, descriptor) => {
|
|
437
|
-
const depthStencil = addDepthStencil(descriptor);
|
|
438
|
-
depthStencil.stencilWriteMask = value;
|
|
439
|
-
},
|
|
440
|
-
stencilCompare: (parameter, value, descriptor) => {
|
|
441
|
-
const stencilFront = addDepthStencilFront(descriptor);
|
|
442
|
-
const stencilBack = addDepthStencilBack(descriptor);
|
|
443
|
-
stencilFront.compare = value;
|
|
444
|
-
stencilBack.compare = value;
|
|
445
|
-
},
|
|
446
|
-
stencilPassOperation: (parameter, value, descriptor) => {
|
|
447
|
-
const stencilFront = addDepthStencilFront(descriptor);
|
|
448
|
-
const stencilBack = addDepthStencilBack(descriptor);
|
|
449
|
-
stencilFront.passOp = value;
|
|
450
|
-
stencilBack.passOp = value;
|
|
451
|
-
},
|
|
452
|
-
stencilFailOperation: (parameter, value, descriptor) => {
|
|
453
|
-
const stencilFront = addDepthStencilFront(descriptor);
|
|
454
|
-
const stencilBack = addDepthStencilBack(descriptor);
|
|
455
|
-
stencilFront.failOp = value;
|
|
456
|
-
stencilBack.failOp = value;
|
|
457
|
-
},
|
|
458
|
-
stencilDepthFailOperation: (parameter, value, descriptor) => {
|
|
459
|
-
const stencilFront = addDepthStencilFront(descriptor);
|
|
460
|
-
const stencilBack = addDepthStencilBack(descriptor);
|
|
461
|
-
stencilFront.depthFailOp = value;
|
|
462
|
-
stencilBack.depthFailOp = value;
|
|
463
|
-
},
|
|
464
|
-
// MULTISAMPLE
|
|
465
|
-
sampleCount: (parameter, value, descriptor) => {
|
|
466
|
-
descriptor.multisample = descriptor.multisample || {};
|
|
467
|
-
descriptor.multisample.count = value;
|
|
468
|
-
},
|
|
469
|
-
sampleMask: (parameter, value, descriptor) => {
|
|
470
|
-
descriptor.multisample = descriptor.multisample || {};
|
|
471
|
-
descriptor.multisample.mask = value;
|
|
472
|
-
},
|
|
473
|
-
sampleAlphaToCoverageEnabled: (parameter, value, descriptor) => {
|
|
474
|
-
descriptor.multisample = descriptor.multisample || {};
|
|
475
|
-
descriptor.multisample.alphaToCoverageEnabled = value;
|
|
476
|
-
},
|
|
477
|
-
// COLOR
|
|
478
|
-
colorMask: (parameter, value, descriptor) => {
|
|
479
|
-
const targets = addColorState(descriptor);
|
|
480
|
-
targets[0].writeMask = value;
|
|
481
|
-
},
|
|
482
|
-
blendColorOperation: (parameter, value, descriptor) => {
|
|
483
|
-
addColorState(descriptor);
|
|
484
|
-
}
|
|
485
|
-
/*
|
|
486
|
-
blendColorSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {
|
|
487
|
-
addColorState(descriptor);
|
|
488
|
-
targets[0].blend = targets[0].blend || {};
|
|
489
|
-
targets[0].blend.color = targets[0].blend.color || {};
|
|
490
|
-
targets[0].blend.color.srcTarget = value;
|
|
491
|
-
},
|
|
492
|
-
|
|
493
|
-
blendColorDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {
|
|
494
|
-
addColorState(descriptor);
|
|
495
|
-
targets[0].blend = targets[0].blend || {};
|
|
496
|
-
targets[0].blend.color = targets[0].blend.color || {};
|
|
497
|
-
targets[0].blend.color.dstTarget = value;
|
|
498
|
-
},
|
|
499
|
-
|
|
500
|
-
blendAlphaOperation: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {
|
|
501
|
-
addColorState(descriptor);
|
|
502
|
-
targets[0].blend = targets[0].blend || {};
|
|
503
|
-
targets[0].blend.alpha = targets[0].blend.alpha || {};
|
|
504
|
-
targets[0].blend.alpha.operation = value;
|
|
505
|
-
},
|
|
506
|
-
|
|
507
|
-
blendAlphaSrcTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {
|
|
508
|
-
addColorState(descriptor);
|
|
509
|
-
targets[0].blend = targets[0].blend || {};
|
|
510
|
-
targets[0].blend.alpha = targets[0].blend.alpha || {};
|
|
511
|
-
targets[0].blend.alpha.srcTarget = value;
|
|
512
|
-
},
|
|
513
|
-
|
|
514
|
-
blendAlphaDstTarget: (parameter, value, descriptor: GPURenderPipelineDescriptor) => {
|
|
515
|
-
addColorState(descriptor);
|
|
516
|
-
targets[0].blend = targets[0].blend || {};
|
|
517
|
-
targets[0].blend.alpha = targets[0].blend.alpha || {};
|
|
518
|
-
targets[0].blend.alpha.dstTarget = value;
|
|
519
|
-
},
|
|
520
|
-
*/
|
|
521
|
-
};
|
|
522
|
-
var DEFAULT_PIPELINE_DESCRIPTOR = {
|
|
523
|
-
// depthStencil: {
|
|
524
|
-
// stencilFront: {},
|
|
525
|
-
// stencilBack: {},
|
|
526
|
-
// // depthWriteEnabled: true,
|
|
527
|
-
// // depthCompare: 'less',
|
|
528
|
-
// // format: 'depth24plus-stencil8',
|
|
529
|
-
// },
|
|
530
|
-
primitive: {
|
|
531
|
-
cullMode: "back",
|
|
532
|
-
topology: "triangle-list"
|
|
533
|
-
},
|
|
534
|
-
vertex: {
|
|
535
|
-
module: void 0,
|
|
536
|
-
entryPoint: "main"
|
|
537
|
-
},
|
|
538
|
-
fragment: {
|
|
539
|
-
module: void 0,
|
|
540
|
-
entryPoint: "main",
|
|
541
|
-
targets: [
|
|
542
|
-
// { format: props.color0Format || 'bgra8unorm' }
|
|
543
|
-
]
|
|
544
|
-
},
|
|
545
|
-
layout: "auto"
|
|
546
|
-
};
|
|
491
|
+
function notSupported(key, value, descriptor) {
|
|
492
|
+
import_core7.log.warn(`${key} parameter not supported in WebGPU`)();
|
|
493
|
+
}
|
|
547
494
|
function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameters = {}) {
|
|
548
495
|
Object.assign(pipelineDescriptor, { ...DEFAULT_PIPELINE_DESCRIPTOR, ...pipelineDescriptor });
|
|
549
496
|
setParameters(pipelineDescriptor, parameters);
|
|
@@ -551,15 +498,15 @@ function applyParametersToRenderPipelineDescriptor(pipelineDescriptor, parameter
|
|
|
551
498
|
function setParameters(pipelineDescriptor, parameters) {
|
|
552
499
|
for (const [key, value] of Object.entries(parameters)) {
|
|
553
500
|
const setterFunction = PARAMETER_TABLE[key];
|
|
554
|
-
if (
|
|
555
|
-
|
|
556
|
-
|
|
501
|
+
if (setterFunction) {
|
|
502
|
+
setterFunction(key, value, pipelineDescriptor);
|
|
503
|
+
} else {
|
|
504
|
+
import_core7.log.error(`Illegal parameter ${key} in WebGPU`)();
|
|
557
505
|
}
|
|
558
|
-
setterFunction(key, value, pipelineDescriptor);
|
|
559
506
|
}
|
|
560
507
|
}
|
|
561
|
-
function addColorState(descriptor) {
|
|
562
|
-
var _a, _b, _c, _d, _e, _f;
|
|
508
|
+
function addColorState(descriptor, attachment) {
|
|
509
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
563
510
|
descriptor.fragment.targets = ((_a = descriptor.fragment) == null ? void 0 : _a.targets) || [];
|
|
564
511
|
if (!Array.isArray((_b = descriptor.fragment) == null ? void 0 : _b.targets)) {
|
|
565
512
|
import_core7.log.warn("parameters: no targets array")();
|
|
@@ -567,21 +514,199 @@ function addColorState(descriptor) {
|
|
|
567
514
|
if (((_d = (_c = descriptor.fragment) == null ? void 0 : _c.targets) == null ? void 0 : _d.length) === 0) {
|
|
568
515
|
(_e = descriptor.fragment.targets) == null ? void 0 : _e.push({});
|
|
569
516
|
}
|
|
570
|
-
return (_f = descriptor.fragment) == null ? void 0 : _f.targets;
|
|
517
|
+
return (_g = (_f = descriptor.fragment) == null ? void 0 : _f.targets) == null ? void 0 : _g[0];
|
|
571
518
|
}
|
|
519
|
+
function addBlendState(descriptor, attachment) {
|
|
520
|
+
const target = addColorState(descriptor, attachment);
|
|
521
|
+
target.blend = target.blend || { color: {}, alpha: {} };
|
|
522
|
+
return target.blend;
|
|
523
|
+
}
|
|
524
|
+
var import_core7, PARAMETER_TABLE, DEFAULT_PIPELINE_DESCRIPTOR;
|
|
525
|
+
var init_webgpu_parameters = __esm({
|
|
526
|
+
"dist/adapter/helpers/webgpu-parameters.js"() {
|
|
527
|
+
"use strict";
|
|
528
|
+
import_core7 = require("@luma.gl/core");
|
|
529
|
+
PARAMETER_TABLE = {
|
|
530
|
+
// RASTERIZATION PARAMETERS
|
|
531
|
+
cullMode: (_, value, descriptor) => {
|
|
532
|
+
descriptor.primitive = descriptor.primitive || {};
|
|
533
|
+
descriptor.primitive.cullMode = value;
|
|
534
|
+
},
|
|
535
|
+
frontFace: (_, value, descriptor) => {
|
|
536
|
+
descriptor.primitive = descriptor.primitive || {};
|
|
537
|
+
descriptor.primitive.frontFace = value;
|
|
538
|
+
},
|
|
539
|
+
// DEPTH
|
|
540
|
+
depthWriteEnabled: (_, value, descriptor) => {
|
|
541
|
+
if (value) {
|
|
542
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
543
|
+
depthStencil.depthWriteEnabled = value;
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
depthCompare: (_, value, descriptor) => {
|
|
547
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
548
|
+
depthStencil.depthCompare = value;
|
|
549
|
+
},
|
|
550
|
+
depthFormat: (_, value, descriptor) => {
|
|
551
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
552
|
+
depthStencil.format = value;
|
|
553
|
+
},
|
|
554
|
+
depthBias: (_, value, descriptor) => {
|
|
555
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
556
|
+
depthStencil.depthBias = value;
|
|
557
|
+
},
|
|
558
|
+
depthBiasSlopeScale: (_, value, descriptor) => {
|
|
559
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
560
|
+
depthStencil.depthBiasSlopeScale = value;
|
|
561
|
+
},
|
|
562
|
+
depthBiasClamp: (_, value, descriptor) => {
|
|
563
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
564
|
+
depthStencil.depthBiasClamp = value;
|
|
565
|
+
},
|
|
566
|
+
// STENCIL
|
|
567
|
+
stencilReadMask: (_, value, descriptor) => {
|
|
568
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
569
|
+
depthStencil.stencilReadMask = value;
|
|
570
|
+
},
|
|
571
|
+
stencilWriteMask: (_, value, descriptor) => {
|
|
572
|
+
const depthStencil = addDepthStencil(descriptor);
|
|
573
|
+
depthStencil.stencilWriteMask = value;
|
|
574
|
+
},
|
|
575
|
+
stencilCompare: (_, value, descriptor) => {
|
|
576
|
+
const stencilFront = addDepthStencilFront(descriptor);
|
|
577
|
+
const stencilBack = addDepthStencilBack(descriptor);
|
|
578
|
+
stencilFront.compare = value;
|
|
579
|
+
stencilBack.compare = value;
|
|
580
|
+
},
|
|
581
|
+
stencilPassOperation: (_, value, descriptor) => {
|
|
582
|
+
const stencilFront = addDepthStencilFront(descriptor);
|
|
583
|
+
const stencilBack = addDepthStencilBack(descriptor);
|
|
584
|
+
stencilFront.passOp = value;
|
|
585
|
+
stencilBack.passOp = value;
|
|
586
|
+
},
|
|
587
|
+
stencilFailOperation: (_, value, descriptor) => {
|
|
588
|
+
const stencilFront = addDepthStencilFront(descriptor);
|
|
589
|
+
const stencilBack = addDepthStencilBack(descriptor);
|
|
590
|
+
stencilFront.failOp = value;
|
|
591
|
+
stencilBack.failOp = value;
|
|
592
|
+
},
|
|
593
|
+
stencilDepthFailOperation: (_, value, descriptor) => {
|
|
594
|
+
const stencilFront = addDepthStencilFront(descriptor);
|
|
595
|
+
const stencilBack = addDepthStencilBack(descriptor);
|
|
596
|
+
stencilFront.depthFailOp = value;
|
|
597
|
+
stencilBack.depthFailOp = value;
|
|
598
|
+
},
|
|
599
|
+
// MULTISAMPLE
|
|
600
|
+
sampleCount: (_, value, descriptor) => {
|
|
601
|
+
descriptor.multisample = descriptor.multisample || {};
|
|
602
|
+
descriptor.multisample.count = value;
|
|
603
|
+
},
|
|
604
|
+
sampleMask: (_, value, descriptor) => {
|
|
605
|
+
descriptor.multisample = descriptor.multisample || {};
|
|
606
|
+
descriptor.multisample.mask = value;
|
|
607
|
+
},
|
|
608
|
+
sampleAlphaToCoverageEnabled: (_, value, descriptor) => {
|
|
609
|
+
descriptor.multisample = descriptor.multisample || {};
|
|
610
|
+
descriptor.multisample.alphaToCoverageEnabled = value;
|
|
611
|
+
},
|
|
612
|
+
// COLOR
|
|
613
|
+
colorMask: (_, value, descriptor) => {
|
|
614
|
+
const target = addColorState(descriptor, 0);
|
|
615
|
+
target.writeMask = value;
|
|
616
|
+
},
|
|
617
|
+
blend: (_, value, descriptor) => {
|
|
618
|
+
if (value) {
|
|
619
|
+
addBlendState(descriptor, 0);
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
blendColorOperation: (_, value, descriptor) => {
|
|
623
|
+
const blend = addBlendState(descriptor, 0);
|
|
624
|
+
blend.color = blend.color || {};
|
|
625
|
+
blend.color.operation = value;
|
|
626
|
+
},
|
|
627
|
+
blendColorSrcFactor: (_, value, descriptor) => {
|
|
628
|
+
const blend = addBlendState(descriptor, 0);
|
|
629
|
+
blend.color = blend.color || {};
|
|
630
|
+
blend.color.srcFactor = value;
|
|
631
|
+
},
|
|
632
|
+
blendColorDstFactor: (_, value, descriptor) => {
|
|
633
|
+
const blend = addBlendState(descriptor, 0);
|
|
634
|
+
blend.color.dstFactor = value;
|
|
635
|
+
},
|
|
636
|
+
blendAlphaOperation: (_, value, descriptor) => {
|
|
637
|
+
const blend = addBlendState(descriptor, 0);
|
|
638
|
+
blend.alpha = blend.alpha || {};
|
|
639
|
+
blend.alpha.operation = value;
|
|
640
|
+
},
|
|
641
|
+
blendAlphaSrcFactor: (_, value, descriptor) => {
|
|
642
|
+
const blend = addBlendState(descriptor, 0);
|
|
643
|
+
blend.alpha = blend.alpha || {};
|
|
644
|
+
blend.alpha.srcFactor = value;
|
|
645
|
+
},
|
|
646
|
+
blendAlphaDstFactor: (_, value, descriptor) => {
|
|
647
|
+
const blend = addBlendState(descriptor, 0);
|
|
648
|
+
blend.alpha = blend.alpha || {};
|
|
649
|
+
blend.alpha.dstFactor = value;
|
|
650
|
+
},
|
|
651
|
+
unclippedDepth: notSupported,
|
|
652
|
+
provokingVertex: notSupported,
|
|
653
|
+
polygonMode: notSupported,
|
|
654
|
+
polygonOffsetLine: notSupported,
|
|
655
|
+
clipDistance0: notSupported,
|
|
656
|
+
clipDistance1: notSupported,
|
|
657
|
+
clipDistance2: notSupported,
|
|
658
|
+
clipDistance3: notSupported,
|
|
659
|
+
clipDistance4: notSupported,
|
|
660
|
+
clipDistance5: notSupported,
|
|
661
|
+
clipDistance6: notSupported,
|
|
662
|
+
clipDistance7: notSupported
|
|
663
|
+
};
|
|
664
|
+
DEFAULT_PIPELINE_DESCRIPTOR = {
|
|
665
|
+
// depthStencil: {
|
|
666
|
+
// stencilFront: {},
|
|
667
|
+
// stencilBack: {},
|
|
668
|
+
// // depthWriteEnabled: true,
|
|
669
|
+
// // depthCompare: 'less',
|
|
670
|
+
// // format: 'depth24plus-stencil8',
|
|
671
|
+
// },
|
|
672
|
+
primitive: {
|
|
673
|
+
cullMode: "back",
|
|
674
|
+
topology: "triangle-list"
|
|
675
|
+
},
|
|
676
|
+
vertex: {
|
|
677
|
+
module: void 0,
|
|
678
|
+
entryPoint: "main"
|
|
679
|
+
},
|
|
680
|
+
fragment: {
|
|
681
|
+
module: void 0,
|
|
682
|
+
entryPoint: "main",
|
|
683
|
+
targets: [
|
|
684
|
+
// { format: props.color0Format || 'bgra8unorm' }
|
|
685
|
+
]
|
|
686
|
+
},
|
|
687
|
+
layout: "auto"
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
});
|
|
572
691
|
|
|
573
692
|
// dist/adapter/helpers/get-bind-group.js
|
|
574
|
-
var import_core8 = require("@luma.gl/core");
|
|
575
693
|
function getBindGroup(device, bindGroupLayout, shaderLayout, bindings) {
|
|
576
694
|
const entries = getBindGroupEntries(bindings, shaderLayout);
|
|
577
|
-
|
|
695
|
+
device.pushErrorScope("validation");
|
|
696
|
+
const bindGroup = device.createBindGroup({
|
|
578
697
|
layout: bindGroupLayout,
|
|
579
698
|
entries
|
|
580
699
|
});
|
|
700
|
+
device.popErrorScope().then((error) => {
|
|
701
|
+
if (error) {
|
|
702
|
+
import_core8.log.error(`bindGroup creation: ${error.message}`, bindGroup)();
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
return bindGroup;
|
|
581
706
|
}
|
|
582
|
-
function getShaderLayoutBinding(shaderLayout, bindingName) {
|
|
707
|
+
function getShaderLayoutBinding(shaderLayout, bindingName, options) {
|
|
583
708
|
const bindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName || `${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase());
|
|
584
|
-
if (!bindingLayout) {
|
|
709
|
+
if (!bindingLayout && !(options == null ? void 0 : options.ignoreWarnings)) {
|
|
585
710
|
import_core8.log.warn(`Binding ${bindingName} not set: Not found in shader layout.`)();
|
|
586
711
|
}
|
|
587
712
|
return bindingLayout || null;
|
|
@@ -591,11 +716,21 @@ function getBindGroupEntries(bindings, shaderLayout) {
|
|
|
591
716
|
for (const [bindingName, value] of Object.entries(bindings)) {
|
|
592
717
|
let bindingLayout = getShaderLayoutBinding(shaderLayout, bindingName);
|
|
593
718
|
if (bindingLayout) {
|
|
594
|
-
|
|
719
|
+
const entry = getBindGroupEntry(value, bindingLayout.location);
|
|
720
|
+
if (entry) {
|
|
721
|
+
entries.push(entry);
|
|
722
|
+
}
|
|
595
723
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
724
|
+
if (value instanceof import_core8.Texture) {
|
|
725
|
+
bindingLayout = getShaderLayoutBinding(shaderLayout, `${bindingName}Sampler`, {
|
|
726
|
+
ignoreWarnings: true
|
|
727
|
+
});
|
|
728
|
+
if (bindingLayout) {
|
|
729
|
+
const entry = getBindGroupEntry(value, bindingLayout.location, { sampler: true });
|
|
730
|
+
if (entry) {
|
|
731
|
+
entries.push(entry);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
599
734
|
}
|
|
600
735
|
}
|
|
601
736
|
return entries;
|
|
@@ -614,7 +749,8 @@ function getBindGroupEntry(binding, index, options) {
|
|
|
614
749
|
binding: index,
|
|
615
750
|
resource: binding.handle
|
|
616
751
|
};
|
|
617
|
-
}
|
|
752
|
+
}
|
|
753
|
+
if (binding instanceof import_core8.Texture) {
|
|
618
754
|
if (options == null ? void 0 : options.sampler) {
|
|
619
755
|
return {
|
|
620
756
|
binding: index,
|
|
@@ -623,14 +759,21 @@ function getBindGroupEntry(binding, index, options) {
|
|
|
623
759
|
}
|
|
624
760
|
return {
|
|
625
761
|
binding: index,
|
|
626
|
-
resource: binding.handle
|
|
762
|
+
resource: binding.view.handle
|
|
627
763
|
};
|
|
628
764
|
}
|
|
629
|
-
|
|
765
|
+
import_core8.log.warn(`invalid binding ${name}`, binding);
|
|
766
|
+
return null;
|
|
630
767
|
}
|
|
768
|
+
var import_core8;
|
|
769
|
+
var init_get_bind_group = __esm({
|
|
770
|
+
"dist/adapter/helpers/get-bind-group.js"() {
|
|
771
|
+
"use strict";
|
|
772
|
+
import_core8 = require("@luma.gl/core");
|
|
773
|
+
}
|
|
774
|
+
});
|
|
631
775
|
|
|
632
776
|
// dist/adapter/helpers/get-vertex-buffer-layout.js
|
|
633
|
-
var import_core9 = require("@luma.gl/core");
|
|
634
777
|
function getWebGPUVertexFormat(format) {
|
|
635
778
|
if (format.endsWith("-webgl")) {
|
|
636
779
|
throw new Error(`WebGPU does not support vertex format ${format}`);
|
|
@@ -657,14 +800,14 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
657
800
|
offset: attributeMapping.byteOffset,
|
|
658
801
|
shaderLocation: location
|
|
659
802
|
});
|
|
660
|
-
byteStride += (0, import_core9.
|
|
803
|
+
byteStride += (0, import_core9.getVertexFormatInfo)(format).byteLength;
|
|
661
804
|
}
|
|
662
805
|
} else {
|
|
663
806
|
const attributeLayout = findAttributeLayout(shaderLayout, mapping.name, usedAttributes);
|
|
664
807
|
if (!attributeLayout) {
|
|
665
808
|
continue;
|
|
666
809
|
}
|
|
667
|
-
byteStride = (0, import_core9.
|
|
810
|
+
byteStride = (0, import_core9.getVertexFormatInfo)(format).byteLength;
|
|
668
811
|
stepMode = attributeLayout.stepMode || (attributeLayout.name.startsWith("instance") ? "instance" : "vertex");
|
|
669
812
|
vertexAttributes.push({
|
|
670
813
|
format: getWebGPUVertexFormat(format),
|
|
@@ -682,7 +825,7 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
682
825
|
for (const attribute of shaderLayout.attributes) {
|
|
683
826
|
if (!usedAttributes.has(attribute.name)) {
|
|
684
827
|
vertexBufferLayouts.push({
|
|
685
|
-
arrayStride: (0, import_core9.
|
|
828
|
+
arrayStride: (0, import_core9.getVertexFormatInfo)("float32x3").byteLength,
|
|
686
829
|
stepMode: attribute.stepMode || (attribute.name.startsWith("instance") ? "instance" : "vertex"),
|
|
687
830
|
attributes: [
|
|
688
831
|
{
|
|
@@ -701,975 +844,1184 @@ function getVertexBufferLayout(shaderLayout, bufferLayout) {
|
|
|
701
844
|
});
|
|
702
845
|
return vertexBufferLayouts;
|
|
703
846
|
}
|
|
704
|
-
function findAttributeLayout(shaderLayout,
|
|
705
|
-
const attribute = shaderLayout.attributes.find((attribute_) => attribute_.name ===
|
|
847
|
+
function findAttributeLayout(shaderLayout, name2, attributeNames) {
|
|
848
|
+
const attribute = shaderLayout.attributes.find((attribute_) => attribute_.name === name2);
|
|
706
849
|
if (!attribute) {
|
|
707
|
-
import_core9.log.warn(`
|
|
850
|
+
import_core9.log.warn(`Supplied attribute not present in shader layout: ${name2}`)();
|
|
708
851
|
return null;
|
|
709
852
|
}
|
|
710
853
|
if (attributeNames) {
|
|
711
|
-
if (attributeNames.has(
|
|
712
|
-
throw new Error(`Found multiple entries for attribute: ${
|
|
854
|
+
if (attributeNames.has(name2)) {
|
|
855
|
+
throw new Error(`Found multiple entries for attribute: ${name2}`);
|
|
713
856
|
}
|
|
714
|
-
attributeNames.add(
|
|
857
|
+
attributeNames.add(name2);
|
|
715
858
|
}
|
|
716
859
|
return attribute;
|
|
717
860
|
}
|
|
861
|
+
var import_core9;
|
|
862
|
+
var init_get_vertex_buffer_layout = __esm({
|
|
863
|
+
"dist/adapter/helpers/get-vertex-buffer-layout.js"() {
|
|
864
|
+
"use strict";
|
|
865
|
+
import_core9 = require("@luma.gl/core");
|
|
866
|
+
}
|
|
867
|
+
});
|
|
718
868
|
|
|
719
869
|
// dist/adapter/resources/webgpu-render-pipeline.js
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
870
|
+
var import_core10, WebGPURenderPipeline;
|
|
871
|
+
var init_webgpu_render_pipeline = __esm({
|
|
872
|
+
"dist/adapter/resources/webgpu-render-pipeline.js"() {
|
|
873
|
+
"use strict";
|
|
874
|
+
import_core10 = require("@luma.gl/core");
|
|
875
|
+
init_webgpu_parameters();
|
|
876
|
+
init_convert_texture_format();
|
|
877
|
+
init_get_bind_group();
|
|
878
|
+
init_get_vertex_buffer_layout();
|
|
879
|
+
WebGPURenderPipeline = class extends import_core10.RenderPipeline {
|
|
880
|
+
device;
|
|
881
|
+
handle;
|
|
882
|
+
vs;
|
|
883
|
+
fs = null;
|
|
884
|
+
/** For internal use to create BindGroups */
|
|
885
|
+
_bindings;
|
|
886
|
+
_bindGroupLayout = null;
|
|
887
|
+
_bindGroup = null;
|
|
888
|
+
get [Symbol.toStringTag]() {
|
|
889
|
+
return "WebGPURenderPipeline";
|
|
890
|
+
}
|
|
891
|
+
constructor(device, props) {
|
|
892
|
+
super(device, props);
|
|
893
|
+
this.device = device;
|
|
894
|
+
this.handle = this.props.handle;
|
|
895
|
+
if (!this.handle) {
|
|
896
|
+
const descriptor = this._getRenderPipelineDescriptor();
|
|
897
|
+
import_core10.log.groupCollapsed(1, `new WebGPURenderPipeline(${this.id})`)();
|
|
898
|
+
import_core10.log.probe(1, JSON.stringify(descriptor, null, 2))();
|
|
899
|
+
import_core10.log.groupEnd(1)();
|
|
900
|
+
this.device.pushErrorScope("validation");
|
|
901
|
+
this.handle = this.device.handle.createRenderPipeline(descriptor);
|
|
902
|
+
this.device.popErrorScope((error) => {
|
|
903
|
+
this.device.reportError(new Error(`${this} creation failed:
|
|
904
|
+
"${error.message}"`), this)();
|
|
905
|
+
this.device.debug();
|
|
906
|
+
});
|
|
745
907
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
this.fs = props.fs;
|
|
751
|
-
this._bindings = { ...this.props.bindings };
|
|
752
|
-
}
|
|
753
|
-
destroy() {
|
|
754
|
-
this.handle = null;
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* @todo Use renderpass.setBindings() ?
|
|
758
|
-
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
759
|
-
*/
|
|
760
|
-
setBindings(bindings) {
|
|
761
|
-
Object.assign(this._bindings, bindings);
|
|
762
|
-
}
|
|
763
|
-
/** @todo - should this be moved to renderpass? */
|
|
764
|
-
draw(options) {
|
|
765
|
-
const webgpuRenderPass = options.renderPass;
|
|
766
|
-
this.device.handle.pushErrorScope("validation");
|
|
767
|
-
webgpuRenderPass.handle.setPipeline(this.handle);
|
|
768
|
-
this.device.handle.popErrorScope().then((error) => {
|
|
769
|
-
if (error) {
|
|
770
|
-
import_core10.log.error(`${this} setPipeline failed:
|
|
771
|
-
"${error.message}"`, this)();
|
|
908
|
+
this.handle.label = this.props.id;
|
|
909
|
+
this.vs = props.vs;
|
|
910
|
+
this.fs = props.fs;
|
|
911
|
+
this._bindings = { ...this.props.bindings };
|
|
772
912
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
// If 0, nothing will be drawn
|
|
786
|
-
options.firstInstance
|
|
787
|
-
);
|
|
788
|
-
}
|
|
789
|
-
options.vertexArray.unbindAfterRender(options.renderPass);
|
|
790
|
-
return true;
|
|
791
|
-
}
|
|
792
|
-
/** Return a bind group created by setBindings */
|
|
793
|
-
_getBindGroup() {
|
|
794
|
-
if (this.shaderLayout.bindings.length === 0) {
|
|
795
|
-
return null;
|
|
796
|
-
}
|
|
797
|
-
this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
|
|
798
|
-
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);
|
|
799
|
-
return this._bindGroup;
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Populate the complex WebGPU GPURenderPipelineDescriptor
|
|
803
|
-
*/
|
|
804
|
-
_getRenderPipelineDescriptor() {
|
|
805
|
-
const vertex = {
|
|
806
|
-
module: this.props.vs.handle,
|
|
807
|
-
entryPoint: this.props.vertexEntryPoint || "main",
|
|
808
|
-
buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)
|
|
809
|
-
};
|
|
810
|
-
const fragment = {
|
|
811
|
-
module: this.props.fs.handle,
|
|
812
|
-
entryPoint: this.props.fragmentEntryPoint || "main",
|
|
813
|
-
targets: [
|
|
814
|
-
{
|
|
815
|
-
// TODO exclamation mark hack!
|
|
816
|
-
format: getWebGPUTextureFormat(this.device.getCanvasContext().format)
|
|
913
|
+
destroy() {
|
|
914
|
+
this.handle = null;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* @todo Use renderpass.setBindings() ?
|
|
918
|
+
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
919
|
+
*/
|
|
920
|
+
setBindings(bindings) {
|
|
921
|
+
for (const [name2, binding] of Object.entries(bindings)) {
|
|
922
|
+
if (this._bindings[name2] !== binding) {
|
|
923
|
+
this._bindGroup = null;
|
|
924
|
+
}
|
|
817
925
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
926
|
+
Object.assign(this._bindings, bindings);
|
|
927
|
+
}
|
|
928
|
+
/** @todo - should this be moved to renderpass? */
|
|
929
|
+
draw(options) {
|
|
930
|
+
const webgpuRenderPass = options.renderPass;
|
|
931
|
+
this.device.pushErrorScope("validation");
|
|
932
|
+
webgpuRenderPass.handle.setPipeline(this.handle);
|
|
933
|
+
this.device.popErrorScope((error) => {
|
|
934
|
+
this.device.reportError(new Error(`${this} setPipeline failed:
|
|
935
|
+
"${error.message}"`), this)();
|
|
936
|
+
this.device.debug();
|
|
937
|
+
});
|
|
938
|
+
const bindGroup = this._getBindGroup();
|
|
939
|
+
if (bindGroup) {
|
|
940
|
+
webgpuRenderPass.handle.setBindGroup(0, bindGroup);
|
|
941
|
+
}
|
|
942
|
+
options.vertexArray.bindBeforeRender(options.renderPass);
|
|
943
|
+
if (options.indexCount) {
|
|
944
|
+
webgpuRenderPass.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
945
|
+
} else {
|
|
946
|
+
webgpuRenderPass.handle.draw(
|
|
947
|
+
options.vertexCount || 0,
|
|
948
|
+
options.instanceCount || 1,
|
|
949
|
+
// If 0, nothing will be drawn
|
|
950
|
+
options.firstInstance
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
options.vertexArray.unbindAfterRender(options.renderPass);
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
/** Return a bind group created by setBindings */
|
|
957
|
+
_getBindGroup() {
|
|
958
|
+
if (this.shaderLayout.bindings.length === 0) {
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
|
|
962
|
+
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);
|
|
963
|
+
return this._bindGroup;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Populate the complex WebGPU GPURenderPipelineDescriptor
|
|
967
|
+
*/
|
|
968
|
+
_getRenderPipelineDescriptor() {
|
|
969
|
+
const vertex = {
|
|
970
|
+
module: this.props.vs.handle,
|
|
971
|
+
entryPoint: this.props.vertexEntryPoint || "main",
|
|
972
|
+
buffers: getVertexBufferLayout(this.shaderLayout, this.props.bufferLayout)
|
|
973
|
+
};
|
|
974
|
+
const targets = [];
|
|
975
|
+
if (this.props.colorAttachmentFormats) {
|
|
976
|
+
for (const format of this.props.colorAttachmentFormats) {
|
|
977
|
+
targets.push(format ? { format: getWebGPUTextureFormat(format) } : null);
|
|
978
|
+
}
|
|
979
|
+
} else {
|
|
980
|
+
targets.push({ format: getWebGPUTextureFormat(this.device.preferredColorFormat) });
|
|
981
|
+
}
|
|
982
|
+
const fragment = {
|
|
983
|
+
module: this.props.fs.handle,
|
|
984
|
+
entryPoint: this.props.fragmentEntryPoint || "main",
|
|
985
|
+
targets
|
|
986
|
+
};
|
|
987
|
+
const layout = this.device.createPipelineLayout({
|
|
988
|
+
shaderLayout: this.shaderLayout
|
|
989
|
+
});
|
|
990
|
+
const descriptor = {
|
|
991
|
+
vertex,
|
|
992
|
+
fragment,
|
|
993
|
+
primitive: {
|
|
994
|
+
topology: this.props.topology
|
|
995
|
+
},
|
|
996
|
+
layout: layout.handle
|
|
997
|
+
};
|
|
998
|
+
const depthFormat = this.props.depthStencilAttachmentFormat || this.device.preferredDepthFormat;
|
|
999
|
+
if (this.props.parameters.depthWriteEnabled) {
|
|
1000
|
+
descriptor.depthStencil = {
|
|
1001
|
+
format: getWebGPUTextureFormat(depthFormat)
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);
|
|
1005
|
+
return descriptor;
|
|
1006
|
+
}
|
|
830
1007
|
};
|
|
831
|
-
if (this.props.parameters.depthWriteEnabled && this.props.parameters.depthCompare) {
|
|
832
|
-
descriptor.depthStencil = {
|
|
833
|
-
format: "depth24plus",
|
|
834
|
-
depthWriteEnabled: this.props.parameters.depthWriteEnabled,
|
|
835
|
-
depthCompare: this.props.parameters.depthCompare
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
applyParametersToRenderPipelineDescriptor(descriptor, this.props.parameters);
|
|
839
|
-
return descriptor;
|
|
840
1008
|
}
|
|
841
|
-
};
|
|
1009
|
+
});
|
|
842
1010
|
|
|
843
1011
|
// dist/adapter/resources/webgpu-framebuffer.js
|
|
844
|
-
var import_core11
|
|
845
|
-
var
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1012
|
+
var import_core11, WebGPUFramebuffer;
|
|
1013
|
+
var init_webgpu_framebuffer = __esm({
|
|
1014
|
+
"dist/adapter/resources/webgpu-framebuffer.js"() {
|
|
1015
|
+
"use strict";
|
|
1016
|
+
import_core11 = require("@luma.gl/core");
|
|
1017
|
+
WebGPUFramebuffer = class extends import_core11.Framebuffer {
|
|
1018
|
+
device;
|
|
1019
|
+
handle = null;
|
|
1020
|
+
colorAttachments = [];
|
|
1021
|
+
depthStencilAttachment = null;
|
|
1022
|
+
constructor(device, props) {
|
|
1023
|
+
super(device, props);
|
|
1024
|
+
this.device = device;
|
|
1025
|
+
this.autoCreateAttachmentTextures();
|
|
1026
|
+
}
|
|
1027
|
+
updateAttachments() {
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
855
1030
|
}
|
|
856
|
-
};
|
|
1031
|
+
});
|
|
857
1032
|
|
|
858
1033
|
// dist/adapter/resources/webgpu-compute-pipeline.js
|
|
859
|
-
var import_core12
|
|
860
|
-
var
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1034
|
+
var import_core12, WebGPUComputePipeline;
|
|
1035
|
+
var init_webgpu_compute_pipeline = __esm({
|
|
1036
|
+
"dist/adapter/resources/webgpu-compute-pipeline.js"() {
|
|
1037
|
+
"use strict";
|
|
1038
|
+
import_core12 = require("@luma.gl/core");
|
|
1039
|
+
init_get_bind_group();
|
|
1040
|
+
WebGPUComputePipeline = class extends import_core12.ComputePipeline {
|
|
1041
|
+
device;
|
|
1042
|
+
handle;
|
|
1043
|
+
/** For internal use to create BindGroups */
|
|
1044
|
+
_bindGroupLayout = null;
|
|
1045
|
+
_bindGroup = null;
|
|
1046
|
+
/** For internal use to create BindGroups */
|
|
1047
|
+
_bindings = {};
|
|
1048
|
+
constructor(device, props) {
|
|
1049
|
+
super(device, props);
|
|
1050
|
+
this.device = device;
|
|
1051
|
+
const webgpuShader = this.props.shader;
|
|
1052
|
+
this.handle = this.props.handle || this.device.handle.createComputePipeline({
|
|
1053
|
+
label: this.props.id,
|
|
1054
|
+
compute: {
|
|
1055
|
+
module: webgpuShader.handle,
|
|
1056
|
+
entryPoint: this.props.entryPoint,
|
|
1057
|
+
constants: this.props.constants
|
|
1058
|
+
},
|
|
1059
|
+
layout: "auto"
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* @todo Use renderpass.setBindings() ?
|
|
1064
|
+
* @todo Do we want to expose BindGroups in the API and remove this?
|
|
1065
|
+
*/
|
|
1066
|
+
setBindings(bindings) {
|
|
1067
|
+
Object.assign(this._bindings, bindings);
|
|
1068
|
+
}
|
|
1069
|
+
/** Return a bind group created by setBindings */
|
|
1070
|
+
_getBindGroup() {
|
|
1071
|
+
this._bindGroupLayout = this._bindGroupLayout || this.handle.getBindGroupLayout(0);
|
|
1072
|
+
this._bindGroup = this._bindGroup || getBindGroup(this.device.handle, this._bindGroupLayout, this.shaderLayout, this._bindings);
|
|
1073
|
+
return this._bindGroup;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
894
1076
|
}
|
|
895
|
-
};
|
|
1077
|
+
});
|
|
896
1078
|
|
|
897
|
-
// dist/adapter/resources/webgpu-
|
|
898
|
-
var import_core13
|
|
899
|
-
var
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1079
|
+
// dist/adapter/resources/webgpu-vertex-array.js
|
|
1080
|
+
var import_core13, import_env, WebGPUVertexArray;
|
|
1081
|
+
var init_webgpu_vertex_array = __esm({
|
|
1082
|
+
"dist/adapter/resources/webgpu-vertex-array.js"() {
|
|
1083
|
+
"use strict";
|
|
1084
|
+
import_core13 = require("@luma.gl/core");
|
|
1085
|
+
import_env = require("@probe.gl/env");
|
|
1086
|
+
WebGPUVertexArray = class extends import_core13.VertexArray {
|
|
1087
|
+
get [Symbol.toStringTag]() {
|
|
1088
|
+
return "WebGPUVertexArray";
|
|
1089
|
+
}
|
|
1090
|
+
device;
|
|
1091
|
+
/** Vertex Array is just a helper class under WebGPU */
|
|
1092
|
+
handle = null;
|
|
1093
|
+
// Create a VertexArray
|
|
1094
|
+
constructor(device, props) {
|
|
1095
|
+
super(device, props);
|
|
1096
|
+
this.device = device;
|
|
1097
|
+
}
|
|
1098
|
+
destroy() {
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Set an elements buffer, for indexed rendering.
|
|
1102
|
+
* Must be a Buffer bound to buffer with usage bit Buffer.INDEX set.
|
|
1103
|
+
*/
|
|
1104
|
+
setIndexBuffer(buffer) {
|
|
1105
|
+
this.indexBuffer = buffer;
|
|
1106
|
+
}
|
|
1107
|
+
/** Set a bufferSlot in vertex attributes array to a buffer, enables the bufferSlot, sets divisor */
|
|
1108
|
+
setBuffer(bufferSlot, buffer) {
|
|
1109
|
+
this.attributes[bufferSlot] = buffer;
|
|
1110
|
+
}
|
|
1111
|
+
bindBeforeRender(renderPass, firstIndex, indexCount) {
|
|
1112
|
+
const webgpuRenderPass = renderPass;
|
|
1113
|
+
const webgpuIndexBuffer = this.indexBuffer;
|
|
1114
|
+
if (webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle) {
|
|
1115
|
+
import_core13.log.info(3, "setting index buffer", webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle, webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType)();
|
|
1116
|
+
webgpuRenderPass.handle.setIndexBuffer(
|
|
1117
|
+
webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle,
|
|
1118
|
+
// @ts-expect-error TODO - we must enforce type
|
|
1119
|
+
webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
for (let location = 0; location < this.maxVertexAttributes; location++) {
|
|
1123
|
+
const webgpuBuffer = this.attributes[location];
|
|
1124
|
+
if (webgpuBuffer == null ? void 0 : webgpuBuffer.handle) {
|
|
1125
|
+
import_core13.log.info(3, `setting vertex buffer ${location}`, webgpuBuffer == null ? void 0 : webgpuBuffer.handle)();
|
|
1126
|
+
webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer == null ? void 0 : webgpuBuffer.handle);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
unbindAfterRender(renderPass) {
|
|
1131
|
+
}
|
|
1132
|
+
// DEPRECATED METHODS
|
|
1133
|
+
/**
|
|
1134
|
+
* @deprecated is this even an issue for WebGPU?
|
|
1135
|
+
* Attribute 0 can not be disable on most desktop OpenGL based browsers
|
|
1136
|
+
*/
|
|
1137
|
+
static isConstantAttributeZeroSupported(device) {
|
|
1138
|
+
return (0, import_env.getBrowser)() === "Chrome";
|
|
930
1139
|
}
|
|
931
|
-
});
|
|
932
|
-
this.handle.label = this.props.id;
|
|
933
|
-
import_core13.log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();
|
|
934
|
-
import_core13.log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();
|
|
935
|
-
import_core13.log.groupEnd(3)();
|
|
936
|
-
}
|
|
937
|
-
destroy() {
|
|
938
|
-
}
|
|
939
|
-
end() {
|
|
940
|
-
this.handle.end();
|
|
941
|
-
}
|
|
942
|
-
setPipeline(pipeline) {
|
|
943
|
-
this.pipeline = pipeline;
|
|
944
|
-
this.handle.setPipeline(this.pipeline.handle);
|
|
945
|
-
}
|
|
946
|
-
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
947
|
-
setBindings(bindings) {
|
|
948
|
-
var _a, _b;
|
|
949
|
-
(_a = this.pipeline) == null ? void 0 : _a.setBindings(bindings);
|
|
950
|
-
const bindGroup = (_b = this.pipeline) == null ? void 0 : _b._getBindGroup();
|
|
951
|
-
if (bindGroup) {
|
|
952
|
-
this.handle.setBindGroup(0, bindGroup);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
setIndexBuffer(buffer, indexFormat, offset = 0, size) {
|
|
956
|
-
this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);
|
|
957
|
-
}
|
|
958
|
-
setVertexBuffer(slot, buffer, offset = 0) {
|
|
959
|
-
this.handle.setVertexBuffer(slot, buffer.handle, offset);
|
|
960
|
-
}
|
|
961
|
-
draw(options) {
|
|
962
|
-
if (options.indexCount) {
|
|
963
|
-
this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
964
|
-
} else {
|
|
965
|
-
this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);
|
|
966
|
-
}
|
|
967
|
-
}
|
|
968
|
-
drawIndirect() {
|
|
969
|
-
}
|
|
970
|
-
setParameters(parameters) {
|
|
971
|
-
const { blendConstant, stencilReference, scissorRect, viewport } = parameters;
|
|
972
|
-
if (blendConstant) {
|
|
973
|
-
this.handle.setBlendConstant(blendConstant);
|
|
974
|
-
}
|
|
975
|
-
if (stencilReference) {
|
|
976
|
-
this.handle.setStencilReference(stencilReference);
|
|
977
|
-
}
|
|
978
|
-
if (scissorRect) {
|
|
979
|
-
this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
|
980
|
-
}
|
|
981
|
-
if (viewport) {
|
|
982
|
-
this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4] ?? 0, viewport[5] ?? 1);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
pushDebugGroup(groupLabel) {
|
|
986
|
-
this.handle.pushDebugGroup(groupLabel);
|
|
987
|
-
}
|
|
988
|
-
popDebugGroup() {
|
|
989
|
-
this.handle.popDebugGroup();
|
|
990
|
-
}
|
|
991
|
-
insertDebugMarker(markerLabel) {
|
|
992
|
-
this.handle.insertDebugMarker(markerLabel);
|
|
993
|
-
}
|
|
994
|
-
beginOcclusionQuery(queryIndex) {
|
|
995
|
-
this.handle.beginOcclusionQuery(queryIndex);
|
|
996
|
-
}
|
|
997
|
-
endOcclusionQuery() {
|
|
998
|
-
this.handle.endOcclusionQuery();
|
|
999
|
-
}
|
|
1000
|
-
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
1001
|
-
// INTERNAL
|
|
1002
|
-
/**
|
|
1003
|
-
* Partial render pass descriptor. Used by WebGPURenderPass.
|
|
1004
|
-
* @returns attachments fields of a renderpass descriptor.
|
|
1005
|
-
*/
|
|
1006
|
-
getRenderPassDescriptor(framebuffer) {
|
|
1007
|
-
const renderPassDescriptor = {
|
|
1008
|
-
colorAttachments: []
|
|
1009
1140
|
};
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
if (this.props.depthReadOnly) {
|
|
1027
|
-
depthStencilAttachment.depthReadOnly = true;
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
// dist/adapter/webgpu-canvas-context.js
|
|
1145
|
+
var import_core14, WebGPUCanvasContext;
|
|
1146
|
+
var init_webgpu_canvas_context = __esm({
|
|
1147
|
+
"dist/adapter/webgpu-canvas-context.js"() {
|
|
1148
|
+
"use strict";
|
|
1149
|
+
import_core14 = require("@luma.gl/core");
|
|
1150
|
+
init_webgpu_framebuffer();
|
|
1151
|
+
WebGPUCanvasContext = class extends import_core14.CanvasContext {
|
|
1152
|
+
device;
|
|
1153
|
+
handle;
|
|
1154
|
+
depthStencilAttachment = null;
|
|
1155
|
+
get [Symbol.toStringTag]() {
|
|
1156
|
+
return "WebGPUCanvasContext";
|
|
1028
1157
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1158
|
+
constructor(device, adapter, props) {
|
|
1159
|
+
super(props);
|
|
1160
|
+
const context = this.canvas.getContext("webgpu");
|
|
1161
|
+
if (!context) {
|
|
1162
|
+
throw new Error(`${this}: Failed to create WebGPU canvas context`);
|
|
1163
|
+
}
|
|
1164
|
+
this.device = device;
|
|
1165
|
+
this.handle = context;
|
|
1166
|
+
this._setAutoCreatedCanvasId(`${this.device.id}-canvas`);
|
|
1167
|
+
this._updateDevice();
|
|
1031
1168
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1169
|
+
/** Destroy any textures produced while configured and remove the context configuration. */
|
|
1170
|
+
destroy() {
|
|
1171
|
+
this.handle.unconfigure();
|
|
1172
|
+
super.destroy();
|
|
1036
1173
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1174
|
+
/** Update framebuffer with properly resized "swap chain" texture views */
|
|
1175
|
+
getCurrentFramebuffer(options = {
|
|
1176
|
+
depthStencilFormat: "depth24plus"
|
|
1177
|
+
}) {
|
|
1178
|
+
const currentColorAttachment = this.getCurrentTexture();
|
|
1179
|
+
if (currentColorAttachment.width !== this.drawingBufferWidth || currentColorAttachment.height !== this.drawingBufferHeight) {
|
|
1180
|
+
const [oldWidth, oldHeight] = this.getDrawingBufferSize();
|
|
1181
|
+
this.drawingBufferWidth = currentColorAttachment.width;
|
|
1182
|
+
this.drawingBufferHeight = currentColorAttachment.height;
|
|
1183
|
+
import_core14.log.log(1, `${this}: Resized to compensate for initial canvas size mismatch ${oldWidth}x${oldHeight} => ${this.drawingBufferWidth}x${this.drawingBufferHeight}px`)();
|
|
1184
|
+
}
|
|
1185
|
+
if (options == null ? void 0 : options.depthStencilFormat) {
|
|
1186
|
+
this._createDepthStencilAttachment(options == null ? void 0 : options.depthStencilFormat);
|
|
1187
|
+
}
|
|
1188
|
+
return new WebGPUFramebuffer(this.device, {
|
|
1189
|
+
colorAttachments: [currentColorAttachment],
|
|
1190
|
+
depthStencilAttachment: this.depthStencilAttachment
|
|
1191
|
+
});
|
|
1041
1192
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1193
|
+
// IMPLEMENTATION OF ABSTRACT METHODS
|
|
1194
|
+
_updateDevice() {
|
|
1195
|
+
if (this.depthStencilAttachment) {
|
|
1196
|
+
this.depthStencilAttachment.destroy();
|
|
1197
|
+
this.depthStencilAttachment = null;
|
|
1198
|
+
}
|
|
1199
|
+
this.handle.configure({
|
|
1200
|
+
device: this.device.handle,
|
|
1201
|
+
format: this.device.preferredColorFormat,
|
|
1202
|
+
// Can be used to define e.g. -srgb views
|
|
1203
|
+
// viewFormats: [...]
|
|
1204
|
+
colorSpace: this.props.colorSpace,
|
|
1205
|
+
alphaMode: this.props.alphaMode
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
/** Wrap the current canvas context texture in a luma.gl texture */
|
|
1209
|
+
getCurrentTexture() {
|
|
1210
|
+
const handle = this.handle.getCurrentTexture();
|
|
1211
|
+
return this.device.createTexture({
|
|
1212
|
+
id: `${this.id}#color-texture`,
|
|
1213
|
+
handle,
|
|
1214
|
+
format: this.device.preferredColorFormat,
|
|
1215
|
+
width: handle.width,
|
|
1216
|
+
height: handle.height
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
/** We build render targets on demand (i.e. not when size changes but when about to render) */
|
|
1220
|
+
_createDepthStencilAttachment(depthStencilFormat) {
|
|
1221
|
+
if (!this.depthStencilAttachment) {
|
|
1222
|
+
this.depthStencilAttachment = this.device.createTexture({
|
|
1223
|
+
id: `${this.id}#depth-stencil-texture`,
|
|
1224
|
+
usage: import_core14.Texture.RENDER_ATTACHMENT,
|
|
1225
|
+
format: depthStencilFormat,
|
|
1226
|
+
width: this.drawingBufferWidth,
|
|
1227
|
+
height: this.drawingBufferHeight
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
return this.depthStencilAttachment;
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1044
1233
|
}
|
|
1045
|
-
};
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
// dist/adapter/resources/webgpu-command-buffer.js
|
|
1237
|
+
var import_core15, WebGPUCommandBuffer;
|
|
1238
|
+
var init_webgpu_command_buffer = __esm({
|
|
1239
|
+
"dist/adapter/resources/webgpu-command-buffer.js"() {
|
|
1240
|
+
"use strict";
|
|
1241
|
+
import_core15 = require("@luma.gl/core");
|
|
1242
|
+
WebGPUCommandBuffer = class extends import_core15.CommandBuffer {
|
|
1243
|
+
device;
|
|
1244
|
+
handle;
|
|
1245
|
+
constructor(commandEncoder, props) {
|
|
1246
|
+
super(commandEncoder.device, {});
|
|
1247
|
+
this.device = commandEncoder.device;
|
|
1248
|
+
this.handle = this.props.handle || commandEncoder.handle.finish({
|
|
1249
|
+
label: (props == null ? void 0 : props.id) || "unnamed-command-buffer"
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
// dist/adapter/resources/webgpu-render-pass.js
|
|
1046
1257
|
function convertColor(color) {
|
|
1047
1258
|
return { r: color[0], g: color[1], b: color[2], a: color[3] };
|
|
1048
1259
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1260
|
+
var import_core16, WebGPURenderPass;
|
|
1261
|
+
var init_webgpu_render_pass = __esm({
|
|
1262
|
+
"dist/adapter/resources/webgpu-render-pass.js"() {
|
|
1263
|
+
"use strict";
|
|
1264
|
+
import_core16 = require("@luma.gl/core");
|
|
1265
|
+
WebGPURenderPass = class extends import_core16.RenderPass {
|
|
1266
|
+
device;
|
|
1267
|
+
handle;
|
|
1268
|
+
/** Active pipeline */
|
|
1269
|
+
pipeline = null;
|
|
1270
|
+
constructor(device, props = {}) {
|
|
1271
|
+
super(device, props);
|
|
1272
|
+
this.device = device;
|
|
1273
|
+
const framebuffer = props.framebuffer || device.getCanvasContext().getCurrentFramebuffer();
|
|
1274
|
+
const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
|
|
1275
|
+
const webgpuQuerySet = props.timestampQuerySet;
|
|
1276
|
+
if (webgpuQuerySet) {
|
|
1277
|
+
renderPassDescriptor.occlusionQuerySet = webgpuQuerySet.handle;
|
|
1278
|
+
}
|
|
1279
|
+
if (device.features.has("timestamp-query")) {
|
|
1280
|
+
const webgpuTSQuerySet = props.timestampQuerySet;
|
|
1281
|
+
renderPassDescriptor.timestampWrites = webgpuTSQuerySet ? {
|
|
1282
|
+
querySet: webgpuTSQuerySet.handle,
|
|
1283
|
+
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
1284
|
+
endOfPassWriteIndex: props.endTimestampIndex
|
|
1285
|
+
} : void 0;
|
|
1286
|
+
}
|
|
1287
|
+
if (!device.commandEncoder) {
|
|
1288
|
+
throw new Error("commandEncoder not available");
|
|
1289
|
+
}
|
|
1290
|
+
this.device.pushErrorScope("validation");
|
|
1291
|
+
this.handle = this.props.handle || device.commandEncoder.handle.beginRenderPass(renderPassDescriptor);
|
|
1292
|
+
this.device.popErrorScope((error) => {
|
|
1293
|
+
this.device.reportError(new Error(`${this} creation failed:
|
|
1294
|
+
"${error.message}"`), this)();
|
|
1295
|
+
this.device.debug();
|
|
1296
|
+
});
|
|
1297
|
+
this.handle.label = this.props.id;
|
|
1298
|
+
import_core16.log.groupCollapsed(3, `new WebGPURenderPass(${this.id})`)();
|
|
1299
|
+
import_core16.log.probe(3, JSON.stringify(renderPassDescriptor, null, 2))();
|
|
1300
|
+
import_core16.log.groupEnd(3)();
|
|
1301
|
+
}
|
|
1302
|
+
destroy() {
|
|
1303
|
+
}
|
|
1304
|
+
end() {
|
|
1305
|
+
this.handle.end();
|
|
1306
|
+
}
|
|
1307
|
+
setPipeline(pipeline) {
|
|
1308
|
+
this.pipeline = pipeline;
|
|
1309
|
+
this.device.pushErrorScope("validation");
|
|
1310
|
+
this.handle.setPipeline(this.pipeline.handle);
|
|
1311
|
+
this.device.popErrorScope((error) => {
|
|
1312
|
+
this.device.reportError(new Error(`${this} setPipeline failed:
|
|
1313
|
+
"${error.message}"`), this)();
|
|
1314
|
+
this.device.debug();
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
/** Sets an array of bindings (uniform buffers, samplers, textures, ...) */
|
|
1318
|
+
setBindings(bindings) {
|
|
1319
|
+
var _a, _b;
|
|
1320
|
+
(_a = this.pipeline) == null ? void 0 : _a.setBindings(bindings);
|
|
1321
|
+
const bindGroup = (_b = this.pipeline) == null ? void 0 : _b._getBindGroup();
|
|
1322
|
+
if (bindGroup) {
|
|
1323
|
+
this.handle.setBindGroup(0, bindGroup);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
setIndexBuffer(buffer, indexFormat, offset = 0, size) {
|
|
1327
|
+
this.handle.setIndexBuffer(buffer.handle, indexFormat, offset, size);
|
|
1328
|
+
}
|
|
1329
|
+
setVertexBuffer(slot, buffer, offset = 0) {
|
|
1330
|
+
this.handle.setVertexBuffer(slot, buffer.handle, offset);
|
|
1331
|
+
}
|
|
1332
|
+
draw(options) {
|
|
1333
|
+
if (options.indexCount) {
|
|
1334
|
+
this.handle.drawIndexed(options.indexCount, options.instanceCount, options.firstIndex, options.baseVertex, options.firstInstance);
|
|
1335
|
+
} else {
|
|
1336
|
+
this.handle.draw(options.vertexCount || 0, options.instanceCount || 1, options.firstIndex, options.firstInstance);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
drawIndirect() {
|
|
1340
|
+
}
|
|
1341
|
+
setParameters(parameters) {
|
|
1342
|
+
const { blendConstant, stencilReference, scissorRect, viewport } = parameters;
|
|
1343
|
+
if (blendConstant) {
|
|
1344
|
+
this.handle.setBlendConstant(blendConstant);
|
|
1345
|
+
}
|
|
1346
|
+
if (stencilReference) {
|
|
1347
|
+
this.handle.setStencilReference(stencilReference);
|
|
1348
|
+
}
|
|
1349
|
+
if (scissorRect) {
|
|
1350
|
+
this.handle.setScissorRect(scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
|
1351
|
+
}
|
|
1352
|
+
if (viewport) {
|
|
1353
|
+
this.handle.setViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4] ?? 0, viewport[5] ?? 1);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
pushDebugGroup(groupLabel) {
|
|
1357
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
1358
|
+
}
|
|
1359
|
+
popDebugGroup() {
|
|
1360
|
+
this.handle.popDebugGroup();
|
|
1361
|
+
}
|
|
1362
|
+
insertDebugMarker(markerLabel) {
|
|
1363
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
1364
|
+
}
|
|
1365
|
+
beginOcclusionQuery(queryIndex) {
|
|
1366
|
+
this.handle.beginOcclusionQuery(queryIndex);
|
|
1367
|
+
}
|
|
1368
|
+
endOcclusionQuery() {
|
|
1369
|
+
this.handle.endOcclusionQuery();
|
|
1370
|
+
}
|
|
1371
|
+
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
1372
|
+
// INTERNAL
|
|
1373
|
+
/**
|
|
1374
|
+
* Partial render pass descriptor. Used by WebGPURenderPass.
|
|
1375
|
+
* @returns attachments fields of a renderpass descriptor.
|
|
1376
|
+
*/
|
|
1377
|
+
getRenderPassDescriptor(framebuffer) {
|
|
1378
|
+
const renderPassDescriptor = {
|
|
1379
|
+
colorAttachments: []
|
|
1068
1380
|
};
|
|
1381
|
+
renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment, index) => {
|
|
1382
|
+
var _a;
|
|
1383
|
+
return {
|
|
1384
|
+
// clear values
|
|
1385
|
+
loadOp: this.props.clearColor !== false ? "clear" : "load",
|
|
1386
|
+
clearValue: convertColor(((_a = this.props.clearColors) == null ? void 0 : _a[index]) || this.props.clearColor || import_core16.RenderPass.defaultClearColor),
|
|
1387
|
+
storeOp: this.props.discard ? "discard" : "store",
|
|
1388
|
+
// ...colorAttachment,
|
|
1389
|
+
view: colorAttachment.handle
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
if (framebuffer.depthStencilAttachment) {
|
|
1393
|
+
renderPassDescriptor.depthStencilAttachment = {
|
|
1394
|
+
view: framebuffer.depthStencilAttachment.handle
|
|
1395
|
+
};
|
|
1396
|
+
const { depthStencilAttachment } = renderPassDescriptor;
|
|
1397
|
+
if (this.props.depthReadOnly) {
|
|
1398
|
+
depthStencilAttachment.depthReadOnly = true;
|
|
1399
|
+
}
|
|
1400
|
+
if (this.props.clearDepth !== false) {
|
|
1401
|
+
depthStencilAttachment.depthClearValue = this.props.clearDepth;
|
|
1402
|
+
}
|
|
1403
|
+
const hasDepthAspect = true;
|
|
1404
|
+
if (hasDepthAspect) {
|
|
1405
|
+
depthStencilAttachment.depthLoadOp = this.props.clearDepth !== false ? "clear" : "load";
|
|
1406
|
+
depthStencilAttachment.depthStoreOp = "store";
|
|
1407
|
+
}
|
|
1408
|
+
const hasStencilAspect = false;
|
|
1409
|
+
if (hasStencilAspect) {
|
|
1410
|
+
depthStencilAttachment.stencilLoadOp = this.props.clearStencil !== false ? "clear" : "load";
|
|
1411
|
+
depthStencilAttachment.stencilStoreOp = "store";
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
return renderPassDescriptor;
|
|
1069
1415
|
}
|
|
1070
|
-
}
|
|
1071
|
-
this.handle = this.props.handle || ((_a = device.commandEncoder) == null ? void 0 : _a.beginComputePass({
|
|
1072
|
-
label: this.props.id,
|
|
1073
|
-
timestampWrites
|
|
1074
|
-
}));
|
|
1075
|
-
}
|
|
1076
|
-
/** @note no WebGPU destroy method, just gc */
|
|
1077
|
-
destroy() {
|
|
1078
|
-
}
|
|
1079
|
-
end() {
|
|
1080
|
-
this.handle.end();
|
|
1081
|
-
}
|
|
1082
|
-
setPipeline(pipeline) {
|
|
1083
|
-
const wgpuPipeline = pipeline;
|
|
1084
|
-
this.handle.setPipeline(wgpuPipeline.handle);
|
|
1085
|
-
this._webgpuPipeline = wgpuPipeline;
|
|
1086
|
-
this.setBindings([]);
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Sets an array of bindings (uniform buffers, samplers, textures, ...)
|
|
1090
|
-
* TODO - still some API confusion - does this method go here or on the pipeline?
|
|
1091
|
-
*/
|
|
1092
|
-
setBindings(bindings) {
|
|
1093
|
-
const bindGroup = this._webgpuPipeline._getBindGroup();
|
|
1094
|
-
this.handle.setBindGroup(0, bindGroup);
|
|
1095
|
-
}
|
|
1096
|
-
/**
|
|
1097
|
-
* Dispatch work to be performed with the current ComputePipeline.
|
|
1098
|
-
* @param x X dimension of the grid of work groups to dispatch.
|
|
1099
|
-
* @param y Y dimension of the grid of work groups to dispatch.
|
|
1100
|
-
* @param z Z dimension of the grid of work groups to dispatch.
|
|
1101
|
-
*/
|
|
1102
|
-
dispatch(x, y, z) {
|
|
1103
|
-
this.handle.dispatchWorkgroups(x, y, z);
|
|
1104
|
-
}
|
|
1105
|
-
/**
|
|
1106
|
-
* Dispatch work to be performed with the current ComputePipeline.
|
|
1107
|
-
*
|
|
1108
|
-
* 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()
|
|
1109
|
-
* @param indirectBuffer
|
|
1110
|
-
* @param indirectOffset offset in buffer to the beginning of the dispatch data.
|
|
1111
|
-
*/
|
|
1112
|
-
dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {
|
|
1113
|
-
const webgpuBuffer = indirectBuffer;
|
|
1114
|
-
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);
|
|
1115
|
-
}
|
|
1116
|
-
pushDebugGroup(groupLabel) {
|
|
1117
|
-
this.handle.pushDebugGroup(groupLabel);
|
|
1118
|
-
}
|
|
1119
|
-
popDebugGroup() {
|
|
1120
|
-
this.handle.popDebugGroup();
|
|
1121
|
-
}
|
|
1122
|
-
insertDebugMarker(markerLabel) {
|
|
1123
|
-
this.handle.insertDebugMarker(markerLabel);
|
|
1416
|
+
};
|
|
1124
1417
|
}
|
|
1125
|
-
};
|
|
1418
|
+
});
|
|
1126
1419
|
|
|
1127
|
-
// dist/adapter/resources/webgpu-
|
|
1128
|
-
var
|
|
1129
|
-
var
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
bindBeforeRender(renderPass, firstIndex, indexCount) {
|
|
1156
|
-
const webgpuRenderPass = renderPass;
|
|
1157
|
-
const webgpuIndexBuffer = this.indexBuffer;
|
|
1158
|
-
if (webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle) {
|
|
1159
|
-
import_core15.log.info(3, "setting index buffer", webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle, webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType)();
|
|
1160
|
-
webgpuRenderPass.handle.setIndexBuffer(
|
|
1161
|
-
webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.handle,
|
|
1162
|
-
// @ts-expect-error TODO - we must enforce type
|
|
1163
|
-
webgpuIndexBuffer == null ? void 0 : webgpuIndexBuffer.indexType
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
for (let location = 0; location < this.maxVertexAttributes; location++) {
|
|
1167
|
-
const webgpuBuffer = this.attributes[location];
|
|
1168
|
-
if (webgpuBuffer == null ? void 0 : webgpuBuffer.handle) {
|
|
1169
|
-
import_core15.log.info(3, `setting vertex buffer ${location}`, webgpuBuffer == null ? void 0 : webgpuBuffer.handle)();
|
|
1170
|
-
webgpuRenderPass.handle.setVertexBuffer(location, webgpuBuffer == null ? void 0 : webgpuBuffer.handle);
|
|
1420
|
+
// dist/adapter/resources/webgpu-compute-pass.js
|
|
1421
|
+
var import_core17, WebGPUComputePass;
|
|
1422
|
+
var init_webgpu_compute_pass = __esm({
|
|
1423
|
+
"dist/adapter/resources/webgpu-compute-pass.js"() {
|
|
1424
|
+
"use strict";
|
|
1425
|
+
import_core17 = require("@luma.gl/core");
|
|
1426
|
+
WebGPUComputePass = class extends import_core17.ComputePass {
|
|
1427
|
+
device;
|
|
1428
|
+
handle;
|
|
1429
|
+
_webgpuPipeline = null;
|
|
1430
|
+
constructor(device, props) {
|
|
1431
|
+
super(device, props);
|
|
1432
|
+
this.device = device;
|
|
1433
|
+
let timestampWrites;
|
|
1434
|
+
if (device.features.has("timestamp-query")) {
|
|
1435
|
+
const webgpuQuerySet = props.timestampQuerySet;
|
|
1436
|
+
if (webgpuQuerySet) {
|
|
1437
|
+
timestampWrites = {
|
|
1438
|
+
querySet: webgpuQuerySet.handle,
|
|
1439
|
+
beginningOfPassWriteIndex: props.beginTimestampIndex,
|
|
1440
|
+
endOfPassWriteIndex: props.endTimestampIndex
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
this.handle = this.props.handle || device.commandEncoder.handle.beginComputePass({
|
|
1445
|
+
label: this.props.id,
|
|
1446
|
+
timestampWrites
|
|
1447
|
+
});
|
|
1171
1448
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1449
|
+
/** @note no WebGPU destroy method, just gc */
|
|
1450
|
+
destroy() {
|
|
1451
|
+
}
|
|
1452
|
+
end() {
|
|
1453
|
+
this.handle.end();
|
|
1454
|
+
}
|
|
1455
|
+
setPipeline(pipeline) {
|
|
1456
|
+
const wgpuPipeline = pipeline;
|
|
1457
|
+
this.handle.setPipeline(wgpuPipeline.handle);
|
|
1458
|
+
this._webgpuPipeline = wgpuPipeline;
|
|
1459
|
+
this.setBindings([]);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Sets an array of bindings (uniform buffers, samplers, textures, ...)
|
|
1463
|
+
* TODO - still some API confusion - does this method go here or on the pipeline?
|
|
1464
|
+
*/
|
|
1465
|
+
setBindings(bindings) {
|
|
1466
|
+
const bindGroup = this._webgpuPipeline._getBindGroup();
|
|
1467
|
+
this.handle.setBindGroup(0, bindGroup);
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Dispatch work to be performed with the current ComputePipeline.
|
|
1471
|
+
* @param x X dimension of the grid of work groups to dispatch.
|
|
1472
|
+
* @param y Y dimension of the grid of work groups to dispatch.
|
|
1473
|
+
* @param z Z dimension of the grid of work groups to dispatch.
|
|
1474
|
+
*/
|
|
1475
|
+
dispatch(x, y, z) {
|
|
1476
|
+
this.handle.dispatchWorkgroups(x, y, z);
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Dispatch work to be performed with the current ComputePipeline.
|
|
1480
|
+
*
|
|
1481
|
+
* 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()
|
|
1482
|
+
* @param indirectBuffer
|
|
1483
|
+
* @param indirectOffset offset in buffer to the beginning of the dispatch data.
|
|
1484
|
+
*/
|
|
1485
|
+
dispatchIndirect(indirectBuffer, indirectByteOffset = 0) {
|
|
1486
|
+
const webgpuBuffer = indirectBuffer;
|
|
1487
|
+
this.handle.dispatchWorkgroupsIndirect(webgpuBuffer.handle, indirectByteOffset);
|
|
1488
|
+
}
|
|
1489
|
+
pushDebugGroup(groupLabel) {
|
|
1490
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
1491
|
+
}
|
|
1492
|
+
popDebugGroup() {
|
|
1493
|
+
this.handle.popDebugGroup();
|
|
1494
|
+
}
|
|
1495
|
+
insertDebugMarker(markerLabel) {
|
|
1496
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1183
1499
|
}
|
|
1184
|
-
};
|
|
1500
|
+
});
|
|
1185
1501
|
|
|
1186
|
-
// dist/adapter/webgpu-
|
|
1187
|
-
var
|
|
1188
|
-
var
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1502
|
+
// dist/adapter/resources/webgpu-command-encoder.js
|
|
1503
|
+
var import_core18, WebGPUCommandEncoder;
|
|
1504
|
+
var init_webgpu_command_encoder = __esm({
|
|
1505
|
+
"dist/adapter/resources/webgpu-command-encoder.js"() {
|
|
1506
|
+
"use strict";
|
|
1507
|
+
import_core18 = require("@luma.gl/core");
|
|
1508
|
+
init_webgpu_command_buffer();
|
|
1509
|
+
init_webgpu_render_pass();
|
|
1510
|
+
init_webgpu_compute_pass();
|
|
1511
|
+
WebGPUCommandEncoder = class extends import_core18.CommandEncoder {
|
|
1512
|
+
device;
|
|
1513
|
+
handle;
|
|
1514
|
+
constructor(device, props = {}) {
|
|
1515
|
+
super(device, props);
|
|
1516
|
+
this.device = device;
|
|
1517
|
+
this.handle = props.handle || this.device.handle.createCommandEncoder({
|
|
1518
|
+
label: this.props.id
|
|
1519
|
+
// TODO was this removed in standard?
|
|
1520
|
+
// measureExecutionTime: this.props.measureExecutionTime
|
|
1521
|
+
});
|
|
1522
|
+
this.handle.label = this.props.id;
|
|
1523
|
+
}
|
|
1524
|
+
destroy() {
|
|
1525
|
+
}
|
|
1526
|
+
finish(props) {
|
|
1527
|
+
this.device.pushErrorScope("validation");
|
|
1528
|
+
const commandBuffer = new WebGPUCommandBuffer(this, {
|
|
1529
|
+
id: (props == null ? void 0 : props.id) || "unnamed-command-buffer"
|
|
1530
|
+
});
|
|
1531
|
+
this.device.popErrorScope((error) => {
|
|
1532
|
+
const message = `${this} command encoding: ${error.message}. Maybe add depthWriteEnabled to your Model?`;
|
|
1533
|
+
this.device.reportError(new Error(message), this)();
|
|
1534
|
+
this.device.debug();
|
|
1535
|
+
});
|
|
1536
|
+
return commandBuffer;
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Allows a render pass to begin against a canvas context
|
|
1540
|
+
* @todo need to support a "Framebuffer" equivalent (aka preconfigured RenderPassDescriptors?).
|
|
1541
|
+
*/
|
|
1542
|
+
beginRenderPass(props) {
|
|
1543
|
+
return new WebGPURenderPass(this.device, props);
|
|
1544
|
+
}
|
|
1545
|
+
beginComputePass(props) {
|
|
1546
|
+
return new WebGPUComputePass(this.device, props);
|
|
1547
|
+
}
|
|
1548
|
+
// beginRenderPass(GPURenderPassDescriptor descriptor): GPURenderPassEncoder;
|
|
1549
|
+
// beginComputePass(optional GPUComputePassDescriptor descriptor = {}): GPUComputePassEncoder;
|
|
1550
|
+
copyBufferToBuffer(options) {
|
|
1551
|
+
const webgpuSourceBuffer = options.sourceBuffer;
|
|
1552
|
+
const WebGPUDestinationBuffer = options.destinationBuffer;
|
|
1553
|
+
this.handle.copyBufferToBuffer(webgpuSourceBuffer.handle, options.sourceOffset ?? 0, WebGPUDestinationBuffer.handle, options.destinationOffset ?? 0, options.size ?? 0);
|
|
1554
|
+
}
|
|
1555
|
+
copyBufferToTexture(options) {
|
|
1556
|
+
var _a, _b, _c;
|
|
1557
|
+
const webgpuSourceBuffer = options.sourceBuffer;
|
|
1558
|
+
const WebGPUDestinationTexture = options.destinationTexture;
|
|
1559
|
+
this.handle.copyBufferToTexture({
|
|
1560
|
+
buffer: webgpuSourceBuffer.handle,
|
|
1561
|
+
offset: options.offset ?? 0,
|
|
1562
|
+
bytesPerRow: options.bytesPerRow,
|
|
1563
|
+
rowsPerImage: options.rowsPerImage
|
|
1564
|
+
}, {
|
|
1565
|
+
texture: WebGPUDestinationTexture.handle,
|
|
1566
|
+
mipLevel: options.mipLevel ?? 0,
|
|
1567
|
+
origin: options.origin ?? {}
|
|
1568
|
+
// aspect: options.aspect
|
|
1569
|
+
}, {
|
|
1570
|
+
// @ts-ignore
|
|
1571
|
+
width: (_a = options.extent) == null ? void 0 : _a[0],
|
|
1572
|
+
height: (_b = options.extent) == null ? void 0 : _b[1],
|
|
1573
|
+
depthOrArrayLayers: (_c = options.extent) == null ? void 0 : _c[2]
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
copyTextureToBuffer(options) {
|
|
1577
|
+
}
|
|
1578
|
+
copyTextureToTexture(options) {
|
|
1579
|
+
}
|
|
1580
|
+
pushDebugGroup(groupLabel) {
|
|
1581
|
+
this.handle.pushDebugGroup(groupLabel);
|
|
1582
|
+
}
|
|
1583
|
+
popDebugGroup() {
|
|
1584
|
+
this.handle.popDebugGroup();
|
|
1585
|
+
}
|
|
1586
|
+
insertDebugMarker(markerLabel) {
|
|
1587
|
+
this.handle.insertDebugMarker(markerLabel);
|
|
1588
|
+
}
|
|
1589
|
+
resolveQuerySet(querySet, destination, options) {
|
|
1590
|
+
const webgpuQuerySet = querySet;
|
|
1591
|
+
const webgpuBuffer = destination;
|
|
1592
|
+
this.handle.resolveQuerySet(webgpuQuerySet.handle, (options == null ? void 0 : options.firstQuery) || 0, (options == null ? void 0 : options.queryCount) || querySet.props.count - ((options == null ? void 0 : options.firstQuery) || 0), webgpuBuffer.handle, (options == null ? void 0 : options.destinationOffset) || 0);
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1278
1595
|
}
|
|
1279
|
-
};
|
|
1596
|
+
});
|
|
1280
1597
|
|
|
1281
1598
|
// dist/adapter/resources/webgpu-query-set.js
|
|
1282
|
-
var
|
|
1283
|
-
var
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1599
|
+
var import_core19, WebGPUQuerySet;
|
|
1600
|
+
var init_webgpu_query_set = __esm({
|
|
1601
|
+
"dist/adapter/resources/webgpu-query-set.js"() {
|
|
1602
|
+
"use strict";
|
|
1603
|
+
import_core19 = require("@luma.gl/core");
|
|
1604
|
+
WebGPUQuerySet = class extends import_core19.QuerySet {
|
|
1605
|
+
device;
|
|
1606
|
+
handle;
|
|
1607
|
+
constructor(device, props) {
|
|
1608
|
+
super(device, props);
|
|
1609
|
+
this.device = device;
|
|
1610
|
+
this.handle = this.props.handle || this.device.handle.createQuerySet({
|
|
1611
|
+
type: this.props.type,
|
|
1612
|
+
count: this.props.count
|
|
1613
|
+
});
|
|
1614
|
+
this.handle.label = this.props.id;
|
|
1615
|
+
}
|
|
1616
|
+
destroy() {
|
|
1617
|
+
var _a;
|
|
1618
|
+
(_a = this.handle) == null ? void 0 : _a.destroy();
|
|
1619
|
+
this.handle = null;
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1299
1622
|
}
|
|
1300
|
-
};
|
|
1623
|
+
});
|
|
1301
1624
|
|
|
1302
1625
|
// dist/adapter/resources/webgpu-pipeline-layout.js
|
|
1303
|
-
var
|
|
1304
|
-
var
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1626
|
+
var import_core20, WebGPUPipelineLayout, isStorageTextureBindingLayout;
|
|
1627
|
+
var init_webgpu_pipeline_layout = __esm({
|
|
1628
|
+
"dist/adapter/resources/webgpu-pipeline-layout.js"() {
|
|
1629
|
+
"use strict";
|
|
1630
|
+
import_core20 = require("@luma.gl/core");
|
|
1631
|
+
WebGPUPipelineLayout = class extends import_core20.PipelineLayout {
|
|
1632
|
+
device;
|
|
1633
|
+
handle;
|
|
1634
|
+
constructor(device, props) {
|
|
1635
|
+
super(device, props);
|
|
1636
|
+
this.device = device;
|
|
1637
|
+
const bindGroupEntries = this.mapShaderLayoutToBindGroupEntries();
|
|
1638
|
+
this.handle = this.device.handle.createPipelineLayout({
|
|
1639
|
+
label: (props == null ? void 0 : props.id) ?? "unnamed-pipeline-layout",
|
|
1640
|
+
bindGroupLayouts: [
|
|
1641
|
+
// TODO (kaapp): We can cache these to re-use them across
|
|
1642
|
+
// layers, particularly if using a separate group for injected
|
|
1643
|
+
// bindings (e.g. project/lighting)
|
|
1644
|
+
this.device.handle.createBindGroupLayout({
|
|
1645
|
+
label: "bind-group-layout",
|
|
1646
|
+
entries: bindGroupEntries
|
|
1647
|
+
})
|
|
1648
|
+
]
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
destroy() {
|
|
1652
|
+
this.handle = null;
|
|
1653
|
+
}
|
|
1654
|
+
mapShaderLayoutToBindGroupEntries() {
|
|
1655
|
+
const bindGroupEntries = [];
|
|
1656
|
+
for (let i = 0; i < this.props.shaderLayout.bindings.length; i++) {
|
|
1657
|
+
const binding = this.props.shaderLayout.bindings[i];
|
|
1658
|
+
const bindingTypeInfo = {};
|
|
1659
|
+
switch (binding.type) {
|
|
1660
|
+
case "uniform": {
|
|
1661
|
+
bindingTypeInfo.buffer = {
|
|
1662
|
+
type: "uniform",
|
|
1663
|
+
hasDynamicOffset: binding.hasDynamicOffset,
|
|
1664
|
+
minBindingSize: binding.minBindingSize
|
|
1665
|
+
};
|
|
1666
|
+
break;
|
|
1667
|
+
}
|
|
1668
|
+
case "read-only-storage": {
|
|
1669
|
+
bindingTypeInfo.buffer = {
|
|
1670
|
+
type: "read-only-storage",
|
|
1671
|
+
hasDynamicOffset: binding.hasDynamicOffset,
|
|
1672
|
+
minBindingSize: binding.minBindingSize
|
|
1673
|
+
};
|
|
1674
|
+
break;
|
|
1675
|
+
}
|
|
1676
|
+
case "sampler": {
|
|
1677
|
+
bindingTypeInfo.sampler = {
|
|
1678
|
+
type: binding.samplerType
|
|
1679
|
+
};
|
|
1680
|
+
break;
|
|
1681
|
+
}
|
|
1682
|
+
case "storage": {
|
|
1683
|
+
if (isStorageTextureBindingLayout(binding)) {
|
|
1684
|
+
bindingTypeInfo.storageTexture = {
|
|
1685
|
+
// TODO (kaapp): Not all formats in the binding layout are supported
|
|
1686
|
+
// by WebGPU, but at least it will provide a clear error for now.
|
|
1687
|
+
format: binding.format,
|
|
1688
|
+
access: binding.access,
|
|
1689
|
+
viewDimension: binding.viewDimension
|
|
1690
|
+
};
|
|
1691
|
+
} else {
|
|
1692
|
+
bindingTypeInfo.buffer = {
|
|
1693
|
+
type: "storage",
|
|
1694
|
+
hasDynamicOffset: binding.hasDynamicOffset,
|
|
1695
|
+
minBindingSize: binding.minBindingSize
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
break;
|
|
1699
|
+
}
|
|
1700
|
+
case "texture": {
|
|
1701
|
+
bindingTypeInfo.texture = {
|
|
1702
|
+
multisampled: binding.multisampled,
|
|
1703
|
+
sampleType: binding.sampleType,
|
|
1704
|
+
viewDimension: binding.viewDimension
|
|
1705
|
+
};
|
|
1706
|
+
break;
|
|
1707
|
+
}
|
|
1708
|
+
default: {
|
|
1709
|
+
import_core20.log.warn("unhandled binding type when creating pipeline descriptor")();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
const VISIBILITY_ALL = GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE;
|
|
1713
|
+
bindGroupEntries.push({
|
|
1714
|
+
binding: binding.location,
|
|
1715
|
+
visibility: binding.visibility || VISIBILITY_ALL,
|
|
1716
|
+
...bindingTypeInfo
|
|
1717
|
+
});
|
|
1340
1718
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1719
|
+
return bindGroupEntries;
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
isStorageTextureBindingLayout = (maybe) => {
|
|
1723
|
+
return maybe.format !== void 0;
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
|
|
1728
|
+
// dist/adapter/webgpu-device.js
|
|
1729
|
+
var webgpu_device_exports = {};
|
|
1730
|
+
__export(webgpu_device_exports, {
|
|
1731
|
+
WebGPUDevice: () => WebGPUDevice
|
|
1732
|
+
});
|
|
1733
|
+
var import_core21, WebGPUDevice;
|
|
1734
|
+
var init_webgpu_device = __esm({
|
|
1735
|
+
"dist/adapter/webgpu-device.js"() {
|
|
1736
|
+
"use strict";
|
|
1737
|
+
import_core21 = require("@luma.gl/core");
|
|
1738
|
+
init_webgpu_buffer();
|
|
1739
|
+
init_webgpu_texture();
|
|
1740
|
+
init_webgpu_external_texture();
|
|
1741
|
+
init_webgpu_sampler();
|
|
1742
|
+
init_webgpu_shader();
|
|
1743
|
+
init_webgpu_render_pipeline();
|
|
1744
|
+
init_webgpu_framebuffer();
|
|
1745
|
+
init_webgpu_compute_pipeline();
|
|
1746
|
+
init_webgpu_vertex_array();
|
|
1747
|
+
init_webgpu_canvas_context();
|
|
1748
|
+
init_webgpu_command_encoder();
|
|
1749
|
+
init_webgpu_query_set();
|
|
1750
|
+
init_webgpu_pipeline_layout();
|
|
1751
|
+
WebGPUDevice = class extends import_core21.Device {
|
|
1752
|
+
/** The underlying WebGPU device */
|
|
1753
|
+
handle;
|
|
1754
|
+
/* The underlying WebGPU adapter */
|
|
1755
|
+
adapter;
|
|
1756
|
+
/* The underlying WebGPU adapter's info */
|
|
1757
|
+
adapterInfo;
|
|
1758
|
+
/** type of this device */
|
|
1759
|
+
type = "webgpu";
|
|
1760
|
+
preferredColorFormat = navigator.gpu.getPreferredCanvasFormat();
|
|
1761
|
+
preferredDepthFormat = "depth24plus";
|
|
1762
|
+
features;
|
|
1763
|
+
info;
|
|
1764
|
+
limits;
|
|
1765
|
+
lost;
|
|
1766
|
+
canvasContext = null;
|
|
1767
|
+
_isLost = false;
|
|
1768
|
+
commandEncoder;
|
|
1769
|
+
get [Symbol.toStringTag]() {
|
|
1770
|
+
return "WebGPUDevice";
|
|
1771
|
+
}
|
|
1772
|
+
toString() {
|
|
1773
|
+
return `WebGPUDevice(${this.id})`;
|
|
1774
|
+
}
|
|
1775
|
+
constructor(props, device, adapter, adapterInfo) {
|
|
1776
|
+
super({ ...props, id: props.id || "webgpu-device" });
|
|
1777
|
+
this.handle = device;
|
|
1778
|
+
this.adapter = adapter;
|
|
1779
|
+
this.adapterInfo = adapterInfo;
|
|
1780
|
+
this.info = this._getInfo();
|
|
1781
|
+
this.features = this._getFeatures();
|
|
1782
|
+
this.limits = this.handle.limits;
|
|
1783
|
+
device.addEventListener("uncapturederror", (event) => {
|
|
1784
|
+
event.preventDefault();
|
|
1785
|
+
const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : "Unknown WebGPU error";
|
|
1786
|
+
this.reportError(new Error(errorMessage), this)();
|
|
1787
|
+
this.debug();
|
|
1788
|
+
});
|
|
1789
|
+
this.lost = new Promise(async (resolve) => {
|
|
1790
|
+
const lostInfo = await this.handle.lost;
|
|
1791
|
+
this._isLost = true;
|
|
1792
|
+
resolve({ reason: "destroyed", message: lostInfo.message });
|
|
1793
|
+
});
|
|
1794
|
+
const canvasContextProps = import_core21.Device._getCanvasContextProps(props);
|
|
1795
|
+
if (canvasContextProps) {
|
|
1796
|
+
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
1348
1797
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1798
|
+
this.commandEncoder = this.createCommandEncoder({});
|
|
1799
|
+
}
|
|
1800
|
+
// TODO
|
|
1801
|
+
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
1802
|
+
// const {glsl = true} = props;
|
|
1803
|
+
// this.glslang = glsl && await loadGlslangModule();
|
|
1804
|
+
destroy() {
|
|
1805
|
+
this.handle.destroy();
|
|
1806
|
+
}
|
|
1807
|
+
get isLost() {
|
|
1808
|
+
return this._isLost;
|
|
1809
|
+
}
|
|
1810
|
+
isVertexFormatSupported(format) {
|
|
1811
|
+
const info = this.getVertexFormatInfo(format);
|
|
1812
|
+
return !info.webglOnly;
|
|
1813
|
+
}
|
|
1814
|
+
getTextureByteAlignment() {
|
|
1815
|
+
return 1;
|
|
1816
|
+
}
|
|
1817
|
+
createBuffer(props) {
|
|
1818
|
+
const newProps = this._normalizeBufferProps(props);
|
|
1819
|
+
return new WebGPUBuffer(this, newProps);
|
|
1820
|
+
}
|
|
1821
|
+
createTexture(props) {
|
|
1822
|
+
return new WebGPUTexture(this, props);
|
|
1823
|
+
}
|
|
1824
|
+
createExternalTexture(props) {
|
|
1825
|
+
return new WebGPUExternalTexture(this, props);
|
|
1826
|
+
}
|
|
1827
|
+
createShader(props) {
|
|
1828
|
+
return new WebGPUShader(this, props);
|
|
1829
|
+
}
|
|
1830
|
+
createSampler(props) {
|
|
1831
|
+
return new WebGPUSampler(this, props);
|
|
1832
|
+
}
|
|
1833
|
+
createRenderPipeline(props) {
|
|
1834
|
+
return new WebGPURenderPipeline(this, props);
|
|
1835
|
+
}
|
|
1836
|
+
createFramebuffer(props) {
|
|
1837
|
+
return new WebGPUFramebuffer(this, props);
|
|
1838
|
+
}
|
|
1839
|
+
createComputePipeline(props) {
|
|
1840
|
+
return new WebGPUComputePipeline(this, props);
|
|
1841
|
+
}
|
|
1842
|
+
createVertexArray(props) {
|
|
1843
|
+
return new WebGPUVertexArray(this, props);
|
|
1844
|
+
}
|
|
1845
|
+
createCommandEncoder(props) {
|
|
1846
|
+
return new WebGPUCommandEncoder(this, props);
|
|
1847
|
+
}
|
|
1848
|
+
// WebGPU specifics
|
|
1849
|
+
createTransformFeedback(props) {
|
|
1850
|
+
throw new Error("Transform feedback not supported in WebGPU");
|
|
1851
|
+
}
|
|
1852
|
+
createQuerySet(props) {
|
|
1853
|
+
return new WebGPUQuerySet(this, props);
|
|
1854
|
+
}
|
|
1855
|
+
createCanvasContext(props) {
|
|
1856
|
+
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
1857
|
+
}
|
|
1858
|
+
createPipelineLayout(props) {
|
|
1859
|
+
return new WebGPUPipelineLayout(this, props);
|
|
1860
|
+
}
|
|
1861
|
+
submit(commandBuffer) {
|
|
1862
|
+
if (!commandBuffer) {
|
|
1863
|
+
commandBuffer = this.commandEncoder.finish();
|
|
1864
|
+
this.commandEncoder.destroy();
|
|
1865
|
+
this.commandEncoder = this.createCommandEncoder({ id: `${this.id}-default-encoder` });
|
|
1354
1866
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1867
|
+
this.pushErrorScope("validation");
|
|
1868
|
+
this.handle.queue.submit([commandBuffer.handle]);
|
|
1869
|
+
this.popErrorScope((error) => {
|
|
1870
|
+
this.reportError(new Error(`${this} command submission: ${error.message}`), this)();
|
|
1871
|
+
this.debug();
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
// WebGPU specific
|
|
1875
|
+
pushErrorScope(scope) {
|
|
1876
|
+
this.handle.pushErrorScope(scope);
|
|
1877
|
+
}
|
|
1878
|
+
popErrorScope(handler) {
|
|
1879
|
+
this.handle.popErrorScope().then((error) => {
|
|
1880
|
+
if (error) {
|
|
1881
|
+
handler(error);
|
|
1370
1882
|
}
|
|
1371
|
-
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
// PRIVATE METHODS
|
|
1886
|
+
_getInfo() {
|
|
1887
|
+
const [driver, driverVersion] = (this.adapterInfo.driver || "").split(" Version ");
|
|
1888
|
+
const vendor = this.adapterInfo.vendor || this.adapter.__brand || "unknown";
|
|
1889
|
+
const renderer = driver || "";
|
|
1890
|
+
const version = driverVersion || "";
|
|
1891
|
+
const gpu = vendor === "apple" ? "apple" : "unknown";
|
|
1892
|
+
const gpuArchitecture = this.adapterInfo.architecture || "unknown";
|
|
1893
|
+
const gpuBackend = this.adapterInfo.backend || "unknown";
|
|
1894
|
+
const gpuType = (this.adapterInfo.type || "").split(" ")[0].toLowerCase() || "unknown";
|
|
1895
|
+
return {
|
|
1896
|
+
type: "webgpu",
|
|
1897
|
+
vendor,
|
|
1898
|
+
renderer,
|
|
1899
|
+
version,
|
|
1900
|
+
gpu,
|
|
1901
|
+
gpuType,
|
|
1902
|
+
gpuBackend,
|
|
1903
|
+
gpuArchitecture,
|
|
1904
|
+
shadingLanguage: "wgsl",
|
|
1905
|
+
shadingLanguageVersion: 100
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
_getFeatures() {
|
|
1909
|
+
const features = new Set(this.handle.features);
|
|
1910
|
+
if (features.has("depth-clamping")) {
|
|
1911
|
+
features.delete("depth-clamping");
|
|
1912
|
+
features.add("depth-clip-control");
|
|
1372
1913
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
multisampled: binding.multisampled,
|
|
1376
|
-
sampleType: binding.sampleType,
|
|
1377
|
-
viewDimension: binding.viewDimension
|
|
1378
|
-
};
|
|
1379
|
-
break;
|
|
1914
|
+
if (features.has("texture-compression-bc")) {
|
|
1915
|
+
features.add("texture-compression-bc5-webgl");
|
|
1380
1916
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1917
|
+
const WEBGPU_ALWAYS_FEATURES = [
|
|
1918
|
+
"timer-query-webgl",
|
|
1919
|
+
"compilation-status-async-webgl",
|
|
1920
|
+
"float32-renderable-webgl",
|
|
1921
|
+
"float16-renderable-webgl",
|
|
1922
|
+
"norm16-renderable-webgl",
|
|
1923
|
+
"texture-filterable-anisotropic-webgl",
|
|
1924
|
+
"shader-noperspective-interpolation-webgl"
|
|
1925
|
+
];
|
|
1926
|
+
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
1927
|
+
features.add(feature);
|
|
1383
1928
|
}
|
|
1929
|
+
return new import_core21.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
1384
1930
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
...bindingTypeInfo
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
return bindGroupEntries;
|
|
1393
|
-
}
|
|
1394
|
-
};
|
|
1395
|
-
var isStorageTextureBindingLayout = (maybe) => {
|
|
1396
|
-
return maybe.format !== void 0;
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
// dist/adapter/webgpu-device.js
|
|
1400
|
-
var WebGPUDevice = class extends import_core19.Device {
|
|
1401
|
-
/** type of this device */
|
|
1402
|
-
type = "webgpu";
|
|
1403
|
-
/** The underlying WebGPU device */
|
|
1404
|
-
handle;
|
|
1405
|
-
/* The underlying WebGPU adapter */
|
|
1406
|
-
adapter;
|
|
1407
|
-
/* The underlying WebGPU adapter's info */
|
|
1408
|
-
adapterInfo;
|
|
1409
|
-
features;
|
|
1410
|
-
info;
|
|
1411
|
-
limits;
|
|
1412
|
-
lost;
|
|
1413
|
-
canvasContext = null;
|
|
1414
|
-
_isLost = false;
|
|
1415
|
-
commandEncoder = null;
|
|
1416
|
-
renderPass = null;
|
|
1417
|
-
constructor(props, device, adapter, adapterInfo) {
|
|
1418
|
-
super({ ...props, id: props.id || "webgpu-device" });
|
|
1419
|
-
this.handle = device;
|
|
1420
|
-
this.adapter = adapter;
|
|
1421
|
-
this.adapterInfo = adapterInfo;
|
|
1422
|
-
this.info = this._getInfo();
|
|
1423
|
-
this.features = this._getFeatures();
|
|
1424
|
-
this.limits = this.handle.limits;
|
|
1425
|
-
device.addEventListener("uncapturederror", (event) => {
|
|
1426
|
-
const errorMessage = event instanceof GPUUncapturedErrorEvent ? event.error.message : "Unknown WebGPU error";
|
|
1427
|
-
this.reportError(new Error(errorMessage));
|
|
1428
|
-
if (this.props.debug) {
|
|
1429
|
-
debugger;
|
|
1430
|
-
}
|
|
1431
|
-
event.preventDefault();
|
|
1432
|
-
});
|
|
1433
|
-
this.lost = new Promise(async (resolve) => {
|
|
1434
|
-
const lostInfo = await this.handle.lost;
|
|
1435
|
-
this._isLost = true;
|
|
1436
|
-
resolve({ reason: "destroyed", message: lostInfo.message });
|
|
1437
|
-
});
|
|
1438
|
-
const canvasContextProps = import_core19.Device._getCanvasContextProps(props);
|
|
1439
|
-
if (canvasContextProps) {
|
|
1440
|
-
this.canvasContext = new WebGPUCanvasContext(this, this.adapter, canvasContextProps);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
// TODO
|
|
1444
|
-
// Load the glslang module now so that it is available synchronously when compiling shaders
|
|
1445
|
-
// const {glsl = true} = props;
|
|
1446
|
-
// this.glslang = glsl && await loadGlslangModule();
|
|
1447
|
-
destroy() {
|
|
1448
|
-
this.handle.destroy();
|
|
1449
|
-
}
|
|
1450
|
-
get isLost() {
|
|
1451
|
-
return this._isLost;
|
|
1452
|
-
}
|
|
1453
|
-
createBuffer(props) {
|
|
1454
|
-
const newProps = this._normalizeBufferProps(props);
|
|
1455
|
-
return new WebGPUBuffer(this, newProps);
|
|
1456
|
-
}
|
|
1457
|
-
createTexture(props) {
|
|
1458
|
-
return new WebGPUTexture(this, props);
|
|
1459
|
-
}
|
|
1460
|
-
createExternalTexture(props) {
|
|
1461
|
-
return new WebGPUExternalTexture(this, props);
|
|
1462
|
-
}
|
|
1463
|
-
createShader(props) {
|
|
1464
|
-
return new WebGPUShader(this, props);
|
|
1465
|
-
}
|
|
1466
|
-
createSampler(props) {
|
|
1467
|
-
return new WebGPUSampler(this, props);
|
|
1468
|
-
}
|
|
1469
|
-
createRenderPipeline(props) {
|
|
1470
|
-
return new WebGPURenderPipeline(this, props);
|
|
1471
|
-
}
|
|
1472
|
-
createFramebuffer(props) {
|
|
1473
|
-
return new WebGPUFramebuffer(this, props);
|
|
1474
|
-
}
|
|
1475
|
-
createComputePipeline(props) {
|
|
1476
|
-
return new WebGPUComputePipeline(this, props);
|
|
1477
|
-
}
|
|
1478
|
-
createVertexArray(props) {
|
|
1479
|
-
return new WebGPUVertexArray(this, props);
|
|
1480
|
-
}
|
|
1481
|
-
// WebGPU specifics
|
|
1482
|
-
/**
|
|
1483
|
-
* Allows a render pass to begin against a canvas context
|
|
1484
|
-
* @todo need to support a "Framebuffer" equivalent (aka preconfigured RenderPassDescriptors?).
|
|
1485
|
-
*/
|
|
1486
|
-
beginRenderPass(props) {
|
|
1487
|
-
this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();
|
|
1488
|
-
return new WebGPURenderPass(this, props);
|
|
1489
|
-
}
|
|
1490
|
-
beginComputePass(props) {
|
|
1491
|
-
this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();
|
|
1492
|
-
return new WebGPUComputePass(this, props);
|
|
1493
|
-
}
|
|
1494
|
-
// createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {
|
|
1495
|
-
// return new WebGPUCommandEncoder(this, props);
|
|
1496
|
-
// }
|
|
1497
|
-
createTransformFeedback(props) {
|
|
1498
|
-
throw new Error("Transform feedback not supported in WebGPU");
|
|
1499
|
-
}
|
|
1500
|
-
createQuerySet(props) {
|
|
1501
|
-
return new WebGPUQuerySet(this, props);
|
|
1502
|
-
}
|
|
1503
|
-
createCanvasContext(props) {
|
|
1504
|
-
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
1505
|
-
}
|
|
1506
|
-
createPipelineLayout(props) {
|
|
1507
|
-
return new WebGPUPipelineLayout(this, props);
|
|
1508
|
-
}
|
|
1509
|
-
submit() {
|
|
1510
|
-
var _a;
|
|
1511
|
-
const commandBuffer = (_a = this.commandEncoder) == null ? void 0 : _a.finish();
|
|
1512
|
-
if (commandBuffer) {
|
|
1513
|
-
this.handle.pushErrorScope("validation");
|
|
1514
|
-
this.handle.queue.submit([commandBuffer]);
|
|
1515
|
-
this.handle.popErrorScope().then((error) => {
|
|
1516
|
-
if (error) {
|
|
1517
|
-
this.reportError(new Error(`WebGPU command submission failed: ${error.message}`));
|
|
1931
|
+
_getDeviceSpecificTextureFormatCapabilities(capabilities) {
|
|
1932
|
+
const { format } = capabilities;
|
|
1933
|
+
if (format.includes("webgl")) {
|
|
1934
|
+
return { format, create: false, render: false, filter: false, blend: false, store: false };
|
|
1518
1935
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
// PRIVATE METHODS
|
|
1523
|
-
_getInfo() {
|
|
1524
|
-
const [driver, driverVersion] = (this.adapterInfo.driver || "").split(" Version ");
|
|
1525
|
-
const vendor = this.adapterInfo.vendor || this.adapter.__brand || "unknown";
|
|
1526
|
-
const renderer = driver || "";
|
|
1527
|
-
const version = driverVersion || "";
|
|
1528
|
-
const gpu = vendor === "apple" ? "apple" : "unknown";
|
|
1529
|
-
const gpuArchitecture = this.adapterInfo.architecture || "unknown";
|
|
1530
|
-
const gpuBackend = this.adapterInfo.backend || "unknown";
|
|
1531
|
-
const gpuType = (this.adapterInfo.type || "").split(" ")[0].toLowerCase() || "unknown";
|
|
1532
|
-
return {
|
|
1533
|
-
type: "webgpu",
|
|
1534
|
-
vendor,
|
|
1535
|
-
renderer,
|
|
1536
|
-
version,
|
|
1537
|
-
gpu,
|
|
1538
|
-
gpuType,
|
|
1539
|
-
gpuBackend,
|
|
1540
|
-
gpuArchitecture,
|
|
1541
|
-
shadingLanguage: "wgsl",
|
|
1542
|
-
shadingLanguageVersion: 100
|
|
1936
|
+
return capabilities;
|
|
1937
|
+
}
|
|
1543
1938
|
};
|
|
1544
1939
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
"float16-renderable-webgl",
|
|
1559
|
-
"norm16-renderable-webgl",
|
|
1560
|
-
"texture-filterable-anisotropic-webgl",
|
|
1561
|
-
"shader-noperspective-interpolation-webgl"
|
|
1562
|
-
];
|
|
1563
|
-
for (const feature of WEBGPU_ALWAYS_FEATURES) {
|
|
1564
|
-
features.add(feature);
|
|
1565
|
-
}
|
|
1566
|
-
return new import_core19.DeviceFeatures(Array.from(features), this.props._disabledFeatures);
|
|
1567
|
-
}
|
|
1568
|
-
_getDeviceSpecificTextureFormatCapabilities(capabilities) {
|
|
1569
|
-
const { format } = capabilities;
|
|
1570
|
-
if (format.includes("webgl")) {
|
|
1571
|
-
return { format, create: false, render: false, filter: false, blend: false, store: false };
|
|
1572
|
-
}
|
|
1573
|
-
return capabilities;
|
|
1574
|
-
}
|
|
1575
|
-
// DEPRECATED METHODS
|
|
1576
|
-
// @deprecated
|
|
1577
|
-
copyExternalImageToTexture(options) {
|
|
1578
|
-
var _a;
|
|
1579
|
-
const {
|
|
1580
|
-
source,
|
|
1581
|
-
sourceX = 0,
|
|
1582
|
-
sourceY = 0,
|
|
1583
|
-
texture,
|
|
1584
|
-
mipLevel = 0,
|
|
1585
|
-
aspect = "all",
|
|
1586
|
-
colorSpace = "display-p3",
|
|
1587
|
-
premultipliedAlpha = false,
|
|
1588
|
-
// destinationX,
|
|
1589
|
-
// destinationY,
|
|
1590
|
-
// desitnationZ,
|
|
1591
|
-
width = texture.width,
|
|
1592
|
-
height = texture.height,
|
|
1593
|
-
depth = 1
|
|
1594
|
-
} = options;
|
|
1595
|
-
const webGpuTexture = texture;
|
|
1596
|
-
(_a = this.handle) == null ? void 0 : _a.queue.copyExternalImageToTexture(
|
|
1597
|
-
// source: GPUImageCopyExternalImage
|
|
1598
|
-
{
|
|
1599
|
-
source,
|
|
1600
|
-
origin: [sourceX, sourceY]
|
|
1601
|
-
},
|
|
1602
|
-
// destination: GPUImageCopyTextureTagged
|
|
1603
|
-
{
|
|
1604
|
-
texture: webGpuTexture.handle,
|
|
1605
|
-
origin: [0, 0, 0],
|
|
1606
|
-
// [x, y, z],
|
|
1607
|
-
mipLevel,
|
|
1608
|
-
aspect,
|
|
1609
|
-
colorSpace,
|
|
1610
|
-
premultipliedAlpha
|
|
1611
|
-
},
|
|
1612
|
-
// copySize: GPUExtent3D
|
|
1613
|
-
[width, height, depth]
|
|
1614
|
-
);
|
|
1615
|
-
}
|
|
1616
|
-
};
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1942
|
+
// dist/index.js
|
|
1943
|
+
var dist_exports = {};
|
|
1944
|
+
__export(dist_exports, {
|
|
1945
|
+
WebGPUBuffer: () => WebGPUBuffer,
|
|
1946
|
+
WebGPUDevice: () => WebGPUDevice,
|
|
1947
|
+
WebGPUSampler: () => WebGPUSampler,
|
|
1948
|
+
WebGPUShader: () => WebGPUShader,
|
|
1949
|
+
WebGPUTexture: () => WebGPUTexture,
|
|
1950
|
+
webgpuAdapter: () => webgpuAdapter
|
|
1951
|
+
});
|
|
1952
|
+
module.exports = __toCommonJS(dist_exports);
|
|
1617
1953
|
|
|
1618
1954
|
// dist/adapter/webgpu-adapter.js
|
|
1619
|
-
var
|
|
1955
|
+
var import_core22 = require("@luma.gl/core");
|
|
1956
|
+
var WebGPUAdapter = class extends import_core22.Adapter {
|
|
1620
1957
|
/** type of device's created by this adapter */
|
|
1621
1958
|
type = "webgpu";
|
|
1622
|
-
constructor() {
|
|
1623
|
-
super();
|
|
1624
|
-
WebGPUDevice.adapter = this;
|
|
1625
|
-
}
|
|
1626
|
-
/** Check if WebGPU is available */
|
|
1627
1959
|
isSupported() {
|
|
1628
1960
|
return Boolean(typeof navigator !== "undefined" && navigator.gpu);
|
|
1629
1961
|
}
|
|
1962
|
+
isDeviceHandle(handle) {
|
|
1963
|
+
if (typeof GPUDevice !== "undefined" && handle instanceof GPUDevice) {
|
|
1964
|
+
return true;
|
|
1965
|
+
}
|
|
1966
|
+
if (handle == null ? void 0 : handle.queue) {
|
|
1967
|
+
return true;
|
|
1968
|
+
}
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1630
1971
|
async create(props) {
|
|
1631
1972
|
var _a;
|
|
1632
1973
|
if (!navigator.gpu) {
|
|
1633
|
-
throw new Error("WebGPU not available.
|
|
1634
|
-
}
|
|
1635
|
-
import_core20.log.groupCollapsed(1, "WebGPUDevice created")();
|
|
1636
|
-
const adapter = await navigator.gpu.requestAdapter({
|
|
1637
|
-
powerPreference: "high-performance"
|
|
1638
|
-
// forceSoftware: false
|
|
1639
|
-
});
|
|
1640
|
-
if (!adapter) {
|
|
1641
|
-
throw new Error("Failed to request WebGPU adapter");
|
|
1974
|
+
throw new Error("WebGPU not available. Recent Chrome browsers should work.");
|
|
1642
1975
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1976
|
+
import_core22.log.groupCollapsed(1, "WebGPUDevice created")();
|
|
1977
|
+
try {
|
|
1978
|
+
const adapter = await navigator.gpu.requestAdapter({
|
|
1979
|
+
powerPreference: "high-performance"
|
|
1980
|
+
// forceSoftware: false
|
|
1981
|
+
});
|
|
1982
|
+
if (!adapter) {
|
|
1983
|
+
throw new Error("Failed to request WebGPU adapter");
|
|
1984
|
+
}
|
|
1985
|
+
const adapterInfo = adapter.info || // @ts-ignore
|
|
1986
|
+
await ((_a = adapter.requestAdapterInfo) == null ? void 0 : _a.call(adapter));
|
|
1987
|
+
import_core22.log.probe(2, "Adapter available", adapterInfo)();
|
|
1988
|
+
const requiredFeatures = [];
|
|
1989
|
+
const requiredLimits = {};
|
|
1990
|
+
if (props._requestMaxLimits) {
|
|
1991
|
+
requiredFeatures.push(...Array.from(adapter.features));
|
|
1992
|
+
const limits = Object.keys(adapter.limits).filter((key) => !["minSubgroupSize", "maxSubgroupSize"].includes(key));
|
|
1993
|
+
for (const key of limits) {
|
|
1994
|
+
const limit = key;
|
|
1995
|
+
const value = adapter.limits[limit];
|
|
1996
|
+
if (typeof value === "number") {
|
|
1997
|
+
requiredLimits[limit] = value;
|
|
1998
|
+
}
|
|
1656
1999
|
}
|
|
1657
2000
|
}
|
|
2001
|
+
const gpuDevice = await adapter.requestDevice({
|
|
2002
|
+
requiredFeatures,
|
|
2003
|
+
requiredLimits
|
|
2004
|
+
});
|
|
2005
|
+
import_core22.log.probe(1, "GPUDevice available")();
|
|
2006
|
+
const { WebGPUDevice: WebGPUDevice2 } = await Promise.resolve().then(() => (init_webgpu_device(), webgpu_device_exports));
|
|
2007
|
+
const device = new WebGPUDevice2(props, gpuDevice, adapter, adapterInfo);
|
|
2008
|
+
import_core22.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
|
|
2009
|
+
import_core22.log.table(1, device.info)();
|
|
2010
|
+
return device;
|
|
2011
|
+
} finally {
|
|
2012
|
+
import_core22.log.groupEnd(1)();
|
|
1658
2013
|
}
|
|
1659
|
-
const gpuDevice = await adapter.requestDevice({
|
|
1660
|
-
requiredFeatures,
|
|
1661
|
-
requiredLimits
|
|
1662
|
-
});
|
|
1663
|
-
import_core20.log.probe(1, "GPUDevice available")();
|
|
1664
|
-
const device = new WebGPUDevice(props, gpuDevice, adapter, adapterInfo);
|
|
1665
|
-
import_core20.log.probe(1, "Device created. For more info, set chrome://flags/#enable-webgpu-developer-features")();
|
|
1666
|
-
import_core20.log.table(1, device.info)();
|
|
1667
|
-
import_core20.log.groupEnd(1)();
|
|
1668
|
-
return device;
|
|
1669
2014
|
}
|
|
1670
2015
|
async attach(handle) {
|
|
1671
2016
|
throw new Error("WebGPUAdapter.attach() not implemented");
|
|
1672
2017
|
}
|
|
1673
2018
|
};
|
|
1674
2019
|
var webgpuAdapter = new WebGPUAdapter();
|
|
2020
|
+
|
|
2021
|
+
// dist/index.js
|
|
2022
|
+
init_webgpu_device();
|
|
2023
|
+
init_webgpu_buffer();
|
|
2024
|
+
init_webgpu_texture();
|
|
2025
|
+
init_webgpu_sampler();
|
|
2026
|
+
init_webgpu_shader();
|
|
1675
2027
|
//# sourceMappingURL=index.cjs.map
|