SPIR-V Backend Progress Devlog

Well @andrewrk it solves so many issues on the CPU-GPU code sharing front but the still missing matrix math and vector swizzle looks really painful.
Really looking forward to this landing.
The work is amazing, having comptime on the GPU really is something !

Btw, is there any example around that touches spec constants ?

12 Likes

This thread might be interesting for you Use of specialization constants in zig shaders

2 Likes

I would never direct anybody to GLSL for anything, anymore. Slang is so much better it’s ridiculous, at this point.

That doesn’t make me happy, and I’m really looking forward to when Zig is good enough to supplant slang, but that’s the current state of the industry.

3 Likes

IMHO GLSL is still perfectly fine if you need a slim solution, e.g. the combo glslang as frontend and SPIRVCross as backend is much smaller and much easier to integrate and customize than Slang. Also, one major advantage of GLSL is that it hasn’t been infected by the OOP/C++ virus like HLSL or MSL :wink:

5 Likes

I’ve been using Zig for my shaders since 0.15.1 (SDF + tile based GUI, mostly compute shaders) and I wouldn’t go back to GLSL.

The largest warts in my pipeline are relying on spirv-opt and (iirc) doing some inline SpirV to get PhysicalStorageBufferAddresses working properly, I need to revisit this.

My GUI was crawling before spirv-opt, but I haven’t tried without it in a while.

1 Like

Have you heard of object oriented assembly? :wink:

1 Like

Auto-differentiation is the killer feature keeping me on Slang right now. I’m not sure if that’s possible in Zig without custom arithmetic types / operator overloading.

Possible, just not as ergonomic. You’d have to use userspace types and functions instead of arithmetic operators.

The whole a.mul(b.add(c)) instead of a * (b + c) stuff.

Yeah… It would be so easy to mess that up. I don’t think that’s a real solution.

Another thing that you could do here that was pointed out I think a couple weeks was instead of writing it as a.mul(b.add(c)) because it is just syntax sugar you can keep the methods defined the same and write something like:

const res: Thing =  .mul(
        a,
        .add(
            b,
            c,
        ),
    );

/// OR

const res: Thing = .mul(a, .add(b, c));               

Doesn’t solve the not able to use operators problem but I find it much more readable and reminds me of lisp.

3 Likes

also wanna plug comath as something neat that’s possible in userland

5 Likes