Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when framebuffer validation fails #4809

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/posteffects/posteffect-bloom.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ BloomEffect.prototype._resize = function (target) {
colorBuffer.magFilter = pc.FILTER_LINEAR;
colorBuffer.addressU = pc.ADDRESS_CLAMP_TO_EDGE;
colorBuffer.addressV = pc.ADDRESS_CLAMP_TO_EDGE;
colorBuffer.name = 'pe-bloom';
colorBuffer.name = 'pe-bloom-' + i;
var bloomTarget = new pc.RenderTarget({
name: "Bloom Render Target " + i,
colorBuffer: colorBuffer,
Expand Down
28 changes: 13 additions & 15 deletions src/platform/graphics/webgl/webgl-render-target.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Debug } from "../../../core/debug.js";

/**
* A WebGL implementation of the RenderTarget.
*
Expand Down Expand Up @@ -112,9 +114,7 @@ class WebglRenderTarget {
}
}

// #if _DEBUG
this._checkFbo(device);
// #endif
Debug.call(() => this._checkFbo(device, target));

// ##### Create MSAA FBO (WebGL2 only) #####
if (device.webgl2 && target._samples > 1) {
Expand Down Expand Up @@ -150,9 +150,8 @@ class WebglRenderTarget {
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this._glMsaaDepthBuffer);
}
}
// #if _DEBUG
this._checkFbo(device);
// #endif

Debug.call(() => this._checkFbo(device, target, 'MSAA'));
}
}

Expand All @@ -161,27 +160,26 @@ class WebglRenderTarget {
*
* @private
*/
_checkFbo(device) {
_checkFbo(device, target, type = '') {
const gl = device.gl;
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
let errorCode;
switch (status) {
case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
console.error("ERROR: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
errorCode = 'FRAMEBUFFER_INCOMPLETE_ATTACHMENT';
break;
case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
console.error("ERROR: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
errorCode = 'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT';
break;
case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
console.error("ERROR: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
errorCode = 'FRAMEBUFFER_INCOMPLETE_DIMENSIONS';
break;
case gl.FRAMEBUFFER_UNSUPPORTED:
console.error("ERROR: FRAMEBUFFER_UNSUPPORTED");
break;
case gl.FRAMEBUFFER_COMPLETE:
break;
default:
errorCode = 'FRAMEBUFFER_UNSUPPORTED';
break;
}

Debug.assert(!errorCode, `Framebuffer creation failed with error code ${errorCode}, render target: ${target.name} ${type}`, target);
}

loseContext() {
Expand Down