Flutter Engine
The Flutter Engine
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#ifndef FLUTTER_IMPELLER_COMPILER_SPIRV_COMPILER_H_
6#define FLUTTER_IMPELLER_COMPILER_SPIRV_COMPILER_H_
7
8#include <cstdint>
9#include <vector>
10
11#include "flutter/fml/mapping.h"
14#include "shaderc/shaderc.hpp"
15
16namespace impeller {
17namespace compiler {
18
20 shaderc_profile profile = shaderc_profile_core;
21 uint32_t version = 460;
22};
23
25 shaderc_target_env env = shaderc_target_env::shaderc_target_env_vulkan;
26 shaderc_env_version version =
27 shaderc_env_version::shaderc_env_version_vulkan_1_1;
28 shaderc_spirv_version spirv_version =
29 shaderc_spirv_version::shaderc_spirv_version_1_3;
30};
31
34 //----------------------------------------------------------------------------
35 // Source Options.
36 //----------------------------------------------------------------------------
37 std::optional<shaderc_source_language> source_langauge;
38 std::optional<SPIRVCompilerSourceProfile> source_profile;
39
40 shaderc_optimization_level optimization_level =
41 shaderc_optimization_level::shaderc_optimization_level_performance;
42
43 //----------------------------------------------------------------------------
44 // Target Options.
45 //----------------------------------------------------------------------------
46 std::optional<SPIRVCompilerTargetEnv> target;
47
48 std::vector<std::string> macro_definitions;
49
50 std::shared_ptr<Includer> includer;
51
53
54 shaderc::CompileOptions BuildShadercOptions() const;
55};
56
58 public:
60 std::shared_ptr<const fml::Mapping> sources);
61
63
64 std::shared_ptr<fml::Mapping> CompileToSPV(
65 std::stringstream& error_stream,
66 const shaderc::CompileOptions& spirv_options) const;
67
68 private:
69 SourceOptions options_;
70 const std::shared_ptr<const fml::Mapping> sources_;
71
72 std::string GetSourcePrefix() const;
73
74 SPIRVCompiler(const SPIRVCompiler&) = delete;
75
76 SPIRVCompiler& operator=(const SPIRVCompiler&) = delete;
77};
78
79} // namespace compiler
80} // namespace impeller
81
82#endif // FLUTTER_IMPELLER_COMPILER_SPIRV_COMPILER_H_
const char * options
std::shared_ptr< fml::Mapping > CompileToSPV(std::stringstream &error_stream, const shaderc::CompileOptions &spirv_options) const
SPIRVCompiler(const SourceOptions &options, std::shared_ptr< const fml::Mapping > sources)
Definition: __init__.py:1
std::optional< shaderc_source_language > source_langauge
std::vector< std::string > macro_definitions
shaderc_optimization_level optimization_level
std::optional< SPIRVCompilerSourceProfile > source_profile
std::shared_ptr< Includer > includer
shaderc::CompileOptions BuildShadercOptions() const
std::optional< SPIRVCompilerTargetEnv > target