blob: 3a4371375091c9271045d0aec92783e422eeae8e [file] [log] [blame]
John Kessenich140f3df2015-06-26 16:58:36 -06001//
John Kessenich927608b2017-01-06 12:34:14 -07002// Copyright (C) 2014 LunarG, Inc.
John Kessenich140f3df2015-06-26 16:58:36 -06003//
John Kessenich927608b2017-01-06 12:34:14 -07004// All rights reserved.
John Kessenich140f3df2015-06-26 16:58:36 -06005//
John Kessenich927608b2017-01-06 12:34:14 -07006// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions
8// are met:
John Kessenich140f3df2015-06-26 16:58:36 -06009//
10// Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12//
13// Redistributions in binary form must reproduce the above
14// copyright notice, this list of conditions and the following
15// disclaimer in the documentation and/or other materials provided
16// with the distribution.
17//
18// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19// contributors may be used to endorse or promote products derived
20// from this software without specific prior written permission.
21//
John Kessenich927608b2017-01-06 12:34:14 -070022// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33// POSSIBILITY OF SUCH DAMAGE.
John Kessenich140f3df2015-06-26 16:58:36 -060034
Aras Pranckevicius23d3c712017-05-10 16:58:38 +030035#pragma once
36
Johannes van Waveren8e1e7172016-10-21 17:21:12 +090037#if _MSC_VER >= 1900
38 #pragma warning(disable : 4464) // relative include path contains '..'
39#endif
40
John Kessenich140f3df2015-06-26 16:58:36 -060041#include "../glslang/Include/intermediate.h"
42
Lei Zhang17535f72016-05-04 15:55:59 -040043#include <string>
44#include <vector>
45
46#include "Logger.h"
47
John Kessenich140f3df2015-06-26 16:58:36 -060048namespace glslang {
49
John Kessenich121853f2017-05-31 17:11:16 -060050struct SpvOptions {
GregFcd1f1692017-09-21 18:40:22 -060051 SpvOptions() : generateDebugInfo(false), disableOptimizer(true),
52 optimizeSize(false) { }
John Kessenich121853f2017-05-31 17:11:16 -060053 bool generateDebugInfo;
GregFcd1f1692017-09-21 18:40:22 -060054 bool disableOptimizer;
55 bool optimizeSize;
John Kessenich121853f2017-05-31 17:11:16 -060056};
57
John Kessenich68d78fd2015-07-12 19:28:10 -060058void GetSpirvVersion(std::string&);
John Kessenicha372a3e2017-11-02 22:32:14 -060059int GetSpirvGeneratorVersion();
John Kessenich121853f2017-05-31 17:11:16 -060060void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
61 SpvOptions* options = nullptr);
62void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
63 spv::SpvBuildLogger* logger, SpvOptions* options = nullptr);
Johannes van Waverenecb0f3b2016-05-27 12:55:53 -050064void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName);
Flavioaea3c892017-02-06 11:46:35 -080065void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName);
John Kessenich140f3df2015-06-26 16:58:36 -060066
John Kessenich6e620c42016-04-07 09:10:47 -060067}