#syntax help with SPIRV zig shader coding

1 messages · Page 1 of 1 (latest)

stray stratus
#

how do you declare the following in zig

  • a SSBO/structured buffer
  • GPU constants such as processed vertex ID
  • a matrix
  • a uniform buffer

i'm looking to see if its possible to translate my shader code from slang/glsl to zig.
having everything in one language would be very...nice.

subtle granite
visual ruin
#
  • a SSBO/structured buffer: you can but it has to be done all in assembly until we get either @SpirvType() or @Opaque()
  • GPU constants such as processed vertex ID: see std.gpu
  • a matrix: no matrix support planned. use array of vectors
  • a uniform buffer:
const UBO = extern struct {
    object_color: @Vector(4, f32),
    light_color: @Vector(4, f32),
};

extern const ubo: UBO addrspace(.uniform);
#

overall, i don't recommend using it for now unless for experiment

stray stratus
subtle granite
#

So the plan is to allow the same matrix math library in both shader and the rest of the program?

visual ruin
#

yes. e.g. zmath just works