2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-05 12:33:02 +00:00

chore: enable techset debugging on dumper creation level

This commit is contained in:
Jan Laupetin
2026-02-28 15:27:03 +01:00
parent 38cb7d3759
commit 5ab3fd7ca0
8 changed files with 60 additions and 28 deletions

View File

@@ -18,7 +18,13 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
RegisterAssetDumper(std::make_unique<xmodel::DumperT5>()); RegisterAssetDumper(std::make_unique<xmodel::DumperT5>());
RegisterAssetDumper(std::make_unique<material::JsonDumperT5>()); RegisterAssetDumper(std::make_unique<material::JsonDumperT5>());
RegisterAssetDumper(std::make_unique<techset::DumperT5>()); RegisterAssetDumper(std::make_unique<techset::DumperT5>(
#ifdef TECHSET_DEBUG
true
#else
false
#endif
));
RegisterAssetDumper(std::make_unique<image::DumperT5>()); RegisterAssetDumper(std::make_unique<image::DumperT5>());
// REGISTER_DUMPER(AssetDumperSndBank, m_sound_bank) // REGISTER_DUMPER(AssetDumperSndBank, m_sound_bank)
// REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch)

View File

@@ -209,7 +209,7 @@ namespace
return commonTechnique; return commonTechnique;
} }
void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset) void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset, const bool debug)
{ {
auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>(); auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>();
const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>(); const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
@@ -220,7 +220,7 @@ namespace
const auto commonTechnique = ConvertToCommonTechnique(*technique); const auto commonTechnique = ConvertToCommonTechnique(*technique);
techset::DumpCommonTechnique( 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 namespace techset
{ {
DumperT5::DumperT5(const bool debug)
: m_debug(debug)
{
}
void DumperT5::Dump(AssetDumpingContext& context) void DumperT5::Dump(AssetDumpingContext& context)
{ {
context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized(); context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized();
@@ -260,7 +265,7 @@ namespace techset
{ {
const auto* techniqueSet = asset.Asset(); const auto* techniqueSet = asset.Asset();
DumpTechset(context, *techniqueSet); DumpTechset(context, *techniqueSet);
DumpTechniques(context, *techniqueSet); DumpTechniques(context, *techniqueSet, m_debug);
DumpShaders(context, *techniqueSet); DumpShaders(context, *techniqueSet);
} }
} // namespace techset } // namespace techset

View File

@@ -8,9 +8,14 @@ namespace techset
class DumperT5 final : public AbstractAssetDumper<T5::AssetTechniqueSet> class DumperT5 final : public AbstractAssetDumper<T5::AssetTechniqueSet>
{ {
public: public:
explicit DumperT5(bool debug);
void Dump(AssetDumpingContext& context) override; void Dump(AssetDumpingContext& context) override;
protected: protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetTechniqueSet::Type>& asset) override; void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T5::AssetTechniqueSet::Type>& asset) override;
private:
bool m_debug;
}; };
} // namespace techset } // namespace techset

View File

@@ -35,7 +35,13 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
// REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts) // REGISTER_DUMPER(AssetDumperXAnimParts, m_xanim_parts)
RegisterAssetDumper(std::make_unique<xmodel::DumperT6>()); RegisterAssetDumper(std::make_unique<xmodel::DumperT6>());
RegisterAssetDumper(std::make_unique<material::JsonDumperT6>()); RegisterAssetDumper(std::make_unique<material::JsonDumperT6>());
RegisterAssetDumper(std::make_unique<techset::DumperT6>()); RegisterAssetDumper(std::make_unique<techset::DumperT6>(
#ifdef TECHSET_DEBUG
true
#else
false
#endif
));
RegisterAssetDumper(std::make_unique<image::DumperT6>()); RegisterAssetDumper(std::make_unique<image::DumperT6>());
RegisterAssetDumper(std::make_unique<sound::SndBankDumperT6>()); RegisterAssetDumper(std::make_unique<sound::SndBankDumperT6>());
// REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch) // REGISTER_DUMPER(AssetDumperSndPatch, m_sound_patch)

View File

@@ -260,7 +260,7 @@ namespace
return commonTechnique; return commonTechnique;
} }
void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset) void DumpTechniques(AssetDumpingContext& context, const MaterialTechniqueSet& techset, const bool debug)
{ {
auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>(); auto* techniqueState = context.GetZoneAssetDumperState<techset::TechniqueDumpingZoneState>();
const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>(); const auto* materialConstantState = context.GetZoneAssetDumperState<MaterialConstantZoneState>();
@@ -271,7 +271,7 @@ namespace
const auto commonTechnique = ConvertToCommonTechnique(*technique); const auto commonTechnique = ConvertToCommonTechnique(*technique);
techset::DumpCommonTechnique( 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 namespace techset
{ {
DumperT6::DumperT6(const bool debug)
: m_debug(debug)
{
}
void DumperT6::Dump(AssetDumpingContext& context) void DumperT6::Dump(AssetDumpingContext& context)
{ {
context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized(); context.GetZoneAssetDumperState<MaterialConstantZoneState>()->EnsureInitialized();
@@ -310,7 +315,7 @@ namespace techset
{ {
const auto* techniqueSet = asset.Asset(); const auto* techniqueSet = asset.Asset();
DumpTechset(context, *techniqueSet); DumpTechset(context, *techniqueSet);
DumpTechniques(context, *techniqueSet); DumpTechniques(context, *techniqueSet, m_debug);
DumpShaders(context, *techniqueSet); DumpShaders(context, *techniqueSet);
} }
} // namespace techset } // namespace techset

View File

@@ -8,9 +8,14 @@ namespace techset
class DumperT6 final : public AbstractAssetDumper<T6::AssetTechniqueSet> class DumperT6 final : public AbstractAssetDumper<T6::AssetTechniqueSet>
{ {
public: public:
explicit DumperT6(bool debug);
void Dump(AssetDumpingContext& context) override; void Dump(AssetDumpingContext& context) override;
protected: protected:
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T6::AssetTechniqueSet::Type>& asset) override; void DumpAsset(AssetDumpingContext& context, const XAssetInfo<T6::AssetTechniqueSet::Type>& asset) override;
private:
bool m_debug;
}; };
} // namespace techset } // namespace techset

View File

@@ -20,8 +20,10 @@ namespace
const DxVersion dxVersion, const DxVersion dxVersion,
const CommonCodeSourceInfos& codeSourceInfos, const CommonCodeSourceInfos& codeSourceInfos,
const CommonStreamRoutingInfos& routingInfos, const CommonStreamRoutingInfos& routingInfos,
const AbstractMaterialConstantZoneState& constantZoneState) const AbstractMaterialConstantZoneState& constantZoneState,
const bool debug)
: AbstractTextDumper(stream), : AbstractTextDumper(stream),
m_debug(debug),
m_dx_version(dxVersion), m_dx_version(dxVersion),
m_code_source_infos(codeSourceInfos), m_code_source_infos(codeSourceInfos),
m_routing_infos(routingInfos), m_routing_infos(routingInfos),
@@ -31,8 +33,7 @@ namespace
void DumpTechnique(const CommonTechnique& technique) void DumpTechnique(const CommonTechnique& technique)
{ {
#ifdef TECHSET_DEBUG if (m_debug && technique.m_flags)
if (technique.m_flags)
{ {
for (auto i = 0u; i < sizeof(CommonTechnique::m_flags) * 8u; i++) for (auto i = 0u; i < sizeof(CommonTechnique::m_flags) * 8u; i++)
{ {
@@ -44,7 +45,6 @@ namespace
} }
} }
} }
#endif
for (const auto& pass : technique.m_passes) for (const auto& pass : technique.m_passes)
DumpPass(technique, pass); DumpPass(technique, pass);
@@ -56,17 +56,18 @@ namespace
m_stream << "{\n"; m_stream << "{\n";
IncIndent(); IncIndent();
#ifdef TECHSET_DEBUG if (m_debug)
for (auto i = 0u; i < sizeof(CommonPass::m_sampler_flags) * 8u; i++)
{ {
const auto mask = 1ull << i; for (auto i = 0u; i < sizeof(CommonPass::m_sampler_flags) * 8u; i++)
if (pass.m_sampler_flags & mask)
{ {
Indent(); const auto mask = 1ull << i;
m_stream << std::format("// CUSTOM SAMPLER FLAGS: 0x{:x}\n", mask); if (pass.m_sampler_flags & mask)
{
Indent();
m_stream << std::format("// CUSTOM SAMPLER FLAGS: 0x{:x}\n", mask);
}
} }
} }
#endif
DumpStateMap(); DumpStateMap();
DumpShader(technique, pass, pass.m_vertex_shader, CommonTechniqueShaderType::VERTEX, m_dx_version); DumpShader(technique, pass, pass.m_vertex_shader, CommonTechniqueShaderType::VERTEX, m_dx_version);
@@ -337,12 +338,10 @@ namespace
Indent(); Indent();
m_stream << std::format("{} = constant.{};\n", codeDestAccessor, codeAccessor); m_stream << std::format("{} = constant.{};\n", codeDestAccessor, codeAccessor);
} }
else else if (m_debug)
{ {
#ifdef TECHSET_DEBUG
Indent(); Indent();
m_stream << std::format("// Omitted due to matching accessors: {} = constant.{};\n", codeDestAccessor, codeAccessor); m_stream << std::format("// Omitted due to matching accessors: {} = constant.{};\n", codeDestAccessor, codeAccessor);
#endif
} }
} }
else else
@@ -363,12 +362,10 @@ namespace
Indent(); Indent();
m_stream << std::format("{} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor); m_stream << std::format("{} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor);
} }
else else if (m_debug)
{ {
#ifdef TECHSET_DEBUG
Indent(); Indent();
m_stream << std::format("// Omitted due to matching accessors: {} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor); m_stream << std::format("// Omitted due to matching accessors: {} = sampler.{};\n", codeDestAccessor, samplerSourceInfo->accessor);
#endif
} }
} }
else else
@@ -429,6 +426,7 @@ namespace
} }
} }
bool m_debug;
DxVersion m_dx_version; DxVersion m_dx_version;
const CommonCodeSourceInfos& m_code_source_infos; const CommonCodeSourceInfos& m_code_source_infos;
const CommonStreamRoutingInfos& m_routing_infos; const CommonStreamRoutingInfos& m_routing_infos;
@@ -443,12 +441,13 @@ namespace techset
const DxVersion dxVersion, const DxVersion dxVersion,
const CommonCodeSourceInfos& codeSourceInfos, const CommonCodeSourceInfos& codeSourceInfos,
const CommonStreamRoutingInfos& routingInfos, const CommonStreamRoutingInfos& routingInfos,
const AbstractMaterialConstantZoneState& constantZoneState) const AbstractMaterialConstantZoneState& constantZoneState,
const bool debug)
{ {
const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique.m_name)); const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique.m_name));
if (techniqueFile) if (techniqueFile)
{ {
TechniqueFileWriter writer(*techniqueFile, dxVersion, codeSourceInfos, routingInfos, constantZoneState); TechniqueFileWriter writer(*techniqueFile, dxVersion, codeSourceInfos, routingInfos, constantZoneState, debug);
writer.DumpTechnique(technique); writer.DumpTechnique(technique);
} }
} }

View File

@@ -11,5 +11,6 @@ namespace techset
DxVersion dxVersion, DxVersion dxVersion,
const CommonCodeSourceInfos& codeSourceInfos, const CommonCodeSourceInfos& codeSourceInfos,
const CommonStreamRoutingInfos& routingInfos, const CommonStreamRoutingInfos& routingInfos,
const AbstractMaterialConstantZoneState& constantZoneState); const AbstractMaterialConstantZoneState& constantZoneState,
bool debug);
} // namespace techset } // namespace techset