Skip to content

Commit 787a028

Browse files
committed
GS/DX12: Add ability to log macros
1 parent d056bbb commit 787a028

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
{
@@ -591,6 +597,26 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob(
591597
{
592598
ComPtr<ID3DBlob> blob;
593599

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+
594620
switch (key.type)
595621
{
596622
case EntryType::VertexShader:
@@ -713,6 +739,21 @@ D3D12ShaderCache::ComPtr<ID3DBlob> D3D12ShaderCache::CompileAndAddShaderBlob(
713739
{
714740
pxAssert(key.type != EntryType::LibraryShader);
715741

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+
716757
std::vector<ComPtr<ID3DBlob>> compiled_blobs;
717758
compiled_blobs.reserve(shader.size());
718759

0 commit comments

Comments
 (0)