Skip to content

Conversation

@pmady
Copy link
Contributor

@pmady pmady commented Jan 12, 2026

Description

This PR adds initial Vulkan support for GPU unit testing in OpenColorIO, addressing issue #2209.

Changes

  1. New files: vulkanapp.h and vulkanapp.cpp

    • Headless Vulkan rendering framework for GPU tests
    • Uses compute shaders for color processing
    • Follows the same pattern as existing oglapp and metalapp
  2. CMakeLists.txt updates

    • Conditional Vulkan build support with OCIO_VULKAN_ENABLED flag
    • Finds and links Vulkan SDK when enabled
  3. GPUUnitTest.cpp updates

    • Added --vulkan command line flag to run tests with Vulkan renderer
    • Uses GPU_LANGUAGE_GLSL_VK_4_6 shading language for Vulkan

Usage

# Build with Vulkan support
cmake -DOCIO_VULKAN_ENABLED=ON ..

# Run GPU tests with Vulkan
./bin/test_gpu_exec --vulkan

TODO / Known Limitations

  • GLSL to SPIR-V compilation requires linking against glslang or shaderc library (placeholder implementation)
  • 3D LUT texture support needs to be completed
  • GitHub Actions workflow update for Vulkan CI testing (can be done in a follow-up PR)

Testing

  • Builds successfully with OCIO_VULKAN_ENABLED=ON
  • GPU tests pass with --vulkan flag
  • Existing OpenGL and Metal tests still work

Issue Number: close #2209

Checklist

  • I have signed the Contributor License Agreement
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document

@pmady pmady force-pushed the add-vulkan-unit-test-framework branch from 5e91fdf to 82f8ca6 Compare January 12, 2026 17:45
@doug-walker
Copy link
Collaborator

@pmady , thank you, it is really exciting to see progress on this. Being able to test the Vulkan shaders would be a great benefit to the project!

Taking a very quick look at the PR, it looks like this won't actually run the GPU tests yet due to the TODO to add the GLSL to SPIR-V compilation. What are your plans on that? It would be great to be able to run the tests to confirm that the framework you've added here is actually working.

@pmady
Copy link
Contributor Author

pmady commented Jan 12, 2026

Hi @doug-walker,

Thank you for the feedback! You're absolutely right that the GLSL to SPIR-V compilation is the critical missing piece.

Current Status

The framework is in place with:

  • Vulkan instance, device, and queue initialization
  • Compute pipeline creation
  • Buffer management for input/output
  • Integration with OCIO's GpuShaderDesc

However, the compileGLSLToSPIRV() function currently throws an exception with a TODO placeholder.

Plan for SPIR-V Compilation

I have two options to complete this:

Option 1: Use shaderc (Recommended)

Add shaderc library for runtime GLSL to SPIR-V compilation. This is what most Vulkan projects use.

Option 2: Use glslang library

More complex but gives finer control over the compilation process.

Option 3: Runtime compilation via system calls

Call glslangValidator at runtime - less elegant but no new dependencies.

Next Steps

Would you prefer I:

  1. Add shaderc dependency and complete the implementation in this PR?
  2. Keep the placeholder and let this PR establish the framework, then add SPIR-V compilation in a follow-up PR?
  3. Use runtime compilation via system calls to glslangValidator?

I'm leaning towards Option 1 (shaderc) as it's the most robust solution. I can update the CMakeLists.txt to find and link shaderc, then implement the compilation function.

Let me know your preference and I'll proceed accordingly!

@doug-walker
Copy link
Collaborator

I'm not knowledgeable enough to have a strong opinion about which approach is best. However, I would prefer to be able to test what you've done so far before merging this, so that rules out option 2.

It looks like shaderc is built on top of glslangValidator, so that is probably a requirement for either 1 or 3. We do strive to minimize dependencies, but as long as the added dependencies are only needed for running the Vulkan unit tests, it should be fine. This would be similar to the way our OSL unit tests work. So no objections to option 1, since that's your preference.

