Skip to content

Commit

Permalink
Merge pull request #15014 from Popov72/fix-webgpu-onresize
Browse files Browse the repository at this point in the history
WebGPU: Fix onResize not triggered on the engine
  • Loading branch information
sebavan authored Apr 20, 2024
2 parents 38d8943 + aed7449 commit 5e920a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
16 changes: 16 additions & 0 deletions packages/dev/core/src/Engines/abstractEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,22 @@ export abstract class AbstractEngine {
this._renderingCanvas.width = width;
this._renderingCanvas.height = height;

if (this.scenes) {
for (let index = 0; index < this.scenes.length; index++) {
const scene = this.scenes[index];

for (let camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
const cam = scene.cameras[camIndex];

cam._currentRenderId = 0;
}
}

if (this.onResizeObservable.hasObservers()) {
this.onResizeObservable.notifyObservers(this);
}
}

return true;
}

Expand Down
35 changes: 0 additions & 35 deletions packages/dev/core/src/Engines/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,41 +774,6 @@ export class Engine extends ThinEngine {
super.beginFrame();
}

/**
* Force a specific size of the canvas
* @param width defines the new canvas' width
* @param height defines the new canvas' height
* @param forceSetSize true to force setting the sizes of the underlying canvas
* @returns true if the size was changed
*/
public override setSize(width: number, height: number, forceSetSize = false): boolean {
if (!this._renderingCanvas) {
return false;
}

if (!super.setSize(width, height, forceSetSize)) {
return false;
}

if (this.scenes) {
for (let index = 0; index < this.scenes.length; index++) {
const scene = this.scenes[index];

for (let camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
const cam = scene.cameras[camIndex];

cam._currentRenderId = 0;
}
}

if (this.onResizeObservable.hasObservers()) {
this.onResizeObservable.notifyObservers(this);
}
}

return true;
}

public override _deletePipelineContext(pipelineContext: IPipelineContext): void {
const webGLPipelineContext = pipelineContext as WebGLPipelineContext;
if (webGLPipelineContext && webGLPipelineContext.program) {
Expand Down

0 comments on commit 5e920a5

Please sign in to comment.