@luma.gl/engine 9.4.0-beta.3 → 9.4.0-beta.5

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/index.cjs CHANGED
@@ -1196,6 +1196,25 @@ var norm16_renderable = "norm16-renderable-webgl";
1196
1196
  var snorm16_renderable = "snorm16-renderable-webgl";
1197
1197
  var float32_filterable = "float32-filterable";
1198
1198
  var float16_filterable = "float16-filterable-webgl";
1199
+ var WEBGPU_CREATE = 1;
1200
+ var WEBGPU_RENDER = 2;
1201
+ var WEBGPU_FILTER = 4;
1202
+ var WEBGPU_BLEND = 8;
1203
+ var WEBGPU_STORE = 16;
1204
+ var WEBGPU_TIER_1_SHIFT = 5;
1205
+ var WEBGPU_CORE_SHIFT = 10;
1206
+ var WEBGPU_CREATE_RENDER = WEBGPU_CREATE | WEBGPU_RENDER;
1207
+ var WEBGPU_CREATE_FILTER = WEBGPU_CREATE | WEBGPU_FILTER;
1208
+ var WEBGPU_CREATE_RENDER_FILTER_BLEND = WEBGPU_CREATE | WEBGPU_RENDER | WEBGPU_FILTER | WEBGPU_BLEND;
1209
+ var WEBGPU_CREATE_RENDER_STORE = WEBGPU_CREATE | WEBGPU_RENDER | WEBGPU_STORE;
1210
+ var WEBGPU_CREATE_FILTER_STORE = WEBGPU_CREATE | WEBGPU_FILTER | WEBGPU_STORE;
1211
+ var WEBGPU_CREATE_RENDER_FILTER_BLEND_STORE = WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_STORE;
1212
+ var WEBGPU_TIER_1_RENDER_BLEND_STORE = (WEBGPU_RENDER | WEBGPU_BLEND | WEBGPU_STORE) << WEBGPU_TIER_1_SHIFT;
1213
+ var WEBGPU_TIER_1_RENDER_BLEND = (WEBGPU_RENDER | WEBGPU_BLEND) << WEBGPU_TIER_1_SHIFT;
1214
+ var WEBGPU_TIER_1_STORE = WEBGPU_STORE << WEBGPU_TIER_1_SHIFT;
1215
+ var WEBGPU_TIER_1_ALL = WEBGPU_CREATE_RENDER_FILTER_BLEND_STORE << WEBGPU_TIER_1_SHIFT;
1216
+ var WEBGPU_CORE_CREATE_RENDER_FILTER_BLEND = WEBGPU_CREATE_RENDER_FILTER_BLEND << WEBGPU_CORE_SHIFT;
1217
+ var WEBGPU_CORE_STORE = WEBGPU_STORE << WEBGPU_CORE_SHIFT;
1199
1218
  function getTextureFormatDefinition(format) {
1200
1219
  const info = TEXTURE_FORMAT_TABLE[format];
1201
1220
  if (!info) {
@@ -1205,72 +1224,71 @@ function getTextureFormatDefinition(format) {
1205
1224
  }
1206
1225
  var TEXTURE_FORMAT_COLOR_DEPTH_TABLE = {
1207
1226
  // 8-bit formats
1208
- "r8unorm": {},
1209
- "rg8unorm": {},
1227
+ "r8unorm": { webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_TIER_1_STORE },
1228
+ "rg8unorm": { webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_TIER_1_STORE },
1210
1229
  "rgb8unorm-webgl": {},
1211
- "rgba8unorm": {},
1212
- "rgba8unorm-srgb": {},
1213
- "r8snorm": { render: snorm8_renderable },
1214
- "rg8snorm": { render: snorm8_renderable },
1230
+ "rgba8unorm": { webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND_STORE },
1231
+ "rgba8unorm-srgb": { webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND },
1232
+ "r8snorm": { render: snorm8_renderable, webgpu: WEBGPU_CREATE_FILTER | WEBGPU_TIER_1_RENDER_BLEND_STORE },
1233
+ "rg8snorm": { render: snorm8_renderable, webgpu: WEBGPU_CREATE_FILTER | WEBGPU_TIER_1_RENDER_BLEND_STORE },
1215
1234
  "rgb8snorm-webgl": {},
1216
- "rgba8snorm": { render: snorm8_renderable },
1217
- "r8uint": {},
1218
- "rg8uint": {},
1219
- "rgba8uint": {},
1220
- "r8sint": {},
1221
- "rg8sint": {},
1222
- "rgba8sint": {},
1223
- "bgra8unorm": {},
1224
- "bgra8unorm-srgb": {},
1225
- "r16unorm": { f: norm16_webgl, render: norm16_renderable },
1226
- "rg16unorm": { f: norm16_webgl, render: norm16_renderable },
1235
+ "rgba8snorm": { render: snorm8_renderable, webgpu: WEBGPU_CREATE_FILTER_STORE | WEBGPU_TIER_1_RENDER_BLEND },
1236
+ "r8uint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1237
+ "rg8uint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1238
+ "rgba8uint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1239
+ "r8sint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1240
+ "rg8sint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1241
+ "rgba8sint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1242
+ "bgra8unorm": { webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND },
1243
+ "bgra8unorm-srgb": { webgpu: WEBGPU_CORE_CREATE_RENDER_FILTER_BLEND },
1244
+ "r16unorm": { f: norm16_webgl, render: norm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1245
+ "rg16unorm": { f: norm16_webgl, render: norm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1227
1246
  "rgb16unorm-webgl": { f: norm16_webgl, render: false },
1228
1247
  // rgb not renderable
1229
- "rgba16unorm": { f: norm16_webgl, render: norm16_renderable },
1230
- "r16snorm": { f: norm16_webgl, render: snorm16_renderable },
1231
- "rg16snorm": { f: norm16_webgl, render: snorm16_renderable },
1248
+ "rgba16unorm": { f: norm16_webgl, render: norm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1249
+ "r16snorm": { f: norm16_webgl, render: snorm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1250
+ "rg16snorm": { f: norm16_webgl, render: snorm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1232
1251
  "rgb16snorm-webgl": { f: norm16_webgl, render: false },
1233
1252
  // rgb not renderable
1234
- "rgba16snorm": { f: norm16_webgl, render: snorm16_renderable },
1235
- "r16uint": {},
1236
- "rg16uint": {},
1237
- "rgba16uint": {},
1238
- "r16sint": {},
1239
- "rg16sint": {},
1240
- "rgba16sint": {},
1241
- "r16float": { render: float16_renderable, filter: "float16-filterable-webgl" },
1242
- "rg16float": { render: float16_renderable, filter: float16_filterable },
1243
- "rgba16float": { render: float16_renderable, filter: float16_filterable },
1244
- "r32uint": {},
1245
- "rg32uint": {},
1246
- "rgba32uint": {},
1247
- "r32sint": {},
1248
- "rg32sint": {},
1249
- "rgba32sint": {},
1250
- "r32float": { render: float32_renderable, filter: float32_filterable },
1251
- "rg32float": { render: false, filter: float32_filterable },
1253
+ "rgba16snorm": { f: norm16_webgl, render: snorm16_renderable, webgpu: WEBGPU_TIER_1_ALL },
1254
+ "r16uint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1255
+ "rg16uint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1256
+ "rgba16uint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1257
+ "r16sint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1258
+ "rg16sint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1259
+ "rgba16sint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1260
+ "r16float": { render: float16_renderable, filter: "float16-filterable-webgl", webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_TIER_1_STORE },
1261
+ "rg16float": { render: float16_renderable, filter: float16_filterable, webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_TIER_1_STORE },
1262
+ "rgba16float": { render: float16_renderable, filter: float16_filterable, webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND_STORE },
1263
+ "r32uint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1264
+ "rg32uint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_CORE_STORE },
1265
+ "rgba32uint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1266
+ "r32sint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1267
+ "rg32sint": { webgpu: WEBGPU_CREATE_RENDER | WEBGPU_CORE_STORE },
1268
+ "rgba32sint": { webgpu: WEBGPU_CREATE_RENDER_STORE },
1269
+ "r32float": { render: float32_renderable, filter: float32_filterable, webgpu: WEBGPU_CREATE_RENDER_STORE },
1270
+ "rg32float": { render: false, filter: float32_filterable, webgpu: WEBGPU_CREATE_RENDER | WEBGPU_CORE_STORE },
1252
1271
  "rgb32float-webgl": { render: float32_renderable, filter: float32_filterable },
1253
- "rgba32float": { render: float32_renderable, filter: float32_filterable },
1272
+ "rgba32float": { render: float32_renderable, filter: float32_filterable, webgpu: WEBGPU_CREATE_RENDER_STORE },
1254
1273
  // Packed 16-bit formats
1255
1274
  "rgba4unorm-webgl": { channels: "rgba", bitsPerChannel: [4, 4, 4, 4], packed: true },
1256
1275
  "rgb565unorm-webgl": { channels: "rgb", bitsPerChannel: [5, 6, 5, 0], packed: true },
1257
1276
  "rgb5a1unorm-webgl": { channels: "rgba", bitsPerChannel: [5, 5, 5, 1], packed: true },
1258
1277
  // Packed 32 bit formats
1259
- "rgb9e5ufloat": { channels: "rgb", packed: true, render: rgb9e5ufloat_renderable },
1260
- // , filter: true},
1261
- "rg11b10ufloat": { channels: "rgb", bitsPerChannel: [11, 11, 10, 0], packed: true, p: 1, render: float32_renderable },
1262
- "rgb10a2unorm": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
1263
- "rgb10a2uint": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1 },
1278
+ "rgb9e5ufloat": { channels: "rgb", packed: true, render: rgb9e5ufloat_renderable, webgpu: WEBGPU_CREATE_FILTER },
1279
+ "rg11b10ufloat": { channels: "rgb", bitsPerChannel: [11, 11, 10, 0], packed: true, p: 1, render: float32_renderable, webgpu: WEBGPU_CREATE_FILTER | WEBGPU_TIER_1_STORE },
1280
+ "rgb10a2unorm": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1, webgpu: WEBGPU_CREATE_RENDER_FILTER_BLEND | WEBGPU_TIER_1_STORE },
1281
+ "rgb10a2uint": { channels: "rgba", bitsPerChannel: [10, 10, 10, 2], packed: true, p: 1, webgpu: WEBGPU_CREATE_RENDER | WEBGPU_TIER_1_STORE },
1264
1282
  // Depth/stencil Formats
1265
1283
  // Depth and stencil formats
1266
- stencil8: { attachment: "stencil", bitsPerChannel: [8, 0, 0, 0], dataType: "uint8" },
1267
- "depth16unorm": { attachment: "depth", bitsPerChannel: [16, 0, 0, 0], dataType: "uint16" },
1268
- "depth24plus": { attachment: "depth", bitsPerChannel: [24, 0, 0, 0], dataType: "uint32" },
1269
- "depth32float": { attachment: "depth", bitsPerChannel: [32, 0, 0, 0], dataType: "float32" },
1284
+ stencil8: { attachment: "stencil", bitsPerChannel: [8, 0, 0, 0], dataType: "uint8", webgpu: WEBGPU_CREATE_RENDER },
1285
+ "depth16unorm": { attachment: "depth", bitsPerChannel: [16, 0, 0, 0], dataType: "uint16", webgpu: WEBGPU_CREATE_RENDER },
1286
+ "depth24plus": { attachment: "depth", bitsPerChannel: [24, 0, 0, 0], dataType: "uint32", webgpu: WEBGPU_CREATE_RENDER },
1287
+ "depth32float": { attachment: "depth", bitsPerChannel: [32, 0, 0, 0], dataType: "float32", webgpu: WEBGPU_CREATE_RENDER },
1270
1288
  // The depth component of the "depth24plus" and "depth24plus-stencil8" formats may be implemented as either a 24-bit depth value or a "depth32float" value.
1271
- "depth24plus-stencil8": { attachment: "depth-stencil", bitsPerChannel: [24, 8, 0, 0], packed: true },
1289
+ "depth24plus-stencil8": { attachment: "depth-stencil", bitsPerChannel: [24, 8, 0, 0], packed: true, webgpu: WEBGPU_CREATE_RENDER },
1272
1290
  // "depth32float-stencil8" feature
1273
- "depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true }
1291
+ "depth32float-stencil8": { attachment: "depth-stencil", bitsPerChannel: [32, 8, 0, 0], packed: true, f: "depth32float-stencil8", webgpu: WEBGPU_CREATE_RENDER }
1274
1292
  };
1275
1293
  var TEXTURE_FORMAT_COMPRESSED_TABLE = {
1276
1294
  // BC compressed formats: check device.features.has("texture-compression-bc");
@@ -1352,6 +1370,7 @@ var TEXTURE_FORMAT_TABLE = {
1352
1370
  var RGB_FORMAT_REGEX = /^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;
1353
1371
  var COLOR_FORMAT_PREFIXES = ["rgb", "rgba", "bgra"];
1354
1372
  var DEPTH_FORMAT_PREFIXES = ["depth", "stencil"];
1373
+ var WEBGPU_CREATE_FILTER2 = 1 | 4;
1355
1374
  var COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
1356
1375
  "bc1",
1357
1376
  "bc2",
@@ -1388,6 +1407,14 @@ var TextureFormatDecoder = class {
1388
1407
  getCapabilities(format) {
1389
1408
  return getTextureFormatCapabilities(format);
1390
1409
  }
1410
+ /** Returns the compact WebGPU capability mask stored in the canonical format table. */
1411
+ getWebGPUCapabilities(format) {
1412
+ const definition = getTextureFormatDefinition(format);
1413
+ if (definition.webgpu !== void 0) {
1414
+ return definition.webgpu;
1415
+ }
1416
+ return this.isCompressed(format) && !format.endsWith("-webgl") ? WEBGPU_CREATE_FILTER2 : 0;
1417
+ }
1391
1418
  /** Computes the memory layout for a texture, in particular including row byte alignment */
1392
1419
  computeMemoryLayout(opts) {
1393
1420
  return computeTextureMemoryLayout(opts);
@@ -1513,6 +1540,7 @@ function getTextureFormatInfoUsingTable(format) {
1513
1540
  delete info.filter;
1514
1541
  delete info.blend;
1515
1542
  delete info.store;
1543
+ delete info.webgpu;
1516
1544
  const formatInfo = {
1517
1545
  ...info,
1518
1546
  format,
@@ -2424,6 +2452,7 @@ var RenderPipeline = class _RenderPipeline extends Resource {
2424
2452
  bufferMode: void 0,
2425
2453
  disableWarnings: false,
2426
2454
  _sharedRenderPipeline: void 0,
2455
+ _uniformBlockLayouts: [],
2427
2456
  bindings: void 0,
2428
2457
  bindGroups: void 0
2429
2458
  };
@@ -2640,12 +2669,13 @@ var PipelineFactory = class _PipelineFactory {
2640
2669
  const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
2641
2670
  const varyingHash = this._getWebGLVaryingHash(props);
2642
2671
  const shaderLayoutHash = this._getHash(JSON.stringify(props.shaderLayout));
2672
+ const uniformBlockLayoutHash = this._getHash(JSON.stringify(props._uniformBlockLayouts));
2643
2673
  const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
2644
2674
  const { type } = this.device;
2645
2675
  switch (type) {
2646
2676
  case "webgl":
2647
2677
  const webglParameterHash = this._getHash(JSON.stringify(props.parameters));
2648
- return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${webglParameterHash}SL${shaderLayoutHash}BL${bufferLayoutHash}`;
2678
+ return `${type}/R/${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${webglParameterHash}SL${shaderLayoutHash}UBL${uniformBlockLayoutHash}BL${bufferLayoutHash}`;
2649
2679
  case "webgpu":
2650
2680
  default:
2651
2681
  const entryPointHash = this._getHash(
@@ -8857,6 +8887,8 @@ var WGSLShaderAssembler = class _WGSLShaderAssembler extends ShaderAssembler {
8857
8887
  const limits = platformInfo.limits || {};
8858
8888
  return {
8859
8889
  LUMA_SUPPORTS_VERTEX_STORAGE_BUFFERS: platformInfo.type === "webgpu" && (limits["maxStorageBuffersInVertexStage"] || 0) > 0,
8890
+ // Native tan() does not provide enough precision on all WebGPU implementations.
8891
+ LUMA_FP32_TAN_PRECISION_WORKAROUND: platformInfo.type === "webgpu" && platformInfo.gpu.toLowerCase() !== "nvidia" && platformInfo.gpu.toLowerCase() !== "amd",
8860
8892
  // Metal may reassociate the floating-point transforms used by classic
8861
8893
  // double-single arithmetic. The integer path makes each rounding point
8862
8894
  // explicit while preserving the public vec2<f32> representation.
@@ -9460,6 +9492,18 @@ function mergeInferredShaderLayout(shaderLayout, inferredShaderLayout, inferredA
9460
9492
  function shaderModuleHasUniforms(module2) {
9461
9493
  return Boolean(module2.uniformTypes && !isObjectEmpty(module2.uniformTypes));
9462
9494
  }
9495
+ function getShaderModuleUniformBlockLayouts(modules) {
9496
+ const uniformBlockLayouts = [];
9497
+ for (const module2 of modules) {
9498
+ const defaultUniformBlockName = getShaderModuleUniformBlockName(module2);
9499
+ const std140BlockNames = new Set([module2.vs, module2.fs].flatMap((shaderSource) => shaderSource ? getGLSLUniformBlocks(shaderSource).filter((block) => block.isStd140).map((block) => block.blockName) : []));
9500
+ const uniformBlockName = std140BlockNames.has(defaultUniformBlockName) ? defaultUniformBlockName : std140BlockNames.size === 1 ? std140BlockNames.values().next().value : void 0;
9501
+ if (shaderModuleHasUniforms(module2) && uniformBlockName) {
9502
+ uniformBlockLayouts.push({ name: uniformBlockName, uniformTypes: module2.uniformTypes });
9503
+ }
9504
+ }
9505
+ return uniformBlockLayouts;
9506
+ }
9463
9507
  function mergeShaderModules(explicitModules, shaderInputModules) {
9464
9508
  const modules = [];
9465
9509
  const moduleNames = /* @__PURE__ */ new Set();
@@ -10195,6 +10239,9 @@ var Model = class _Model {
10195
10239
  this.setShaderInputs(shaderInputs);
10196
10240
  const modules = mergeShaderModules(this.props.modules, shaderInputs.getModules());
10197
10241
  const defines = { ...resolvedPlugins.defines, ...this.props.defines };
10242
+ if (this.device.type === "webgl") {
10243
+ this.props._uniformBlockLayouts = getShaderModuleUniformBlockLayouts(modules);
10244
+ }
10198
10245
  this.props.shaderLayout = mergeShaderModuleBindingsIntoLayout(this.props.shaderLayout, modules) || null;
10199
10246
  const isWebGPU = this.device.type === "webgpu";
10200
10247
  if (isWebGPU && this.props.source) {