summaryrefslogtreecommitdiff
path: root/Rend/demos/build.c
blob: 3d6700658c5fd642d8e5e2609d3d6175aca06c40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#define POOF_IMPLEMENTATION
#include "poof.h"

void add_podium_config(Poof_CC *cc) {
    poof_cmd_append(&cc->includes, "Podium");

#if defined(PODIUM_WIN32)
    poof_cc_append_win32(cc, "-DPODIUM_WIN32", "-luser32", "-lgdi32");
    const char *vulkan_sdk = getenv("VULKAN_SDK");
    if (vulkan_sdk) {
        char inc_buf[512], lib_buf[512];
        snprintf(inc_buf, sizeof(inc_buf), "-I%s/Include", vulkan_sdk);
        snprintf(lib_buf, sizeof(lib_buf), "-L%s/Lib", vulkan_sdk);
        poof_cc_append_win32(cc, strdup(inc_buf), strdup(lib_buf));
    }
    poof_cc_append_win32(cc, "-lvulkan-1");
#else
    poof_cc_append_linux(cc, "-lX11", "-D_REENTRANT", "-lpulse", "-lpulse-simple", "-pthread", "-lvulkan");
#endif
}

int main(int argc, char **argv) {
    POOF_GO_REBUILD_URSELF(argc, argv);

    Poof_Batch batch = {0};

    {
        Poof_Cmd cmd = {0};
        poof_cmd_append(&cmd, "slangc", "rend_compute.slang", "-target", "spirv", "-entry", "particleMain", "-stage", "compute", "-o", "compute/particle.spv");
        poof_batch_append_cmd(&batch, cmd);
    }

    {
        Poof_Cmd cmd = {0};
        poof_cmd_append(&cmd, "slangc", "rend_compute.slang", "-target", "spirv", "-entry", "sandMain", "-stage", "compute", "-o", "compute/sand.spv");
        poof_batch_append_cmd(&batch, cmd);
    }

    {
        Poof_Cmd cmd = {0};
        poof_cmd_append(&cmd, "slangc", "rend_compute.slang", "-target", "spirv", "-entry", "vertMain", "-stage", "vertex", "-o", "compute/vert.spv");
        poof_batch_append_cmd(&batch, cmd);
    }

    {
        Poof_Cmd cmd = {0};
        poof_cmd_append(&cmd, "slangc", "rend_compute.slang", "-target", "spirv", "-entry", "fragMain", "-stage", "fragment", "-o", "compute/frag.spv");
        poof_batch_append_cmd(&batch, cmd);
    }

    // Debug build
    {
        Poof_CC cc;
        poof_cc_init(&cc, POOF_CC_GCC, POOF_TARGET_HOST);
        cc.debug_mode = true;
        cc.optimization = POOF_O0;
        cc.output = "compute/rend_compute_demo";
        poof_cmd_append(&cc.inputs, "rend_compute.c");
        poof_cmd_append(&cc.includes, "..", ".");
        poof_cmd_append(&cc.defines, "REND_DEBUG");
        poof_cmd_append(&cc.libs, "m");
        poof_cmd_append(&cc.extra_flags, "-ggdb");
        add_podium_config(&cc);

        poof_batch_append_cc(&batch, &cc);
    }

    // Debug build
    {
        Poof_CC cc;
        poof_cc_init(&cc, POOF_CC_GCC, POOF_TARGET_HOST);
        cc.debug_mode = true;
        cc.optimization = POOF_O3 | POOF_MSSE2;
        cc.output = "compute/rend_compute_fast";
        poof_cmd_append(&cc.inputs, "rend_compute.c");
        poof_cmd_append(&cc.includes, "..");
        poof_cmd_append(&cc.libs, "m");
        add_podium_config(&cc);

        poof_batch_append_cc(&batch, &cc);
    }

    poof_batch_run(&batch, "Rend Demos");
    return 0;
}