Compiling shaders #838
-
Simple question (or maybe not that simple), is there a way to compile shaders without creating a kfile.js? Is there a command for it? I'm asking because I'm working on a Zig binding for Kinc, and I want to do it in a way that allows users to be completely oblivious to kmake (and ideally shader compilation in general) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
To be more specific, I'm looking at making an API like this: In the users build.zig: const kinc = @import("Kinc.zig/build.zig");
// exe is a build step (*std.Build.Step.Compile)
kinc.link("Kinc.zig/Kinc", exe);
//shader.frag.glsl and shader.vert.glsl, and put the artifacts in zig-out/shader.frag and zig-out/shader.vert respectively
kinc.compileGLSLShader("src/shader.frag.glsl", .fragment, "zig-out/shader.frag", exe);
kinc.compileGLSLShader("src/shader.vert.glsl", .vertex, "zig-out/shader.vert", exe); |
Beta Was this translation helpful? Give feedback.
-
After reading the source code some more and messing around for a bit, I figured out that is the job of krafix in the tools. So for example, There are some additional options:
I'm still not sure what Reguardless, this is enough information to me to get shaders functional in my binding, so I'll mark this as the answer. |
Beta Was this translation helpful? Give feedback.
After reading the source code some more and messing around for a bit, I figured out that is the job of krafix in the tools.
So for example,
krafix spirv [workspace]/src/shaders/shader.frag.glsl [workspace]/out/shaders/shader.frag [path/to/Kinc]/Build linux
will compileshader.frag.glsl
into SPIRV for Linux, and write the result toout/shaders/shader.frag
There are some additional options:
--debug
--version [version]
--outputintermediatespirv
I'm still not sure what
--version
means exactly - I'm guessing it means the version for the output? But is it the version of the target API? (eg: Vulkan 1.3) Or is it the version of the output file? (eg: spirv 1.5)Reguardless, this is enough inform…