Skip to content
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
"pnpm": {
"overrides": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
}
2 changes: 1 addition & 1 deletion packages/auxiliary-lines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
},
"dependencies": {
"@galacean/engine-toolkit-custom-material": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/custom-gltf-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/custom-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/draco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"types/**/*"
],
"dependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/dynamic-bone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/framebuffer-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/geometry-sketch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
4 changes: 2 additions & 2 deletions packages/gizmo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0",
"@galacean/engine-ui": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0",
"@galacean/engine-ui": ">=2.0.0-0"
},
"dependencies": {
"@galacean/engine-toolkit-framebuffer-picker": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/input-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/lines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/navigation-gizmo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
},
"dependencies": {
"@galacean/engine-toolkit-controls": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/outline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
2 changes: 1 addition & 1 deletion packages/skeleton-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
9 changes: 5 additions & 4 deletions packages/stats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
Statistics toolkit to gather performance data

## Features
- fps: frame rate;
- memory: CPU memory;
- fps: frame rate;
- JS Memory: JS heap memory (MB);
- totalGraphicsMemory: total graphics memory (MB);
- textureMemory: texture memory (MB);
- bufferMemory: buffer memory (MB);
- drawCall: draw call count;
- triangles: triangle count;
- lines: line count;
- points: point count;
- textures: texture count;
- shaders: shader count;
- webglContext: webgl context type;

## npm
Expand Down
2 changes: 1 addition & 1 deletion packages/stats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"types/**/*"
],
"peerDependencies": {
"@galacean/engine": ">=1.6.0-0"
"@galacean/engine": ">=2.0.0-0"
}
}
38 changes: 20 additions & 18 deletions packages/stats/src/Core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Engine } from "@galacean/engine";
import DrawCallHook from "./hooks/DrawCallHook";
import { RequestHook } from "./hooks/RequestHook";
import ShaderHook from "./hooks/ShaderHook";
import TextureHook from "./hooks/TextureHook";


