rs2spirv_driver.sh revision 04ac689251b180cb9f569083f71a5d66825734e2
1# Copyright 2016, The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#!/bin/bash
16
17if [ $# -lt 3 ]; then
18  echo 1>&2 "$0: not enough arguments"
19  echo 1>&2 $#
20  exit 2
21fi
22
23AND_HOME=$ANDROID_BUILD_TOP
24SPIRV_TOOLS_PATH=$1
25
26script_name="$2"
27script=${2%.*} # Remove extension.
28
29output_folder="$3"
30mkdir -p $output_folder
31
32eval llvm-rs-cc -o "$output_folder" -S -emit-llvm -Wall -Werror -target-api 24 \
33  -I "$AND_HOME/external/clang/lib/Headers" -I "$AND_HOME/frameworks/rs/scriptc" \
34  "$script_name"
35eval llvm-as "$output_folder/bc32/$script.ll" -o "$output_folder/$script.bc"
36eval rs2spirv "$output_folder/$script.bc" -o "$output_folder/$script.rs.spv" \
37              -wo "$output_folder/$script.w.spt"
38eval "$SPIRV_TOOLS_PATH/spirv-dis" "$output_folder/$script.rs.spv" \
39              --no-color > "$output_folder/$script.rs.spt"
40eval rs2spirv -o "$output_folder/$script.spt" -lk "$output_folder/$script.rs.spt" \
41              -lw "$output_folder/$script.w.spt"
42eval "$SPIRV_TOOLS_PATH/spirv-as" "$output_folder/$script.spt" \
43              -o "$output_folder/$script.spv"
44echo
45eval rs2spirv "$output_folder/$script.spv" -print-as-words
46echo
47eval "$SPIRV_TOOLS_PATH/spirv-val" "$output_folder/$script.spv"
48echo
49