| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <map> |
| 7 |
#include <memory> |
| 8 |
#include <string> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include <glslang/Public/ShaderLang.h> |
| 12 |
|
| 13 |
namespace VideoCommon |
| 14 |
{ |
| 15 |
class ShaderIncluder final : public glslang::TShader::Includer |
| 16 |
{ |
| 17 |
public: |
| 18 |
ShaderIncluder(std::string user_path, std::string system_path); |
| 19 |
~ShaderIncluder() override = default; |
| 20 |
|
| 21 |
std::vector<std::string> GetIncludes() const; |
| 22 |
|
| 23 |
private: |
| 24 |
IncludeResult* includeLocal(const char* header_name, const char* includer_name, |
| 25 |
std::size_t depth) override; |
| 26 |
IncludeResult* includeSystem(const char* header_name, const char* includer_name, |
| 27 |
std::size_t depth) override; |
| 28 |
void releaseInclude(IncludeResult* result) override; |
| 29 |
|
| 30 |
IncludeResult* ProcessInclude(const std::string& root, const char* header_name, |
| 31 |
const char* includer_name, std::size_t depth); |
| 32 |
std::string_view GetDirectory(std::string_view path) const; |
| 33 |
|
| 34 |
std::string m_root_user_path; |
| 35 |
std::string m_root_system_path; |
| 36 |
std::vector<std::string> m_dirs; |
| 37 |
|
| 38 |
struct IncludeResultData |
| 39 |
{ |
| 40 |
std::unique_ptr<IncludeResult> result; |
| 41 |
std::string file_data; |
| 42 |
}; |
| 43 |
std::map<std::string, IncludeResultData, std::less<>> m_include_results; |
| 44 |
}; |
| 45 |
|
| 46 |
} |