|
17 | 17 |
|
18 | 18 | #include <d3dcompiler.h> |
19 | 19 |
|
| 20 | +//#define DEBUG_LIBS 1 |
| 21 | + |
20 | 22 | #pragma pack(push, 1) |
21 | 23 | struct CacheIndexEntry |
22 | 24 | { |
@@ -189,6 +191,10 @@ bool D3D12ShaderCache::CreateNew( |
189 | 191 | bool D3D12ShaderCache::ReadExisting(const std::string& index_filename, const std::string& blob_filename, |
190 | 192 | std::FILE*& index_file, std::FILE*& blob_file, CacheIndex& index) |
191 | 193 | { |
| 194 | +#if DEBUG_LIBS |
| 195 | + return false; |
| 196 | +#endif |
| 197 | + |
192 | 198 | index_file = FileSystem::OpenCFile(index_filename.c_str(), "r+b"); |
193 | 199 | if (!index_file) |
194 | 200 | { |
@@ -591,6 +597,26 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob( |
591 | 597 | { |
592 | 598 | ComPtr<ID3DBlob> blob; |
593 | 599 |
|
| 600 | +#if DEBUG_LIBS |
| 601 | + { |
| 602 | + std::vector<std::string> macro_list; |
| 603 | + |
| 604 | + if (macros) |
| 605 | + { |
| 606 | + const D3D_SHADER_MACRO* c_macro = macros; |
| 607 | + |
| 608 | + while (c_macro->Name != nullptr) |
| 609 | + { |
| 610 | + macro_list.push_back(fmt::format("{} = {}", c_macro->Name, c_macro->Definition)); |
| 611 | + c_macro++; |
| 612 | + } |
| 613 | + } |
| 614 | + |
| 615 | + Console.WriteLnFmt("Compiling {} with macros:\n\t{}", shader_name, |
| 616 | + macro_list.empty() ? "None" : StringUtil::JoinString(macro_list.begin(), macro_list.end(), "\n\t")); |
| 617 | + } |
| 618 | +#endif |
| 619 | + |
594 | 620 | switch (key.type) |
595 | 621 | { |
596 | 622 | case EntryType::VertexShader: |
@@ -713,6 +739,21 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob( |
713 | 739 | { |
714 | 740 | pxAssert(key.type != EntryType::LibraryShader); |
715 | 741 |
|
| 742 | +#if DEBUG_LIBS |
| 743 | + { |
| 744 | + std::vector<std::string> macro_list; |
| 745 | + const D3D_SHADER_MACRO* c_macro = macros; |
| 746 | + while (c_macro->Name != nullptr) |
| 747 | + { |
| 748 | + macro_list.push_back(fmt::format("{} = {}", c_macro->Name, c_macro->Definition)); |
| 749 | + c_macro++; |
| 750 | + } |
| 751 | + |
| 752 | + Console.WriteLnFmt("Compiling linked shader with macros:\n\t{}", |
| 753 | + macro_list.empty() ? "None" : StringUtil::JoinString(macro_list.begin(), macro_list.end(), "\n\t")); |
| 754 | + } |
| 755 | +#endif |
| 756 | + |
716 | 757 | std::vector<ComPtr<ID3DBlob>> compiled_blobs; |
717 | 758 | compiled_blobs.reserve(shader.size()); |
718 | 759 |
|
|
0 commit comments