Skip to content

Commit 7fce7e0

Browse files
committed
Add OpenGL OCIO GLSL support and tests
Implement OpenGL-specific OCIO runtime/preview/path and test support. Refactor OCIO shader runtime to support targets (Vulkan vs OpenGL), add ensure_ocio_shader_runtime_glsl and preflight_ocio_runtime_shader_glsl, and select the correct shader language for each target. Implement OpenGL OCIO preview pipeline in imiv_renderer_opengl.cpp (shader build, texture upload, uniforms, program lifecycle, drawing, and cleanup), wire renderer-specific preflight and cleanup in imiv_app.cpp, and add OpenGL-specific regression tests and a smoke regression script. Update CMake to conditionally register Vulkan or OpenGL test variants and add documentation for backend coverage (imiv_backends.md).
1 parent 9eb186c commit 7fce7e0

7 files changed

Lines changed: 1342 additions & 124 deletions

File tree

src/imiv/CMakeLists.txt

Lines changed: 98 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -836,59 +836,117 @@ if (TARGET imiv
836836
AND BUILD_TESTING
837837
AND Python3_EXECUTABLE
838838
AND _imiv_test_engine_sources
839-
AND _imiv_has_runtime_glslang
840839
AND EXISTS "${_imiv_ocio_live_update_config}")
841-
add_test (
842-
NAME imiv_ocio_live_update_regression
843-
COMMAND
844-
"${Python3_EXECUTABLE}"
845-
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
846-
--bin "$<TARGET_FILE:imiv>"
847-
--cwd "$<TARGET_FILE_DIR:imiv>"
848-
--oiiotool "$<TARGET_FILE:oiiotool>"
849-
--idiff "$<TARGET_FILE:idiff>"
850-
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
851-
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_update_regression"
852-
--image "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_update_regression/ocio_live_input.exr"
853-
--ocio-config "${_imiv_ocio_live_update_config}")
854-
set_tests_properties (
855-
imiv_ocio_live_update_regression PROPERTIES
856-
LABELS "imiv;imiv_ocio;gui"
857-
TIMEOUT 300)
840+
if (_imiv_renderer_is_vulkan AND _imiv_has_runtime_glslang)
841+
add_test (
842+
NAME imiv_ocio_live_update_regression
843+
COMMAND
844+
"${Python3_EXECUTABLE}"
845+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
846+
--bin "$<TARGET_FILE:imiv>"
847+
--cwd "$<TARGET_FILE_DIR:imiv>"
848+
--oiiotool "$<TARGET_FILE:oiiotool>"
849+
--idiff "$<TARGET_FILE:idiff>"
850+
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
851+
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_update_regression"
852+
--image "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_update_regression/ocio_live_input.exr"
853+
--ocio-config "${_imiv_ocio_live_update_config}")
854+
set_tests_properties (
855+
imiv_ocio_live_update_regression PROPERTIES
856+
LABELS "imiv;imiv_ocio;gui"
857+
TIMEOUT 300)
858858

859-
add_test (
860-
NAME imiv_ocio_live_display_update_regression
861-
COMMAND
862-
"${Python3_EXECUTABLE}"
863-
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
864-
--bin "$<TARGET_FILE:imiv>"
865-
--cwd "$<TARGET_FILE_DIR:imiv>"
866-
--oiiotool "$<TARGET_FILE:oiiotool>"
867-
--idiff "$<TARGET_FILE:idiff>"
868-
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
869-
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_display_update_regression"
870-
--image "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_display_update_regression/ocio_live_input.exr"
871-
--ocio-config "${_imiv_ocio_live_update_config}"
872-
--display "sRGB - Display"
873-
--target-display "Display P3 - Display"
874-
--raw-view "Un-tone-mapped"
875-
--target-view "Un-tone-mapped")
876-
set_tests_properties (
877-
imiv_ocio_live_display_update_regression PROPERTIES
878-
LABELS "imiv;imiv_ocio;gui"
879-
TIMEOUT 300)
859+
add_test (
860+
NAME imiv_ocio_live_display_update_regression
861+
COMMAND
862+
"${Python3_EXECUTABLE}"
863+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
864+
--bin "$<TARGET_FILE:imiv>"
865+
--cwd "$<TARGET_FILE_DIR:imiv>"
866+
--oiiotool "$<TARGET_FILE:oiiotool>"
867+
--idiff "$<TARGET_FILE:idiff>"
868+
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
869+
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_display_update_regression"
870+
--image "${CMAKE_BINARY_DIR}/imiv_captures/ocio_live_display_update_regression/ocio_live_input.exr"
871+
--ocio-config "${_imiv_ocio_live_update_config}"
872+
--display "sRGB - Display"
873+
--target-display "Display P3 - Display"
874+
--raw-view "Un-tone-mapped"
875+
--target-view "Un-tone-mapped")
876+
set_tests_properties (
877+
imiv_ocio_live_display_update_regression PROPERTIES
878+
LABELS "imiv;imiv_ocio;gui"
879+
TIMEOUT 300)
880+
elseif (_imiv_renderer_is_opengl)
881+
add_test (
882+
NAME imiv_opengl_ocio_live_update_regression
883+
COMMAND
884+
"${Python3_EXECUTABLE}"
885+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
886+
--bin "$<TARGET_FILE:imiv>"
887+
--cwd "$<TARGET_FILE_DIR:imiv>"
888+
--oiiotool "$<TARGET_FILE:oiiotool>"
889+
--idiff "$<TARGET_FILE:idiff>"
890+
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
891+
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/opengl_ocio_live_update_regression"
892+
--image "${CMAKE_BINARY_DIR}/imiv_captures/opengl_ocio_live_update_regression/ocio_live_input.exr"
893+
--ocio-config "${_imiv_ocio_live_update_config}")
894+
set_tests_properties (
895+
imiv_opengl_ocio_live_update_regression PROPERTIES
896+
LABELS "imiv;imiv_ocio;imiv_opengl;gui"
897+
TIMEOUT 300)
898+
899+
add_test (
900+
NAME imiv_opengl_ocio_live_display_update_regression
901+
COMMAND
902+
"${Python3_EXECUTABLE}"
903+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_ocio_live_update_regression.py"
904+
--bin "$<TARGET_FILE:imiv>"
905+
--cwd "$<TARGET_FILE_DIR:imiv>"
906+
--oiiotool "$<TARGET_FILE:oiiotool>"
907+
--idiff "$<TARGET_FILE:idiff>"
908+
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
909+
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/opengl_ocio_live_display_update_regression"
910+
--image "${CMAKE_BINARY_DIR}/imiv_captures/opengl_ocio_live_display_update_regression/ocio_live_input.exr"
911+
--ocio-config "${_imiv_ocio_live_update_config}"
912+
--display "sRGB - Display"
913+
--target-display "Display P3 - Display"
914+
--raw-view "Un-tone-mapped"
915+
--target-view "Un-tone-mapped")
916+
set_tests_properties (
917+
imiv_opengl_ocio_live_display_update_regression PROPERTIES
918+
LABELS "imiv;imiv_ocio;imiv_opengl;gui"
919+
TIMEOUT 300)
920+
endif ()
880921
elseif (TARGET imiv
881922
AND OIIO_BUILD_TESTS
882923
AND BUILD_TESTING)
883924
message (STATUS
884-
"imiv: live OCIO update regression test not added (requires Python3, ImGui Test Engine, runtime glslang, and temp OCIO config)")
925+
"imiv: live OCIO update regression test not added (requires Python3, ImGui Test Engine, temp OCIO config, and either Vulkan runtime glslang or the OpenGL renderer)")
885926
endif ()
886927

