Skip to content

Commit 976ea19

Browse files
committed
imiv: multi-backend CMake refactor
Refactor imiv CMake to support multiple renderer backends (Vulkan/Metal/OpenGL) enabled independently. Introduces OIIO_IMIV_DEFAULT_RENDERER (replacing deprecated OIIO_IMIV_RENDERER) and OIIO_IMIV_ENABLE_VULKAN/ENABLE_METAL/ENABLE_OPENGL (AUTO/ON/OFF) options, generates imiv_build_config.h, and sets IMIV_WITH_* compile defines. Improves Vulkan and glslang discovery (including explicit Vulkan SDK handling and MSVC CRT compatibility), conditionally enables backend-specific ImGui sources, and selects a sensible default backend when multiple backends are available. Adds imiv_backend.cpp/h and supporting docs/tools, a CTest option OIIO_IMIV_ADD_BACKEND_VERIFY_CTEST to run per-backend verification tests, and updates various regression test invocations to pass backend arguments and rename selection test to ux_actions_regression.
1 parent 1f68951 commit 976ea19

52 files changed

Lines changed: 4468 additions & 1188 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/imiv/CMakeLists.txt

Lines changed: 515 additions & 296 deletions
Large diffs are not rendered by default.

src/imiv/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# imiv Verification
2+
3+
Canonical cross-platform verifier:
4+
5+
```bash
6+
python src/imiv/tools/imiv_backend_verify.py ...
7+
```
8+
9+
Use the same runner everywhere. It selects the right regression set for the
10+
requested backend.
11+
12+
Linux / WSL Vulkan:
13+
14+
```bash
15+
python src/imiv/tools/imiv_backend_verify.py \
16+
--backend vulkan \
17+
--build-dir build_u \
18+
--out-dir verify_vulkan \
19+
--trace
20+
```
21+
22+
Linux / WSL OpenGL:
23+
24+
```bash
25+
python src/imiv/tools/imiv_backend_verify.py \
26+
--backend opengl \
27+
--build-dir build_u \
28+
--out-dir verify_opengl \
29+
--trace
30+
```
31+
32+
macOS Metal:
33+
34+
```bash
35+
python3 src/imiv/tools/imiv_backend_verify.py \
36+
--backend metal \
37+
--build-dir build \
38+
--out-dir verify_metal \
39+
--trace
40+
```
41+
42+
macOS OpenGL:
43+
44+
```bash
45+
python3 src/imiv/tools/imiv_backend_verify.py \
46+
--backend opengl \
47+
--build-dir build \
48+
--out-dir verify_opengl \
49+
--trace
50+
```
51+
52+
macOS Vulkan, if MoltenVK is available:
53+
54+
```bash
55+
python3 src/imiv/tools/imiv_backend_verify.py \
56+
--backend vulkan \
57+
--build-dir build \
58+
--out-dir verify_vulkan \
59+
--trace
60+
```
61+
62+
Windows Vulkan:
63+
64+
```bat
65+
python src\imiv\tools\imiv_backend_verify.py ^
66+
--backend vulkan ^
67+
--build-dir build ^
68+
--config Debug ^
69+
--out-dir verify_vulkan ^
70+
--trace
71+
```
72+
73+
Windows OpenGL:
74+
75+
```bat
76+
python src\imiv\tools\imiv_backend_verify.py ^
77+
--backend opengl ^
78+
--build-dir build ^
79+
--config Debug ^
80+
--out-dir verify_opengl ^
81+
--trace
82+
```
83+
84+
If the build is already up to date, add:
85+
86+
```text
87+
--skip-configure --skip-build
88+
```
89+
90+
If you run through `uv` from the repo root, use:
91+
92+
```bash
93+
uv run --no-project python src/imiv/tools/imiv_backend_verify.py ...
94+
```
95+
96+
Optional backend-wide `ctest` entries from one multi-backend build:
97+
98+
```bash
99+
cmake -S . -B build_u \
100+
-D OIIO_IMIV_ENABLE_VULKAN=AUTO \
101+
-D OIIO_IMIV_ENABLE_OPENGL=AUTO \
102+
-D OIIO_IMIV_ENABLE_METAL=OFF \
103+
-D OIIO_IMIV_DEFAULT_RENDERER=vulkan \
104+
-D OIIO_IMIV_ADD_BACKEND_VERIFY_CTEST=ON
105+
```
106+
107+
```bash
108+
ctest --test-dir build_u -N | rg imiv_backend_verify
109+
```
110+
111+
Main output logs:
112+
113+
- `verify_smoke.log`
114+
- `verify_ux.log`
115+
- `verify_screenshot.log`
116+
- `verify_sampling.log`
117+
- `verify_orientation.log`
118+
- `verify_ocio_missing.log`
119+
- `verify_ocio_config_source.log`
120+
- `verify_ocio_live.log`
121+
- `verify_ocio_live_display.log`

