@luma.gl/webgpu 9.3.0-alpha.8 → 9.3.0

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
@@ -1091,6 +1091,7 @@ var init_webgpu_render_pipeline = __esm({
1091
1091
  this.device.pushErrorScope("validation");
1092
1092
  this.handle = this.device.handle.createRenderPipeline(descriptor);
1093
1093
  this.device.popErrorScope((error) => {
1094
+ this.linkStatus = "error";
1094
1095
  this.device.reportError(new Error(`${this} creation failed:
1095
1096
  "${error.message}"`), this)();
1096
1097
  this.device.debug();
@@ -1098,6 +1099,7 @@ var init_webgpu_render_pipeline = __esm({
1098
1099
  }
1099
1100
  this.descriptor = descriptor;
1100
1101
  this.handle.label = this.props.id;
1102
+ this.linkStatus = "success";
1101
1103
  this.vs = props.vs;
1102
1104
  this.fs = props.fs;
1103
1105
  this._bindingsByGroup = props.bindGroups || (0, import_core9.normalizeBindingsByGroup)(this.shaderLayout, props.bindings);
@@ -1128,6 +1130,10 @@ var init_webgpu_render_pipeline = __esm({
1128
1130
  }
1129
1131
  /** @todo - should this be moved to renderpass? */
1130
1132
  draw(options) {
1133
+ if (this.isErrored) {
1134
+ import_core9.log.info(2, `RenderPipeline:${this.id}.draw() aborted - pipeline initialization failed`)();
1135
+ return false;
1136
+ }
1131
1137
  const webgpuRenderPass = options.renderPass;
1132
1138
  const instanceCount = options.instanceCount && options.instanceCount > 0 ? options.instanceCount : 1;
1133
1139
  this.device.pushErrorScope("validation");
@@ -3022,28 +3028,52 @@ var init_generate_mipmaps_webgpu = __esm({
3022
3028
  });
3023
3029
 
3024
3030
  // dist/adapter/helpers/get-bind-group.js
3025
- function getBindGroup(device, bindGroupLayout, shaderLayout, bindings, group) {
3031
+ function getBindGroup(device, bindGroupLayout, shaderLayout, bindings, group, label) {
3026
3032
  const entries = getBindGroupEntries(bindings, shaderLayout, group);
3027
3033
  if (entries.length === 0) {
3028
3034
  return null;
3029
3035
  }
3030
3036
  device.pushErrorScope("validation");
3031
3037
  const bindGroup = device.handle.createBindGroup({
3038
+ label,
3032
3039
  layout: bindGroupLayout,
3033
3040
  entries
3034
3041
  });
3035
3042
  device.popErrorScope((error) => {
3036
- import_core24.log.error(`bindGroup creation: ${error.message}`, bindGroup)();
3043
+ const summary = formatBindGroupCreationErrorSummary(shaderLayout, bindings, entries, group);
3044
+ import_core24.log.error(`bindGroup creation: ${summary}
3045
+ Raw WebGPU error: ${error.message}`, bindGroup)();
3037
3046
  });
3038
3047
  return bindGroup;
3039
3048
  }
3049
+ function formatBindGroupCreationErrorSummary(shaderLayout, bindings, entries, group) {
3050
+ const expectedBindings = getExpectedBindingsForGroup(shaderLayout, group);
3051
+ const expectedByLocation = new Map(expectedBindings.map((bindingSummary) => [bindingSummary.location, bindingSummary]));
3052
+ const providedBindings = entries.map((entry) => expectedByLocation.get(entry.binding) || getUnexpectedEntrySummary(entry)).sort(compareBindingSummaries);
3053
+ const missingBindings = expectedBindings.filter((bindingSummary) => !providedBindings.some((provided) => provided.location === bindingSummary.location));
3054
+ const unexpectedBindings = providedBindings.filter((bindingSummary) => !expectedByLocation.has(bindingSummary.location));
3055
+ const unmatchedLogicalBindings = Object.keys(bindings).filter((bindingName) => !resolveGroupBinding(bindingName, bindings, shaderLayout, group)).sort();
3056
+ const lines = [
3057
+ `bindGroup creation failed for group ${group}: expected ${expectedBindings.length}, provided ${providedBindings.length}`,
3058
+ `expected: ${formatBindingSummaryList(expectedBindings)}`,
3059
+ `provided: ${formatBindingSummaryList(providedBindings)}`
3060
+ ];
3061
+ if (missingBindings.length > 0) {
3062
+ lines.push(`missing: ${formatBindingSummaryList(missingBindings)}`);
3063
+ }
3064
+ if (unexpectedBindings.length > 0) {
3065
+ lines.push(`unexpected entries: ${formatBindingSummaryList(unexpectedBindings)}`);
3066
+ }
3067
+ if (unmatchedLogicalBindings.length > 0) {
3068
+ lines.push(`unmatched logical bindings: ${unmatchedLogicalBindings.join(", ")}`);
3069
+ }
3070
+ return lines.join("\n");
3071
+ }
3040
3072
  function getBindGroupEntries(bindings, shaderLayout, group) {
3041
3073
  const entries = [];
3042
3074
  for (const [bindingName, value] of Object.entries(bindings)) {
3043
- const exactBindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName);
3044
- const bindingLayout = exactBindingLayout || (0, import_core24.getShaderLayoutBinding)(shaderLayout, bindingName);
3045
- const isShadowedAlias = !exactBindingLayout && bindingLayout ? bindingLayout.name in bindings : false;
3046
- if (!isShadowedAlias && (bindingLayout == null ? void 0 : bindingLayout.group) === group) {
3075
+ const { bindingLayout, isShadowedAlias } = resolveGroupBinding(bindingName, bindings, shaderLayout, group) || { bindingLayout: null, isShadowedAlias: false };
3076
+ if (!isShadowedAlias && bindingLayout) {
3047
3077
  const entry = bindingLayout ? getBindGroupEntry(value, bindingLayout.location, void 0, bindingName) : null;
3048
3078
  if (entry) {
3049
3079
  entries.push(entry);
@@ -3097,6 +3127,44 @@ function getBindGroupEntry(binding, index, options, bindingName = "unknown") {
3097
3127
  import_core24.log.warn(`invalid binding ${bindingName}`, binding);
3098
3128
  return null;
3099
3129
  }
3130
+ function getExpectedBindingsForGroup(shaderLayout, group) {
3131
+ return shaderLayout.bindings.filter((bindingLayout) => bindingLayout.group === group).map((bindingLayout) => toBindingSummary(bindingLayout)).sort(compareBindingSummaries);
3132
+ }
3133
+ function resolveGroupBinding(bindingName, bindings, shaderLayout, group) {
3134
+ const exactBindingLayout = shaderLayout.bindings.find((binding) => binding.name === bindingName);
3135
+ const bindingLayout = exactBindingLayout || (0, import_core24.getShaderLayoutBinding)(shaderLayout, bindingName, { ignoreWarnings: true });
3136
+ const isShadowedAlias = !exactBindingLayout && bindingLayout ? bindingLayout.name in bindings : false;
3137
+ if (isShadowedAlias || !bindingLayout || bindingLayout.group !== group) {
3138
+ return null;
3139
+ }
3140
+ return { bindingLayout, isShadowedAlias };
3141
+ }
3142
+ function toBindingSummary(bindingLayout) {
3143
+ return {
3144
+ name: bindingLayout.name,
3145
+ location: bindingLayout.location,
3146
+ type: bindingLayout.type
3147
+ };
3148
+ }
3149
+ function getUnexpectedEntrySummary(entry) {
3150
+ return {
3151
+ name: "?",
3152
+ location: entry.binding,
3153
+ type: "unknown"
3154
+ };
3155
+ }
3156
+ function compareBindingSummaries(left, right) {
3157
+ if (left.location !== right.location) {
3158
+ return left.location - right.location;
3159
+ }
3160
+ return left.name.localeCompare(right.name);
3161
+ }
3162
+ function formatBindingSummaryList(bindings) {
3163
+ if (bindings.length === 0) {
3164
+ return "none";
3165
+ }
3166
+ return bindings.map((binding) => `${binding.name}@${binding.location}`).join(", ");
3167
+ }
3100
3168
  var import_core24;
3101
3169
  var init_get_bind_group = __esm({
3102
3170
  "dist/adapter/helpers/get-bind-group.js"() {
@@ -3181,10 +3249,9 @@ var init_webgpu_device = __esm({
3181
3249
  this.reportError(new Error(errorMessage), this)();
3182
3250
  this.debug();
3183
3251
  });
3184
- this.lost = new Promise(async (resolve) => {
3185
- const lostInfo = await this.handle.lost;
3252
+ this.lost = this.handle.lost.then((lostInfo) => {
3186
3253
  this._isLost = true;
3187
- resolve({ reason: "destroyed", message: lostInfo.message });
3254
+ return { reason: "destroyed", message: lostInfo.message };
3188
3255
  });
3189
3256
  const canvasContextProps = import_core25.Device._getCanvasContextProps(props);
3190
3257
  if (canvasContextProps) {
@@ -3275,14 +3342,15 @@ var init_webgpu_device = __esm({
3275
3342
  _createBindGroupLayoutWebGPU(pipeline, group) {
3276
3343
  return pipeline.handle.getBindGroupLayout(group);
3277
3344
  }
3278
- _createBindGroupWebGPU(bindGroupLayout, shaderLayout, bindings, group) {
3345
+ _createBindGroupWebGPU(bindGroupLayout, shaderLayout, bindings, group, label) {
3279
3346
  if (Object.keys(bindings).length === 0) {
3280
3347
  return this.handle.createBindGroup({
3348
+ label,
3281
3349
  layout: bindGroupLayout,
3282
3350
  entries: []
3283
3351
  });
3284
3352
  }
3285
- return getBindGroup(this, bindGroupLayout, shaderLayout, bindings, group);
3353
+ return getBindGroup(this, bindGroupLayout, shaderLayout, bindings, group, label);
3286
3354
  }
3287
3355
  submit(commandBuffer) {
3288
3356
  let submittedCommandEncoder = null;