@luma.gl/webgpu 9.0.0-alpha.21 → 9.0.0-alpha.24
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/resources/webgpu-command-encoder.d.ts +3 -11
- package/dist/adapter/resources/webgpu-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.d.ts +0 -17
- package/dist/adapter/resources/webgpu-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +2 -84
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts +6 -1
- package/dist/adapter/resources/webgpu-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +19 -1
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts +1 -1
- package/dist/adapter/resources/webgpu-sampler.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts +1 -1
- package/dist/adapter/resources/webgpu-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +3 -2
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.d.ts +10 -3
- package/dist/adapter/resources/webgpu-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +8 -1
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts +1 -1
- package/dist/adapter/webgpu-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.d.ts +15 -2
- package/dist/adapter/webgpu-device.d.ts.map +1 -1
- package/dist/adapter/webgpu-device.js +33 -3
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +386 -172
- package/dist/index.cjs +82 -88
- package/dist.min.js +4 -4
- package/package.json +4 -4
- package/src/adapter/resources/webgpu-command-encoder.ts +40 -21
- package/src/adapter/resources/webgpu-framebuffer.ts +6 -107
- package/src/adapter/resources/webgpu-render-pass.ts +34 -4
- package/src/adapter/resources/webgpu-shader.ts +2 -2
- package/src/adapter/resources/webgpu-texture.ts +8 -2
- package/src/adapter/webgpu-canvas-context.ts +2 -1
- package/src/adapter/webgpu-device.ts +73 -4
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
package/dist/index.cjs
CHANGED
|
@@ -189,6 +189,8 @@ var WebGPUTexture = class extends import_api3.Texture {
|
|
|
189
189
|
if (this.props.data) {
|
|
190
190
|
this.setData({ data: this.props.data });
|
|
191
191
|
}
|
|
192
|
+
this.width = this.handle.width;
|
|
193
|
+
this.height = this.handle.height;
|
|
192
194
|
this.sampler = props.sampler instanceof WebGPUSampler ? props.sampler : new WebGPUSampler(this.device, props.sampler);
|
|
193
195
|
this.view = this.handle.createView({
|
|
194
196
|
// format: this.props.format,
|
|
@@ -273,7 +275,7 @@ var WebGPUTexture = class extends import_api3.Texture {
|
|
|
273
275
|
depth
|
|
274
276
|
]
|
|
275
277
|
);
|
|
276
|
-
return
|
|
278
|
+
return { width, height };
|
|
277
279
|
}
|
|
278
280
|
/*
|
|
279
281
|
async readPixels() {
|
|
@@ -403,7 +405,7 @@ var WebGPUShader = class extends import_api5.Shader {
|
|
|
403
405
|
destroy() {
|
|
404
406
|
}
|
|
405
407
|
createHandle() {
|
|
406
|
-
const { source } = this.props;
|
|
408
|
+
const { source, stage } = this.props;
|
|
407
409
|
let language = this.props.language;
|
|
408
410
|
if (!language) {
|
|
409
411
|
language = source.includes("->") ? "wgsl" : "glsl";
|
|
@@ -415,7 +417,7 @@ var WebGPUShader = class extends import_api5.Shader {
|
|
|
415
417
|
return this.device.handle.createShaderModule({
|
|
416
418
|
code: source,
|
|
417
419
|
// @ts-expect-error
|
|
418
|
-
transform: (glsl) => this.device.glslang.compileGLSL(glsl,
|
|
420
|
+
transform: (glsl) => this.device.glslang.compileGLSL(glsl, stage)
|
|
419
421
|
});
|
|
420
422
|
default:
|
|
421
423
|
throw new Error(language);
|
|
@@ -932,7 +934,7 @@ var WebGPURenderPass = class extends import_api10.RenderPass {
|
|
|
932
934
|
this.pipeline = null;
|
|
933
935
|
this.device = device;
|
|
934
936
|
const framebuffer = props.framebuffer || device.canvasContext.getCurrentFramebuffer();
|
|
935
|
-
const renderPassDescriptor = framebuffer
|
|
937
|
+
const renderPassDescriptor = this.getRenderPassDescriptor(framebuffer);
|
|
936
938
|
this.handle = this.props.handle || device.commandEncoder.beginRenderPass(renderPassDescriptor);
|
|
937
939
|
this.handle.label = this.props.id;
|
|
938
940
|
}
|
|
@@ -1017,6 +1019,30 @@ var WebGPURenderPass = class extends import_api10.RenderPass {
|
|
|
1017
1019
|
// beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1018
1020
|
// endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
|
|
1019
1021
|
// executeBundles(bundles: Iterable<GPURenderBundle>): void;
|
|
1022
|
+
// INTERNAL
|
|
1023
|
+
/**
|
|
1024
|
+
* Partial render pass descriptor. Used by WebGPURenderPass.
|
|
1025
|
+
* @returns attachments fields of a renderpass descriptor.
|
|
1026
|
+
*/
|
|
1027
|
+
getRenderPassDescriptor(framebuffer) {
|
|
1028
|
+
const renderPassDescriptor = {
|
|
1029
|
+
colorAttachments: []
|
|
1030
|
+
};
|
|
1031
|
+
renderPassDescriptor.colorAttachments = framebuffer.colorAttachments.map((colorAttachment) => ({
|
|
1032
|
+
// clear values
|
|
1033
|
+
loadOp: "clear",
|
|
1034
|
+
colorClearValue: this.props.clearColor || [0, 0, 0, 0],
|
|
1035
|
+
storeOp: this.props.discard ? "discard" : "store",
|
|
1036
|
+
// ...colorAttachment,
|
|
1037
|
+
view: colorAttachment.handle.createView()
|
|
1038
|
+
}));
|
|
1039
|
+
if (framebuffer.depthStencilAttachment) {
|
|
1040
|
+
renderPassDescriptor.depthStencilAttachment = __spreadProps(__spreadValues({}, this.props), {
|
|
1041
|
+
view: framebuffer.depthStencilAttachment.handle.createView()
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
return renderPassDescriptor;
|
|
1045
|
+
}
|
|
1020
1046
|
};
|
|
1021
1047
|
|
|
1022
1048
|
// src/adapter/resources/webgpu-compute-pass.ts
|
|
@@ -1086,88 +1112,8 @@ var import_api12 = require("@luma.gl/api");
|
|
|
1086
1112
|
var WebGPUFramebuffer = class extends import_api12.Framebuffer {
|
|
1087
1113
|
constructor(device, props) {
|
|
1088
1114
|
super(device, props);
|
|
1089
|
-
this.colorAttachments = [];
|
|
1090
|
-
this.depthStencilAttachment = null;
|
|
1091
|
-
/** Partial render pass descriptor. Used by WebGPURenderPass */
|
|
1092
|
-
this.renderPassDescriptor = {
|
|
1093
|
-
colorAttachments: []
|
|
1094
|
-
};
|
|
1095
1115
|
this.device = device;
|
|
1096
|
-
|
|
1097
|
-
this.depthStencilAttachment = this.createDepthStencilTexture(props);
|
|
1098
|
-
}
|
|
1099
|
-
if (props.colorAttachments) {
|
|
1100
|
-
this.colorAttachments = props.colorAttachments.map((colorAttachment) => this.createColorTexture(this.props, colorAttachment));
|
|
1101
|
-
}
|
|
1102
|
-
if (this.depthStencilAttachment) {
|
|
1103
|
-
this.renderPassDescriptor.depthStencilAttachment = {
|
|
1104
|
-
view: this.depthStencilAttachment.handle.createView(),
|
|
1105
|
-
// Add default clear values
|
|
1106
|
-
depthClearValue: 1,
|
|
1107
|
-
depthStoreOp: "store",
|
|
1108
|
-
stencilClearValue: 0,
|
|
1109
|
-
stencilStoreOp: "store"
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
if (this.colorAttachments.length > 0) {
|
|
1113
|
-
this.renderPassDescriptor.colorAttachments = this.colorAttachments.map((colorAttachment) => ({
|
|
1114
|
-
view: colorAttachment.handle.createView(),
|
|
1115
|
-
loadOp: "clear",
|
|
1116
|
-
loadValue: [0, 0, 0, 0],
|
|
1117
|
-
storeOp: "store"
|
|
1118
|
-
}));
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
/** Create depth stencil texture */
|
|
1122
|
-
createDepthStencilTexture(props) {
|
|
1123
|
-
if (props.depthStencilAttachment instanceof WebGPUTexture) {
|
|
1124
|
-
return props.depthStencilAttachment;
|
|
1125
|
-
}
|
|
1126
|
-
if (typeof props.depthStencilAttachment === "string") {
|
|
1127
|
-
return this.device._createTexture({
|
|
1128
|
-
id: "depth-stencil-attachment",
|
|
1129
|
-
format: props.depthStencilAttachment,
|
|
1130
|
-
width: props.width,
|
|
1131
|
-
height: props.height,
|
|
1132
|
-
usage: import_api12.Texture.RENDER_ATTACHMENT
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
throw new Error("type");
|
|
1136
|
-
}
|
|
1137
|
-
createColorTexture(props, texture) {
|
|
1138
|
-
if (texture instanceof WebGPUTexture) {
|
|
1139
|
-
return texture;
|
|
1140
|
-
}
|
|
1141
|
-
if (typeof texture === "string") {
|
|
1142
|
-
return this.device._createTexture({
|
|
1143
|
-
id: "color-attachment",
|
|
1144
|
-
format: texture,
|
|
1145
|
-
width: props.width,
|
|
1146
|
-
height: props.height,
|
|
1147
|
-
usage: import_api12.Texture.RENDER_ATTACHMENT
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
throw new Error("type");
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Create new textures with correct size for all attachments.
|
|
1154
|
-
* @note destroys existing textures.
|
|
1155
|
-
*/
|
|
1156
|
-
_resizeAttachments(width, height) {
|
|
1157
|
-
for (let i = 0; i < this.colorAttachments.length; ++i) {
|
|
1158
|
-
if (this.colorAttachments[i]) {
|
|
1159
|
-
const resizedTexture = this.device._createTexture(__spreadProps(__spreadValues({}, this.colorAttachments[i].props), { width, height }));
|
|
1160
|
-
this.colorAttachments[i].destroy();
|
|
1161
|
-
this.colorAttachments[i] = resizedTexture;
|
|
1162
|
-
this.renderPassDescriptor.colorAttachments[i].view = resizedTexture.handle.createView();
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
if (this.depthStencilAttachment) {
|
|
1166
|
-
const resizedTexture = this.device._createTexture(__spreadProps(__spreadValues({}, this.depthStencilAttachment.props), { width, height }));
|
|
1167
|
-
this.depthStencilAttachment.destroy();
|
|
1168
|
-
this.depthStencilAttachment = resizedTexture;
|
|
1169
|
-
this.renderPassDescriptor.depthStencilAttachment.view = resizedTexture.handle.createView();
|
|
1170
|
-
}
|
|
1116
|
+
this.autoCreateAttachmentTextures();
|
|
1171
1117
|
}
|
|
1172
1118
|
};
|
|
1173
1119
|
|
|
@@ -1297,7 +1243,8 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1297
1243
|
if (!adapter) {
|
|
1298
1244
|
throw new Error("Failed to request WebGPU adapter");
|
|
1299
1245
|
}
|
|
1300
|
-
|
|
1246
|
+
const adapterInfo = yield adapter.requestAdapterInfo();
|
|
1247
|
+
import_api14.log.probe(1, "Adapter available", adapterInfo)();
|
|
1301
1248
|
const gpuDevice = yield adapter.requestDevice({
|
|
1302
1249
|
requiredFeatures: adapter.features
|
|
1303
1250
|
// TODO ensure we obtain best limits
|
|
@@ -1342,8 +1289,9 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1342
1289
|
get isLost() {
|
|
1343
1290
|
return this._isLost;
|
|
1344
1291
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1292
|
+
createBuffer(props) {
|
|
1293
|
+
const newProps = this._getBufferProps(props);
|
|
1294
|
+
return new WebGPUBuffer(this, newProps);
|
|
1347
1295
|
}
|
|
1348
1296
|
_createTexture(props) {
|
|
1349
1297
|
return new WebGPUTexture(this, props);
|
|
@@ -1379,6 +1327,9 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1379
1327
|
this.commandEncoder = this.commandEncoder || this.handle.createCommandEncoder();
|
|
1380
1328
|
return new WebGPUComputePass(this, props);
|
|
1381
1329
|
}
|
|
1330
|
+
// createCommandEncoder(props: CommandEncoderProps): WebGPUCommandEncoder {
|
|
1331
|
+
// return new WebGPUCommandEncoder(this, props);
|
|
1332
|
+
// }
|
|
1382
1333
|
createCanvasContext(props) {
|
|
1383
1334
|
return new WebGPUCanvasContext(this, this.adapter, props);
|
|
1384
1335
|
}
|
|
@@ -1437,6 +1388,49 @@ var _WebGPUDevice = class extends import_api14.Device {
|
|
|
1437
1388
|
features.add("glsl-texture-lod");
|
|
1438
1389
|
return features;
|
|
1439
1390
|
}
|
|
1391
|
+
copyExternalImageToTexture(options) {
|
|
1392
|
+
var _a;
|
|
1393
|
+
const {
|
|
1394
|
+
source,
|
|
1395
|
+
sourceX = 0,
|
|
1396
|
+
sourceY = 0,
|
|
1397
|
+
texture,
|
|
1398
|
+
mipLevel = 0,
|
|
1399
|
+
aspect = "all",
|
|
1400
|
+
colorSpace = "display-p3",
|
|
1401
|
+
premultipliedAlpha = false,
|
|
1402
|
+
// destinationX,
|
|
1403
|
+
// destinationY,
|
|
1404
|
+
// desitnationZ,
|
|
1405
|
+
width = texture.width,
|
|
1406
|
+
height = texture.height,
|
|
1407
|
+
depth = 1
|
|
1408
|
+
} = options;
|
|
1409
|
+
const webGpuTexture = texture;
|
|
1410
|
+
(_a = this.handle) == null ? void 0 : _a.queue.copyExternalImageToTexture(
|
|
1411
|
+
// source: GPUImageCopyExternalImage
|
|
1412
|
+
{
|
|
1413
|
+
source,
|
|
1414
|
+
origin: [sourceX, sourceY]
|
|
1415
|
+
},
|
|
1416
|
+
// destination: GPUImageCopyTextureTagged
|
|
1417
|
+
{
|
|
1418
|
+
texture: webGpuTexture.handle,
|
|
1419
|
+
origin: [0, 0, 0],
|
|
1420
|
+
// [x, y, z],
|
|
1421
|
+
mipLevel,
|
|
1422
|
+
aspect,
|
|
1423
|
+
colorSpace,
|
|
1424
|
+
premultipliedAlpha
|
|
1425
|
+
},
|
|
1426
|
+
// copySize: GPUExtent3D
|
|
1427
|
+
[
|
|
1428
|
+
width,
|
|
1429
|
+
height,
|
|
1430
|
+
depth
|
|
1431
|
+
]
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1440
1434
|
};
|
|
1441
1435
|
var WebGPUDevice = _WebGPUDevice;
|
|
1442
1436
|
WebGPUDevice.type = "webgpu";
|