summaryrefslogtreecommitdiff
path: root/src/effect_sources.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/effect_sources.zig')
-rw-r--r--src/effect_sources.zig68
1 files changed, 24 insertions, 44 deletions
diff --git a/src/effect_sources.zig b/src/effect_sources.zig
index 08680860..f45bf293 100644
--- a/src/effect_sources.zig
+++ b/src/effect_sources.zig
@@ -3,55 +3,41 @@ const build_config = @import("pardes_config");
const config = @import("config.zig");
const filesystem = @import("fs.zig");
-const shader_dir = if (build_config.gui_shader_sources_prebuilt)
- "shaders/prebuilt/"
-else
- "shaders/";
+const shader_dir = "shaders/";
const ui_vertex_path = shader_dir ++ "ui.vert.glsl";
const ui_fragment_path = shader_dir ++ "ui.frag.glsl";
const image_vertex_path = shader_dir ++ "image.vert.glsl";
const image_fragment_path = shader_dir ++ "image.frag.glsl";
-const scene_vertex_path = shader_dir ++ "crt.vert.glsl";
-const scene_fragment_path = shader_dir ++ "crt.frag.glsl";
+const post_vertex_path = shader_dir ++ "post.vert.glsl";
+// The bundled post pass as compiled: the prefix and the pass together.
+const post_crt_path = shader_dir ++ "post-crt.frag.glsl";
+const post_bloom_path = shader_dir ++ "post-bloom.frag.glsl";
+const post_vignette_path = shader_dir ++ "post-vignette.frag.glsl";
+const post_grain_path = shader_dir ++ "post-grain.frag.glsl";
+const bloom_down_path = shader_dir ++ "bloom-down.frag.glsl";
+const bloom_up_path = shader_dir ++ "bloom-up.frag.glsl";
pub const Backend = @TypeOf(build_config.platform);
pub const backend: Backend = build_config.platform;
-pub const GuiShaderSourceMode = enum {
- live,
- prebuilt_snapshot,
-
- pub fn label(mode: GuiShaderSourceMode) []const u8 {
- return switch (mode) {
- .live => "live GLSL compiled during this build",
- .prebuilt_snapshot => "paired GLSL snapshot for committed SPIR-V",
- };
- }
-};
-
-/// Only the SDL backend consumes GLSL/SPIR-V. Other backends deliberately have
-/// no shader-source mode rather than being mislabeled "live" or "prebuilt".
-pub fn guiShaderSourceMode() ?GuiShaderSourceMode {
- if (backend != .gui) return null;
- return if (build_config.gui_shader_sources_prebuilt)
- .prebuilt_snapshot
- else
- .live;
-}
-
pub const files = switch (backend) {
.tty => [_]filesystem.Source{
.{ .path = "src/tty/panel_compositor.zig", .contents = @embedFile("tty/panel_compositor.zig") },
},
.gui => [_]filesystem.Source{
.{ .path = "src/gui/gui.zig", .contents = @embedFile("gui/gui.zig") },
- .{ .path = "src/gui/crt.zig", .contents = @embedFile("gui/crt.zig") },
+ .{ .path = "src/gui/Post.zig", .contents = @embedFile("gui/Post.zig") },
.{ .path = ui_vertex_path, .contents = @embedFile("effect-source-ui.vert.glsl") },
.{ .path = ui_fragment_path, .contents = @embedFile("effect-source-ui.frag.glsl") },
.{ .path = image_vertex_path, .contents = @embedFile("effect-source-image.vert.glsl") },
.{ .path = image_fragment_path, .contents = @embedFile("effect-source-image.frag.glsl") },
- .{ .path = scene_vertex_path, .contents = @embedFile("effect-source-crt.vert.glsl") },
- .{ .path = scene_fragment_path, .contents = @embedFile("effect-source-crt.frag.glsl") },
+ .{ .path = post_vertex_path, .contents = @embedFile("effect-source-post.vert.glsl") },
+ .{ .path = post_crt_path, .contents = @embedFile("effect-source-post-crt.frag.glsl") },
+ .{ .path = post_bloom_path, .contents = @embedFile("effect-source-post-bloom.frag.glsl") },
+ .{ .path = post_vignette_path, .contents = @embedFile("effect-source-post-vignette.frag.glsl") },
+ .{ .path = post_grain_path, .contents = @embedFile("effect-source-post-grain.frag.glsl") },
+ .{ .path = bloom_down_path, .contents = @embedFile("effect-source-bloom-down.frag.glsl") },
+ .{ .path = bloom_up_path, .contents = @embedFile("effect-source-bloom-up.frag.glsl") },
},
.macos => [_]filesystem.Source{
.{ .path = "src/macos/Sources/PardesView.swift", .contents = @embedFile("macos/Sources/PardesView.swift") },
@@ -69,8 +55,13 @@ pub fn forSetting(setting: config.Runtime.Setting) ?[]const []const u8 {
.macos => &.{ "src/layout.zig", "src/pardes.zig", "src/macos/Sources/PardesView.swift", "src/macos/Sources/ScenePostprocessor.swift", "shaders/crt.ci.metal" },
.web, .esp32p4 => null,
},
- .scene => switch (backend) {
- .gui => &.{ "src/gui/crt.zig", "src/gui/gui.zig", scene_vertex_path, scene_fragment_path },
+ .scene => |effect| switch (backend) {
+ .gui => switch (effect) {
+ .crt => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_crt_path },
+ .bloom => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, bloom_down_path, bloom_up_path, post_bloom_path },
+ .vignette => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_vignette_path },
+ .grain => &.{ "src/gui/Post.zig", "src/gui/gui.zig", post_vertex_path, post_grain_path },
+ },
.macos => &.{ "src/macos/Sources/PardesView.swift", "src/macos/Sources/ScenePostprocessor.swift", "shaders/crt.ci.metal" },
.tty, .web, .esp32p4 => null,
},
@@ -107,14 +98,3 @@ test "EffectCode paths resolve uniquely to this backend's archived inputs" {
try std.testing.expectEqual(backend == .gui, filesystem.sourceBytes("src/gui/gui.zig") != null);
try std.testing.expectEqual(backend == .macos, filesystem.sourceBytes("src/macos/Sources/PardesView.swift") != null);
}
-
-test "shader source provenance is GUI-only and follows the build input" {
- if (comptime backend == .gui) {
- const expected: GuiShaderSourceMode = if (build_config.gui_shader_sources_prebuilt)
- .prebuilt_snapshot
- else
- .live;
- try std.testing.expectEqual(expected, guiShaderSourceMode().?);
- try std.testing.expect(expected.label().len > 0);
- } else try std.testing.expect(guiShaderSourceMode() == null);
-}