Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015-2016 ARM Limited |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Hans-Kristian Arntzen | 147e53a | 2016-04-04 09:36:04 +0200 | [diff] [blame] | 17 | #ifndef SPIRV_CPP_HPP |
| 18 | #define SPIRV_CPP_HPP |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 19 | |
Hans-Kristian Arntzen | 147e53a | 2016-04-04 09:36:04 +0200 | [diff] [blame] | 20 | #include "spirv_glsl.hpp" |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
Hans-Kristian Arntzen | 147e53a | 2016-04-04 09:36:04 +0200 | [diff] [blame] | 23 | namespace spirv_cross |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 24 | { |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 25 | class CompilerCPP : public CompilerGLSL |
| 26 | { |
| 27 | public: |
| 28 | CompilerCPP(std::vector<uint32_t> spirv_) |
| 29 | : CompilerGLSL(move(spirv_)) |
| 30 | { |
| 31 | } |
| 32 | std::string compile() override; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 33 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 34 | private: |
| 35 | void emit_header() override; |
| 36 | void emit_c_linkage(); |
| 37 | void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 38 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 39 | void emit_resources(); |
| 40 | void emit_buffer_block(const SPIRVariable &type); |
| 41 | void emit_push_constant_block(const SPIRVariable &var); |
| 42 | void emit_interface_block(const SPIRVariable &type); |
| 43 | void emit_block_chain(SPIRBlock &block); |
| 44 | void emit_uniform(const SPIRVariable &var); |
| 45 | void emit_shared(const SPIRVariable &var); |
Hans-Kristian Arntzen | 2eb6037 | 2016-05-23 14:18:00 +0200 | [diff] [blame] | 46 | void emit_block_struct(SPIRType &type); |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 47 | |
papostolou | e108d85 | 2016-05-18 10:46:33 +0300 | [diff] [blame] | 48 | std::string constant_expression(const SPIRConstant &c) override; |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 49 | std::string argument_decl(const SPIRFunction::Parameter &arg); |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 50 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 51 | std::vector<std::string> resource_registrations; |
| 52 | std::string impl_type; |
| 53 | std::string resource_type; |
| 54 | uint32_t shared_counter = 0; |
| 55 | }; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | #endif |