Skip to content

Commit 4d32c74

Browse files
committed
GS/DX12: Add ability to log macros
1 parent b31109b commit 4d32c74

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

pcsx2/GS/Renderers/DX12/D3D12ShaderCache.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#include <d3dcompiler.h>
1919

20+
//#define DEBUG_LIBS 1
21+
2022
#pragma pack(push, 1)
2123
struct CacheIndexEntry
2224
{
@@ -189,6 +191,10 @@ bool D3D12ShaderCache::CreateNew(
189191
bool D3D12ShaderCache::ReadExisting(const std::string& index_filename, const std::string& blob_filename,
190192
std::FILE*& index_file, std::FILE*& blob_file, CacheIndex& index)
191193
{
194+
#if DEBUG_LIBS
195+
return false;
196+
#endif
197+
192198
index_file = FileSystem::OpenCFile(index_filename.c_str(), "r+b");
193199
if (!index_file)
194200
{
@@ -562,6 +568,26 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob(
562568
{
563569
ComPtr<ID3DBlob> blob;
564570

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+
565591
switch (key.type)
566592
{
567593
case EntryType::VertexShader:
@@ -684,6 +710,21 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob(
684710
{
685711
pxAssert(key.type != EntryType::LibraryShader);
686712

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+
687728
std::vector<ComPtr<ID3DBlob>> compiled_blobs;
688729
compiled_blobs.reserve(shader.size());
689730

0 commit comments

Comments
 (0)