887928
if (TARGET imiv
888929
AND OIIO_BUILD_TESTS
889930
AND BUILD_TESTING
890931
AND Python3_EXECUTABLE
891932
AND _imiv_test_engine_sources)
933+
if (_imiv_renderer_is_opengl)
934+
add_test (
935+
NAME imiv_opengl_smoke_regression
936+
COMMAND
937+
"${Python3_EXECUTABLE}"
938+
"${CMAKE_CURRENT_SOURCE_DIR}/tools/imiv_opengl_smoke_regression.py"
939+
--bin "$<TARGET_FILE:imiv>"
940+
--cwd "$<TARGET_FILE_DIR:imiv>"
941+
--env-script "${CMAKE_BINARY_DIR}/imiv_env.sh"
942+
--out-dir "${CMAKE_BINARY_DIR}/imiv_captures/opengl_smoke_regression"
943+
--open "${PROJECT_SOURCE_DIR}/ASWF/logos/openimageio-stacked-gradient.png")
944+
set_tests_properties (
945+
imiv_opengl_smoke_regression PROPERTIES
946+
LABELS "imiv;imiv_opengl;gui"
947+
TIMEOUT 180)
948+
endif ()
949+
892950
if (EXISTS "${_imiv_ocio_live_update_config}")
893951
add_test (
894952
NAME imiv_ocio_config_source_regression

src/imiv/imiv_app.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,20 @@ run(const AppConfig& config)
424424
clamp_placeholder_ui_state(ui_state);
425425
if (ui_state.use_ocio) {
426426
std::string ocio_preflight_error;
427-
if (!preflight_ocio_runtime_shader(ui_state, nullptr,
428-
ocio_preflight_error)) {
427+
#if defined(IMIV_BACKEND_VULKAN_GLFW)
428+
const bool ocio_preflight_ok
429+
= preflight_ocio_runtime_shader(ui_state, nullptr,
430+
ocio_preflight_error);
431+
#elif defined(IMIV_BACKEND_OPENGL_GLFW)
432+
const bool ocio_preflight_ok
433+
= preflight_ocio_runtime_shader_glsl(ui_state, nullptr,
434+
ocio_preflight_error);
435+
#else
436+
ocio_preflight_error
437+
= "OCIO preview is not implemented on this renderer";
438+
const bool ocio_preflight_ok = false;
439+
#endif
440+
if (!ocio_preflight_ok) {
429441
ui_state.use_ocio = false;
430442
if (verbose_logging) {
431443
print("imiv: OCIO preflight unavailable, using standard "
@@ -605,6 +617,10 @@ run(const AppConfig& config)
605617
#if defined(IMIV_BACKEND_VULKAN_GLFW) || defined(IMIV_BACKEND_METAL_GLFW) \
606618
|| defined(IMIV_BACKEND_OPENGL_GLFW)
607619
uninstall_drag_drop(window);
620+
#endif
621+
#if defined(IMIV_BACKEND_OPENGL_GLFW)
622+
renderer_cleanup_window(renderer_state);
623+
renderer_cleanup(renderer_state);
608624
#endif
609625
renderer_imgui_shutdown();
610626
platform_glfw_imgui_shutdown();
@@ -613,8 +629,10 @@ run(const AppConfig& config)
613629
test_engine_destroy(test_engine_runtime);
614630
#endif
615631

632+
#if !defined(IMIV_BACKEND_OPENGL_GLFW)
616633
renderer_cleanup_window(renderer_state);
617634
renderer_cleanup(renderer_state);
635+
#endif
618636
platform_glfw_destroy_window(window);
619637
platform_glfw_terminate();
620638
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)