Skip to content
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
39 changes: 39 additions & 0 deletions .github/workflows/system-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ on:
- "**.cpp"
- "**.hpp"
- "**.hxx"
- "**.vert"
- "**.frag"
- "meson.build"
- "meson_options.txt"
- "**/meson.build"
- "subprojects/*.wrap"
- "subprojects/packagefiles/**"
- ".github/workflows/system-packages.yml"
pull_request:
paths:
Expand All @@ -21,10 +24,13 @@ on:
- "**.cpp"
- "**.hpp"
- "**.hxx"
- "**.vert"
- "**.frag"
- "meson.build"
- "meson_options.txt"
- "**/meson.build"
- "subprojects/*.wrap"
- "subprojects/packagefiles/**"
- ".github/workflows/system-packages.yml"

jobs:
Expand Down Expand Up @@ -133,6 +139,39 @@ jobs:
- name: Build
run: meson compile -C build/

- name: Verify Qt-only frontend
if: matrix.build_type == 'debug'
env:
CC: ccache ${{ matrix.platform.cc }}
CXX: ccache ${{ matrix.platform.cxx }}
run: |
meson setup build-qt-only/ \
--buildtype=debug \
--wrap-mode=forcefallback \
-Dtesting=false -Dexamples=false \
-Dqt=true -Dglfw=false -Dimgui=false
ninja -C build-qt-only/ \
visualization/libbalsaVisualization.so.p/src_qt_vulkan_film.cpp.o \
visualization/libbalsaVisualization.so.p/src_qt_vulkan_window.cpp.o \
visualization/tools/mesh_viewer_qt.p/mesh_viewer_qt.cpp.o

- name: Verify GLFW ImGui frontend
if: matrix.build_type == 'debug'
env:
CC: ccache ${{ matrix.platform.cc }}
CXX: ccache ${{ matrix.platform.cxx }}
run: |
meson setup build-glfw-imgui/ \
--buildtype=debug \
--wrap-mode=forcefallback \
-Dtesting=false -Dexamples=false \
-Dqt=false -Dglfw=true -Dimgui=true
ninja -C build-glfw-imgui/ \
visualization/libbalsaVisualization.so.p/src_glfw_vulkan_film.cpp.o \
visualization/libbalsaVisualization.so.p/src_glfw_vulkan_window.cpp.o \
visualization/libbalsaVisualization.so.p/src_vulkan_imgui_integration.cpp.o \
visualization/tools/mesh_viewer_glfw.p/mesh_viewer_glfw.cpp.o

- name: ccache stats
run: ccache -s

