1#!/bin/bash
2
3# Copyright 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16export GFXSTREAM_DIR=$(pwd)
17if [ -z "$1" ];
18then
19    export MESA_DIR=$(pwd)/../../../external/mesa3d
20else
21    export MESA_DIR=$1
22fi
23
24export PREFIX_DIR=src/gfxstream
25
26# We should use just use one vk.xml eventually..
27export VK_MESA_XML=$MESA_DIR/src/vulkan/registry/vk.xml
28export VK_XML=$GFXSTREAM_DIR/codegen/vulkan/vulkan-docs-next/xml/vk.xml
29
30export GFXSTREAM_GUEST_ENCODER_DIR=/tmp/
31export GFXSTREAM_HOST_DECODER_DIR=$GFXSTREAM_DIR/host/vulkan
32export GFXSTREAM_OUTPUT_DIR=$GFXSTREAM_HOST_DECODER_DIR/cereal
33export GFXSTREAM_SCRIPTS_DIR=$GFXSTREAM_DIR/scripts
34
35export GEN_VK=$GFXSTREAM_DIR/$PREFIX_DIR/codegen/scripts/genvk.py
36export CUSTOM_XML=$GFXSTREAM_DIR/$PREFIX_DIR/codegen/xml/vk_gfxstream.xml
37
38# For testing Mesa codegen copy only
39#export GEN_VK=$MESA_DIR/$PREFIX_DIR/codegen/scripts/genvk.py
40#export CUSTOM_XML=$MESA_DIR/$PREFIX_DIR/codegen/xml/vk_gfxstream.xml
41
42python3 $GEN_VK -registry $VK_XML -registryGfxstream $CUSTOM_XML cereal -o $GFXSTREAM_OUTPUT_DIR
43
44export CEREAL_VARIANT=guest
45export GFXSTREAM_GUEST_ENCODER_DIR=$GFXSTREAM_DIR/guest/vulkan_enc
46python3 $GEN_VK -registry $VK_MESA_XML -registryGfxstream $CUSTOM_XML cereal -o /tmp/
47
48# Should have a unified headers dir here:
49python3 $GEN_VK -registry $CUSTOM_XML vulkan_gfxstream.h -o $GFXSTREAM_GUEST_ENCODER_DIR
50python3 $GEN_VK -registry $CUSTOM_XML vulkan_gfxstream.h -o $GFXSTREAM_HOST_DECODER_DIR
51