2 * Copyright 2018-2021 Bradley Austin Davis
3 * SPDX-License-Identifier: Apache-2.0 OR MIT
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * At your option, you may choose to accept this material under either:
20 * 1. The Apache License, Version 2.0, found at <http://www.apache.org/licenses/LICENSE-2.0>, or
21 * 2. The MIT License, found at <http://opensource.org/licenses/MIT>.
24 #ifndef SPIRV_CROSS_REFLECT_HPP
25 #define SPIRV_CROSS_REFLECT_HPP
27 #include "spirv_glsl.hpp"
35 namespace SPIRV_CROSS_NAMESPACE
37 class CompilerReflection
: public CompilerGLSL
39 using Parent
= CompilerGLSL
;
42 explicit CompilerReflection(std::vector
<uint32_t> spirv_
)
43 : Parent(std::move(spirv_
))
45 options
.vulkan_semantics
= true;
48 CompilerReflection(const uint32_t *ir_
, size_t word_count
)
49 : Parent(ir_
, word_count
)
51 options
.vulkan_semantics
= true;
54 explicit CompilerReflection(const ParsedIR
&ir_
)
57 options
.vulkan_semantics
= true;
60 explicit CompilerReflection(ParsedIR
&&ir_
)
61 : CompilerGLSL(std::move(ir_
))
63 options
.vulkan_semantics
= true;
66 void set_format(const std::string
&format
);
67 std::string
compile() override
;
70 static std::string
execution_model_to_str(spv::ExecutionModel model
);
72 void emit_entry_points();
74 void emit_resources();
75 void emit_specialization_constants();
77 void emit_type(uint32_t type_id
, bool &emitted_open_tag
);
78 void emit_type_member(const SPIRType
&type
, uint32_t index
);
79 void emit_type_member_qualifiers(const SPIRType
&type
, uint32_t index
);
80 void emit_type_array(const SPIRType
&type
);
81 void emit_resources(const char *tag
, const SmallVector
<Resource
> &resources
);
82 bool type_is_reference(const SPIRType
&type
) const;
84 std::string
to_member_name(const SPIRType
&type
, uint32_t index
) const;
86 std::shared_ptr
<simple_json::Stream
> json_stream
;
89 } // namespace SPIRV_CROSS_NAMESPACE