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## --- 64-bit keys ---
31
32$HS_GEN -v -a "glsl" -D HS_INTEL_GEN8 -t 2 -w 8 -r 16 -s 21504 -S 65536 -b 16 -B 48 -m 1 -M 1 -f 1 -F 1 -c 1 -C 1 -z
33
34##
35## remove trailing whitespace from generated files
36##
37
38sed -i 's/[[:space:]]*$//' hs_config.h
39sed -i 's/[[:space:]]*$//' hs_modules.h
40
41##
42##
43##
44
45whereis glslangValidator
46
47##
48## FIXME -- convert this to a bash script
49##
50## Note that we can use xargs instead of the cmd for/do
51##
52
53for f in *.comp
54do
55    dos2unix $f
56    clang-format -style=Mozilla -i $f
57    cpp -P -I ../.. -I ../../.. $f > ${f%%.*}.pre.comp
58    clang-format -style=Mozilla -i ${f%%.*}.pre.comp
59    glslangValidator --target-env vulkan1.1 -o ${f%%.*}.spv ${f%%.*}.pre.comp
60    spirv-opt -O ${f%%.*}.spv -o ${f%%.*}.spv
61##  spirv-remap -v --do-everything --input %%~nf.spv --output remap
62    xxd -i < ${f%%.*}.spv > ${f%%.*}.spv.xxd
63    len=$(wc -c < ${f%%.*}.spv)
64    echo ${f%%.*}.spv $len
65    printf "%.8x" $len | xxd -r -p | xxd -i > ${f%%.*}.len.xxd
66done
67
68##
69## dump a binary
70##
71
72cc -I ../../.. -I ../../../../.. -D=HS_DUMP -o hs_dump *.c
73hs_dump
74
75##
76## delete temporary files
77##
78
79rm *.pre.comp
80rm *.comp
81rm *.spv
82