From b80432127649079f8a99d3d4d66076b070e1b45b Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Mon, 26 Feb 2024 13:03:28 +0000 Subject: [PATCH] When WebGPU validation fails, current markers are logged out --- examples/src/examples/graphics/shapes/example.mjs | 2 +- src/platform/graphics/webgpu/webgpu-debug.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/src/examples/graphics/shapes/example.mjs b/examples/src/examples/graphics/shapes/example.mjs index d0bd6d05e6f..c408c097ca6 100644 --- a/examples/src/examples/graphics/shapes/example.mjs +++ b/examples/src/examples/graphics/shapes/example.mjs @@ -47,7 +47,7 @@ let x = -1, shapes.forEach(function (shape) { // Create an entity with a render component - const entity = new pc.Entity(); + const entity = new pc.Entity(shape); entity.addComponent('render', { type: shape }); diff --git a/src/platform/graphics/webgpu/webgpu-debug.js b/src/platform/graphics/webgpu/webgpu-debug.js index 4d43d26b0d4..75786d5f7c1 100644 --- a/src/platform/graphics/webgpu/webgpu-debug.js +++ b/src/platform/graphics/webgpu/webgpu-debug.js @@ -1,4 +1,5 @@ import { Debug } from "../../../core/debug.js"; +import { DebugGraphics } from "../debug-graphics.js"; // Maximum number of times a duplicate error message is logged. const MAX_DUPLICATES = 5; @@ -12,6 +13,8 @@ const MAX_DUPLICATES = 5; class WebgpuDebug { static _scopes = []; + static _markers = []; + /** @type {Map} */ static _loggedMessages = new Map(); @@ -24,6 +27,7 @@ class WebgpuDebug { static validate(device) { device.wgpu.pushErrorScope('validation'); WebgpuDebug._scopes.push('validation'); + WebgpuDebug._markers.push(DebugGraphics.toString()); } /** @@ -35,6 +39,7 @@ class WebgpuDebug { static memory(device) { device.wgpu.pushErrorScope('out-of-memory'); WebgpuDebug._scopes.push('out-of-memory'); + WebgpuDebug._markers.push(DebugGraphics.toString()); } /** @@ -46,6 +51,7 @@ class WebgpuDebug { static internal(device) { device.wgpu.pushErrorScope('internal'); WebgpuDebug._scopes.push('internal'); + WebgpuDebug._markers.push(DebugGraphics.toString()); } /** @@ -57,6 +63,7 @@ class WebgpuDebug { */ static end(device, ...args) { const header = WebgpuDebug._scopes.pop(); + const marker = WebgpuDebug._markers.pop(); Debug.assert(header, 'Non matching end.'); device.wgpu.popErrorScope().then((error) => { @@ -65,7 +72,7 @@ class WebgpuDebug { if (count < MAX_DUPLICATES) { const tooMany = count === MAX_DUPLICATES - 1 ? ' (Too many errors, ignoring this one from now)' : ''; WebgpuDebug._loggedMessages.set(error.message, count + 1); - console.error(`WebGPU ${header} error: ${error.message}`, tooMany, ...args); + console.error(`WebGPU ${header} error: ${error.message}`, tooMany, "while rendering", marker, ...args); } } });