blob: 261ae9083057637e9cd988815c659ca47d5cfda9 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_IMPELLER_COMPILER_COMPILER_H_
#define FLUTTER_IMPELLER_COMPILER_COMPILER_H_
#include <initializer_list>
#include <sstream>
#include <string>
#include "flutter/fml/mapping.h"
#include "impeller/compiler/include_dir.h"
#include "impeller/compiler/reflector.h"
#include "impeller/compiler/source_options.h"
#include "impeller/compiler/spirv_compiler.h"
#include "impeller/compiler/types.h"
#include "spirv_msl.hpp"
#include "spirv_parser.hpp"
#include "third_party/abseil-cpp/absl/status/status.h"
namespace impeller {
namespace compiler {
class Compiler {
public:
Compiler(const std::shared_ptr<const fml::Mapping>& source_mapping,
const SourceOptions& options,
Reflector::Options reflector_options);
~Compiler();
bool IsValid() const;
std::shared_ptr<fml::Mapping> GetSPIRVAssembly() const;
std::shared_ptr<fml::Mapping> GetSLShaderSource() const;
std::string GetErrorMessages() const;
/// Gets verbose error messages if available.
///
/// This is only populated when GetErrorMessages() returns a truncated error
/// message. If GetErrorMessages() did not have to be truncated, this will
/// return an empty string.
std::string GetVerboseErrorMessages() const;
const std::vector<std::string>& GetIncludedFileNames() const;
std::unique_ptr<fml::Mapping> CreateDepfileContents(
std::initializer_list<std::string> targets) const;
const Reflector* GetReflector() const;
private:
SourceOptions options_;
std::shared_ptr<fml::Mapping> spirv_assembly_;
std::shared_ptr<fml::Mapping> sl_mapping_;
std::stringstream error_stream_;
std::stringstream verbose_error_stream_;
std::unique_ptr<Reflector> reflector_;
std::vector<std::string> included_file_names_;
bool is_valid_ = false;
std::string GetSourcePrefix() const;
std::string GetDependencyNames(const std::string& separator) const;
absl::Status ValidateSkSLResult(const std::string& sksl);
Compiler(const Compiler&) = delete;
Compiler& operator=(const Compiler&) = delete;
};
} // namespace compiler
} // namespace impeller
#endif // FLUTTER_IMPELLER_COMPILER_COMPILER_H_