src/imiv/imiv_actions.cpp

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,17 @@ env_flag_is_truthy(const char* name)
168168
bool
169169
viewer_texture_has_gpu_lifetime(const RendererTexture& texture)
170170
{
171-
#if defined(IMIV_BACKEND_VULKAN_GLFW)
172-
return texture.image != VK_NULL_HANDLE
173-
|| texture.source_image != VK_NULL_HANDLE
174-
|| texture.set != VK_NULL_HANDLE
175-
|| texture.nearest_mag_set != VK_NULL_HANDLE
176-
|| texture.pixelview_set != VK_NULL_HANDLE
177-
|| texture.upload_submit_pending || texture.preview_submit_pending;
178-
#else
179-
(void)texture;
180-
return false;
181-
#endif
171+
return texture.backend != nullptr;
182172
}
183173

184174
void
185175
quiesce_viewer_texture_lifetime(RendererState& renderer_state,
186176
const RendererTexture& texture)
187177
{
188-
#if defined(IMIV_BACKEND_VULKAN_GLFW)
189-
if (renderer_state.device == VK_NULL_HANDLE
190-
|| !viewer_texture_has_gpu_lifetime(texture)) {
178+
if (!viewer_texture_has_gpu_lifetime(texture))
191179
return;
192-
}
193-
VkResult err = vkDeviceWaitIdle(renderer_state.device);
194-
check_vk_result(err);
195-
#else
196-
(void)renderer_state;
197-
(void)texture;
198-
#endif
180+
std::string error_message;
181+
renderer_wait_idle(renderer_state, error_message);
199182
}
200183

201184
bool
@@ -677,9 +660,7 @@ close_current_image_action(RendererState& vk_state, ViewerState& viewer,
677660
{
678661
const std::string closing_path = viewer.image.path;
679662
const int closing_index = viewer.current_path_index;
680-
#if defined(IMIV_BACKEND_VULKAN_GLFW)
681663
quiesce_viewer_texture_lifetime(vk_state, viewer.texture);
682-
#endif
683664
renderer_destroy_texture(vk_state, viewer.texture);
684665
remove_loaded_image_path(viewer, closing_path);
685666
if (!viewer.loaded_image_paths.empty()) {
@@ -847,10 +828,6 @@ capture_main_viewport_screenshot_action(RendererState& vk_state,
847828

848829
int width = std::max(0, vk_state.framebuffer_width);
849830
int height = std::max(0, vk_state.framebuffer_height);
850-
#if defined(IMIV_BACKEND_VULKAN_GLFW)
851-
width = std::max(width, vk_state.window_data.Width);
852-
height = std::max(height, vk_state.window_data.Height);
853-
#endif
854831
if (width <= 0 || height <= 0) {
855832
viewer.last_error = "screenshot failed: main viewport size is invalid";
856833
return false;

0 commit comments

Comments
 (0)