VulkanCompute - run GPU compute shaders on your waves
Hi all,
I'd like to share an experimental XOP, VulkanCompute, that lets you run a GLSL compute shader on the GPU using Vulkan, with Igor waves as the GPU buffers and Igor scalars as push constants. It's handy when you have a heavy, highly parallel per-element calculation and want to offload it to the GPU.
A demo procedure and full help file are included in the attached zip.
What it does
- You write a small GLSL compute shader as an Igor string.
- Input/output waves are bound as
std430storage buffers (SSBOs):/INwaves first, then/OUTwaves, all in descriptor set 0. - Scalars are passed through a push-constant wave (
/PC), marshaled as floats. - Results are copied straight back into your output wave.
You don't need to be a GLSL expert. In practice the easiest way to get a shader is to start from one of the provided examples and tweak it, or to ask an AI assistant (ChatGPT, Claude, Copilot, etc.) to generate the GLSL for your calculation - just tell it the binding convention above (/IN waves at bindings 0..N-1, /OUT waves next, scalars in the push-constant block as floats). Paste the result into an Igor string and go.
Two operations
VulkanCompute- compile-and-run a GLSL shader on the GPU.VulkanCompileShader- precompile a shader once to a SPIR-V wave, then reuse it viaVulkanCompute /SPV=...to skip the per-call compile.
Quick example (waveC = varA*waveA*waveB + varB):
The demo .ipf goes further, with a compute-bound example (a per-element transcendental loop) that shows a real GPU speedup, plus a precompile-and-reuse example. To see it in action, just run one of these two functions from the command line:
DemoGPUvs1CoreAndMultiCoreCPU()- times the same heavy calculation on the GPU, on a single CPU core, and on all CPU cores viaMultiThread, and prints the timings side by side.DemoGPUPrecompiledVsMultiCoreCPU()- same comparison, but the shader is precompiled once withVulkanCompileShaderso the GPU timing reflects only the dispatch, not the one-time compile.
A word on performance: the GPU is not a magic "make it faster" button. For simple element-wise math (like the example above), MatrixOp/FastOp on the CPU are typically faster, because the calculation is memory-bandwidth bound and the cost is dominated by moving data to and from the GPU. VulkanCompute pays off when the per-element work is heavy (many operations per value) or when you run many kernels over resident data.
Requirements / installation
- Igor Pro 10 (64-bit), Windows only. This build targets Igor Pro 10 and is not available for macOS.
- A Vulkan-capable GPU driver (recent NVIDIA/AMD/Intel drivers already include the Vulkan runtime
vulkan-1.dll). No Vulkan SDK is needed. - Igor loads only XOPs whose file name ends in
64.xop, so the file must be named VulkanCompute64.xop. Put it (or a shortcut to it) in anIgor Extensions (64-bit)folder and relaunch Igor. Drop the.ihfhelp file next to it.
Notes / caveats
- Computation is fp32 by default. Double precision (
/DBL) works only if your GPU reports theshaderFloat64feature. - Waves named in
/INand/OUTare resolved in the current data folder. - This is an early, main-thread-only build for Igor Pro 10 on Windows - feedback welcome. It is Windows only; a macOS version (via MoltenVK) is not built.
Attached: VulkanCompute.xop, VulkanCompute.ihf, and VulkanCompute_Demo.ipf.
Give it a try and let me know what performance you see on your hardware.
AG