1#!/bin/bash
2
3##
4## Copyright 2018 Google Inc.
5##
6## Use of this source code is governed by a BSD-style license that can
7## be found in the LICENSE file.
8##
9
10##
11## exit on error
12##
13
14## set -e
15
16##
17## delete the previous images
18##
19
20rm *.comp
21rm *.spv
22rm *.xxd
23
24##
25##
26##
27
28HS_GEN=../../../../gen/hs_gen
29
30## --- 32-bit keys ---
31
32## $HS_GEN -v -a "glsl" -D HS_NVIDIA_SM35 -t 1 -w 32 -r 32 -s 49152 -S 65536 -b 32 -m 1 -M 1 -f 1 -F 1 -c 1 -C 1 -z
33$HS_GEN -v -a "glsl" -D HS_NVIDIA_SM35 -t 1 -w 32 -r 16 -s 32768 -S 32768 -b 16 -m 1 -M 1 -p 1 -P 1 -f 0 -F 0 -c 0 -C 0 -z
34
35##
36## remove trailing whitespace from generated files
37##
38
39sed -i 's/[[:space:]]*$//' hs_config.h
40sed -i 's/[[:space:]]*$//' hs_modules.h
41
42##
43##
44##
45
46whereis glslangValidator
47
48##
49## FIXME -- convert this to a bash script
50##
51## Note that we can use xargs instead of the cmd for/do
52##
53
54for f in *.comp
55do
56    dos2unix $f
57    clang-format -style=Mozilla -i $f
58    cpp -P -I ../.. -I ../../.. $f > ${f%%.*}.pre.comp
59    clang-format -style=Mozilla -i ${f%%.*}.pre.comp
60    glslangValidator --target-env vulkan1.1 -o ${f%%.*}.spv ${f%%.*}.pre.comp
61    spirv-opt -O ${f%%.*}.spv -o ${f%%.*}.spv
62##  spirv-remap -v --do-everything --input %%~nf.spv --output remap
63    xxd -i < ${f%%.*}.spv > ${f%%.*}.spv.xxd
64    len=$(wc -c < ${f%%.*}.spv)
65    echo ${f%%.*}.spv $len
66    printf "%.8x" $len | xxd -r -p | xxd -i > ${f%%.*}.len.xxd
67done
68
69##
70## dump a binary
71##
72
73cc -I ../../.. -I ../../../../.. -D=HS_DUMP -o hs_dump *.c
74hs_dump
75
76##
77## delete temporary files
78##
79
80rm *.pre.comp
81rm *.comp
82rm *.spv
83