diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 99549385..19c5e277 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -18,7 +18,13 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) RegisterAssetDumper(std::make_unique()); RegisterAssetDumper(std::make_unique()); - RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique( +#ifdef TECHSET_DEBUG + true +#else + false +#endif + )); RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperSndBank, m_sound_bank) // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) diff --git a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp index 30dcaf02..6f37efe8 100644 --- a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.cpp @@ -209,7 +209,7 @@ namespace return commonTechnique; } - void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset) + void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset, const bool debug) { auto* techniqueState = context.GetZoneAssetDumperState(); const auto* materialConstantState = context.GetZoneAssetDumperState(); @@ -220,7 +220,7 @@ namespace const auto commonTechnique = ConvertToCommonTechnique(*technique); techset::DumpCommonTechnique( - context, commonTechnique, techset::DxVersion::DX9, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState); + context, commonTechnique, techset::DxVersion::DX9, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState, debug); } } } @@ -250,6 +250,11 @@ namespace namespace techset { + DumperT5::DumperT5(const bool debug) + : m_debug(debug) + { + } + void DumperT5::Dump(AssetDumpingContext& context) { context.GetZoneAssetDumperState()->EnsureInitialized(); @@ -260,7 +265,7 @@ namespace techset { const auto* techniqueSet = asset.Asset(); DumpTechset(context, *techniqueSet); - DumpTechniques(context, *techniqueSet); + DumpTechniques(context, *techniqueSet, m_debug); DumpShaders(context, *techniqueSet); } } // namespace techset diff --git a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h index 1d1aef2d..bbaadf35 100644 --- a/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h +++ b/src/ObjWriting/Game/T5/Techset/TechsetDumperT5.h @@ -8,9 +8,14 @@ namespace techset class DumperT5 final : public AbstractAssetDumper { public: + explicit DumperT5(bool debug); + void Dump(AssetDumpingContext& context) override; protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; + + private: + bool m_debug; }; } // namespace techset diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 9f8f7b12..b43d4947 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -35,7 +35,13 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) RegisterAssetDumper(std::make_unique()); RegisterAssetDumper(std::make_unique()); - RegisterAssetDumper(std::make_unique()); + RegisterAssetDumper(std::make_unique( +#ifdef TECHSET_DEBUG + true +#else + false +#endif + )); RegisterAssetDumper(std::make_unique()); RegisterAssetDumper(std::make_unique()); // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp index e696658e..ba204f1c 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp @@ -260,7 +260,7 @@ namespace return commonTechnique; } - void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset) + void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset, const bool debug) { auto* techniqueState = context.GetZoneAssetDumperState(); const auto* materialConstantState = context.GetZoneAssetDumperState(); @@ -271,7 +271,7 @@ namespace const auto commonTechnique = ConvertToCommonTechnique(*technique); techset::DumpCommonTechnique( - context, commonTechnique, techset::DxVersion::DX11, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState); + context, commonTechnique, techset::DxVersion::DX11, commonCodeSourceInfos, commonRoutingInfos, *materialConstantState, debug); } } } @@ -300,6 +300,11 @@ namespace namespace techset { + DumperT6::DumperT6(const bool debug) + : m_debug(debug) + { + } + void DumperT6::Dump(AssetDumpingContext& context) { context.GetZoneAssetDumperState()->EnsureInitialized(); @@ -310,7 +315,7 @@ namespace techset { const auto* techniqueSet = asset.Asset(); DumpTechset(context, *techniqueSet); - DumpTechniques(context, *techniqueSet); + DumpTechniques(context, *techniqueSet, m_debug); DumpShaders(context, *techniqueSet); } } // namespace techset diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h index d69edb93..913d1e85 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h @@ -8,9 +8,14 @@ namespace techset class DumperT6 final : public AbstractAssetDumper { public: + explicit DumperT6(bool debug); + void Dump(AssetDumpingContext& context) override; protected: void DumpAsset(AssetDumpingContext& context, const XAssetInfo& asset) override; + + private: + bool m_debug; }; } // namespace techset diff --git a/src/ObjWriting/Techset/CommonTechniqueDumper.cpp b/src/ObjWriting/Techset/CommonTechniqueDumper.cpp index b43b626c..d5c64043 100644 --- a/src/ObjWriting/Techset/CommonTechniqueDumper.cpp +++ b/src/ObjWriting/Techset/CommonTechniqueDumper.cpp @@ -20,8 +20,10 @@ namespace const DxVersion dxVersion, const CommonCodeSourceInfos& codeSourceInfos, const CommonStreamRoutingInfos& routingInfos, - const AbstractMaterialConstantZoneState& constantZoneState) + const AbstractMaterialConstantZoneState& constantZoneState, + const bool debug) : AbstractTextDumper(stream), + m_debug(debug), m_dx_version(dxVersion), m_code_source_infos(codeSourceInfos), m_routing_infos(routingInfos), @@ -31,8 +33,7 @@ namespace void DumpTechnique(const CommonTechnique& technique) { -#ifdef TECHSET_DEBUG - if (technique.m_flags) + if (m_debug && technique.m_flags) { for (auto i = 0u; i < sizeof(CommonTechnique::m_flags) * 8u; i++) { @@ -44,7 +45,6 @@ namespace } } } -#endif for (const auto& pass : technique.m_passes) DumpPass(technique, pass); @@ -56,17 +56,18 @@ namespace m_stream << "{\n"; IncIndent(); -#ifdef TECHSET_DEBUG - for (auto i = 0u; i < sizeof(CommonPass::m_sampler_flags) * 8u; i++) + if (m_debug) { - const auto mask = 1ull << i; - if (pass.m_sampler_flags & mask) + for (auto i = 0u; i < sizeof(CommonPass::m_sampler_flags) * 8u; i++) { - Indent(); - m_stream << std::format("// CUSTOM SAMPLER FLAGS: 0x{:x}\n", mask); + const auto mask = 1ull << i; + if (pass.m_sampler_flags & mask) + { + Indent(); + m_stream << std::format("// CUSTOM SAMPLER FLAGS: 0x{:x}\n", mask); + } } } -#endif DumpStateMap(); DumpShader(technique, pass, pass.m_vertex_shader, CommonTechniqueShaderType::VERTEX, m_dx_version); @@ -337,12 +338,10 @@ namespace Indent(); m_stream << std::format("{} = constant.{};\n", codeDestAccessor, codeAccessor); } - else + else if (m_debug) { -#ifdef TECHSET_DEBUG Indent(); m_stream << std::format("// Omitted due to matching accessors: {} = constant.{};\n", codeDestAccessor, codeAccessor); -#endif } } else @@ -363,12 +362,10 @@ namespace Indent(); m_stream << std::format("{} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor); } - else + else if (m_debug) { -#ifdef TECHSET_DEBUG Indent(); m_stream << std::format("// Omitted due to matching accessors: {} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor); -#endif } } else @@ -429,6 +426,7 @@ namespace } } + bool m_debug; DxVersion m_dx_version; const CommonCodeSourceInfos& m_code_source_infos; const CommonStreamRoutingInfos& m_routing_infos; @@ -443,12 +441,13 @@ namespace techset const DxVersion dxVersion, const CommonCodeSourceInfos& codeSourceInfos, const CommonStreamRoutingInfos& routingInfos, - const AbstractMaterialConstantZoneState& constantZoneState) + const AbstractMaterialConstantZoneState& constantZoneState, + const bool debug) { const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique.m_name)); if (techniqueFile) { - TechniqueFileWriter writer(*techniqueFile, dxVersion, codeSourceInfos, routingInfos, constantZoneState); + TechniqueFileWriter writer(*techniqueFile, dxVersion, codeSourceInfos, routingInfos, constantZoneState, debug); writer.DumpTechnique(technique); } } diff --git a/src/ObjWriting/Techset/CommonTechniqueDumper.h b/src/ObjWriting/Techset/CommonTechniqueDumper.h index f2a6a4bd..828dbcb9 100644 --- a/src/ObjWriting/Techset/CommonTechniqueDumper.h +++ b/src/ObjWriting/Techset/CommonTechniqueDumper.h @@ -11,5 +11,6 @@ namespace techset DxVersion dxVersion, const CommonCodeSourceInfos& codeSourceInfos, const CommonStreamRoutingInfos& routingInfos, - const AbstractMaterialConstantZoneState& constantZoneState); + const AbstractMaterialConstantZoneState& constantZoneState, + bool debug); } // namespace techset