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

Update to Babylon.js 7.6.2 #1373

Merged
merged 26 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
72aa1be
Update to Babylon.js 7.0.0
bghgary Mar 28, 2024
76b8be5
Disable SetWindowText in visual tests as it can hang the app forever
bghgary Mar 28, 2024
58ccd54
- Update to latest JsRuntimeHost with lots of fixes.
bghgary Apr 6, 2024
7bef079
napi/napi_pointer.h --> napi/pointer.h
bghgary Apr 6, 2024
5e2f600
Bump JsRuntimeHost
bghgary Apr 6, 2024
2980a8b
Bump JsRuntimeHost
bghgary Apr 19, 2024
1f87a56
Merge remote-tracking branch 'origin/master' into update-bjs
bghgary Apr 19, 2024
b1dfd7f
Revert incorrect fuzzy equal change
bghgary Apr 19, 2024
c5c2469
Fix compile error on linux
bghgary Apr 19, 2024
daa6ac6
Missed changing a header
bghgary Apr 19, 2024
9dbdaf2
Fix install
bghgary Apr 19, 2024
0909b5d
Merge branch 'update-bjs' of https://github.com/bghgary/BabylonNative…
bghgary Apr 19, 2024
9c7083c
Address feedback
bghgary May 10, 2024
788b706
Fix let/const issue
bghgary May 10, 2024
3001254
Update scissor test reference images
bghgary May 10, 2024
c4a385d
Revert CopyTexture changes and fix an issue with CreateFrameBuffer te…
bghgary May 10, 2024
76c6e0f
Isolate validation test variables
bghgary May 14, 2024
b6c6e25
Update dynamic texture clip test to fail if feature isn't working
bghgary May 14, 2024
7d64934
Update to Babylon.js 7.6.1
bghgary May 14, 2024
2252eb3
Merge remote-tracking branch 'origin/master' into update-bjs
bghgary May 14, 2024
540a165
Add support for unbinding textures
bghgary May 16, 2024
e6cce11
Fix excludedGraphicsApis in config
bghgary May 16, 2024
c884bf7
Ugh
bghgary May 16, 2024
ec1ee3b
Fix package-lock.json
bghgary May 16, 2024
fdb29d6
Merge remote-tracking branch 'origin/master' into update-bjs
bghgary May 17, 2024
52a821b
Fix Apple
bghgary May 17, 2024
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Apps/Playground/ReferenceImages/scissor-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 15 additions & 18 deletions Apps/Playground/Scripts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
},
{
"title": "GLTF ClearCoat",
"playgroundId": "#YG3BBF#4",
"referenceImage": "glTFClearCoat.png",
"renderCount": 50,
"excludeFromAutomaticTesting": false
"playgroundId": "#YG3BBF#33",
"referenceImage": "glTFClearCoat.png"
},
{
"title": "Iridescence GLTF",
Expand Down Expand Up @@ -255,27 +253,26 @@
},
{
"title": "Scissor test",
"renderCount": 10,
"playgroundId": "#W7E7CF#12",
"playgroundId": "#W7E7CF#34",
"excludedEngines": [ "D3D12" ],
"referenceImage": "scissor-test.png",
"excludedGraphicsApis": [ "D3D12" ],
"comment": "TODO: reenable D3D12 when automatica mip-maps issue is fixed in bgfx"
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
},
{
"title": "Scissor test with 0.9 hardware scaling",
"renderCount": 10,
"playgroundId": "#W7E7CF#27",
"referenceImage": "scissorTestWith0.9HardwareScaling.png",
"excludedGraphicsApis": [ "D3D12" ],
"comment": "TODO: reenable D3D12 when automatica mip-maps issue is fixed in bgfx"
"playgroundId": "#W7E7CF#34",
"replace": "//options//, hardwareScalingLevel = 0.9;",
"excludedEngines": [ "D3D12" ],
"referenceImage": "scissor-test-2.png",
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
},
{
"title": "Scissor test with 1.5 hardware scaling",
"renderCount": 10,
"playgroundId": "#W7E7CF#28",
"referenceImage": "scissorTestWith1.5HardwareScaling.png",
"excludedGraphicsApis": [ "D3D12" ],
"comment": "TODO: reenable D3D12 when automatica mip-maps issue is fixed in bgfx"
"playgroundId": "#W7E7CF#34",
"replace": "//options//, hardwareScalingLevel = 1.5;",
"excludedEngines": [ "D3D12" ],
"referenceImage": "scissor-test-3.png",
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
},
{
"title": "Scissor test with negative x and y",
Expand Down
4 changes: 2 additions & 2 deletions Apps/Playground/Scripts/playground_runner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (typeof createScene === "function") {
var engine = new BABYLON.NativeEngine({adaptToDeviceRatio: true});
var scene = createScene();
const engine = new BABYLON.NativeEngine({adaptToDeviceRatio: true});
const scene = createScene();
if (scene.then) {
scene.then(function (scene) {
engine.runRenderLoop(function () {
Expand Down
165 changes: 81 additions & 84 deletions Apps/Playground/Scripts/validation_native.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
var engine;
var canvas;
var currentScene;
var config;
var justOnce;
var saveResult = true;
var testWidth = 600;
var testHeight = 400;
var generateReferences = false;
let currentScene;
let config;
const justOnce = false;
const saveResult = true;
const testWidth = 600;
const testHeight = 400;
const generateReferences = false;

const engine = new BABYLON.NativeEngine();
engine.getCaps().parallelShaderCompile = undefined;

engine.getRenderingCanvas = function () {
return window;
}

engine.getInputElement = function () {
return 0;
}

const canvas = window;

// Random replacement
var seed = 1;
let seed = 1;
Math.random = function () {
var x = Math.sin(seed++) * 10000;
const x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}

function compare(test, renderData, referenceImage, threshold, errorRatio) {
var size = renderData.length;
var referenceData = TestUtils.getImageData(referenceImage);
var differencesCount = 0;
const referenceData = TestUtils.getImageData(referenceImage);
if (referenceData.length != renderData.length) {
throw new Error(`Reference data length (${referenceData.length}) must match render data length (${renderData.length})`);
}

const size = renderData.length;
let differencesCount = 0;

for (var index = 0; index < size; index += 4) {
for (let index = 0; index < size; index += 4) {
if (Math.abs(renderData[index] - referenceData[index]) < threshold &&
Math.abs(renderData[index + 1] - referenceData[index + 1]) < threshold &&
Math.abs(renderData[index + 2] - referenceData[index + 2]) < threshold) {
Expand All @@ -43,7 +58,7 @@ function compare(test, renderData, referenceImage, threshold, errorRatio) {
console.log("No pixel difference!");
}

let error = (differencesCount * 100) / (size / 4) > errorRatio;
const error = (differencesCount * 100) / (size / 4) > errorRatio;

const width = testWidth / engine.getHardwareScalingLevel();
const height = testHeight / engine.getHardwareScalingLevel();
Expand All @@ -64,13 +79,13 @@ function saveRenderedResult(test, renderData) {
return false; // no error
}

function evaluate(test, resultCanvas, result, referenceImage, index, waitRing, done, compareFunction) {
function evaluate(test, referenceImage, done, compareFunction) {
engine._engine.getFrameBufferData(function (screenshot) {
var testRes = true;
let testRes = true;

if (!test.onlyVisual) {

var defaultErrorRatio = 2.5;
const defaultErrorRatio = 2.5;

if (compareFunction(test, screenshot, referenceImage, test.threshold || 25, test.errorRatio || defaultErrorRatio)) {
testRes = false;
Expand All @@ -89,9 +104,9 @@ function evaluate(test, resultCanvas, result, referenceImage, index, waitRing, d
});
}

function processCurrentScene(test, resultCanvas, result, renderImage, index, waitRing, done, compareFunction) {
function processCurrentScene(test, renderImage, done, compareFunction) {
currentScene.useConstantAnimationDeltaTime = true;
var renderCount = test.renderCount || 1;
let renderCount = test.renderCount || 1;

currentScene.executeWhenReady(function () {
if (currentScene.activeCamera && currentScene.activeCamera.useAutoRotationBehavior) {
Expand All @@ -104,7 +119,7 @@ function processCurrentScene(test, resultCanvas, result, renderImage, index, wai

if (renderCount === 0) {
engine.stopRenderLoop();
evaluate(test, resultCanvas, result, renderImage, index, waitRing, done, compareFunction);
evaluate(test, renderImage, done, compareFunction);
}
}
catch (e) {
Expand All @@ -115,11 +130,11 @@ function processCurrentScene(test, resultCanvas, result, renderImage, index, wai
});
}

function loadPlayground(test, done, index, referenceImage, compareFunction) {
function loadPlayground(test, done, referenceImage, compareFunction) {
if (test.sceneFolder) {
BABYLON.SceneLoader.Load(config.root + test.sceneFolder, test.sceneFilename, engine, function (newScene) {
currentScene = newScene;
processCurrentScene(test, resultCanvas, result, referenceImage, index, waitRing, done, compareFunction);
processCurrentScene(test, referenceImage, done, compareFunction);
},
null,
function (loadedScene, msg) {
Expand All @@ -132,14 +147,14 @@ function loadPlayground(test, done, index, referenceImage, compareFunction) {
test.playgroundId += "#0";
}

var snippetUrl = "https://snippet.babylonjs.com";
var pgRoot = "https://playground.babylonjs.com";
const snippetUrl = "https://snippet.babylonjs.com";
const pgRoot = "https://playground.babylonjs.com";

var retryTime = 500;
var maxRetry = 5;
var retry = 0;
const retryTime = 500;
const maxRetry = 5;
let retry = 0;

var onError = function () {
const onError = function () {
retry++;
if (retry < maxRetry) {
setTimeout(function () {
Expand All @@ -153,15 +168,14 @@ function loadPlayground(test, done, index, referenceImage, compareFunction) {
}
}

var loadPG = function () {
var xmlHttp = new XMLHttpRequest();
const loadPG = function () {
const xmlHttp = new XMLHttpRequest();
xmlHttp.addEventListener("readystatechange", function () {
if (xmlHttp.readyState === 4) {
try {
xmlHttp.onreadystatechange = null;
var snippet = JSON.parse(xmlHttp.responseText);
var code = JSON.parse(snippet.jsonPayload).code.toString();
code = code
const snippet = JSON.parse(xmlHttp.responseText);
let code = JSON.parse(snippet.jsonPayload).code.toString()
.replace(/"\/textures\//g, '"' + pgRoot + "/textures/")
.replace(/"textures\//g, '"' + pgRoot + "/textures/")
.replace(/\/scenes\//g, pgRoot + "/scenes/")
Expand All @@ -179,22 +193,19 @@ function loadPlayground(test, done, index, referenceImage, compareFunction) {
}

currentScene = eval(code + "\r\ncreateScene(engine)");
var resultCanvas = 0;
var result;
var waitRing;

if (currentScene.then) {
// Handle if createScene returns a promise
currentScene.then(function (scene) {
currentScene = scene;
processCurrentScene(test, resultCanvas, result, referenceImage, index, waitRing, done, compareFunction);
processCurrentScene(test, referenceImage, done, compareFunction);
}).catch(function (e) {
console.error(e);
onError();
})
} else {
// Handle if createScene returns a scene
processCurrentScene(test, resultCanvas, result, referenceImage, index, waitRing, done, compareFunction);
processCurrentScene(test, referenceImage, done, compareFunction);
}

}
Expand All @@ -218,38 +229,38 @@ function loadPlayground(test, done, index, referenceImage, compareFunction) {
BABYLON.Tools.BaseUrl = config.root + test.specificRoot;
}

var request = new XMLHttpRequest();
const request = new XMLHttpRequest();
request.open('GET', config.root + test.scriptToRun, true);

request.onreadystatechange = function () {
if (request.readyState === 4) {
try {
request.onreadystatechange = null;

var scriptToRun = request.responseText.replace(/..\/..\/assets\//g, config.root + "/Assets/");
const scriptToRun = request.responseText.replace(/..\/..\/assets\//g, config.root + "/Assets/");
scriptToRun = scriptToRun.replace(/..\/..\/Assets\//g, config.root + "/Assets/");
scriptToRun = scriptToRun.replace(/\/assets\//g, config.root + "/Assets/");

if (test.replace) {
var split = test.replace.split(",");
for (var i = 0; i < split.length; i += 2) {
var source = split[i].trim();
var destination = split[i + 1].trim();
const split = test.replace.split(",");
for (let i = 0; i < split.length; i += 2) {
const source = split[i].trim();
const destination = split[i + 1].trim();
scriptToRun = scriptToRun.replace(source, destination);
}
}

if (test.replaceUrl) {
var split = test.replaceUrl.split(",");
for (var i = 0; i < split.length; i++) {
var source = split[i].trim();
var regex = new RegExp(source, "g");
const split = test.replaceUrl.split(",");
for (let i = 0; i < split.length; i++) {
const source = split[i].trim();
const regex = new RegExp(source, "g");
scriptToRun = scriptToRun.replace(regex, config.root + test.rootPath + source);
}
}

currentScene = eval(scriptToRun + test.functionToCall + "(engine)");
processCurrentScene(test, resultCanvas, result, renderImage, index, waitRing, done, compareFunction);
processCurrentScene(test, renderImage, done, compareFunction);
}
catch (e) {
console.error(e);
Expand All @@ -270,7 +281,7 @@ function runTest(index, done) {
done(false);
}

var test = config.tests[index];
const test = config.tests[index];
if (test.onlyVisual || test.excludeFromAutomaticTesting) {
done(true);
return;
Expand All @@ -279,48 +290,35 @@ function runTest(index, done) {
done(true);
return;
}
let testInfo = "Running " + test.title;
const testInfo = "Running " + test.title;
console.log(testInfo);
TestUtils.setTitle(testInfo);

seed = 1;

let onLoadFileError = function (request, exception) {
console.error("Failed to retrieve " + url + ".", exception);
done(false);
};
var onload = function (data, responseURL) {
if (typeof (data) === "string") {
throw new Error("Decode Image from string data not yet implemented.");
}
if (generateReferences) {
loadPlayground(test, done, undefined, saveRenderedResult);
} else {
const onLoadFileError = function (request, exception) {
console.error("Failed to retrieve " + url + ".", exception);
done(false);
};

var referenceImage = TestUtils.decodeImage(data);
loadPlayground(test, done, index, referenceImage, compare);
const onload = function (data, responseURL) {
if (typeof (data) === "string") {
throw new Error("Decode Image from string data not yet implemented.");
}

};
const referenceImage = TestUtils.decodeImage(data);
loadPlayground(test, done, referenceImage, compare);
};

if (generateReferences) {
loadPlayground(test, done, index, undefined, saveRenderedResult);
} else {
// run test and image comparison
const url = "app:///ReferenceImages/" + test.referenceImage;
BABYLON.Tools.LoadFile(url, onload, undefined, undefined, /*useArrayBuffer*/true, onLoadFileError);
}
}

engine = new BABYLON.NativeEngine();
engine.getCaps().parallelShaderCompile = undefined;

engine.getRenderingCanvas = function () {
return window;
}

engine.getInputElement = function () {
return 0;
}

canvas = window;

OffscreenCanvas = function (width, height) {
return {
width: width
Expand All @@ -345,16 +343,15 @@ document = {
removeEventListener: function () { }
}

var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open("GET", "app:///Scripts/config.json", true);

xhr.addEventListener("readystatechange", function () {
if (xhr.status === 200) {
config = JSON.parse(xhr.responseText);

// Run tests
var index = 0;
var recursiveRunTest = function (i) {
const recursiveRunTest = function (i) {
runTest(i, function (status) {
if (!status) {
TestUtils.exit(-1);
Expand All @@ -370,7 +367,7 @@ xhr.addEventListener("readystatechange", function () {
});
}

recursiveRunTest(index);
recursiveRunTest(0);
}
}, false);

Expand Down
Loading
Loading