-
Notifications
You must be signed in to change notification settings - Fork 483
gpu: Add Vulkan unit test framework #2243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gpu: Add Vulkan unit test framework #2243
Conversation
5e91fdf to
82f8ca6
Compare
|
@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. |
|
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 StatusThe framework is in place with:
However, the Plan for SPIR-V CompilationI 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 libraryMore complex but gives finer control over the compilation process. Option 3: Runtime compilation via system callsCall Next StepsWould you prefer I:
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! |
|
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. |
|
Hi @doug-walker, Thanks for the guidance! I've implemented Option 1 using glslang (which shaderc is built on top of). Changes MadeCMakeLists.txt:
vulkanapp.cpp:
The glslang dependency is only required when building with The implementation should now allow the Vulkan GPU tests to actually run. Please let me know if you'd like any adjustments! |
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>
a63b811 to
c3037be
Compare
|
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>
|
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 --vulkanQuick 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 --vulkanQuick 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 --vulkanCommon IssuesCMake 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 driversTests crash: # Enable validation layers for debugging
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
./tests/gpu/ocio_gpu_test --vulkanExpected OutputLet me know if you run into any issues! |
Signed-off-by: pmady <pavan4devops@gmail.com>
bbc3100 to
0b79abf
Compare
|
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. |
Description
This PR adds initial Vulkan support for GPU unit testing in OpenColorIO, addressing issue #2209.
Changes
New files:
vulkanapp.handvulkanapp.cppoglappandmetalappCMakeLists.txt updates
OCIO_VULKAN_ENABLEDflagGPUUnitTest.cpp updates
--vulkancommand line flag to run tests with Vulkan rendererGPU_LANGUAGE_GLSL_VK_4_6shading language for VulkanUsage
TODO / Known Limitations
glslangorshaderclibrary (placeholder implementation)Testing
OCIO_VULKAN_ENABLED=ON--vulkanflagIssue Number: close #2209
Checklist