| 24 | }; |
| 25 | |
| 26 | static bool tryGetEmbeddedShaderSource(String path, std::string& data) { |
| 27 | #if DORA_HAS_EMBEDDED_BGFX_SHADERS |
| 28 | std::string file = path.toString(); |
| 29 | while (!file.empty() && file.front() == '/') { |
| 30 | file.erase(file.begin()); |
| 31 | } |
| 32 | auto pos = file.find_last_of("/\\"); |
| 33 | if (pos != std::string::npos) { |
| 34 | file.erase(0, pos + 1); |
| 35 | } |
| 36 | if (file == "bgfx_shader.sh") { |
| 37 | data = BgfxEmbeddedShaders::kBgfxShaderSh; |
| 38 | return true; |
| 39 | } |
| 40 | if (file == "bgfx_compute.sh") { |
| 41 | data = BgfxEmbeddedShaders::kBgfxComputeSh; |
| 42 | return true; |
| 43 | } |
| 44 | #else |
| 45 | DORA_UNUSED_PARAM(path); |
| 46 | DORA_UNUSED_PARAM(data); |
| 47 | #endif |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | static const std::string& loadShaderFileData(ShaderCompilerFileContext& context, String path) { |
| 52 | std::string key = path.toString(); |