RetroArch
spirv_cpp.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2018 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 
17 #ifndef SPIRV_CROSS_CPP_HPP
18 #define SPIRV_CROSS_CPP_HPP
19 
20 #include "spirv_glsl.hpp"
21 #include <utility>
22 #include <vector>
23 
24 namespace spirv_cross
25 {
26 class CompilerCPP : public CompilerGLSL
27 {
28 public:
29  CompilerCPP(std::vector<uint32_t> spirv_)
30  : CompilerGLSL(move(spirv_))
31  {
32  }
33 
34  CompilerCPP(const uint32_t *ir, size_t word_count)
35  : CompilerGLSL(ir, word_count)
36  {
37  }
38 
39  std::string compile() override;
40 
41  // Sets a custom symbol name that can override
42  // spirv_cross_get_interface.
43  //
44  // Useful when several shader interfaces are linked
45  // statically into the same binary.
47  {
48  interface_name = std::move(name);
49  }
50 
51 private:
52  void emit_header() override;
53  void emit_c_linkage();
54  void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override;
55 
56  void emit_resources();
57  void emit_buffer_block(const SPIRVariable &type) override;
58  void emit_push_constant_block(const SPIRVariable &var) override;
61  void emit_uniform(const SPIRVariable &var) override;
62  void emit_shared(const SPIRVariable &var);
64  std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id) override;
65 
67 
68  std::vector<std::string> resource_registrations;
72 
74 };
75 } // namespace spirv_cross
76 
77 #endif
GLuint const GLchar * name
Definition: glext.h:6671
Definition: spirv_glsl.hpp:56
void emit_push_constant_block(const SPIRVariable &var) override
Definition: spirv_cpp.cpp:112
std::string argument_decl(const SPIRFunction::Parameter &arg)
Definition: spirv_cpp.cpp:417
void emit_c_linkage()
Definition: spirv_cpp.cpp:340
Definition: spirv_common.hpp:369
void emit_uniform(const SPIRVariable &var) override
Definition: spirv_cpp.cpp:79
void emit_block_struct(SPIRType &type)
Definition: spirv_cpp.cpp:132
void emit_resources()
Definition: spirv_cpp.cpp:144
GLsizei const GLchar *const * string
Definition: glext.h:6699
void emit_interface_block(const SPIRVariable &type)
Definition: spirv_cpp.cpp:43
void emit_buffer_block(const SPIRVariable &type) override
Definition: spirv_cpp.cpp:23
GLenum type
Definition: glext.h:6233
Definition: barrier.hpp:23
std::string compile() override
Definition: spirv_cpp.cpp:283
void emit_header() override
Definition: spirv_cpp.cpp:456
GLenum func
Definition: glext.h:6668
void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override
Definition: spirv_cpp.cpp:377
void emit_shared(const SPIRVariable &var)
Definition: spirv_cpp.cpp:70
std::string interface_name
Definition: spirv_cpp.hpp:73
void set_interface_name(std::string name)
Definition: spirv_cpp.hpp:46
std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id) override
Definition: spirv_cpp.cpp:434
static int block
Definition: psp2.c:31
CompilerCPP(std::vector< uint32_t > spirv_)
Definition: spirv_cpp.hpp:29
void emit_block_chain(SPIRBlock &block)
Definition: spirv_common.hpp:803
std::string impl_type
Definition: spirv_cpp.hpp:69
Definition: spirv_common.hpp:699
CompilerCPP(const uint32_t *ir, size_t word_count)
Definition: spirv_cpp.hpp:34
uint32_t shared_counter
Definition: spirv_cpp.hpp:71
std::string resource_type
Definition: spirv_cpp.hpp:70
Definition: spirv_common.hpp:97
Definition: spirv_common.hpp:554
std::vector< std::string > resource_registrations
Definition: spirv_cpp.hpp:68
Definition: spirv_common.hpp:686
Definition: spirv_cpp.hpp:26
unsigned int uint32_t
Definition: stdint.h:126