Skip to content

Commit 4a0d3c0

Browse files
committed
tests: validate manager-driven DrawList rendering
1 parent 6114b61 commit 4a0d3c0

3 files changed

Lines changed: 84 additions & 4 deletions

File tree

‎.github/workflows/continuous-integration-workflow.yml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ jobs:
116116
$installedPrefix = (Join-Path $env:GITHUB_WORKSPACE "cmake_install_dir").Replace('\', '/')
117117
cmake -S $smokeSource -B $smokeBuild -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH="$installedPrefix"
118118
cmake --build $smokeBuild --config Release
119-
- name: Run compatibility tests
120-
if: matrix.legacy_gl_renderer == 'ON'
119+
- name: Run tests
121120
run: ctest -C Release -VV
122121
working-directory: cmake_build_dir
123122
- name: Create Artifacts
@@ -157,8 +156,7 @@ jobs:
157156
-DCMAKE_BUILD_TYPE=Release \
158157
-DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/cmake_install_dir"
159158
cmake --build installed-package-smoke --config Release -- -j4
160-
- name: Run compatibility tests
161-
if: matrix.legacy_gl_renderer == 'ON'
159+
- name: Run tests
162160
run: ctest -C Release -VV
163161
working-directory: cmake_build_dir
164162
- name: Create Artifacts

‎testsuite/CMakeLists.txt‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,18 @@ if(HAVE_EGL)
145145
add_test(NAME DrawListPickingTest COMMAND DrawListPickingTest)
146146
set_tests_properties(DrawListPickingTest PROPERTIES SKIP_RETURN_CODE 77)
147147

148+
add_executable(DrawListManagerTest drawlist-manager-test.cpp)
149+
target_link_libraries(DrawListManagerTest Coin ${COIN_TARGET_LINK_LIBRARIES})
150+
target_compile_definitions(DrawListManagerTest PRIVATE COIN_INTERNAL)
151+
target_include_directories(DrawListManagerTest PRIVATE
152+
${PROJECT_SOURCE_DIR}/src
153+
${PROJECT_SOURCE_DIR}/include
154+
${PROJECT_BINARY_DIR}/include
155+
${COIN_TARGET_INCLUDE_DIRECTORIES}
156+
)
157+
add_test(NAME DrawListManagerTest COMMAND DrawListManagerTest)
158+
set_tests_properties(DrawListManagerTest PROPERTIES SKIP_RETURN_CODE 77)
159+
148160
add_executable(EGLBindingTest egl-binding-test.cpp)
149161
target_link_libraries(EGLBindingTest Coin ${COIN_TARGET_LINK_LIBRARIES})
150162
target_compile_definitions(EGLBindingTest PRIVATE COIN_INTERNAL)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#include "rendering/CoinOffscreenGLCanvas.h"
2+
3+
#include <Inventor/SoDB.h>
4+
#include <Inventor/SoRenderManager.h>
5+
#include <Inventor/SbViewportRegion.h>
6+
#include <Inventor/nodes/SoCube.h>
7+
#include <Inventor/nodes/SoSeparator.h>
8+
9+
#include <cstdlib>
10+
#include <iostream>
11+
12+
namespace {
13+
14+
int skip(const char * reason)
15+
{
16+
std::cout << "SKIP: " << reason << std::endl;
17+
return 77;
18+
}
19+
20+
void set_environment(const char * name, const char * value)
21+
{
22+
#ifdef _WIN32
23+
_putenv_s(name, value);
24+
#else
25+
setenv(name, value, 1);
26+
#endif
27+
}
28+
29+
}
30+
31+
int
32+
main()
33+
{
34+
set_environment("COIN_EGL", "1");
35+
set_environment("EGL_PLATFORM", "surfaceless");
36+
set_environment("COIN_EGL_CORE_PROFILE", "1");
37+
38+
SoDB::init();
39+
CoinOffscreenGLCanvas canvas;
40+
canvas.setWantedSize(SbVec2s(32, 32));
41+
if (canvas.activateGLContext() == 0) {
42+
SoDB::finish();
43+
return skip("core EGL offscreen context is unavailable");
44+
}
45+
46+
SoSeparator * root = new SoSeparator;
47+
SoCube * cube = new SoCube;
48+
root->addChild(cube);
49+
root->ref();
50+
51+
uint8_t pixel[4] = {0, 0, 0, 0};
52+
{
53+
SoRenderManager manager;
54+
manager.setViewportRegion(SbViewportRegion(SbVec2s(32, 32)));
55+
manager.setSceneGraph(root);
56+
manager.setRenderPipeline(SoRenderManager::RenderPipeline::DRAW_LIST);
57+
manager.render(TRUE, TRUE);
58+
canvas.readPixels(pixel, SbVec2s(1, 1), 1, 4);
59+
}
60+
61+
root->unref();
62+
canvas.deactivateGLContext();
63+
SoDB::finish();
64+
65+
if (pixel[0] == 0 && pixel[1] == 0 && pixel[2] == 0) {
66+
std::cerr << "FAIL: manager DrawList pipeline produced no pixels" << std::endl;
67+
return 1;
68+
}
69+
return 0;
70+
}

0 commit comments

Comments
 (0)