| Flutter Impeller |

compiler.cc
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 #include "impeller/compiler/compiler.h"
6
7 #include <filesystem>
8 #include <memory>
9 #include <optional>
10 #include <sstream>
11 #include <string>
12 #include <utility>
13
14 #include "flutter/fml/paths.h"
15 #include "impeller/base/allocation.h"
16 #include "impeller/compiler/compiler_backend.h"
17 #include "impeller/compiler/constants.h"
18 #include "impeller/compiler/includer.h"
19 #include "impeller/compiler/logger.h"
20 #include "impeller/compiler/spirv_compiler.h"
21 #include "impeller/compiler/uniform_sorter.h"
22 #include "impeller/compiler/utilities.h"
23
24 namespace impeller {
25 namespace compiler {
26
27 static uint32_t ParseMSLVersion(const std::string& msl_version) {
28 std::stringstream sstream(msl_version);
29 std::string version_part;
30 uint32_t major = 1;
31 uint32_t minor = 2;
32 uint32_t patch = 0;
33 if (std::getline(sstream, version_part, '.')) {
34 major = std::stoi(version_part);
35 if (std::getline(sstream, version_part, '.')) {
36 minor = std::stoi(version_part);
37 if (std::getline(sstream, version_part, '.')) {
38 patch = std::stoi(version_part);
39 }
40 }
41 }
42 if (major < 1 || (major == 1 && minor < 2)) {
43 std::cerr << "--metal-version version must be at least 1.2. Have "
44 << msl_version << std::endl;
45 }
46 return spirv_cross::CompilerMSL::Options::make_msl_version(major, minor,
47 patch);
48 }
49
50 static CompilerBackend CreateMSLCompiler(
51 const spirv_cross::ParsedIR& ir,
52 const SourceOptions& source_options,
53 std::optional<uint32_t> msl_version_override = {}) {
54 auto sl_compiler = std::make_shared<spirv_cross::CompilerMSL>(ir);
55 spirv_cross::CompilerMSL::Options sl_options;
56 sl_options.platform =
57 TargetPlatformToMSLPlatform(source_options.target_platform);
58 sl_options.msl_version = msl_version_override.value_or(
59 ParseMSLVersion(source_options.metal_version));
60 sl_options.ios_use_simdgroup_functions =
61 sl_options.is_ios() &&
62 sl_options.msl_version >=
63 spirv_cross::CompilerMSL::Options::make_msl_version(2, 4, 0);
64 sl_options.use_framebuffer_fetch_subpasses = true;
65 sl_compiler->set_msl_options(sl_options);
66
67 // Sort the float and sampler uniforms according to their declared/decorated
68 // order. For user authored fragment shaders, the API for setting uniform
69 // values uses the index of the uniform in the declared order. By default, the
70 // metal backend of spirv-cross will order uniforms according to usage. To fix
71 // this, we use the sorted order and the add_msl_resource_binding API to force
72 // the ordering to match the declared order. Note that while this code runs
73 // for all compiled shaders, it will only affect fragment shaders due to the
74 // specified stage.
75 auto floats =
76 SortUniforms(&ir, sl_compiler.get(), spirv_cross::SPIRType::Float);
77 auto images =
78 SortUniforms(&ir, sl_compiler.get(), spirv_cross::SPIRType::SampledImage);
79
80 uint32_t buffer_offset = 0;
81 uint32_t sampler_offset = 0;
82 for (auto& float_id : floats) {
83 sl_compiler->add_msl_resource_binding(
84 {.stage = spv::ExecutionModel::ExecutionModelFragment,
85 .basetype = spirv_cross::SPIRType::BaseType::Float,
86 .desc_set = sl_compiler->get_decoration(float_id,
87 spv::DecorationDescriptorSet),
88 .binding =
89 sl_compiler->get_decoration(float_id, spv::DecorationBinding),
90 .count = 1u,
91 .msl_buffer = buffer_offset});
92 buffer_offset++;
93 }
94 for (auto& image_id : images) {
95 sl_compiler->add_msl_resource_binding({
96 .stage = spv::ExecutionModel::ExecutionModelFragment,
97 .basetype = spirv_cross::SPIRType::BaseType::SampledImage,
98 .desc_set =
99 sl_compiler->get_decoration(image_id, spv::DecorationDescriptorSet),
100 .binding =
101 sl_compiler->get_decoration(image_id, spv::DecorationBinding),
102 .count = 1u,
103 // A sampled image is both an image and a sampler, so both
104 // offsets need to be set or depending on the partiular shader
105 // the bindings may be incorrect.
106 .msl_texture = sampler_offset,
107 .msl_sampler = sampler_offset,
108 });
109 sampler_offset++;
110 }
111
112 return CompilerBackend(sl_compiler);
113 }
114
115 static CompilerBackend CreateVulkanCompiler(
116 const spirv_cross::ParsedIR& ir,
117 const SourceOptions& source_options) {
118 // TODO(dnfield): It seems like what we'd want is a CompilerGLSL with
119 // vulkan_semantics set to true, but that has regressed some things on GLES
120 // somehow. In the mean time, go back to using CompilerMSL, but set the Metal
121 // Language version to something really high so that we don't get weird
122 // complaints about using Metal features while trying to build Vulkan shaders.
123 // https://github.com/flutter/flutter/issues/123795
124 return CreateMSLCompiler(
125 ir, source_options,
126 spirv_cross::CompilerMSL::Options::make_msl_version(3, 0, 0));
127 }
128
129 static CompilerBackend CreateGLSLCompiler(const spirv_cross::ParsedIR& ir,
130 const SourceOptions& source_options) {
131 auto gl_compiler = std::make_shared<spirv_cross::CompilerGLSL>(ir);
132
133 // Walk the variables and insert the external image extension if any of them
134 // begins with the external texture prefix. Unfortunately, we can't walk
135 // `gl_compiler->get_shader_resources().separate_samplers` until the compiler
136 // is further along.
137 //
138 // Unfortunately, we can't just let the shader author add this extension and
139 // use `samplerExternalOES` directly because compiling to spirv requires the
140 // source language profile to be at least 310 ES, but this extension is
141 // incompatible with ES 310+.
142 for (auto& id : ir.ids_for_constant_or_variable) {
143 if (StringStartsWith(ir.get_name(id), kExternalTexturePrefix)) {
144 gl_compiler->require_extension("GL_OES_EGL_image_external");
145 break;
146 }
147 }
148
149 spirv_cross::CompilerGLSL::Options sl_options;
150 sl_options.force_zero_initialized_variables = true;
151 sl_options.vertex.fixup_clipspace = true;
152 if (source_options.target_platform == TargetPlatform::kOpenGLES ||
153 source_options.target_platform == TargetPlatform::kRuntimeStageGLES) {
154 sl_options.version = source_options.gles_language_version > 0
155 ? source_options.gles_language_version
156 : 100;
157 sl_options.es = true;
158 gl_compiler->set_variable_type_remap_callback(
159 [&](const spirv_cross::SPIRType& type, const std::string& var_name,
160 std::string& name_of_type) {
161 if (StringStartsWith(var_name, kExternalTexturePrefix)) {
162 name_of_type = "samplerExternalOES";
163 }
164 });
165 } else {
166 sl_options.version = source_options.gles_language_version > 0
167 ? source_options.gles_language_version
168 : 120;
169 sl_options.es = false;
170 }
171 gl_compiler->set_common_options(sl_options);
172 return CompilerBackend(gl_compiler);
173 }
174
175 static CompilerBackend CreateSkSLCompiler(const spirv_cross::ParsedIR& ir,
176 const SourceOptions& source_options) {
177 auto sksl_compiler = std::make_shared<CompilerSkSL>(ir);
178 return CompilerBackend(sksl_compiler);
179 }
180
181 static bool EntryPointMustBeNamedMain(TargetPlatform platform) {
182 switch (platform) {
183 case TargetPlatform::kUnknown:
184 FML_UNREACHABLE();
185 case TargetPlatform::kMetalDesktop:
186 case TargetPlatform::kMetalIOS:
187 case TargetPlatform::kVulkan:
188 case TargetPlatform::kRuntimeStageMetal:
189 case TargetPlatform::kRuntimeStageVulkan:
190 return false;
191 case TargetPlatform::kSkSL:
192 case TargetPlatform::kOpenGLES:
193 case TargetPlatform::kOpenGLDesktop:
194 case TargetPlatform::kRuntimeStageGLES:
195 return true;
196 }
197 FML_UNREACHABLE();
198 }
199
200 static CompilerBackend CreateCompiler(const spirv_cross::ParsedIR& ir,
201 const SourceOptions& source_options) {
202 CompilerBackend compiler;
203 switch (source_options.target_platform) {
204 case TargetPlatform::kMetalDesktop:
205 case TargetPlatform::kMetalIOS:
206 case TargetPlatform::kRuntimeStageMetal:
207 compiler = CreateMSLCompiler(ir, source_options);
208 break;
209 case TargetPlatform::kVulkan:
210 case TargetPlatform::kRuntimeStageVulkan:
211 compiler = CreateVulkanCompiler(ir, source_options);
212 break;
213 case TargetPlatform::kUnknown:
214 case TargetPlatform::kOpenGLES:
215 case TargetPlatform::kOpenGLDesktop:
216 case TargetPlatform::kRuntimeStageGLES:
217 compiler = CreateGLSLCompiler(ir, source_options);
218 break;
219 case TargetPlatform::kSkSL:
220 compiler = CreateSkSLCompiler(ir, source_options);
221 }
222 if (!compiler) {
223 return {};
224 }
225 auto* backend = compiler.GetCompiler();
226 if (!EntryPointMustBeNamedMain(source_options.target_platform) &&
227 source_options.source_language == SourceLanguage::kGLSL) {
228 backend->rename_entry_point("main", source_options.entry_point_name,
229 ToExecutionModel(source_options.type));
230 }
231 return compiler;
232 }
233
234 Compiler::Compiler(const std::shared_ptr<const fml::Mapping>& source_mapping,
235 const SourceOptions& source_options,
236 Reflector::Options reflector_options)
237 : options_(source_options) {
238 if (!source_mapping || source_mapping->GetMapping() == nullptr) {
239 COMPILER_ERROR(error_stream_)
240 << "Could not read shader source or shader source was empty.";
241 return;
242 }
243
244 if (source_options.target_platform == TargetPlatform::kUnknown) {
245 COMPILER_ERROR(error_stream_) << "Target platform not specified.";
246 return;
247 }
248
249 SPIRVCompilerOptions spirv_options;
250
251 // Make sure reflection is as effective as possible. The generated shaders
252 // will be processed later by backend specific compilers.
253 spirv_options.generate_debug_info = true;
254
255 switch (options_.source_language) {
256 case SourceLanguage::kGLSL:
257 // Expects GLSL 4.60 (Core Profile).
258 // https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf
259 spirv_options.source_langauge =
260 shaderc_source_language::shaderc_source_language_glsl;
261 spirv_options.source_profile = SPIRVCompilerSourceProfile{
262 shaderc_profile::shaderc_profile_core, //
263 460, //
264 };
265 break;
266 case SourceLanguage::kHLSL:
267 spirv_options.source_langauge =
268 shaderc_source_language::shaderc_source_language_hlsl;
269 break;
270 case SourceLanguage::kUnknown:
271 COMPILER_ERROR(error_stream_) << "Source language invalid.";
272 return;
273 }
274
275 switch (source_options.target_platform) {
276 case TargetPlatform::kMetalDesktop:
277 case TargetPlatform::kMetalIOS: {
278 SPIRVCompilerTargetEnv target;
279
280 if (source_options.use_half_textures) {
281 target.env = shaderc_target_env::shaderc_target_env_opengl;
282 target.version = shaderc_env_version::shaderc_env_version_opengl_4_5;
283 target.spirv_version = shaderc_spirv_version::shaderc_spirv_version_1_0;
284 } else {
285 target.env = shaderc_target_env::shaderc_target_env_vulkan;
286 target.version = shaderc_env_version::shaderc_env_version_vulkan_1_1;
287 target.spirv_version = shaderc_spirv_version::shaderc_spirv_version_1_3;
288 }
289
290 spirv_options.target = target;
291 } break;
292 case TargetPlatform::kOpenGLES:
293 case TargetPlatform::kOpenGLDesktop:
294 case TargetPlatform::kVulkan: {
295 SPIRVCompilerTargetEnv target;
296
297 target.env = shaderc_target_env::shaderc_target_env_vulkan;
298 target.version = shaderc_env_version::shaderc_env_version_vulkan_1_1;
299 target.spirv_version = shaderc_spirv_version::shaderc_spirv_version_1_3;
300
301 spirv_options.target = target;
302 } break;
303 case TargetPlatform::kRuntimeStageMetal:
304 case TargetPlatform::kRuntimeStageGLES:
305 case TargetPlatform::kRuntimeStageVulkan: {
306 SPIRVCompilerTargetEnv target;
307
308 target.env = shaderc_target_env::shaderc_target_env_opengl;
309 target.version = shaderc_env_version::shaderc_env_version_opengl_4_5;
310 target.spirv_version = shaderc_spirv_version::shaderc_spirv_version_1_0;
311
312 spirv_options.target = target;
313 spirv_options.macro_definitions.push_back("IMPELLER_GRAPHICS_BACKEND");
314 } break;
315 case TargetPlatform::kSkSL: {
316 SPIRVCompilerTargetEnv target;
317
318 target.env = shaderc_target_env::shaderc_target_env_opengl;
319 target.version = shaderc_env_version::shaderc_env_version_opengl_4_5;
320 target.spirv_version = shaderc_spirv_version::shaderc_spirv_version_1_0;
321
322 // When any optimization level above 'zero' is enabled, the phi merges at
323 // loop continue blocks are rendered using syntax that is supported in
324 // GLSL, but not in SkSL.
325 // https://bugs.chromium.org/p/skia/issues/detail?id=13518.
326 spirv_options.optimization_level =
327 shaderc_optimization_level::shaderc_optimization_level_zero;
328 spirv_options.target = target;
329 spirv_options.macro_definitions.push_back("SKIA_GRAPHICS_BACKEND");
330 } break;
331 case TargetPlatform::kUnknown:
332 COMPILER_ERROR(error_stream_) << "Target platform invalid.";
333 return;
334 }
335
336 // Implicit definition that indicates that this compilation is for the device
337 // (instead of the host).
338 spirv_options.macro_definitions.push_back("IMPELLER_DEVICE");
339 for (const auto& define : source_options.defines) {
340 spirv_options.macro_definitions.push_back(define);
341 }
342
343 std::vector<std::string> included_file_names;
344 spirv_options.includer = std::make_shared<Includer>(
345 options_.working_directory, options_.include_dirs,
346 [&included_file_names](auto included_name) {
347 included_file_names.emplace_back(std::move(included_name));
348 });
349
350 // SPIRV Generation.
351 SPIRVCompiler spv_compiler(source_options, source_mapping);
352
353 spirv_assembly_ = spv_compiler.CompileToSPV(
354 error_stream_, spirv_options.BuildShadercOptions());
355
356 if (!spirv_assembly_) {
357 return;
358 } else {
359 included_file_names_ = std::move(included_file_names);
360 }
361
362 // SL Generation.
363 spirv_cross::Parser parser(
364 reinterpret_cast<const uint32_t*>(spirv_assembly_->GetMapping()),
365 spirv_assembly_->GetSize() / sizeof(uint32_t));
366 // The parser and compiler must be run separately because the parser contains
367 // meta information (like type member names) that are useful for reflection.
368 parser.parse();
369
370 const auto parsed_ir =
371 std::make_shared<spirv_cross::ParsedIR>(parser.get_parsed_ir());
372
373 auto sl_compiler = CreateCompiler(*parsed_ir, options_);
374
375 if (!sl_compiler) {
376 COMPILER_ERROR(error_stream_)
377 << "Could not create compiler for target platform.";
378 return;
379 }
380
381 // We need to invoke the compiler even if we don't use the SL mapping later
382 // for Vulkan. The reflector needs information that is only valid after a
383 // successful compilation call.
384 auto sl_compilation_result =
385 CreateMappingWithString(sl_compiler.GetCompiler()->compile());
386
387 // If the target is Vulkan, our shading language is SPIRV which we already
388 // have. We just need to strip it of debug information. If it isn't, we need
389 // to invoke the appropriate compiler to compile the SPIRV to the target SL.
390 if (source_options.target_platform == TargetPlatform::kVulkan) {
391 auto stripped_spirv_options = spirv_options;
392 stripped_spirv_options.generate_debug_info = false;
393 sl_mapping_ = spv_compiler.CompileToSPV(
394 error_stream_, stripped_spirv_options.BuildShadercOptions());
395 } else {
396 sl_mapping_ = sl_compilation_result;
397 }
398
399 if (!sl_mapping_) {
400 COMPILER_ERROR(error_stream_) << "Could not generate SL from SPIRV";
401 return;
402 }
403
404 reflector_ = std::make_unique<Reflector>(std::move(reflector_options), //
405 parsed_ir, //
406 GetSLShaderSource(), //
407 sl_compiler //
408 );
409
410 if (!reflector_->IsValid()) {
411 COMPILER_ERROR(error_stream_)
412 << "Could not complete reflection on generated shader.";
413 return;
414 }
415
416 is_valid_ = true;
417 }
418
419 Compiler::~Compiler() = default;
420
421 std::shared_ptr<fml::Mapping> Compiler::GetSPIRVAssembly() const {
422 return spirv_assembly_;
423 }
424
425 std::shared_ptr<fml::Mapping> Compiler::GetSLShaderSource() const {
426 return sl_mapping_;
427 }
428
429 bool Compiler::IsValid() const {
430 return is_valid_;
431 }
432
433 std::string Compiler::GetSourcePrefix() const {
434 std::stringstream stream;
435 stream << options_.file_name << ": ";
436 return stream.str();
437 }
438
439 std::string Compiler::GetErrorMessages() const {
440 return error_stream_.str();
441 }
442
443 const std::vector<std::string>& Compiler::GetIncludedFileNames() const {
444 return included_file_names_;
445 }
446
447 static std::string JoinStrings(std::vector<std::string> items,
448 const std::string& separator) {
449 std::stringstream stream;
450 for (size_t i = 0, count = items.size(); i < count; i++) {
451 const auto is_last = (i == count - 1);
452
453 stream << items[i];
454 if (!is_last) {
455 stream << separator;
456 }
457 }
458 return stream.str();
459 }
460
461 std::string Compiler::GetDependencyNames(const std::string& separator) const {
462 std::vector<std::string> dependencies = included_file_names_;
463 dependencies.push_back(options_.file_name);
464 return JoinStrings(dependencies, separator);
465 }
466
467 std::unique_ptr<fml::Mapping> Compiler::CreateDepfileContents(
468 std::initializer_list<std::string> targets_names) const {
469 // https://github.com/ninja-build/ninja/blob/master/src/depfile_parser.cc#L28
470 const auto targets = JoinStrings(targets_names, " ");
471 const auto dependencies = GetDependencyNames(" ");
472
473 std::stringstream stream;
474 stream << targets << ": " << dependencies << "\n";
475
476 auto contents = std::make_shared<std::string>(stream.str());
477 return std::make_unique<fml::NonOwnedMapping>(
478 reinterpret_cast<const uint8_t*>(contents->data()), contents->size(),
479 [contents](auto, auto) {});
480 }
481
482 const Reflector* Compiler::GetReflector() const {
483 return reflector_.get();
484 }
485
486 } // namespace compiler
487 } // namespace impeller
impeller::compiler::Compiler::~Compiler
~Compiler()
impeller::compiler::CreateVulkanCompiler
static CompilerBackend CreateVulkanCompiler(const spirv_cross::ParsedIR &ir, const SourceOptions &source_options)
Definition: compiler.cc:115
uniform_sorter.h
impeller::compiler::SourceOptions::type
SourceType type
Definition: source_options.h:20
impeller::compiler::Compiler::CreateDepfileContents
std::unique_ptr< fml::Mapping > CreateDepfileContents(std::initializer_list< std::string > targets) const
Definition: compiler.cc:467
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
logger.h
impeller::compiler::CreateSkSLCompiler
static CompilerBackend CreateSkSLCompiler(const spirv_cross::ParsedIR &ir, const SourceOptions &source_options)
Definition: compiler.cc:175
allocation.h
impeller::compiler::SourceOptions::include_dirs
std::vector< IncludeDir > include_dirs
Definition: source_options.h:24
impeller::compiler::CompilerBackend
Definition: compiler_backend.h:19
impeller::compiler::EntryPointMustBeNamedMain
static bool EntryPointMustBeNamedMain(TargetPlatform platform)
Definition: compiler.cc:181
impeller::compiler::ParseMSLVersion
static uint32_t ParseMSLVersion(const std::string &msl_version)
Definition: compiler.cc:27
impeller::compiler::TargetPlatform::kMetalDesktop
@ kMetalDesktop
impeller::compiler::SourceOptions::metal_version
std::string metal_version
Definition: source_options.h:30
impeller::compiler::TargetPlatformToMSLPlatform
spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(TargetPlatform platform)
Definition: types.cc:205
impeller::compiler::SourceOptions
Definition: source_options.h:19
impeller::compiler::SourceOptions::use_half_textures
bool use_half_textures
Whether half-precision textures should be supported, requiring opengl semantics. Only used on metal t...
Definition: source_options.h:34
impeller::compiler::SPIRVCompilerOptions::includer
std::shared_ptr< Includer > includer
Definition: spirv_compiler.h:49
impeller::compiler::CreateGLSLCompiler
static CompilerBackend CreateGLSLCompiler(const spirv_cross::ParsedIR &ir, const SourceOptions &source_options)
Definition: compiler.cc:129
impeller::compiler::TargetPlatform::kMetalIOS
@ kMetalIOS
impeller::compiler::Compiler::Compiler
Compiler(const std::shared_ptr< const fml::Mapping > &source_mapping, const SourceOptions &options, Reflector::Options reflector_options)
Definition: compiler.cc:234
impeller::compiler::TargetPlatform
TargetPlatform
Definition: types.h:28
impeller::compiler::SourceLanguage::kGLSL
@ kGLSL
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::SourceOptions::source_language
SourceLanguage source_language
Definition: source_options.h:22
impeller::compiler::kExternalTexturePrefix
constexpr char kExternalTexturePrefix[]
Definition: constants.h:10
impeller::SortUniforms
std::vector< spirv_cross::ID > SortUniforms(const spirv_cross::ParsedIR *ir, const spirv_cross::Compiler *compiler, std::optional< spirv_cross::SPIRType::BaseType > type_filter, bool include)
Sorts uniform declarations in an IR according to decoration order.
Definition: uniform_sorter.cc:9
impeller::compiler::SPIRVCompilerOptions::target
std::optional< SPIRVCompilerTargetEnv > target
Definition: spirv_compiler.h:45
impeller::compiler::SourceLanguage::kHLSL
@ kHLSL
impeller::compiler::TargetPlatform::kVulkan
@ kVulkan
impeller::compiler::SourceOptions::entry_point_name
std::string entry_point_name
Definition: source_options.h:26
impeller::compiler::Compiler::GetErrorMessages
std::string GetErrorMessages() const
Definition: compiler.cc:439
impeller::compiler::TargetPlatform::kRuntimeStageVulkan
@ kRuntimeStageVulkan
impeller::compiler::Compiler::GetSPIRVAssembly
std::shared_ptr< fml::Mapping > GetSPIRVAssembly() const
Definition: compiler.cc:421
impeller::compiler::SourceOptions::gles_language_version
uint32_t gles_language_version
Definition: source_options.h:27
impeller::compiler::SPIRVCompilerOptions
Definition: spirv_compiler.h:31
impeller::compiler::SPIRVCompilerSourceProfile
Definition: spirv_compiler.h:18
impeller::compiler::JoinStrings
static std::string JoinStrings(std::vector< std::string > items, const std::string &separator)
Definition: compiler.cc:447
impeller::compiler::Reflector
Definition: reflector.h:49
impeller::compiler::Compiler::GetReflector
const Reflector * GetReflector() const
Definition: compiler.cc:482
impeller::compiler::SourceOptions::file_name
std::string file_name
Definition: source_options.h:25
impeller::compiler::Reflector::Options
Definition: reflector.h:51
compiler_backend.h
compiler.h
impeller::compiler::SPIRVCompilerTargetEnv::version
shaderc_env_version version
Definition: spirv_compiler.h:25
spirv_compiler.h
utilities.h
impeller::compiler::SourceLanguage::kUnknown
@ kUnknown
impeller::compiler::CompilerBackend::GetCompiler
spirv_cross::Compiler * GetCompiler()
Definition: compiler_backend.cc:51
impeller::compiler::ToExecutionModel
spv::ExecutionModel ToExecutionModel(SourceType type)
Definition: types.cc:187
impeller::compiler::SPIRVCompilerOptions::source_langauge
std::optional< shaderc_source_language > source_langauge
Definition: spirv_compiler.h:36
impeller::compiler::SourceOptions::working_directory
std::shared_ptr< fml::UniqueFD > working_directory
Definition: source_options.h:23
impeller::compiler::SPIRVCompilerTargetEnv::spirv_version
shaderc_spirv_version spirv_version
Definition: spirv_compiler.h:27
impeller::compiler::SourceOptions::target_platform
TargetPlatform target_platform
Definition: source_options.h:21
impeller::compiler::SPIRVCompilerOptions::macro_definitions
std::vector< std::string > macro_definitions
Definition: spirv_compiler.h:47
impeller::compiler::Compiler::IsValid
bool IsValid() const
Definition: compiler.cc:429
impeller::CreateMappingWithString
std::shared_ptr< fml::Mapping > CreateMappingWithString(std::string string)
Definition: allocation.cc:112
impeller::compiler::SPIRVCompilerOptions::BuildShadercOptions
shaderc::CompileOptions BuildShadercOptions() const
Definition: spirv_compiler.cc:274
impeller::compiler::TargetPlatform::kOpenGLDesktop
@ kOpenGLDesktop
impeller::compiler::SourceOptions::defines
std::vector< std::string > defines
Definition: source_options.h:28
impeller::compiler::TargetPlatform::kUnknown
@ kUnknown
impeller::compiler::TargetPlatform::kOpenGLES
@ kOpenGLES
constants.h
impeller::compiler::Compiler::GetSLShaderSource
std::shared_ptr< fml::Mapping > GetSLShaderSource() const
Definition: compiler.cc:425
impeller::compiler::CreateMSLCompiler
static CompilerBackend CreateMSLCompiler(const spirv_cross::ParsedIR &ir, const SourceOptions &source_options, std::optional< uint32_t > msl_version_override={})
Definition: compiler.cc:50
impeller::compiler::CreateCompiler
static CompilerBackend CreateCompiler(const spirv_cross::ParsedIR &ir, const SourceOptions &source_options)
Definition: compiler.cc:200
impeller::compiler::Compiler::GetIncludedFileNames
const std::vector< std::string > & GetIncludedFileNames() const
Definition: compiler.cc:443
impeller::compiler::TargetPlatform::kRuntimeStageMetal
@ kRuntimeStageMetal
impeller::compiler::SPIRVCompiler
Definition: spirv_compiler.h:54
impeller::compiler::StringStartsWith
bool StringStartsWith(const std::string &target, const std::string &prefix)
Definition: utilities.cc:64
impeller
Definition: aiks_context.cc:10
COMPILER_ERROR
#define COMPILER_ERROR(stream)
Definition: logger.h:37
impeller::compiler::SPIRVCompilerOptions::optimization_level
shaderc_optimization_level optimization_level
Definition: spirv_compiler.h:39
impeller::compiler::TargetPlatform::kSkSL
@ kSkSL
impeller::compiler::TargetPlatform::kRuntimeStageGLES
@ kRuntimeStageGLES
impeller::compiler::SPIRVCompilerTargetEnv
Definition: spirv_compiler.h:23