September 09

I'm happy to announce that I've managed to generate OpenGL compute shaders from the OpenCL compilation pipeline. Through the use of the means that we can generate GLSL, HLSL and MSL source

The setup and compilation steps is very janky at the moment but does produce legit looking GLSL/HLSL. I say looks, because I lack the means to run it at the moment. This will hopefully become less janky in the future.

To produce a compute shader source you will need:
ldc built with as with the regular means of producing OpenCL SPIR-V, with applied to convert the OpenCL SPIR-V to OpenGL compute SPIR-V and to convert the resulting GL compute SPIR-V to HLSL/MSL if desired.

The full compilation steps are then (I did say it was janky):

ldc2 --mdcompute-targets=ocl-200 -m32 ./kernel.d other_files.d -Iother_imports
llvm-spirv -r kernels_ocl200_32.spv
llvm-dis kernels_ocl200_32.bc
clspv -x=ir kernels_ocl200_32.ll
# and optionally
spirv-cross --hlsl a.spv --output a.hlsl

32-bit mode for ldc is required because only 32-bit OpenCL SPIR-V can be converted into OpenGL compute SPIR-V. If -m32 doesn't work the you may have to supply an equivalent -mtriple