blob: 342f3a92dba8d08685d5591562b16df97001d021 [file] [log] [blame]
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +01001/*
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 Arntzen147e53a2016-04-04 09:36:04 +020017#ifndef SPIRV_CPP_HPP
18#define SPIRV_CPP_HPP
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010019
Hans-Kristian Arntzen147e53a2016-04-04 09:36:04 +020020#include "spirv_glsl.hpp"
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010021#include <vector>
22
Hans-Kristian Arntzen147e53a2016-04-04 09:36:04 +020023namespace spirv_cross
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010024{
Hans-Kristian Arntzen4b8ed532016-05-05 09:33:18 +020025class CompilerCPP : public CompilerGLSL
26{
27public:
28 CompilerCPP(std::vector<uint32_t> spirv_)
29 : CompilerGLSL(move(spirv_))
30 {
31 }
32 std::string compile() override;
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010033
Hans-Kristian Arntzen4b8ed532016-05-05 09:33:18 +020034private:
35 void emit_header() override;
36 void emit_c_linkage();
37 void emit_function_prototype(SPIRFunction &func, uint64_t return_flags) override;
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010038
Hans-Kristian Arntzen4b8ed532016-05-05 09:33:18 +020039 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 Arntzen2eb60372016-05-23 14:18:00 +020046 void emit_block_struct(SPIRType &type);
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010047
papostoloue108d852016-05-18 10:46:33 +030048 std::string constant_expression(const SPIRConstant &c) override;
Hans-Kristian Arntzen4b8ed532016-05-05 09:33:18 +020049 std::string argument_decl(const SPIRFunction::Parameter &arg);
Hans-Kristian Arntzen75471fb2016-03-02 18:09:16 +010050
Hans-Kristian Arntzen4b8ed532016-05-05 09:33:18 +020051 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 Arntzen75471fb2016-03-02 18:09:16 +010056}
57
58#endif