Skip to content

Commit 2f391ee

Browse files
committed
Add probe state and refactor Vulkan cleanup
Include pixel probe info in test state output and make Vulkan resource management more robust. - imiv_developer_tools.cpp: Write probe fields (probe_valid, probe_pos, probe_channel_count) into the test-engine JSON output so runner tests can inspect probe state. - imiv_image_view.cpp: Use env_read_int_value to fetch forced probe coordinates and simplify validation logic. - imiv_vulkan_setup.cpp: Factor repeated destroy logic into small helper functions (shader module, pipeline, pipeline layout, descriptor set layout, descriptor pool, render pass) and use them across cleanup paths; change init_* functions to build resources in a linear, transactional manner (do-break cleanup) so partial failures clean up correctly; ensure shader modules are destroyed on failure and centralize descriptor pool destruction. - tools/imiv_area_probe_closeup_regression.py: Add _run_runner helper and a two-step test flow: run a pixel-closeup probe to capture probe state JSON (validate probe_valid and probe_pos), then run the area-probe closeup runner. Also add probe_state_path and related checks. These changes improve testability of the pixel probe feature and harden Vulkan resource lifecycle handling to avoid leaks on error paths. Signed-off-by: Vlad <shaamaan@gmail.com>
1 parent b351a0e commit 2f391ee

4 files changed

Lines changed: 252 additions & 171 deletions

File tree

src/imiv/imiv_developer_tools.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,13 @@ write_test_engine_viewer_state_json(const std::filesystem::path& out_path,
636636
test_engine_json_write_vec2(f, viewport_size);
637637
std::fputs(",\n \"orientation\": ", f);
638638
std::fprintf(f, "%d", viewer.image.orientation);
639+
std::fputs(",\n \"probe_valid\": ", f);
640+
std::fputs(viewer.probe_valid ? "true" : "false", f);
641+
std::fputs(",\n \"probe_pos\": [", f);
642+
std::fprintf(f, "%d,%d", viewer.probe_x, viewer.probe_y);
643+
std::fputs("]", f);
644+
std::fputs(",\n \"probe_channel_count\": ", f);
645+
std::fprintf(f, "%zu", viewer.probe_channels.size());
639646
std::fputs(",\n \"area_probe_lines\": [", f);
640647
for (size_t i = 0; i < viewer.area_probe_lines.size(); ++i) {
641648
if (i > 0)

src/imiv/imiv_image_view.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ namespace {
2626

2727
bool apply_forced_probe_from_env(ViewerState& viewer)
2828
{
29-
const int forced_x
30-
= env_int_value_clamped("IMIV_IMGUI_TEST_ENGINE_PROBE_X", -1, 0,
31-
1000000);
32-
const int forced_y
33-
= env_int_value_clamped("IMIV_IMGUI_TEST_ENGINE_PROBE_Y", -1, 0,
34-
1000000);
35-
if (forced_x < 0 || forced_y < 0 || viewer.image.path.empty())
29+
int forced_x = -1;
30+
int forced_y = -1;
31+
if (!env_read_int_value("IMIV_IMGUI_TEST_ENGINE_PROBE_X", forced_x)
32+
|| !env_read_int_value("IMIV_IMGUI_TEST_ENGINE_PROBE_Y", forced_y)
33+
|| forced_x < 0 || forced_y < 0 || viewer.image.path.empty()) {
3634
return false;
35+
}
3736

3837
const int px = std::clamp(forced_x, 0,
3938
std::max(0, viewer.image.width - 1));

0 commit comments

Comments
 (0)