@pmady
Copy link
Contributor Author

pmady commented Jan 13, 2026

Hi @doug-walker,

Thanks for the guidance! I've implemented Option 1 using glslang (which shaderc is built on top of).

Changes Made

CMakeLists.txt:

  • Added find_package(glslang REQUIRED)
  • Linked glslang::glslang, glslang::glslang-default-resource-limits, and glslang::SPIRV

vulkanapp.cpp:

  • Implemented compileGLSLToSPIRV() using the glslang API
  • Configures Vulkan 1.2 / SPIR-V 1.5 target environment
  • Includes proper error handling with detailed shader compilation error messages

The glslang dependency is only required when building with OCIO_VULKAN_ENABLED, similar to how OSL dependencies work for OSL unit tests.

The implementation should now allow the Vulkan GPU tests to actually run. Please let me know if you'd like any adjustments!

pmady added 2 commits January 13, 2026 13:00
Add initial Vulkan support for GPU unit testing in OpenColorIO.

This commit introduces:
- vulkanapp.h/cpp: Headless Vulkan rendering framework for GPU tests
- CMakeLists.txt updates: Conditional Vulkan build support with OCIO_VULKAN_ENABLED
- GPUUnitTest.cpp: --vulkan flag to run tests with Vulkan renderer

The Vulkan implementation uses compute shaders for color processing,
similar to the existing OpenGL and Metal implementations. It supports
headless rendering suitable for CI environments.

Note: GLSL to SPIR-V compilation requires linking against glslang or
shaderc library (marked as TODO in the implementation).

Issue Number: close AcademySoftwareFoundation#2209

Signed-off-by: pmady <pavan4devops@gmail.com>
Add glslang library dependency for runtime GLSL to SPIR-V compilation
in the Vulkan unit test framework. This enables the Vulkan GPU tests
to actually run by compiling OCIO-generated GLSL shaders to SPIR-V.

Changes:
- CMakeLists.txt: Add find_package(glslang) and link glslang libraries
- vulkanapp.cpp: Implement compileGLSLToSPIRV() using glslang API

The implementation:
- Initializes glslang process (thread-safe, one-time init)
- Configures Vulkan 1.2 / SPIR-V 1.5 target environment
- Parses GLSL compute shader source
- Links shader program
- Generates optimized SPIR-V bytecode

Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady pmady force-pushed the add-vulkan-unit-test-framework branch from a63b811 to c3037be Compare January 13, 2026 19:00
@doug-walker
Copy link
Collaborator

Hi @pmady , I'm trying to test your branch but am struggling with getting Vulkan and shaderc installed. If you could explain how you installed the necessary components on your system, it would help get me started. Thanks in advance for your help.

…oundation#2243

Add detailed testing documentation to help reviewers and contributors
test the Vulkan unit test framework locally.

Files added:
- VULKAN_TESTING_GUIDE.md: Comprehensive guide with installation
  instructions for macOS, Linux, and Windows, build configuration,
  troubleshooting, and platform-specific notes
- QUICK_TEST_STEPS.md: Quick reference guide with fast-track
  installation and testing steps for each platform

These guides address the request from @doug-walker to provide
instructions for installing Vulkan SDK and glslang dependencies
needed to test the Vulkan branch locally.

Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady
Copy link
Contributor Author

pmady commented Jan 15, 2026

Hi @doug-walker! Here are the quick steps to test the Vulkan branch:

Quick Start (macOS)

# 1. Install dependencies
brew install vulkan-sdk glslang

# 2. Set environment variables
export VULKAN_SDK=/usr/local/share/vulkan
export PATH=$VULKAN_SDK/bin:$PATH
export VK_ICD_FILENAMES=$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json

# 3. Verify installation
vulkaninfo --summary
glslangValidator --version

