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 #pragma once
6 
7 #include <memory>
8 #include <utility>
9 #include <variant>
10 
11 #include "flutter/fml/logging.h"
12 #include "flutter/fml/macros.h"
13 #include "spirv_glsl.hpp"
14 
15 namespace impeller {
16 namespace compiler {
17 
18 class CompilerSkSL : public spirv_cross::CompilerGLSL {
19  public:
20  explicit CompilerSkSL(std::vector<uint32_t> spirv_)
21  : CompilerGLSL(std::move(spirv_)) {}
22 
23  CompilerSkSL(const uint32_t* ir_, size_t word_count)
24  : CompilerGLSL(ir_, word_count) {}
25 
26  explicit CompilerSkSL(const spirv_cross::ParsedIR& ir_)
27  : spirv_cross::CompilerGLSL(ir_) {}
28 
29  explicit CompilerSkSL(spirv_cross::ParsedIR&& ir_)
30  : spirv_cross::CompilerGLSL(std::move(ir_)) {}
31 
32  std::string compile() override;
33 
34  private:
35  std::string output_name_;
36 
37  void emit_header() override;
38 
39  void emit_uniform(const spirv_cross::SPIRVariable& var) override;
40 
41  void fixup_user_functions();
42 
43  void detect_unsupported_resources();
44  bool emit_constant_resources();
45  bool emit_struct_resources();
46  bool emit_uniform_resources();
47  bool emit_output_resources();
48  bool emit_global_variable_resources();
49  bool emit_undefined_values();
50  void emit_resources();
51 
52  void emit_interface_block(const spirv_cross::SPIRVariable& var);
53 
54  void emit_function_prototype(
55  spirv_cross::SPIRFunction& func,
56  const spirv_cross::Bitset& return_flags) override;
57 
58  std::string image_type_glsl(const spirv_cross::SPIRType& type,
59  uint32_t id = 0) override;
60 
61  std::string builtin_to_glsl(spv::BuiltIn builtin,
62  spv::StorageClass storage) override;
63 
64  std::string to_texture_op(
65  const spirv_cross::Instruction& i,
66  bool sparse,
67  bool* forward,
68  spirv_cross::SmallVector<uint32_t>& inherited_expressions) override;
69 
70  std::string to_function_name(
71  const spirv_cross::CompilerGLSL::TextureFunctionNameArguments& args)
72  override;
73 
74  std::string to_function_args(
75  const spirv_cross::CompilerGLSL::TextureFunctionArguments& args,
76  bool* p_forward) override;
77 };
78 
79 } // namespace compiler
80 } // namespace impeller
impeller::compiler::CompilerSkSL::CompilerSkSL
CompilerSkSL(const uint32_t *ir_, size_t word_count)
Definition: spirv_sksl.h:23
impeller::compiler::CompilerSkSL::compile
std::string compile() override
Definition: spirv_sksl.cc:24
impeller::compiler::CompilerSkSL::CompilerSkSL
CompilerSkSL(std::vector< uint32_t > spirv_)
Definition: spirv_sksl.h:20
impeller::compiler::CompilerSkSL::CompilerSkSL
CompilerSkSL(spirv_cross::ParsedIR &&ir_)
Definition: spirv_sksl.h:29
std
Definition: comparable.h:98
impeller::compiler::CompilerSkSL
Definition: spirv_sksl.h:18
impeller
Definition: aiks_context.cc:10
impeller::compiler::CompilerSkSL::CompilerSkSL
CompilerSkSL(const spirv_cross::ParsedIR &ir_)
Definition: spirv_sksl.h:26