summaryrefslogtreecommitdiff
path: root/examples/shaders/src/uniforms.zig
diff options
context:
space:
mode:
Diffstat (limited to 'examples/shaders/src/uniforms.zig')
-rw-r--r--examples/shaders/src/uniforms.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/shaders/src/uniforms.zig b/examples/shaders/src/uniforms.zig
new file mode 100644
index 0000000..5810e46
--- /dev/null
+++ b/examples/shaders/src/uniforms.zig
@@ -0,0 +1,21 @@
+//! What every fragment shader here reads: the one definition, imported by
+//! the sketch, by the Zig shaders, and written out as GLSL for the others.
+const builtin = @import("builtin");
+
+/// GLSL's vec2. On the GPU a vector, which SPIR-V lays out as vec2 (an
+/// array in a uniform block gets a 16-byte stride under std140); on the
+/// CPU an array, since extern structs cannot hold vectors there.
+pub const vec2 = if (builtin.cpu.arch.isSpirV()) @Vector(2, f32) else [2]f32;
+
+pub const Uniforms = extern struct {
+ /// Pixels.
+ resolution: vec2,
+ /// Pixels, y up as in GL.
+ mouse: vec2,
+ /// Seconds.
+ time: f32,
+ pad0: f32 = 0,
+ pad1: vec2 = .{ 0, 0 },
+
+ pub const glsl = .{ .uniform = .{ .set = 3, .instance = "u" } };
+};