declare global {
interface Performance {
Expand All @@ -14,25 +13,24 @@ declare global {
*/
export class Core {
private readonly gl: WebGLRenderingContext | WebGL2RenderingContext;
private readonly engine: Engine;
private drawCallHook: DrawCallHook;
private textureHook: TextureHook;
private shaderHook: ShaderHook;
private requestHook: RequestHook;

private samplingFrames: number = 60;
private samplingIndex: number = 0;
private updateCounter: number = 0;
private updateTime: number = 0;

constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {
constructor(engine: Engine) {
// @ts-ignore
const gl = engine._hardwareRenderer.gl;
this.gl = gl;
this.engine = engine;
this.hook(gl);
}

private hook(gl: WebGLRenderingContext | WebGL2RenderingContext): void {
this.drawCallHook = new DrawCallHook(gl);
this.textureHook = new TextureHook(gl);
this.shaderHook = new ShaderHook(gl);
this.requestHook = new RequestHook();
}

/**
Expand All @@ -47,8 +45,6 @@ export class Core {
*/
public release(): void {
this.drawCallHook && this.drawCallHook.release();
this.textureHook && this.textureHook.release();
this.shaderHook && this.shaderHook.release();
}

/**
Expand All @@ -69,16 +65,17 @@ export class Core {

this.samplingIndex = 0;

const renderingStatistics = this.engine.renderingStatistics;
let data: PerformanceData = {
fps: Math.round((this.updateCounter * 1000) / (now - this.updateTime)),
memory: performance.memory && (performance.memory.usedJSHeapSize / 1048576) >> 0,
drawCall: this.drawCallHook.drawCall,
triangles: this.drawCallHook.triangles,
lines: this.drawCallHook.lines,
points: this.drawCallHook.points,
textures: this.textureHook.textures,
size: this.requestHook.size,
shaders: this.shaderHook.shaders,
textureMemory: formatBytes(renderingStatistics.textureMemory),
bufferMemory: formatBytes(renderingStatistics.bufferMemory),
totalGraphicsMemory: formatBytes(renderingStatistics.totalMemory),
webglContext:
window.hasOwnProperty("WebGL2RenderingContext") && this.gl instanceof WebGL2RenderingContext ? "2.0" : "1.0"
};
Expand All @@ -99,8 +96,13 @@ interface PerformanceData {
triangles: number;
lines: number;
points: number;
textures: number;
shaders: number;
size: string;
textureMemory: string;
bufferMemory: string;
totalGraphicsMemory: string;
webglContext: string;
}

function formatBytes(bytes: number): string {
const mb = bytes / 1048576;
return mb.toFixed(2);
}
22 changes: 12 additions & 10 deletions packages/stats/src/Monitor.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { Engine } from "@galacean/engine";
import { Core } from "./Core";

let tpl = `
<dl>
<dt>FPS</dt>
<dd>0</dd>
<dt>Memory <span class="unit">(MB)</span></dt>
<dt>JS Memory <span class="unit">(MB)</span></dt>
<dd>0</dd>
<dt>DrawCall</dt>
<dt>Total Graphics Memory <span class="unit">(MB)</span></dt>
<dd>0</dd>
<dt>Triangles</dt>
<dt>Texture Memory <span class="unit">(MB)</span></dt>
<dd>0</dd>
<dt>Textures</dt>
<dt>Buffer Memory <span class="unit">(MB)</span></dt>
<dd>0</dd>
<dt>Shaders</dt>
<dt>DrawCall</dt>
<dd>0</dd>
<dt>Network Size <span class="unit">(MB)</span></dt>
<dt>Triangles</dt>
<dd>0</dd>
<dt>WebGL</dt>
<dt>WebGL</dt>
<dd></dd>
</dl>
`;
Expand Down Expand Up @@ -53,6 +54,7 @@ let css = `
font-size: ${20 / 7.5}vh;
padding: ${10 / 7.5}vh 0 ${10 / 7.5}vh;
}

`;

export default class Monitor {
Expand All @@ -61,10 +63,10 @@ export default class Monitor {
private container: HTMLElement;
private readonly items: string[];

constructor(gl: WebGLRenderingContext | WebGL2RenderingContext) {
this.core = new Core(gl);
constructor(engine: Engine) {
this.core = new Core(engine);
this.items = [];
this.items = ["fps", "memory", "drawCall", "triangles", "textures", "shaders", "size", "webglContext"];
this.items = ["fps", "memory", "totalGraphicsMemory", "textureMemory", "bufferMemory", "drawCall", "triangles", "webglContext"];
Comment on lines 68 to +69
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix prettier failure in items initialization.

Line 69 is flagged by prettier/prettier. Reformatting this array (and removing the redundant initial assignment) should clear the lint error.

💡 Proposed fix
-    this.items = [];
-    this.items = ["fps", "memory", "totalGraphicsMemory", "textureMemory", "bufferMemory", "drawCall", "triangles", "webglContext"];
+    this.items = [
+      "fps",
+      "memory",
+      "totalGraphicsMemory",
+      "textureMemory",
+      "bufferMemory",
+      "drawCall",
+      "triangles",
+      "webglContext"
+    ];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.items = [];
this.items = ["fps", "memory", "drawCall", "triangles", "textures", "shaders", "size", "webglContext"];
this.items = ["fps", "memory", "totalGraphicsMemory", "textureMemory", "bufferMemory", "drawCall", "triangles", "webglContext"];
this.items = [
"fps",
"memory",
"totalGraphicsMemory",
"textureMemory",
"bufferMemory",
"drawCall",
"triangles",
"webglContext"
];
🧰 Tools
🪛 ESLint

[error] 69-69: Replace "fps",·"memory",·"totalGraphicsMemory",·"textureMemory",·"bufferMemory",·"drawCall",·"triangles",·"webglContext" with ⏎······"fps",⏎······"memory",⏎······"totalGraphicsMemory",⏎······"textureMemory",⏎······"bufferMemory",⏎······"drawCall",⏎······"triangles",⏎······"webglContext"⏎····

(prettier/prettier)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/stats/src/Monitor.ts` around lines 68 - 69, The array initialization
for Monitor.items is duplicated and formatted in a way that triggers prettier;
remove the redundant this.items = [] assignment and replace the single-line
array with a properly formatted array literal assigned to this.items (keep the
existing values "fps", "memory", "totalGraphicsMemory", "textureMemory",
"bufferMemory", "drawCall", "triangles", "webglContext") inside the Monitor
constructor or initializer so the assignment is singular and conforms to
prettier formatting for arrays.

this.createContainer();
this.update = this.update.bind(this);
}
Expand Down
13 changes: 1 addition & 12 deletions packages/stats/src/Stats.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import { Script, Camera } from "@galacean/engine";
import { hookRequest } from "./hooks/RequestHook";
import Monitor from "./Monitor";

/**
* Display engine status data such as FPS.
*/
export class Stats extends Script {
private monitor: Monitor;
private camera: Camera;

static hookRequest() {
hookRequest();
}

override set enabled(value: boolean) {
value ? this._setupMonitor() : this.monitor.destroy();
}

override onBeginRender(camera: Camera): void {
this.camera = camera;
if (!this.monitor) {
this._setupMonitor();
}
Expand All @@ -31,10 +24,6 @@ export class Stats extends Script {
}

private _setupMonitor() {
// @ts-ignore
const gl = this.camera.engine._hardwareRenderer.gl;
if (gl) {
this.monitor = new Monitor(gl);
}
this.monitor = new Monitor(this.engine);
}
}
Loading
Loading