Expand Down
6 changes: 3 additions & 3 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ option('openvdb', type : 'boolean', value : false, description : 'Build openvdb
option('json', type : 'boolean', value : true, description : 'Use json')
option('protobuf', type : 'boolean', value : false, description : 'Use protobuf')
option('partio', type : 'boolean', value : false, description : 'Use partio')
option('imgui', type : 'boolean', value : true, description : 'Use imgui')
option('imgui', type : 'boolean', value : true, description : 'Build the ImGui UI frontend (currently requires GLFW)')
option('alembic', type : 'boolean', value : false, description : 'Use alembic')
option('perfetto', type : 'boolean', value : false, description : 'Use perfetto')

option('visualization', type : 'boolean', value : true, description : 'Build visualization library')
option('glfw', type : 'boolean', value : true, description : 'Use glfw')
option('qt', type : 'boolean', value : true, description : 'Use qt')
option('glfw', type : 'boolean', value : true, description : 'Build the GLFW window backend')
option('qt', type : 'boolean', value : true, description : 'Build the Qt window and widget frontend')
3 changes: 3 additions & 0 deletions subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*/
!patches/
!packagefiles/
!packagefiles/colormap_shaders/
!packagefiles/colormap_shaders/meson.build

# Auto-generated wrap-redirects from transitive deps
lua.wrap
Expand Down
1 change: 1 addition & 0 deletions subprojects/colormap_shaders.wrap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[wrap-git]
url = https://github.com/mtao/colormap-shaders.git
revision = 142a208adf287335d53d368aa5dea6ec708a8aef
patch_directory = colormap_shaders

[provide]
colormap_shaders = colormap_shaders_dep
9 changes: 9 additions & 0 deletions subprojects/packagefiles/colormap_shaders/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project('colormap_shaders', 'cpp', version: '0.0')

colormap_shader_dir = meson.current_source_dir() / 'shaders' / 'glsl'
colormap_shaders_dep = declare_dependency(
include_directories: include_directories('include'),
variables: {'shader_dir': colormap_shader_dir},
)

meson.override_dependency('colormap_shaders', colormap_shaders_dep)
19 changes: 15 additions & 4 deletions visualization/examples/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@

test_example_scene_dep = static_library('vulkan_scene', 'vulkan_scene.cpp', dependencies: [visualization_dep])
executable('vulkan_window', 'vulkan_window.cpp', 'vulkan_scene.cpp', dependencies: [visualization_dep])
#executable('test_vulkan_window', 'test_vulkan_window.cpp', 'example_vulkan_scene.cpp', dependencies: [visualization_dep])
executable('vulkan_window_glfw', 'vulkan_window_glfw.cpp', dependencies: [visualization_dep], link_with: [test_example_scene_dep])
# The existing example scene includes an ImGui overlay, so only build it for
# the GLFW + ImGui frontend. Qt-only examples should not acquire ImGui.
if get_option('glfw') and get_option('imgui')
test_example_scene_dep = static_library(
'vulkan_scene',
'vulkan_scene.cpp',
dependencies: [visualization_dep],
)
executable(
'vulkan_window_glfw',
'vulkan_window_glfw.cpp',
dependencies: [visualization_dep],
link_with: [test_example_scene_dep],
)
endif
13 changes: 9 additions & 4 deletions visualization/examples/vulkan_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#else
#include <spdlog/spdlog.h>
#include <balsa/visualization/shaders/flat.hpp>
#include <balsa/visualization/shaders/embedded_sources.hpp>
#include "vulkan_scene.hpp"
#include <imgui.h>
#pragma GCC diagnostic push
Expand All @@ -20,13 +21,17 @@ class TriangleShader : public Shader<ET> {

template<scene_graph::concepts::embedding_traits ET>
std::vector<uint32_t> TriangleShader<ET>::vert_spirv() const {
const static std::string fname = ":/glsl/triangle.vert";
return AbstractShader::compile_glsl_from_path(fname, AbstractShader::ShaderType::Vertex);
const auto source = builtin_shader_library().find("examples/triangle/vertex");
return AbstractShader::compile_glsl(
source ? std::string_view{*source} : std::string_view{},
AbstractShader::ShaderType::Vertex);
}
template<scene_graph::concepts::embedding_traits ET>
std::vector<uint32_t> TriangleShader<ET>::frag_spirv() const {
const static std::string fname = ":/glsl/triangle.frag";
return AbstractShader::compile_glsl_from_path(fname, AbstractShader::ShaderType::Fragment);
const auto source = builtin_shader_library().find("examples/triangle/fragment");
return AbstractShader::compile_glsl(
source ? std::string_view{*source} : std::string_view{},
AbstractShader::ShaderType::Fragment);
}
}// namespace balsa::visualization::shaders

Expand Down
142 changes: 8 additions & 134 deletions visualization/include/balsa/visualization/colormap_list.hpp
Original file line number Diff line number Diff line change
@@ -1,143 +1,17 @@
#if !defined(BALSA_VISUALIZATION_COLORMAP_LIST_HPP)
#define BALSA_VISUALIZATION_COLORMAP_LIST_HPP
#pragma once

#include <cstddef>
#include <string>
#include "balsa/visualization/shaders/embedded_sources.hpp"

namespace balsa::visualization {

// ── Colormap names ──────────────────────────────────────────────────
//
// Canonical list of available colormaps from the colormap_shaders
// subproject. Shared by both ImGui and Qt UI panels so the list
// stays in sync. Each name corresponds to a Qt resource alias
// at ":/colormap-shaders/<name>.frag".

inline constexpr const char *k_colormap_names[] = {
// MATLAB family
"MATLAB_jet",
"MATLAB_parula",
"MATLAB_hot",
"MATLAB_cool",
"MATLAB_spring",
"MATLAB_summer",
"MATLAB_autumn",
"MATLAB_winter",
"MATLAB_bone",
"MATLAB_copper",
"MATLAB_pink",
"MATLAB_hsv",
// transform family
"transform_rainbow",
"transform_seismic",
"transform_hot_metal",
"transform_grayscale_banded",
"transform_space",
"transform_supernova",
"transform_ether",
"transform_malachite",
"transform_morning_glory",
"transform_peanut_butter_and_jerry",
"transform_purple_haze",
"transform_rose",
"transform_saturn",
"transform_lava_waves",
"transform_apricot",
"transform_carnation",
// IDL ColorBrewer (sequential / diverging)
"IDL_CB-Blues",
"IDL_CB-Greens",
"IDL_CB-Greys",
"IDL_CB-Oranges",
"IDL_CB-Purples",
"IDL_CB-Reds",
"IDL_CB-BuGn",
"IDL_CB-BuPu",
"IDL_CB-GnBu",
"IDL_CB-OrRd",
"IDL_CB-PuBu",
"IDL_CB-PuBuGn",
"IDL_CB-PuOr",
"IDL_CB-PuRd",
"IDL_CB-RdBu",
"IDL_CB-RdGy",
"IDL_CB-RdPu",
"IDL_CB-RdYiBu",
"IDL_CB-RdYiGn",
"IDL_CB-BrBG",
"IDL_CB-PiYG",
"IDL_CB-PRGn",
"IDL_CB-Spectral",
"IDL_CB-YIGn",
"IDL_CB-YIGnBu",
"IDL_CB-YIOrBr",
// IDL ColorBrewer (qualitative)
"IDL_CB-Accent",
"IDL_CB-Dark2",
"IDL_CB-Paired",
"IDL_CB-Pastel1",
"IDL_CB-Pastel2",
"IDL_CB-Set1",
"IDL_CB-Set2",
"IDL_CB-Set3",
// IDL classic
"IDL_Rainbow",
"IDL_Rainbow_2",
"IDL_Rainbow_18",
"IDL_Rainbow+Black",
"IDL_Rainbow+White",
"IDL_Blue-Red",
"IDL_Blue-Red_2",
"IDL_Blue-White_Linear",
"IDL_Blue-Green-Red-Yellow",
"IDL_Blue-Pastel-Red",
"IDL_Blue_Waves",
"IDL_Green-Pink",
"IDL_Green-Red-Blue-White",
"IDL_Green-White_Exponential",
"IDL_Green-White_Linear",
"IDL_Red-Purple",
"IDL_Red_Temperature",
"IDL_Black-White_Linear",
"IDL_16_Level",
"IDL_Beach",
"IDL_Eos_A",
"IDL_Eos_B",
"IDL_Hardcandy",
"IDL_Haze",
"IDL_Hue_Sat_Lightness_1",
"IDL_Hue_Sat_Lightness_2",
"IDL_Hue_Sat_Value_1",
"IDL_Hue_Sat_Value_2",
"IDL_Mac_Style",
"IDL_Nature",
"IDL_Ocean",
"IDL_Pastels",
"IDL_Peppermint",
"IDL_Plasma",
"IDL_Prism",
"IDL_Purple-Red+Stripes",
"IDL_Standard_Gamma-II",
"IDL_Steps",
"IDL_Stern_Special",
"IDL_Volcano",
"IDL_Waves",
// Other
"gnuplot",
"kbinani_altitude",
};

inline constexpr int k_colormap_count = static_cast<int>(
sizeof(k_colormap_names) / sizeof(k_colormap_names[0]));

// Find the index of a colormap name, or -1 if not found.
inline int find_colormap_index(const std::string &name) {
for (int i = 0; i < k_colormap_count; ++i) {
if (name == k_colormap_names[i]) return i;
inline auto find_colormap_index(std::string_view name) -> int {
const auto names = shaders::colormap_names();
for (std::size_t i = 0; i < names.size(); ++i) {
if (name == names[i]) {
return static_cast<int>(i);
}
}
return -1;
}

}// namespace balsa::visualization

#endif
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
#if !defined(BALSA_VISUALIZATION_SHADERS_ABSTRACT_SHADER_HPP)
#define BALSA_VISUALIZATION_SHADERS_ABSTRACT_SHADER_HPP

#include <memory>
#include <limits>
#include <string>
#include <cstdint>
#include <string_view>
#include <vector>
// Camera is not needed by AbstractShader.

namespace shaderc {
class CompileOptions;
}

// calls qrc which can't be used in a namespace
void balsa_visualization_shaders_initialize_resources();

namespace balsa::visualization::shaders {

class AbstractShader {
Expand All @@ -23,18 +19,14 @@ class AbstractShader {
Fragment

};
AbstractShader();
std::vector<uint32_t> compile_glsl(const std::string &glsl, ShaderType) const;
// supports qresource so can't use filesystem path
std::vector<uint32_t> compile_glsl_from_path(const std::string &path, ShaderType) const;
AbstractShader() = default;
auto compile_glsl(std::string_view glsl, ShaderType type) const -> std::vector<uint32_t>;


virtual void add_compile_options(shaderc::CompileOptions &) const {}
virtual ~AbstractShader() {}
virtual ~AbstractShader() = default;
virtual std::vector<uint32_t> vert_spirv() const { return {}; }
virtual std::vector<uint32_t> frag_spirv() const { return {}; }

static std::string read_path_to_string(const std::string &path);
};
}// namespace balsa::visualization::shaders
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "balsa/visualization/shaders/shader_library.hpp"

#include <optional>
#include <span>
#include <string_view>

namespace balsa::visualization::shaders {

auto colormap_shader_source(std::string_view name) -> std::optional<std::string_view>;
auto colormap_names() -> std::span<const std::string_view>;

}// namespace balsa::visualization::shaders
11 changes: 7 additions & 4 deletions visualization/include/balsa/visualization/shaders/flat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <limits>
#include <vulkan/vulkan_core.h>
#include "balsa/scene_graph/embedding_traits.hpp"
#include "balsa/visualization/shaders/embedded_sources.hpp"
#include "balsa/visualization/shaders/shader.hpp"

namespace balsa::visualization::shaders {
Expand All @@ -19,13 +20,15 @@ class FlatShader : public Shader<ET> {

template<scene_graph::concepts::embedding_traits ET>
std::vector<uint32_t> FlatShader<ET>::vert_spirv() const {
const static std::string fname = ":/glsl/flat.vert";
return AbstractShader::compile_glsl_from_path(fname, AbstractShader::ShaderType::Vertex);
const auto source = builtin_shader_library().find("flat/vertex");
return AbstractShader::compile_glsl(
source ? std::string_view{*source} : std::string_view{}, AbstractShader::ShaderType::Vertex);
}
template<scene_graph::concepts::embedding_traits ET>
std::vector<uint32_t> FlatShader<ET>::frag_spirv() const {
const static std::string fname = ":/glsl/flat.frag";
return AbstractShader::compile_glsl_from_path(fname, AbstractShader::ShaderType::Fragment);
const auto source = builtin_shader_library().find("flat/fragment");
return AbstractShader::compile_glsl(
source ? std::string_view{*source} : std::string_view{}, AbstractShader::ShaderType::Fragment);
}
}// namespace balsa::visualization::shaders
#endif
Loading