-
-
Save EtienneParmentier/88f98d2be9c38b8d46e693b01d3a69e5 to your computer and use it in GitHub Desktop.
This crashes on windows, and I can't figure out why ? There is no stacktrace shwon, it is hard for me to find the issue. Using zig 0.14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn main() !void { | |
std.debug.print("{any}", @embedFile("fragment_shader")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
pub fn build(b: *std.Build) !void { | |
const shaderRootFile = b.option(std.Build.LazyPath, "shader_file", "The root file of your shader\n(default: fragment.zig)") orelse b.path("fragment.zig"); | |
const execRootFile = b.option(std.Build.LazyPath, "executable_file", "The root file of the executable\n(default: app.zig)") orelse b.path("app.zig"); | |
const shaderOptimize = b.option(std.builtin.OptimizeMode, "shader_optimize", "shader optimisation mode\n(default: Debug)") orelse std.builtin.OptimizeMode.Debug; | |
const execOptimize = b.standardOptimizeOption(.{}); | |
const execTarget = b.standardTargetOptions(.{ | |
.default_target = std.Target.Query{ | |
.os_tag = builtin.target.os.tag, | |
}, | |
}); | |
const shaderTarget = b.resolveTargetQuery(.{ | |
.cpu_model = .{ .explicit = &std.Target.spirv.cpu.vulkan_v1_2 }, | |
.cpu_features_add = std.Target.spirv.featureSet(&.{.int64}), | |
.cpu_arch = .spirv64, | |
.os_tag = .vulkan, | |
.ofmt = .spirv, | |
}); | |
const shaderBinary = b.addObject(.{ | |
.name = "fragment_shader", | |
.root_source_file = shaderRootFile, | |
.optimize = shaderOptimize, | |
.target = shaderTarget, | |
.use_llvm = false, | |
}); | |
const executableModule = b.createModule(.{ | |
.root_source_file = execRootFile, | |
.optimize = execOptimize, | |
.target = execTarget, | |
}); | |
executableModule.addAnonymousImport("fragment_shader", .{ | |
.root_source_file = shaderBinary.getEmittedBin(), | |
}); | |
const executableBin = b.addExecutable(.{ | |
.root_module = executableModule, | |
.name = "project", | |
}); | |
b.installArtifact(executableBin); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const gpu = std.gpu; | |
const UBO = extern struct { | |
object_color: @Vector(4, f32), | |
light_color: @Vector(4, f32), | |
}; | |
extern const ubo: UBO addrspace(.uniform); | |
extern var frag_color: Vec4 addrspace(.output); | |
export fn fragmentMain() callconv(.spirv_fragment) void { | |
// Annotation | |
gpu.fragmentOrigin(fragmentMain, .upper_left); | |
gpu.binding(&ubo, 0, 0); | |
gpu.location(&frag_color, 0); | |
frag_color = ubo.object_color * ubo.light_color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment