|
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 | { |
@@ -562,6 +568,26 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob( |
562 | 568 | { |
563 | 569 | ComPtr<ID3DBlob> blob; |
564 | 570 |
|
| 571 | +#if DEBUG_LIBS |
| 572 | + { |
| 573 | + std::vector<std::string> macro_list; |
| 574 | + |
| 575 | + if (macros) |
| 576 | + { |
| 577 | + const D3D_SHADER_MACRO* c_macro = macros; |
| 578 | + |
| 579 | + while (c_macro->Name != nullptr) |
| 580 | + { |
| 581 | + macro_list.push_back(fmt::format("{} = {}", c_macro->Name, c_macro->Definition)); |
| 582 | + c_macro++; |
| 583 | + } |
| 584 | + } |
| 585 | + |
| 586 | + Console.WriteLnFmt("Compiling {} with macros:\n\t{}", shader_name, |
| 587 | + macro_list.empty() ? "None" : StringUtil::JoinString(macro_list.begin(), macro_list.end(), "\n\t")); |
| 588 | + } |
| 589 | +#endif |
| 590 | + |
565 | 591 | switch (key.type) |
566 | 592 | { |
567 | 593 | case EntryType::VertexShader: |
@@ -684,6 +710,21 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob( |
684 | 710 | { |
685 | 711 | pxAssert(key.type != EntryType::LibraryShader); |
686 | 712 |
|
| 713 | +#if DEBUG_LIBS |
| 714 | + { |
| 715 | + std::vector<std::string> macro_list; |
| 716 | + const D3D_SHADER_MACRO* c_macro = macros; |
| 717 | + while (c_macro->Name != nullptr) |
| 718 | + { |
| 719 | + macro_list.push_back(fmt::format("{} = {}", c_macro->Name, c_macro->Definition)); |
| 720 | + c_macro++; |
| 721 | + } |
| 722 | + |
| 723 | + Console.WriteLnFmt("Compiling linked shader with macros:\n\t{}", |
| 724 | + macro_list.empty() ? "None" : StringUtil::JoinString(macro_list.begin(), macro_list.end(), "\n\t")); |
| 725 | + } |
| 726 | +#endif |
| 727 | + |
687 | 728 | std::vector<ComPtr<ID3DBlob>> compiled_blobs; |
688 | 729 | compiled_blobs.reserve(shader.size()); |
689 | 730 |
|
|
0 commit comments