| 654 | } |
| 655 | template <bool force_source = false> |
| 656 | void write_location(std::string &s, const location &loc) |
| 657 | { |
| 658 | if (loc.source.empty() || !_debug_info) |
| 659 | return; |
| 660 | |
| 661 | s += "#line " + std::to_string(loc.line); |
| 662 | |
| 663 | size_t offset = s.size(); |
| 664 | |
| 665 | // Avoid writing the file name every time to reduce output text size |
| 666 | if constexpr (force_source) |
| 667 | { |
| 668 | s += " \"" + loc.source + '\"'; |
| 669 | } |
| 670 | else if (loc.source != _current_location) |
| 671 | { |
| 672 | s += " \"" + loc.source + '\"'; |
| 673 | |
| 674 | _current_location = loc.source; |
| 675 | } |
| 676 | |
| 677 | // Need to escape string for new DirectX Shader Compiler (dxc) |
| 678 | if (_shader_model >= 60) |
| 679 | { |
| 680 | for (; (offset = s.find('\\', offset)) != std::string::npos; offset += 2) |
| 681 | s.insert(offset, "\\", 1); |
| 682 | } |
| 683 | |
| 684 | s += '\n'; |
| 685 | } |
| 686 | void write_texture_format(std::string &s, texture_format format) |
| 687 | { |
| 688 | switch (format) |
no test coverage detected