-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-shaders.sh
executable file
·60 lines (49 loc) · 3.68 KB
/
build-shaders.sh
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
# Aldaron's Device Interface / GPU #
# Copyright (c) 2017 Plop Grizzly, Jeron Lau <jeron.lau@plopgrizzly.com> #
# Licensed under the MIT LICENSE #
# _ _ #
# /@\——————/@\ #
# .——— . | o o | .———— . . #
# | | | .——— .——— .——. [] .——. | .—— ———: ———: | . . #
# | | | | | | | \ \ <##> / / | | | / / | | | #
# |——— | | | | | | ¯ ¯ | | -- | | / / | \ / #
# | | | | |——— | | | | | | / / | | #
# | | ——— | | | ———— | | :——— :——— | | #
# | \ / __/ #
# ¯————————————¯ #
# gen-spirv.sh #
SPIRV_OPT="spirv-opt --strip-debug --freeze-spec-const --eliminate-dead-const --fold-spec-const-op-composite --unify-const"
SRC=src/shaders/glsl
OUT_UNOPTIMIZED=target/spv/unoptimized
OUT_OPTIMIZED=target/spv/optimized
OUT_RELEASE=target/spv/release
mkdir -p $OUT_UNOPTIMIZED/
mkdir -p $OUT_OPTIMIZED/
mkdir -p $OUT_RELEASE/
glslangValidator $SRC/solid-frag.glsl -V -o $OUT_UNOPTIMIZED/solid-frag.spv -S frag
glslangValidator $SRC/solid-vert.glsl -V -o $OUT_UNOPTIMIZED/solid-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/solid-frag.spv -o $OUT_OPTIMIZED/solid-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/solid-vert.spv -o $OUT_OPTIMIZED/solid-vert.spv
glslangValidator $SRC/gradient-frag.glsl -V -o $OUT_UNOPTIMIZED/gradient-frag.spv -S frag
glslangValidator $SRC/gradient-vert.glsl -V -o $OUT_UNOPTIMIZED/gradient-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/gradient-frag.spv -o $OUT_OPTIMIZED/gradient-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/gradient-vert.spv -o $OUT_OPTIMIZED/gradient-vert.spv
glslangValidator $SRC/texture-frag.glsl -V -o $OUT_UNOPTIMIZED/texture-frag.spv -S frag
glslangValidator $SRC/texture-vert.glsl -V -o $OUT_UNOPTIMIZED/texture-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/texture-frag.spv -o $OUT_OPTIMIZED/texture-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/texture-vert.spv -o $OUT_OPTIMIZED/texture-vert.spv
glslangValidator $SRC/faded-frag.glsl -V -o $OUT_UNOPTIMIZED/faded-frag.spv -S frag
glslangValidator $SRC/faded-vert.glsl -V -o $OUT_UNOPTIMIZED/faded-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/faded-frag.spv -o $OUT_OPTIMIZED/faded-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/faded-vert.spv -o $OUT_OPTIMIZED/faded-vert.spv
glslangValidator $SRC/tinted-frag.glsl -V -o $OUT_UNOPTIMIZED/tinted-frag.spv -S frag
glslangValidator $SRC/tinted-vert.glsl -V -o $OUT_UNOPTIMIZED/tinted-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/tinted-frag.spv -o $OUT_OPTIMIZED/tinted-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/tinted-vert.spv -o $OUT_OPTIMIZED/tinted-vert.spv
glslangValidator $SRC/complex-frag.glsl -V -o $OUT_UNOPTIMIZED/complex-frag.spv -S frag
glslangValidator $SRC/complex-vert.glsl -V -o $OUT_UNOPTIMIZED/complex-vert.spv -S vert
$SPIRV_OPT $OUT_UNOPTIMIZED/complex-frag.spv -o $OUT_OPTIMIZED/complex-frag.spv
$SPIRV_OPT $OUT_UNOPTIMIZED/complex-vert.spv -o $OUT_OPTIMIZED/complex-vert.spv
spirv-remap --map all --dce all --strip-all --input $OUT_OPTIMIZED/*.spv --output $OUT_RELEASE/
cp $OUT_RELEASE/* src/shaders/res/
# cp $OUT_UNOPTIMIZED/* src/native_renderer/vulkan/res/