From 8b82fbb44901eed3390e9d9e844532a20ce43fdf Mon Sep 17 00:00:00 2001 From: TJnotJT Date: Fri, 1 May 2026 19:47:47 -0400 Subject: [PATCH] GS/HW: Add constant buffer dumping. --- pcsx2/GS/Renderers/Common/GSDevice.cpp | 61 ++++++++++++++++++++++++-- pcsx2/GS/Renderers/Common/GSDevice.h | 3 +- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/Renderers/Common/GSDevice.cpp b/pcsx2/GS/Renderers/Common/GSDevice.cpp index 597143e6e5..f78405e4ef 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.cpp +++ b/pcsx2/GS/Renderers/Common/GSDevice.cpp @@ -1559,8 +1559,51 @@ static void DumpBlendMultipass(DrawConfigWriter& out, const GSHWDrawConfig::Blen DumpBlendState(out.WithIndent(), bmp.blend); } +template +static void DumpVector4(DrawConfigWriter& out, const char* name, const T& val) +{ + out.WriteLn("{}: [{}, {}, {}, {}]", name, val.x, val.y, val.z, val.w); +}; + +template +static void DumpVector2(DrawConfigWriter& out, const char* name, const T& val) +{ + out.WriteLn("{}: [{}, {}]", name, val.x, val.y); +}; + +static void DumpPSConstantBuffer(DrawConfigWriter& out, const GSHWDrawConfig::PSConstantBuffer& cb) +{ + DumpVector4(out, "FogColor_AREF", cb.FogColor_AREF); + DumpVector4(out, "WH", cb.WH); + DumpVector4(out, "TA_MaxDepth_Af", cb.TA_MaxDepth_Af); + DumpVector4(out, "FbMask", cb.FbMask); + DumpVector4(out, "HalfTexel", cb.HalfTexel); + DumpVector4(out, "MinMax", cb.MinMax); + DumpVector4(out, "LODParams", cb.LODParams); + DumpVector4(out, "STRange", cb.STRange); + DumpVector4(out, "ChannelShuffle", cb.ChannelShuffle); + DumpVector2(out, "ChannelShuffleOffset", cb.ChannelShuffleOffset); + DumpVector2(out, "TCOffsetHack", cb.TCOffsetHack); + DumpVector2(out, "STScale", cb.STScale); + DumpVector4(out, "DitherMatrix_0", cb.DitherMatrix[0]); + DumpVector4(out, "DitherMatrix_1", cb.DitherMatrix[1]); + DumpVector4(out, "DitherMatrix_2", cb.DitherMatrix[2]); + DumpVector4(out, "DitherMatrix_3", cb.DitherMatrix[3]); + DumpVector4(out, "ScaleFactor", cb.ScaleFactor); +} + +static void DumpVSConstantBuffer(DrawConfigWriter& out, const GSHWDrawConfig::VSConstantBuffer& cb) +{ + DumpVector2(out, "vertex_scale", cb.vertex_scale); + DumpVector2(out, "vertex_offset", cb.vertex_offset); + DumpVector2(out, "texture_scale", cb.texture_scale); + DumpVector2(out, "texture_offset", cb.texture_offset); + DumpVector2(out, "point_size", cb.point_size); + DumpVector2(out, "max_depth", cb.max_depth); +} + static void DumpConfig(DrawConfigWriter& out, const GSHWDrawConfig& conf, - bool ps, bool vs, bool bs, bool dss, bool ss, bool asp, bool bmp) + bool ps, bool vs, bool bs, bool dss, bool ss, bool asp, bool bmp, bool cbvs, bool cbps) { out.WriteLn("topology: {} ({})", GetTopologyName(conf.topology), static_cast(conf.topology)); out.WriteLn("require_one_barrier: {}", conf.require_one_barrier); @@ -1612,15 +1655,27 @@ static void DumpConfig(DrawConfigWriter& out, const GSHWDrawConfig& conf, out.WriteLn("blend_multi_pass:"); DumpBlendMultipass(out.WithIndent(), conf.blend_multi_pass); } + + if (cbvs) + { + out.WriteLn("cb_vs:"); + DumpVSConstantBuffer(out.WithIndent(), conf.cb_vs); + } + + if (cbps) + { + out.WriteLn("cb_ps:"); + DumpPSConstantBuffer(out.WithIndent(), conf.cb_ps); + } } void GSHWDrawConfig::DumpConfig(const std::string& path, const GSHWDrawConfig& conf, - bool ps, bool vs, bool bs, bool dss, bool ss, bool asp, bool bmp) + bool ps, bool vs, bool bs, bool dss, bool ss, bool asp, bool bmp, bool cbvs, bool cbps) { if (FileSystem::ManagedCFilePtr file = FileSystem::OpenManagedCFile(path.c_str(), "w")) { DrawConfigWriter writer; - ::DumpConfig(writer, conf, ps, vs, bs, dss, ss, asp, bmp); + ::DumpConfig(writer, conf, ps, vs, bs, dss, ss, asp, bmp, cbvs, cbps); fwrite(writer.buffer.data(), 1, writer.buffer.size(), file.get()); } } diff --git a/pcsx2/GS/Renderers/Common/GSDevice.h b/pcsx2/GS/Renderers/Common/GSDevice.h index bec2488da7..fb4b66149f 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.h +++ b/pcsx2/GS/Renderers/Common/GSDevice.h @@ -879,7 +879,8 @@ struct alignas(16) GSHWDrawConfig // Dumping static void DumpConfig(const std::string& path, const GSHWDrawConfig& conf, - bool ps = true, bool vs = true, bool bs = true, bool dss = true, bool ss = true, bool asp = true, bool bmp = true); + bool ps = true, bool vs = true, bool bs = true, bool dss = true, bool ss = true, bool asp = true, bool bmp = true, + bool cbvs = true, bool cbps = true); }; static inline u32 GetExpansionFactor(GSHWDrawConfig::VSExpand expand)