# Zig gpu kernel for macOS (via spirv)

> Source: <https://ziggit.dev/t/zig-gpu-kernel-for-macos-via-spirv/14458#post_7>
> Published: 2026-11-08 15:33:39+00:00

I finally got some time to look at this a bit more, [see here.](https://codeberg.org/Danielkonge/mac_gpu_example.zig) (LLM disclosure: I got lazy with comments and docstrings, and some of the setup was done with LLM help, since I didn’t want to really focus on writing a proper SHA256 implementation without slices that I could use. What I was interested in was just playing with mac GPU kernels in zig code.)

The build system stuff ended up all being pretty easy, and the main annoyance was actually that I couldn’t find a nice way to use slices in the kernel. When compiling directly for `amdgcn-amdhsa-none` or `nvptx64-cuda-none` you don’t run into this, but going through `spirv64-vulkan` it is a problem.

Overall I thought the setup worked pretty well, and if you only use `spirv-cross` to get `.metal` files and don’t compile them with `xcrun`, I guess everything should work well cross platform too.

[As an aside, I saw recently that `spirv-cross` was added to allyourcodebase, so the build steps might be nicer with that now: [https://codeberg.org/allyourcodebase/spirv-cross](https://codeberg.org/allyourcodebase/spirv-cross)]
