From 8f7e043ecefcece5ea4c89dddcf094a45a97f57c Mon Sep 17 00:00:00 2001 From: Raanan Weber Date: Tue, 16 Aug 2022 17:11:14 +0200 Subject: [PATCH] Fix tests running locally --- .../dev/core/src/Materials/Textures/texture.ts | 14 +++++++++----- .../tools/testTools/src/visualizationUtils.ts | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/dev/core/src/Materials/Textures/texture.ts b/packages/dev/core/src/Materials/Textures/texture.ts index 8be8195f865..574cc1c1eb1 100644 --- a/packages/dev/core/src/Materials/Textures/texture.ts +++ b/packages/dev/core/src/Materials/Textures/texture.ts @@ -938,7 +938,7 @@ export class Texture extends BaseTexture { return null; } - const onLoaded = () => { + const onLoaded = (texture: Texture | null) => { // Clear cache if (texture && texture._texture) { texture._texture._cachedWrapU = null; @@ -975,7 +975,7 @@ export class Texture extends BaseTexture { const mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps); mirrorTexture._waitingRenderList = parsedTexture.renderList; mirrorTexture.mirrorPlane = Plane.FromArray(parsedTexture.mirrorPlane); - onLoaded(); + onLoaded(mirrorTexture); return mirrorTexture; } else if (parsedTexture.isRenderTarget) { let renderTargetTexture: Nullable = null; @@ -999,7 +999,7 @@ export class Texture extends BaseTexture { ); renderTargetTexture._waitingRenderList = parsedTexture.renderList; } - onLoaded(); + onLoaded(renderTargetTexture); return renderTargetTexture; } else { let texture: Texture; @@ -1012,7 +1012,9 @@ export class Texture extends BaseTexture { !generateMipMaps, parsedTexture.invertY, parsedTexture.samplingMode, - onLoaded, + () => { + onLoaded(texture); + }, parsedTexture._creationFlags ?? 0, parsedTexture._useSRGBBuffer ?? false ); @@ -1027,7 +1029,9 @@ export class Texture extends BaseTexture { if (parsedTexture.url && (parsedTexture.url.startsWith("data:") || Texture.UseSerializedUrlIfAny)) { url = parsedTexture.url; } - texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY, parsedTexture.samplingMode, onLoaded); + texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY, parsedTexture.samplingMode, () => { + onLoaded(texture); + }); } return texture; diff --git a/packages/tools/testTools/src/visualizationUtils.ts b/packages/tools/testTools/src/visualizationUtils.ts index d306e9e09ea..0ea0abc784f 100644 --- a/packages/tools/testTools/src/visualizationUtils.ts +++ b/packages/tools/testTools/src/visualizationUtils.ts @@ -91,6 +91,7 @@ export const evaluateInitEngineForVisualization = async (engineName: string, use window.engine = engine; } window.engine!.renderEvenInBackground = true; + window.engine.getCaps().parallelShaderCompile = undefined; return { forceUseReverseDepthBuffer: window.forceUseReverseDepthBuffer, forceUseNonCompatibilityMode: window.forceUseNonCompatibilityMode, @@ -233,11 +234,17 @@ export const evaluateRenderSceneForVisualization = async (renderCount: number) = } window.engine.runRenderLoop(function () { try { - window.scene && window.scene.render(); - renderCount--; - if (renderCount <= 0 && window.scene!.isReady()) { - window.engine && window.engine.stopRenderLoop(); - return resolve(true); + if (renderCount === 0) { + if (window.scene!.isReady()) { + window.engine && window.engine.stopRenderLoop(); + return resolve(true); + } else { + console.error("Scene is not ready after rendering is done"); + return resolve(false); + } + } else { + window.scene && window.scene.render(); + renderCount--; } } catch (e) { window.engine && window.engine.stopRenderLoop();