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

Render pass tracing now logs values used to clear color/depth/stencil buffer #7239

Merged
merged 3 commits into from
Dec 27, 2024
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
21 changes: 14 additions & 7 deletions src/core/math/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,31 @@ class Color {
* is the same format as used in HTML/CSS.
*
* @param {boolean} alpha - If true, the output string will include the alpha value.
* @param {boolean} [asArray] - If true, the output will be an array of numbers. Defaults to false.
* @returns {string} The color in string form.
* @example
* const c = new pc.Color(1, 1, 1);
* // Outputs #ffffffff
* console.log(c.toString());
*/
toString(alpha) {
let s = `#${((1 << 24) + (Math.round(this.r * 255) << 16) + (Math.round(this.g * 255) << 8) + Math.round(this.b * 255)).toString(16).slice(1)}`;
toString(alpha, asArray) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const { r, g, b, a } = this;

// If any component exceeds 1 (HDR), return the color as an array
if (asArray || r > 1 || g > 1 || b > 1) {
return `${r.toFixed(3)}, ${g.toFixed(3)}, ${b.toFixed(3)}, ${a.toFixed(3)}`;
}

let s = `#${((1 << 24) + (Math.round(r * 255) << 16) + (Math.round(g * 255) << 8) + Math.round(b * 255)).toString(16).slice(1)}`;
if (alpha === true) {
const a = Math.round(this.a * 255).toString(16);
const aa = Math.round(a * 255).toString(16);
if (this.a < 16 / 255) {
s += `0${a}`;
s += `0${aa}`;
} else {
s += a;
s += aa;
}

}

return s;
}

Expand Down
12 changes: 9 additions & 3 deletions src/platform/graphics/render-pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ class RenderPass {
`${colorOps.store ? 'store' : 'discard'} ` +
`${colorOps.resolve ? 'resolve ' : ''}` +
`${colorOps.genMipmaps ? 'mipmaps ' : ''}` +
` [format: ${colorFormat}]`);
` [format: ${colorFormat}]` +
` ${colorOps.clear ? `[clear: ${colorOps.clearValue.toString(true, true)}]` : ''}`
);
}

if (this.depthStencilOps) {
Expand All @@ -513,14 +515,18 @@ class RenderPass {
`${this.depthStencilOps.clearDepth ? 'clear' : 'load'}->` +
`${this.depthStencilOps.storeDepth ? 'store' : 'discard'}` +
`${this.depthStencilOps.resolveDepth ? ' resolve' : ''}` +
`${depthFormat}`);
`${depthFormat}` +
`${this.depthStencilOps.clearDepth ? ` [clear: ${this.depthStencilOps.clearDepthValue}]` : ''}`
);
}

if (hasStencil) {
Debug.trace(TRACEID_RENDER_PASS_DETAIL, ' stencOps: ' +
`${this.depthStencilOps.clearStencil ? 'clear' : 'load'}->` +
`${this.depthStencilOps.storeStencil ? 'store' : 'discard'}` +
`${depthFormat}`);
`${depthFormat}` +
`${this.depthStencilOps.clearStencil ? ` [clear: ${this.depthStencilOps.clearStencilValue}]` : ''}`
);
}
}
}
Expand Down
Loading