Flutter Impeller
spirv_compiler.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 <vector>
8 
9 #include "flutter/fml/macros.h"
10 #include "flutter/fml/mapping.h"
13 #include "shaderc/shaderc.hpp"
14 
15 namespace impeller {
16 namespace compiler {
17 
19  shaderc_profile profile = shaderc_profile_core;
20  uint32_t version = 460;
21 };
22 
24  shaderc_target_env env = shaderc_target_env::shaderc_target_env_vulkan;
25  shaderc_env_version version =
26  shaderc_env_version::shaderc_env_version_vulkan_1_1;
27  shaderc_spirv_version spirv_version =
28  shaderc_spirv_version::shaderc_spirv_version_1_3;
29 };
30 
32  bool generate_debug_info = true;
33  //----------------------------------------------------------------------------
34  // Source Options.
35  //----------------------------------------------------------------------------
36  std::optional<shaderc_source_language> source_langauge;
37  std::optional<SPIRVCompilerSourceProfile> source_profile;
38 
39  shaderc_optimization_level optimization_level =
40  shaderc_optimization_level::shaderc_optimization_level_performance;
41 
42  //----------------------------------------------------------------------------
43  // Target Options.
44  //----------------------------------------------------------------------------
45  std::optional<SPIRVCompilerTargetEnv> target;
46 
47  std::vector<std::string> macro_definitions;
48 
49  std::shared_ptr<Includer> includer;
50 
51  shaderc::CompileOptions BuildShadercOptions() const;
52 };
53 
55  public:
56  SPIRVCompiler(const SourceOptions& options,
57  std::shared_ptr<const fml::Mapping> sources);
58 
60 
61  std::shared_ptr<fml::Mapping> CompileToSPV(
62  std::stringstream& error_stream,
63  const shaderc::CompileOptions& spirv_options) const;
64 
65  private:
66  SourceOptions options_;
67  const std::shared_ptr<const fml::Mapping> sources_;
68 
69  std::string GetSourcePrefix() const;
70 
71  FML_DISALLOW_COPY_AND_ASSIGN(SPIRVCompiler);
72 };
73 
74 } // namespace compiler
75 } // namespace impeller
impeller::compiler::SPIRVCompiler::~SPIRVCompiler
~SPIRVCompiler()
impeller::compiler::SPIRVCompiler::CompileToSPV
std::shared_ptr< fml::Mapping > CompileToSPV(std::stringstream &error_stream, const shaderc::CompileOptions &spirv_options) const
Definition: spirv_compiler.cc:21
impeller::compiler::SPIRVCompilerOptions::generate_debug_info
bool generate_debug_info
Definition: spirv_compiler.h:32
impeller::compiler::SPIRVCompiler::SPIRVCompiler
SPIRVCompiler(const SourceOptions &options, std::shared_ptr< const fml::Mapping > sources)
Definition: spirv_compiler.cc:15
impeller::compiler::SourceOptions
Definition: source_options.h:19
impeller::compiler::SPIRVCompilerOptions::includer
std::shared_ptr< Includer > includer
Definition: spirv_compiler.h:49
impeller::compiler::SPIRVCompilerOptions::source_profile
std::optional< SPIRVCompilerSourceProfile > source_profile
Definition: spirv_compiler.h:37
impeller::compiler::SPIRVCompilerTargetEnv::env
shaderc_target_env env
Definition: spirv_compiler.h:24
includer.h
impeller::compiler::SPIRVCompilerOptions::target
std::optional< SPIRVCompilerTargetEnv > target
Definition: spirv_compiler.h:45
source_options.h
impeller::compiler::SPIRVCompilerOptions
Definition: spirv_compiler.h:31
impeller::compiler::SPIRVCompilerSourceProfile
Definition: spirv_compiler.h:18
impeller::compiler::SPIRVCompilerTargetEnv::version
shaderc_env_version version
Definition: spirv_compiler.h:25
impeller::compiler::SPIRVCompilerOptions::source_langauge
std::optional< shaderc_source_language > source_langauge
Definition: spirv_compiler.h:36
impeller::compiler::SPIRVCompilerSourceProfile::profile
shaderc_profile profile
Definition: spirv_compiler.h:19
impeller::compiler::SPIRVCompilerTargetEnv::spirv_version
shaderc_spirv_version spirv_version
Definition: spirv_compiler.h:27
impeller::compiler::SPIRVCompilerOptions::macro_definitions
std::vector< std::string > macro_definitions
Definition: spirv_compiler.h:47
impeller::compiler::SPIRVCompilerOptions::BuildShadercOptions
shaderc::CompileOptions BuildShadercOptions() const
Definition: spirv_compiler.cc:274
impeller::compiler::SPIRVCompilerSourceProfile::version
uint32_t version
Definition: spirv_compiler.h:20
impeller::compiler::SPIRVCompiler
Definition: spirv_compiler.h:54
impeller
Definition: aiks_context.cc:10
impeller::compiler::SPIRVCompilerOptions::optimization_level
shaderc_optimization_level optimization_level
Definition: spirv_compiler.h:39
impeller::compiler::SPIRVCompilerTargetEnv
Definition: spirv_compiler.h:23