Skip to content

Commit

Permalink
When glslang transpilation fails on WebGPU, add stack trace to the er…
Browse files Browse the repository at this point in the history
…ror message (#6681)

* When glslang transpilation fails on WebGPU, add stack trace to the error message

* small comment fix

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Jun 11, 2024
1 parent 31aa18b commit d72a707
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -1852,8 +1852,8 @@ class WebglGraphicsDevice extends GraphicsDevice {
* call.
* @param {boolean} [primitive.indexed] - True to interpret the primitive as indexed, thereby
* using the currently set index buffer and false otherwise.
* @param {number} [numInstances] - The number of instances to render when using
* ANGLE_instanced_arrays. Defaults to 1.
* @param {number} [numInstances] - The number of instances to render when using instancing.
* Defaults to 1.
* @param {boolean} [keepBuffers] - Optionally keep the current set of vertex / index buffers /
* VAO. This is used when rendering of multiple views, for example under WebXR.
* @example
Expand Down
9 changes: 6 additions & 3 deletions src/platform/graphics/webgpu/webgpu-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,15 @@ class WebgpuShader {
transpile(src, shaderType, originalSrc) {
try {
const spirv = this.shader.device.glslang.compileGLSL(src, shaderType);
return this.shader.device.twgsl.convertSpirV2WGSL(spirv);
const wgsl = this.shader.device.twgsl.convertSpirV2WGSL(spirv);
return wgsl;
} catch (err) {
console.error(`Failed to transpile webgl ${shaderType} shader [${this.shader.label}] to WebGPU: [${err.message}] while rendering ${DebugGraphics.toString()}`, {
console.error(`Failed to transpile webgl ${shaderType} shader [${this.shader.label}] to WebGPU while rendering ${DebugGraphics.toString()}, error:\n [${err.stack}]`, {
processed: src,
original: originalSrc,
shader: this.shader
shader: this.shader,
error: err,
stack: err.stack
});
}
}
Expand Down

0 comments on commit d72a707

Please sign in to comment.