Flutter Impeller
spirv_sksl.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_COMPILER_SPIRV_SKSL_H_
6 #define FLUTTER_IMPELLER_COMPILER_SPIRV_SKSL_H_
7 
8 #include <cstdint>
9 #include <memory>
10 #include <utility>
11 #include <variant>
12 
13 #include "flutter/fml/logging.h"
14 #include "spirv_glsl.hpp"
15 
16 namespace impeller {
17 namespace compiler {
18 
19 class CompilerSkSL : public spirv_cross::CompilerGLSL {
20  public:
21  explicit CompilerSkSL(std::vector<uint32_t> spirv_)
22  : CompilerGLSL(std::move(spirv_)) {}
23 
24  CompilerSkSL(const uint32_t* ir_, size_t word_count)
25  : CompilerGLSL(ir_, word_count) {}
26 
27  explicit CompilerSkSL(const spirv_cross::ParsedIR& ir_)
28  : spirv_cross::CompilerGLSL(ir_) {}
29 
30  explicit CompilerSkSL(spirv_cross::ParsedIR&& ir_)
31  : spirv_cross::CompilerGLSL(std::move(ir_)) {}
32 
33  std::string compile() override;
34 
35  private:
36  std::string output_name_;
37 
38  void emit_header() override;
39 
40  void emit_uniform(const spirv_cross::SPIRVariable& var) override;
41 
42  void fixup_user_functions();
43 
44  void detect_unsupported_resources();
45  bool emit_constant_resources();
46  bool emit_struct_resources();
47  bool emit_uniform_resources();
48  bool emit_output_resources();
49  bool emit_global_variable_resources();
50  bool emit_undefined_values();
51  void emit_resources();
52 
53  void emit_interface_block(const spirv_cross::SPIRVariable& var);
54 
55  void emit_function_prototype(
56  spirv_cross::SPIRFunction& func,
57  const spirv_cross::Bitset& return_flags) override;
58 
59  std::string image_type_glsl(const spirv_cross::SPIRType& type,
60  uint32_t id = 0,
61  bool member = false) override;
62 
63  std::string builtin_to_glsl(spv::BuiltIn builtin,
64  spv::StorageClass storage) override;
65 
66  std::string to_texture_op(
67  const spirv_cross::Instruction& i,
68  bool sparse,
69  bool* forward,
70  spirv_cross::SmallVector<uint32_t>& inherited_expressions) override;
71 
72  std::string to_function_name(
73  const spirv_cross::CompilerGLSL::TextureFunctionNameArguments& args)
74  override;
75 
76  std::string to_function_args(
77  const spirv_cross::CompilerGLSL::TextureFunctionArguments& args,
78  bool* p_forward) override;
79 };
80 
81 } // namespace compiler
82 } // namespace impeller
83 
84 #endif // FLUTTER_IMPELLER_COMPILER_SPIRV_SKSL_H_
GLenum type
CompilerSkSL(const uint32_t *ir_, size_t word_count)
Definition: spirv_sksl.h:24
std::string compile() override
Definition: spirv_sksl.cc:24
CompilerSkSL(const spirv_cross::ParsedIR &ir_)
Definition: spirv_sksl.h:27
CompilerSkSL(spirv_cross::ParsedIR &&ir_)
Definition: spirv_sksl.h:30
CompilerSkSL(std::vector< uint32_t > spirv_)
Definition: spirv_sksl.h:21
Definition: comparable.h:95