Skip to content

Commit

Permalink
Fix compatibility with VTK and glad (#1631)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk authored Oct 16, 2024
1 parent d5f3e17 commit d9fa161
Show file tree
Hide file tree
Showing 97 changed files with 1,483 additions and 264 deletions.
5 changes: 5 additions & 0 deletions .github/actions/coverage-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ runs:
-DF3D_PLUGIN_BUILD_USD=ON
-DF3D_PLUGIN_BUILD_VDB=ON
-DF3D_STRICT_BUILD=ON
-DF3D_TESTING_ENABLE_EXTERNAL_EGL=ON
-DF3D_TESTING_ENABLE_EXTERNAL_GLFW=ON
-DF3D_TESTING_ENABLE_EXTERNAL_OSMESA=ON
-DF3D_TESTING_ENABLE_EXTERNAL_QT=ON
-DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=ON
-DF3D_TESTING_ENABLE_GLX_TESTS=ON
- name: Build
shell: bash
Expand Down
15 changes: 10 additions & 5 deletions .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ inputs:
description: 'Label to control bundle'
required: false
default: 'no-bundle'
egl_label:
description: 'Label to control egl'
rendering_backend:
description: 'Label to control the rendering backend'
required: false
default: 'no-egl'
default: 'auto'
static_label:
description: 'Label to control static build'
required: false
Expand Down Expand Up @@ -82,7 +82,6 @@ runs:
vtk_version: ${{inputs.vtk_version}}
vtk_sha_file: ./source/.github/actions/vtk_commit_sha
raytracing_label: ${{inputs.raytracing_label}}
egl_label: ${{inputs.egl_label}}
cpu: ${{inputs.cpu}}

- name: Install F3D dependencies
Expand Down Expand Up @@ -165,6 +164,12 @@ runs:
-DF3D_PLUGIN_BUILD_USD=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_PLUGIN_BUILD_VDB=${{ matrix.vtk_version != 'v9.2.6' && (runner.os != 'Windows' || matrix.vtk_version != 'v9.3.1') && inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_STRICT_BUILD=ON
-DF3D_TESTING_ENABLE_EXTERNAL_EGL=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
-DF3D_TESTING_ENABLE_EXTERNAL_GLFW=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
-DF3D_TESTING_ENABLE_EXTERNAL_OSMESA=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
-DF3D_TESTING_ENABLE_EXTERNAL_QT=${{ runner.os == 'Linux' && 'ON' || 'OFF' }}
-DF3D_TESTING_ENABLE_GLX_TESTS=${{ inputs.rendering_backend == 'auto' && 'ON' || 'OFF' }}
-DF3D_TESTING_FORCE_RENDERING_BACKEND=${{ inputs.rendering_backend }}
-DF3D_WINDOWS_GUI=ON
${{ runner.os == 'Windows' && '-Ax64 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL' || null }}
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15' || null }}
Expand All @@ -178,7 +183,7 @@ runs:
- name: Run Xvfb ubuntu
if: |
runner.os == 'Linux' &&
inputs.egl_label != 'egl'
inputs.rendering_backend == 'auto'
shell: bash
run: Xvfb $DISPLAY -screen 0 1280x1024x24 &

Expand Down
7 changes: 6 additions & 1 deletion .github/actions/sanitizer-ci/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Sanitzier CI'
name: 'Sanitizer CI'
description: 'Sanitizer CI'
inputs:
sanitizer_type:
Expand Down Expand Up @@ -78,6 +78,11 @@ runs:
-DF3D_PLUGIN_BUILD_VDB=OFF
-DF3D_SANITIZER=${{inputs.sanitizer_type}}
-DF3D_STRICT_BUILD=ON
-DF3D_TESTING_ENABLE_EXTERNAL_EGL=ON
-DF3D_TESTING_ENABLE_EXTERNAL_GLFW=ON
-DF3D_TESTING_ENABLE_EXTERNAL_OSMESA=ON
-DF3D_TESTING_ENABLE_EXTERNAL_QT=ON
-DF3D_TESTING_ENABLE_GLX_TESTS=ON
-DF3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS=ON
- name: Build
Expand Down
9 changes: 2 additions & 7 deletions .github/actions/vtk-install-dep/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ inputs:
description: 'Label to control raytracing'
required: false
default: 'no-raytracing'
egl_label:
description: 'Label to control egl'
required: false
default: 'no-egl'
cpu:
description: 'CPU architecture to build for'
required: false
Expand Down Expand Up @@ -47,7 +43,7 @@ runs:
uses: actions/cache@v4
with:
path: dependencies/vtk_install
key: vtk-${{env.VTK_SHA_OR_TAG}}-${{runner.os}}-${{inputs.raytracing_label}}-${{inputs.egl_label}}-${{inputs.cpu}}-8
key: vtk-${{env.VTK_SHA_OR_TAG}}-${{runner.os}}-${{inputs.raytracing_label}}-${{inputs.cpu}}-3

- name: Setup VTK
if: steps.cache-vtk.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -86,7 +82,6 @@ runs:
-DVTKOSPRAY_ENABLE_DENOISER=ON
-DVTK_BUILD_TESTING=OFF
-DVTK_DEBUG_LEAKS=ON
-DVTK_DEFAULT_RENDER_WINDOW_HEADLESS=${{ inputs.egl_label == 'egl' && 'ON' || 'OFF' }}
-DVTK_ENABLE_LOGGING=OFF
-DVTK_ENABLE_REMOTE_MODULES=OFF
-DVTK_ENABLE_WRAPPING=OFF
Expand Down Expand Up @@ -116,7 +111,7 @@ runs:
-DVTK_MODULE_ENABLE_VTK_RenderingRayTracing=${{ inputs.raytracing_label == 'raytracing' && 'YES' || 'DEFAULT' }}
-DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2=YES
-DVTK_MODULE_ENABLE_VTK_TestingCore=YES
-DVTK_OPENGL_HAS_EGL=${{ inputs.egl_label == 'egl' && 'ON' || 'OFF' }}
-DVTK_OPENGL_HAS_EGL=${{ inputs.vtk_version == 'commit' && 'ON' || 'OFF' }}
-DVTK_SMP_IMPLEMENTATION_TYPE=TBB
-DVTK_VERSIONED_INSTALL=OFF
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15' || null }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/vtk_commit_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6a898fd91da30d3ff903416bf856f0d1cea82cdf
e19dd33b9813ce6609121d62dd02b8edf8fba33d
22 changes: 14 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,42 @@ jobs:
- raytracing_label: raytracing
- exclude_deprecated_label: no-exclude-deprecated
- optional_deps_label: optional-deps
- egl_label: no-egl
- rendering_backend: auto
- static_label: no-static
- build_type: headless
- build_type: egl
vtk_version: commit
raytracing_label: raytracing
optional_deps_label: optional-deps
exclude_deprecated_label: no-exclude-deprecated
egl_label: egl
rendering_backend: egl
static_label: no-static
- build_type: osmesa
vtk_version: commit
raytracing_label: raytracing
optional_deps_label: optional-deps
exclude_deprecated_label: no-exclude-deprecated
rendering_backend: osmesa
static_label: no-static
- build_type: exclude_deprecated
vtk_version: commit
raytracing_label: raytracing
optional_deps_label: optional-deps
exclude_deprecated_label: exclude-deprecated
egl_label: no-egl
rendering_backend: auto
static_label: no-static
- build_type: no_optional_deps
vtk_version: commit
raytracing_label: no-raytracing
optional_deps_label: no-optional-deps
exclude_deprecated_label: no-exclude-deprecated
egl_label: no-egl
rendering_backend: auto
static_label: no-static
- build_type: static_libs
vtk_version: commit
raytracing_label: no-raytracing
optional_deps_label: optional-deps
exclude_deprecated_label: no-exclude-deprecated
egl_label: no-egl
rendering_backend: auto
static_label: static

runs-on: ubuntu-latest
Expand All @@ -139,7 +146,6 @@ jobs:
raytracing_label: ${{matrix.raytracing_label}}
optional_deps_label: ${{matrix.optional_deps_label}}
exclude_deprecated_label: ${{matrix.exclude_deprecated_label}}
egl_label: ${{matrix.egl_label}}
static_label: ${{matrix.static_label}}
lfs_sha: ${{ needs.cache_lfs.outputs.lfs_sha}}

Expand Down Expand Up @@ -182,7 +188,7 @@ jobs:
strategy:
fail-fast: false
matrix:
vtk_version: [commit, v9.3.1, v9.2.6]
vtk_version: [commit, v9.3.1] # VTK 9.2.6 not compatible with recent clang version on macOS
bundle_label: [no-bundle]
static_label: [no-static]
include:
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/nightly_vtk_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ jobs:
if: ${{ needs.check_nightly.outputs.should_run == 'true' }}
strategy:
fail-fast: false
matrix:
build_type: [standard]
include:
- egl_label: no-egl
- build_type: headless
egl_label: egl

matrix:
build_type: [standard]
include:
- rendering_backend: auto
- build_type: egl
rendering_backend: egl
- build_type: osmesa
rendering_backend: osmesa
runs-on: ubuntu-latest
container: ghcr.io/f3d-app/f3d-ci

Expand All @@ -123,7 +124,7 @@ jobs:
vtk_version: ${{needs.check_nightly.outputs.vtk_sha}}
raytracing_label: 'raytracing'
exclude_deprecated_label: ${{matrix.exclude_deprecated_label}}
egl_label: ${{matrix.egl_label}}
rendering_backend: ${{matrix.rendering_backend}}
lfs_sha: ${{ needs.cache_lfs.outputs.lfs_sha}}

#----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions .lsan.supp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ leak:TKernel
# TBB
leak:libtbb

# OSMesa
leak:libOSMesa

# Potential mesa/VTK leak with incomplete callstack
# forces us to hide all leaks from the tests using a render window
# https://gitlab.kitware.com/vtk/vtk/-/issues/18504
Expand Down
3 changes: 3 additions & 0 deletions .tsan.supp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ race:libOpenEXR
# dmon
# https://github.com/septag/dmon/issues/33
race:dmon.h

# OSMesa
race:libOSMesa
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ find_package(VTK 9.2.6 REQUIRED
RenderingVolumeOpenGL2
TestingCore
jsoncpp
opengl
OPTIONAL_COMPONENTS
opengl
IOExodus
IOOpenVDB
RenderingExternal
RenderingRayTracing)
message(STATUS "VTK ${VTK_VERSION} found")

if(VTK_VERSION VERSION_LESS 9.3.20240914)
# Not optional before
find_package(VTK REQUIRED COMPONENTS opengl)
endif()

# Shared options between application and library
include(GNUInstallDirs)
cmake_dependent_option(F3D_WINDOWS_GUI "Build a non-console Win32 application" ON "WIN32" OFF)
Expand Down Expand Up @@ -184,10 +189,18 @@ list(APPEND f3d_link_options_public ${f3d_sanitizer_link_options})
option(BUILD_TESTING "Build the tests" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_RENDERING_TESTS "Enable rendering tests" ON "BUILD_TESTING" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS "Enable long timeout tests" OFF "BUILD_TESTING" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_GLX_TESTS "Enable test that require a X server running on Linux" ON "F3D_TESTING_ENABLE_RENDERING_TESTS AND UNIX AND NOT APPLE" OFF)
if(BUILD_TESTING)
enable_testing()
endif()

# Testing offscreen backend
if(NOT F3D_TESTING_FORCE_RENDERING_BACKEND)
set(F3D_TESTING_FORCE_RENDERING_BACKEND "auto" CACHE STRING "Force testing offscreen backend" FORCE)
set_property(CACHE F3D_TESTING_FORCE_RENDERING_BACKEND PROPERTY STRINGS "auto" "egl" "osmesa")
endif()
mark_as_advanced(F3D_TESTING_FORCE_RENDERING_BACKEND)

# Figure out F3D configuration directory
if(UNIX AND NOT APPLE)
option(F3D_LINUX_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX "Install the default configuration at the prefix root instead of system wide" OFF)
Expand Down
8 changes: 5 additions & 3 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ if (F3D_MODULE_EXR)
target_compile_definitions(f3d PRIVATE F3D_MODULE_EXR)
endif ()

# Headless EGL build
if (VTK_OPENGL_HAS_EGL)
target_compile_definitions(f3d PRIVATE F3D_HEADLESS_BUILD)
if(VTK_VERSION VERSION_LESS 9.3.20240914)
# Headless EGL build
if (VTK_OPENGL_HAS_EGL)
target_compile_definitions(f3d PRIVATE F3D_HEADLESS_BUILD)
endif ()
endif ()

# F3D_STRICT_BUILD
Expand Down
1 change: 1 addition & 0 deletions application/F3DOptionsTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static inline const std::array<CLIGroup, 8> CLIOptions = {{
{ "config", "", "Specify the configuration file to use. absolute/relative path or filename/filestem to search in configuration file locations", "<filePath/filename/fileStem>", "" },
{ "dry-run", "", "Do not read the configuration file", "<bool>", "1" },
{ "no-render", "", "Do not read the configuration file", "<bool>", "1" },
{ "rendering-backend", "", "Backend to use when rendering (auto|glx|wgl|egl|osmesa)", "<string>", "" },
{ "max-size", "", "Maximum size in Mib of a file to load, negative value means unlimited", "<size in Mib>", "" },
{ "watch", "", "Watch current file and automatically reload it whenever it is modified on disk", "<bool>", "1" },
{ "load-plugins", "", "List of plugins to load separated with a comma", "<paths or names>", "" },
Expand Down
1 change: 1 addition & 0 deletions application/F3DOptionsTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static inline const OptionsDict DefaultAppOptions = {
{ "config", "" },
{ "dry-run", "false" },
{ "no-render", "false" },
{ "rendering-backend", "auto" },
{ "max-size", "-1.0" },
{ "watch", "false" },
{ "load-plugins", "" },
Expand Down
32 changes: 29 additions & 3 deletions application/F3DStarter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class F3DStarter::F3DInternals
std::string Output;
bool NoBackground;
bool NoRender;
std::string RenderingBackend;
double MaxSize;
bool Watch;
std::vector<std::string> Plugins;
Expand Down Expand Up @@ -557,6 +558,8 @@ class F3DStarter::F3DInternals
this->AppOptions.Output = f3d::options::parse<std::string>(appOptions.at("output"));
this->AppOptions.NoBackground = f3d::options::parse<bool>(appOptions.at("no-background"));
this->AppOptions.NoRender = f3d::options::parse<bool>(appOptions.at("no-render"));
this->AppOptions.RenderingBackend =
f3d::options::parse<std::string>(appOptions.at("rendering-backend"));
this->AppOptions.MaxSize = f3d::options::parse<double>(appOptions.at("max-size"));
this->AppOptions.Watch = f3d::options::parse<bool>(appOptions.at("watch"));
this->AppOptions.Plugins = { f3d::options::parse<std::vector<std::string>>(
Expand Down Expand Up @@ -759,13 +762,36 @@ int F3DStarter::Start(int argc, char** argv)

if (this->Internals->AppOptions.NoRender)
{
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::window::Type::NONE);
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::createNone());
}
else
{
bool offscreen = !reference.empty() || !output.empty();
this->Internals->Engine = std::make_unique<f3d::engine>(
offscreen ? f3d::window::Type::NATIVE_OFFSCREEN : f3d::window::Type::NATIVE);

if (this->Internals->AppOptions.RenderingBackend == "egl")
{
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::createEGL(offscreen));
}
else if (this->Internals->AppOptions.RenderingBackend == "osmesa")
{
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::createOSMesa());
}
else if (this->Internals->AppOptions.RenderingBackend == "glx")
{
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::createGLX(offscreen));
}
else if (this->Internals->AppOptions.RenderingBackend == "wgl")
{
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::createWGL(offscreen));
}
else
{
if (this->Internals->AppOptions.RenderingBackend != "auto")
{
f3d::log::warn("--rendering-backend value is invalid, falling back to \"auto\"");
}
this->Internals->Engine = std::make_unique<f3d::engine>(f3d::engine::create(offscreen));
}

f3d::window& window = this->Internals->Engine->getWindow();
window.setWindowName(F3D::AppTitle).setIcon(F3DIcon, sizeof(F3DIcon));
Expand Down
Loading

0 comments on commit d9fa161

Please sign in to comment.