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

Fix tests running locally #12877

Merged
merged 1 commit into from
Aug 16, 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
14 changes: 9 additions & 5 deletions packages/dev/core/src/Materials/Textures/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<RenderTargetTexture> = null;
Expand All @@ -999,7 +999,7 @@ export class Texture extends BaseTexture {
);
renderTargetTexture._waitingRenderList = parsedTexture.renderList;
}
onLoaded();
onLoaded(renderTargetTexture);
return renderTargetTexture;
} else {
let texture: Texture;
Expand All @@ -1012,7 +1012,9 @@ export class Texture extends BaseTexture {
!generateMipMaps,
parsedTexture.invertY,
parsedTexture.samplingMode,
onLoaded,
() => {
onLoaded(texture);
},
parsedTexture._creationFlags ?? 0,
parsedTexture._useSRGBBuffer ?? false
);
Expand All @@ -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;
Expand Down
17 changes: 12 additions & 5 deletions packages/tools/testTools/src/visualizationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down