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 | c172a35 | 2016-05-30 21:45:16 +0200 | [diff] [blame] | 21 | #include <utility> |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
Hans-Kristian Arntzen | 147e53a | 2016-04-04 09:36:04 +0200 | [diff] [blame] | 24 | namespace spirv_cross |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 25 | { |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 26 | class CompilerCPP : public CompilerGLSL |
| 27 | { |
| 28 | public: |
| 29 | CompilerCPP(std::vector<uint32_t> spirv_) |
| 30 | : CompilerGLSL(move(spirv_)) |
| 31 | { |
| 32 | } |
| 33 | std::string compile() override; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 34 | |
Hans-Kristian Arntzen | c172a35 | 2016-05-30 21:45:16 +0200 | [diff] [blame] | 35 | // Sets a custom symbol name that can override |
| 36 | // spirv_cross_get_interface. |
| 37 | // |
| 38 | // Useful when several shader interfaces are linked |
| 39 | // statically into the same binary. |
| 40 | void set_interface_name(std::string name) |
| 41 | { |
| 42 | interface_name = std::move(name); |
| 43 | } |
| 44 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 45 | private: |
| 46 | void emit_header() override; |
| 47 | void emit_c_linkage(); |
| 48 | void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 49 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 50 | void emit_resources(); |
| 51 | void emit_buffer_block(const SPIRVariable &type); |
| 52 | void emit_push_constant_block(const SPIRVariable &var); |
| 53 | void emit_interface_block(const SPIRVariable &type); |
| 54 | void emit_block_chain(SPIRBlock &block); |
| 55 | void emit_uniform(const SPIRVariable &var); |
| 56 | void emit_shared(const SPIRVariable &var); |
Hans-Kristian Arntzen | 2eb6037 | 2016-05-23 14:18:00 +0200 | [diff] [blame] | 57 | void emit_block_struct(SPIRType &type); |
Hans-Kristian Arntzen | 168e46f | 2016-05-28 13:09:26 +0200 | [diff] [blame] | 58 | std::string variable_decl(const SPIRType &type, const std::string &name) override; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 59 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 60 | std::string argument_decl(const SPIRFunction::Parameter &arg); |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 61 | |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 62 | std::vector<std::string> resource_registrations; |
| 63 | std::string impl_type; |
| 64 | std::string resource_type; |
| 65 | uint32_t shared_counter = 0; |
Hans-Kristian Arntzen | c172a35 | 2016-05-30 21:45:16 +0200 | [diff] [blame] | 66 | |
| 67 | std::string interface_name; |
Hans-Kristian Arntzen | 4b8ed53 | 2016-05-05 09:33:18 +0200 | [diff] [blame] | 68 | }; |
Hans-Kristian Arntzen | 75471fb | 2016-03-02 18:09:16 +0100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | #endif |