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.zig98
1 files changed, 0 insertions, 98 deletions
diff --git a/src/effect_sources.zig b/src/effect_sources.zig
deleted file mode 100644
index 39d86a1d..00000000
--- a/src/effect_sources.zig
+++ /dev/null
@@ -1,98 +0,0 @@
-const std = @import("std");
-const build_config = @import("pardes_config");
-const config = @import("config.zig");
-const filesystem = @import("fs.zig");
-
-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 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 files = switch (backend) {
- .tui => [_]filesystem.Source{
- .{ .path = "src/tui/panel_compositor.zig", .contents = @embedFile("tui/panel_compositor.zig") },
- },
- .gui => [_]filesystem.Source{
- .{ .path = "src/gui/gui.zig", .contents = @embedFile("gui/gui.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 = 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") },
- .{ .path = "src/macos/Sources/ScenePostprocessor.swift", .contents = @embedFile("macos/Sources/ScenePostprocessor.swift") },
- .{ .path = "shaders/crt.ci.metal", .contents = @embedFile("effect-source-crt.ci.metal") },
- },
-};
-
-pub fn forSetting(setting: config.Runtime.Setting) ?[]const []const u8 {
- return switch (setting.action) {
- .transition => switch (backend) {
- .tui => &.{ "src/layout.zig", "src/pardes.zig", "src/tui/panel_compositor.zig" },
- .gui => &.{ "src/layout.zig", "src/pardes.zig", "src/gui/gui.zig", ui_vertex_path, ui_fragment_path, image_vertex_path, image_fragment_path },
- .macos => &.{ "src/layout.zig", "src/pardes.zig", "src/macos/Sources/PardesView.swift", "src/macos/Sources/ScenePostprocessor.swift", "shaders/crt.ci.metal" },
- },
- .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" },
- .tui => null,
- },
- else => null,
- };
-}
-
-test "EffectCode paths resolve uniquely to this backend's archived inputs" {
- if (!@import("memory.zig").limits.embedded_sources) return error.SkipZigTest;
- for (config.Runtime.settings) |setting| {
- const available = switch (setting.action) {
- .transition => backend == .tui or backend == .gui or backend == .macos,
- .scene => backend == .gui or backend == .macos,
- else => false,
- };
- const paths = forSetting(setting);
- try std.testing.expectEqual(available, paths != null);
- if (paths) |listed| for (listed, 0..) |path, i| {
- const bytes = filesystem.sourceBytes(path) orelse return error.MissingEffectSource;
- try std.testing.expect(bytes.len > 0);
- for (listed[0..i]) |previous| try std.testing.expect(!std.mem.eql(u8, path, previous));
- };
- }
- for (files) |file| {
- const archived = filesystem.sourceBytes(file.path) orelse return error.MissingEffectSource;
- try std.testing.expectEqualStrings(file.contents, archived);
- var matches: usize = 0;
- for (filesystem.sources) |source| if (std.mem.eql(u8, source.path, file.path)) {
- matches += 1;
- };
- try std.testing.expectEqual(@as(usize, 1), matches);
- }
- try std.testing.expectEqual(backend == .tui, filesystem.sourceBytes("src/tui/panel_compositor.zig") != null);
- 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);
-}