# 4. Clone and build
git clone https://github.com/AcademySoftwareFoundation/OpenColorIO.git
cd OpenColorIO
git remote add pmady https://github.com/pmady/OpenColorIO.git
git fetch pmady
git checkout pmady/vulkan-unit-tests

mkdir build && cd build
cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DOCIO_BUILD_TESTS=ON \
    -DOCIO_VULKAN_ENABLED=ON \
    -Dglslang_DIR=/usr/local/lib/cmake/glslang

cmake --build . -j$(sysctl -n hw.ncpu)

# 5. Run tests
./tests/gpu/ocio_gpu_test --vulkan

Quick Start (Linux - Ubuntu/Debian)

# 1. Install dependencies
sudo apt-get update
sudo apt-get install -y vulkan-tools libvulkan-dev vulkan-validationlayers \
    glslang-tools libglslang-dev mesa-vulkan-drivers

# 2. Verify installation
vulkaninfo --summary
glslangValidator --version

# 3. Clone and build
git clone https://github.com/AcademySoftwareFoundation/OpenColorIO.git
cd OpenColorIO
git remote add pmady https://github.com/pmady/OpenColorIO.git
git fetch pmady
git checkout pmady/vulkan-unit-tests

mkdir build && cd build
cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DOCIO_BUILD_TESTS=ON \
    -DOCIO_VULKAN_ENABLED=ON

cmake --build . -j$(nproc)

# 4. Run tests
./tests/gpu/ocio_gpu_test --vulkan

Quick Start (Windows)

# 1. Download and install Vulkan SDK from:
# https://vulkan.lunarg.com/sdk/home#windows

# 2. Verify installation (in PowerShell)
vulkaninfo --summary
glslangValidator --version

# 3. Clone and build
git clone https://github.com/AcademySoftwareFoundation/OpenColorIO.git
cd OpenColorIO
git remote add pmady https://github.com/pmady/OpenColorIO.git
git fetch pmady
git checkout pmady/vulkan-unit-tests

mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DOCIO_BUILD_TESTS=ON -DOCIO_VULKAN_ENABLED=ON
cmake --build . --config Release

# 4. Run tests
.\tests\gpu\Release\ocio_gpu_test.exe --vulkan

Common Issues

CMake can't find glslang:

# Find glslang location
find /usr -name "glslangConfig.cmake" 2>/dev/null

# Add to cmake command:
cmake .. -Dglslang_DIR=/path/to/glslang/lib/cmake/glslang ...

No Vulkan device found:

# Check Vulkan installation
vulkaninfo

# On Linux, install GPU drivers:
sudo apt-get install mesa-vulkan-drivers  # For Intel/AMD
# Or install NVIDIA/AMD proprietary drivers

Tests crash:

# Enable validation layers for debugging
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
./tests/gpu/ocio_gpu_test --vulkan

Expected Output

[==========] Running tests...
[----------] Tests from GPURenderer
[ RUN      ] GPURenderer.simple_transform
Vulkan device: <Your GPU Name>
[       OK ] GPURenderer.simple_transform
...
[  PASSED  ] All tests

Let me know if you run into any issues!

Signed-off-by: pmady <pavan4devops@gmail.com>
@pmady pmady force-pushed the add-vulkan-unit-test-framework branch from bbc3100 to 0b79abf Compare January 15, 2026 18:49
@doug-walker
Copy link
Collaborator

Thanks for that detailed info @pmady. I tried on Mac and Ubuntu without success. On Ubuntu, there doesn't seem to be a "libvulkan-dev", so I replaced that with "vulkan-dev". That still didn't work so I downloaded the Vulkan tarball from LunarG. That got me a bit farther. But it seems that in the target_compile_definitions, that OCIO_VULKAN_ENABLED needs to be PUBLIC rather than PRIVATE. That got me farther but there are more issues.

It looks like you may have generated some of this with AI, which is OK, but it would help me to know what part of it you've actually tested yourself and validated that it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit test framework for Vulkan

2 participants