summaryrefslogtreecommitdiff
path: root/examples/shaders/src/uniforms.zig
blob: 5810e46963d069ce11c6004a0b6a02b14a7bee07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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" } };
};