mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-03-16 09:53:04 +00:00
chore: use templating for t6 techset compilation
This commit is contained in:
@@ -51,6 +51,9 @@ function ObjCompiling:project()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObjCommon:use()
|
||||||
|
useSourceTemplating("ObjCompiling")
|
||||||
|
|
||||||
self:include(includes)
|
self:include(includes)
|
||||||
minilzo:include(includes)
|
minilzo:include(includes)
|
||||||
Utils:include(includes)
|
Utils:include(includes)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "ObjCompilerT6.h"
|
#include "ObjCompilerT6.h"
|
||||||
|
|
||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
|
#include "Game/T6/Techset/TechniqueCompilerT6.h"
|
||||||
|
#include "Game/T6/Techset/TechsetCompilerT6.h"
|
||||||
|
#include "Game/T6/Techset/VertexDeclCompilerT6.h"
|
||||||
#include "Image/ImageIPakPostProcessor.h"
|
#include "Image/ImageIPakPostProcessor.h"
|
||||||
#include "Image/ImageIwdPostProcessor.h"
|
#include "Image/ImageIwdPostProcessor.h"
|
||||||
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
|
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
|
||||||
#include "Techset/TechniqueCompilerT6.h"
|
|
||||||
#include "Techset/TechsetCompilerT6.h"
|
|
||||||
#include "Techset/VertexDeclCompilerT6.h"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ namespace
|
|||||||
auto& memory = zone.Memory();
|
auto& memory = zone.Memory();
|
||||||
|
|
||||||
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||||
collection.AddAssetCreator(techset::CreateCompilerT6(memory, searchPath));
|
collection.AddAssetCreator(techset::CreateTechsetCompilerT6(memory, searchPath));
|
||||||
|
|
||||||
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, zone, searchPath));
|
collection.AddSubAssetCreator(techset::CreateTechniqueCompilerT6(memory, zone, searchPath));
|
||||||
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT6(memory));
|
collection.AddSubAssetCreator(techset::CreateVertexDeclCompilerT6(memory));
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Asset/IAssetCreator.h"
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace techset
|
|
||||||
{
|
|
||||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Asset/IAssetCreator.h"
|
|
||||||
#include "SearchPath/ISearchPath.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace techset
|
|
||||||
{
|
|
||||||
std::unique_ptr<IAssetCreator> CreateCompilerT6(MemoryManager& memory, ISearchPath& searchPath);
|
|
||||||
} // namespace techset
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
#include "VertexDeclCompilerT6.h"
|
|
||||||
|
|
||||||
#include "Game/T6/T6.h"
|
|
||||||
#include "Game/T6/Techset/TechsetConstantsT6.h"
|
|
||||||
#include "Techset/CommonVertexDeclCreator.h"
|
|
||||||
#include "Utils/Logging/Log.h"
|
|
||||||
|
|
||||||
using namespace T6;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class VertexDeclCompilerT6 final : public SubAssetCreator<SubAssetVertexDecl>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit VertexDeclCompilerT6(MemoryManager& memory)
|
|
||||||
: m_memory(memory)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) override
|
|
||||||
{
|
|
||||||
const auto commonVertexDecl = techset::CreateVertexDeclFromName(subAssetName, commonRoutingInfos);
|
|
||||||
if (!commonVertexDecl)
|
|
||||||
return AssetCreationResult::Failure();
|
|
||||||
|
|
||||||
if (commonVertexDecl->m_routing.size() > std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
|
||||||
{
|
|
||||||
con::error("Vertex declaration can only have up to {} routing entries", std::extent_v<decltype(MaterialVertexStreamRouting::data)>);
|
|
||||||
return AssetCreationResult::Failure();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
|
||||||
|
|
||||||
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
|
||||||
{
|
|
||||||
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
|
||||||
vertexDecl->routing.data[vertexDecl->streamCount].dest = commonRoutingEntry.m_destination;
|
|
||||||
vertexDecl->hasOptionalSource = vertexDecl->hasOptionalSource || commonRoutingEntry.m_source >= STREAM_SRC_OPTIONAL_BEGIN;
|
|
||||||
|
|
||||||
vertexDecl->streamCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<SubAssetVertexDecl>(subAssetName, vertexDecl)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
MemoryManager& m_memory;
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace techset
|
|
||||||
{
|
|
||||||
std::unique_ptr<ISubAssetCreator> CreateVertexDeclCompilerT6(MemoryManager& memory)
|
|
||||||
{
|
|
||||||
return std::make_unique<VertexDeclCompilerT6>(memory);
|
|
||||||
}
|
|
||||||
} // namespace techset
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Asset/IAssetCreator.h"
|
|
||||||
#include "Utils/MemoryManager.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace techset
|
|
||||||
{
|
|
||||||
std::unique_ptr<ISubAssetCreator> CreateVertexDeclCompilerT6(MemoryManager& memory);
|
|
||||||
}
|
|
||||||
@@ -326,7 +326,7 @@ namespace
|
|||||||
const techset::CommonShaderArgCreatorDestination& input) override
|
const techset::CommonShaderArgCreatorDestination& input) override
|
||||||
{
|
{
|
||||||
assert(m_shader_info);
|
assert(m_shader_info);
|
||||||
// TODO
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +577,6 @@ namespace
|
|||||||
return std::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
return NoResult{};
|
return NoResult{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,50 @@
|
|||||||
#include "TechniqueCompilerT6.h"
|
#options GAME(T6)
|
||||||
|
|
||||||
#include "Game/T6/T6.h"
|
#filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".cpp"
|
||||||
#include "Game/T6/Techset/TechsetConstantsT6.h"
|
|
||||||
#include "PrecompiledIndexT6.h"
|
#set COMPILER_HEADER "\"TechniqueCompiler" + GAME + ".h\""
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
#set TECHSET_CONSTANTS_HEADER "\"Game/" + GAME + "/Techset/TechsetConstants" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See TechniqueCompiler.cpp.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#include COMPILER_HEADER
|
||||||
|
|
||||||
|
#include GAME_HEADER
|
||||||
|
#include TECHSET_CONSTANTS_HEADER
|
||||||
#include "Techset/CommonShaderArgCreator.h"
|
#include "Techset/CommonShaderArgCreator.h"
|
||||||
#include "Techset/CommonTechniqueLoader.h"
|
#include "Techset/CommonTechniqueLoader.h"
|
||||||
#include "Techset/LiteralConstsZoneState.h"
|
#include "Techset/LiteralConstsZoneState.h"
|
||||||
#include "Utils/StringUtils.h"
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
|
#if defined(FEATURE_T6)
|
||||||
|
#set PRECOMPILED_INDEX_HEADER "\"Game/" + GAME + "/Techset/PrecompiledIndex" + GAME + ".h\""
|
||||||
|
#include PRECOMPILED_INDEX_HEADER
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace T6;
|
using namespace GAME;
|
||||||
|
|
||||||
|
#set SHADER_LOADER_CLASS_NAME "TechniqueShaderLoader" + GAME
|
||||||
|
#set COMPILER_CLASS_NAME "TechniqueCompiler" + GAME
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -236,10 +267,10 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TechniqueShaderLoaderT6 final : public techset::ITechniqueShaderLoader
|
class SHADER_LOADER_CLASS_NAME final : public techset::ITechniqueShaderLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TechniqueShaderLoaderT6(AssetCreationContext& context)
|
explicit SHADER_LOADER_CLASS_NAME(AssetCreationContext& context)
|
||||||
: m_context(context)
|
: m_context(context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -282,10 +313,10 @@ namespace
|
|||||||
AssetCreationContext& m_context;
|
AssetCreationContext& m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TechniqueCompilerT6 final : public SubAssetCreator<SubAssetTechnique>
|
class COMPILER_CLASS_NAME final : public SubAssetCreator<SubAssetTechnique>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
COMPILER_CLASS_NAME(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
||||||
: m_memory(memory),
|
: m_memory(memory),
|
||||||
m_zone(zone),
|
m_zone(zone),
|
||||||
m_search_path(searchPath)
|
m_search_path(searchPath)
|
||||||
@@ -295,7 +326,7 @@ namespace
|
|||||||
AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) override
|
AssetCreationResult CreateSubAsset(const std::string& subAssetName, AssetCreationContext& context) override
|
||||||
{
|
{
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
TechniqueShaderLoaderT6 shaderLoader(context);
|
SHADER_LOADER_CLASS_NAME shaderLoader(context);
|
||||||
const auto commonShaderArgCreator = techset::CommonShaderArgCreator::CreateDx11(shaderLoader, context, commonCodeSourceInfos);
|
const auto commonShaderArgCreator = techset::CommonShaderArgCreator::CreateDx11(shaderLoader, context, commonCodeSourceInfos);
|
||||||
|
|
||||||
const auto commonTechnique =
|
const auto commonTechnique =
|
||||||
@@ -336,10 +367,12 @@ namespace
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateTechniqueCompiler" + GAME
|
||||||
|
|
||||||
namespace techset
|
namespace techset
|
||||||
{
|
{
|
||||||
std::unique_ptr<ISubAssetCreator> CreateTechniqueCompilerT6(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
std::unique_ptr<ISubAssetCreator> CREATE_COMPILER_METHOD(MemoryManager& memory, Zone& zone, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
return std::make_unique<TechniqueCompilerT6>(memory, zone, searchPath);
|
return std::make_unique<COMPILER_CLASS_NAME>(memory, zone, searchPath);
|
||||||
}
|
}
|
||||||
} // namespace techset
|
} // namespace techset
|
||||||
36
src/ObjCompiling/Techset/TechniqueCompiler.h.template
Normal file
36
src/ObjCompiling/Techset/TechniqueCompiler.h.template
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#options GAME(T6)
|
||||||
|
|
||||||
|
#filename "Game/" + GAME + "/Techset/TechniqueCompiler" + GAME + ".h"
|
||||||
|
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See TechniqueCompiler.h.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IAssetCreator.h"
|
||||||
|
#include "SearchPath/ISearchPath.h"
|
||||||
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateTechniqueCompiler" + GAME
|
||||||
|
|
||||||
|
namespace techset
|
||||||
|
{
|
||||||
|
std::unique_ptr<ISubAssetCreator> CREATE_COMPILER_METHOD(MemoryManager& memory, Zone& zone, ISearchPath& searchPath);
|
||||||
|
}
|
||||||
@@ -1,11 +1,37 @@
|
|||||||
#include "TechsetCompilerT6.h"
|
#options GAME(T6)
|
||||||
|
|
||||||
#include "Game/T6/T6.h"
|
#filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".cpp"
|
||||||
#include "Game/T6/Techset/TechsetConstantsT6.h"
|
|
||||||
|
#set COMPILER_HEADER "\"TechsetCompiler" + GAME + ".h\""
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
#set TECHSET_CONSTANTS_HEADER "\"Game/" + GAME + "/Techset/TechsetConstants" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See TechsetCompiler.cpp.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#include COMPILER_HEADER
|
||||||
|
|
||||||
|
#include GAME_HEADER
|
||||||
|
#include TECHSET_CONSTANTS_HEADER
|
||||||
#include "Techset/CommonTechsetLoader.h"
|
#include "Techset/CommonTechsetLoader.h"
|
||||||
#include "Techset/TechsetCommon.h"
|
#include "Techset/TechsetCommon.h"
|
||||||
|
|
||||||
using namespace T6;
|
using namespace GAME;
|
||||||
|
|
||||||
|
#set COMPILER_CLASS_NAME "TechsetCompiler" + GAME
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -71,10 +97,10 @@ namespace
|
|||||||
return techset;
|
return techset;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TechsetCompilerT6 final : public AssetCreator<AssetTechniqueSet>
|
class COMPILER_CLASS_NAME final : public AssetCreator<AssetTechniqueSet>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TechsetCompilerT6(ISearchPath& searchPath, MemoryManager& memory)
|
COMPILER_CLASS_NAME(ISearchPath& searchPath, MemoryManager& memory)
|
||||||
: m_search_path(searchPath),
|
: m_search_path(searchPath),
|
||||||
m_memory(memory)
|
m_memory(memory)
|
||||||
{
|
{
|
||||||
@@ -106,8 +132,6 @@ namespace
|
|||||||
// but the game determines the material type by techset name.
|
// but the game determines the material type by techset name.
|
||||||
// So this may just be a constraint that cannot be changed.
|
// So this may just be a constraint that cannot be changed.
|
||||||
ApplyMaterialTypeToTechnique(*techset->techniques[techniqueIndex], materialType);
|
ApplyMaterialTypeToTechnique(*techset->techniques[techniqueIndex], materialType);
|
||||||
|
|
||||||
// Precompiled index?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AssetCreationResult::Success(context.AddAsset(AssetRegistration<AssetTechniqueSet>(assetName, techset)));
|
return AssetCreationResult::Success(context.AddAsset(AssetRegistration<AssetTechniqueSet>(assetName, techset)));
|
||||||
@@ -119,10 +143,12 @@ namespace
|
|||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateTechsetCompiler" + GAME
|
||||||
|
|
||||||
namespace techset
|
namespace techset
|
||||||
{
|
{
|
||||||
std::unique_ptr<IAssetCreator> CreateCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
std::unique_ptr<IAssetCreator> CREATE_COMPILER_METHOD(MemoryManager& memory, ISearchPath& searchPath)
|
||||||
{
|
{
|
||||||
return std::make_unique<TechsetCompilerT6>(searchPath, memory);
|
return std::make_unique<COMPILER_CLASS_NAME>(searchPath, memory);
|
||||||
}
|
}
|
||||||
} // namespace techset
|
} // namespace techset
|
||||||
36
src/ObjCompiling/Techset/TechsetCompiler.h.template
Normal file
36
src/ObjCompiling/Techset/TechsetCompiler.h.template
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#options GAME(T6)
|
||||||
|
|
||||||
|
#filename "Game/" + GAME + "/Techset/TechsetCompiler" + GAME + ".h"
|
||||||
|
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See TechsetCompiler.h.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IAssetCreator.h"
|
||||||
|
#include "SearchPath/ISearchPath.h"
|
||||||
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateTechsetCompiler" + GAME
|
||||||
|
|
||||||
|
namespace techset
|
||||||
|
{
|
||||||
|
std::unique_ptr<IAssetCreator> CREATE_COMPILER_METHOD(MemoryManager& memory, ISearchPath& searchPath);
|
||||||
|
}
|
||||||
97
src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template
Normal file
97
src/ObjCompiling/Techset/VertexDeclCompiler.cpp.template
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#options GAME(T6)
|
||||||
|
|
||||||
|
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".cpp"
|
||||||
|
|
||||||
|
#set COMPILER_HEADER "\"VertexDeclCompiler" + GAME + ".h\""
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
#set TECHSET_CONSTANTS_HEADER "\"Game/" + GAME + "/Techset/TechsetConstants" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See VertexDeclCompiler.cpp.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#include COMPILER_HEADER
|
||||||
|
|
||||||
|
#include GAME_HEADER
|
||||||
|
#include TECHSET_CONSTANTS_HEADER
|
||||||
|
#include "Techset/CommonVertexDeclCreator.h"
|
||||||
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
|
using namespace GAME;
|
||||||
|
|
||||||
|
#set COMPILER_CLASS_NAME "VertexDeclCompiler" + GAME
|
||||||
|
|
||||||
|
#if defined(FEATURE_T6)
|
||||||
|
#define ABSTRACT_CREATOR_NAME SubAssetCreator
|
||||||
|
#define OVERRIDEN_CREATOR_METHOD CreateSubAsset
|
||||||
|
#define ASSET_NAME SubAssetVertexDecl
|
||||||
|
#define INTERFACE_NAME ISubAssetCreator
|
||||||
|
#else
|
||||||
|
#define ABSTRACT_CREATOR_NAME AssetCreator
|
||||||
|
#define OVERRIDEN_CREATOR_METHOD CreateAsset
|
||||||
|
#define ASSET_NAME AssetVertexDecl
|
||||||
|
#define INTERFACE_NAME IAssetCreator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class COMPILER_CLASS_NAME final : public ABSTRACT_CREATOR_NAME<ASSET_NAME>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit COMPILER_CLASS_NAME(MemoryManager& memory)
|
||||||
|
: m_memory(memory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetCreationResult OVERRIDEN_CREATOR_METHOD(const std::string& assetName, AssetCreationContext& context) override
|
||||||
|
{
|
||||||
|
const auto commonVertexDecl = techset::CreateVertexDeclFromName(assetName, commonRoutingInfos);
|
||||||
|
if (!commonVertexDecl)
|
||||||
|
return AssetCreationResult::Failure();
|
||||||
|
|
||||||
|
if (commonVertexDecl->m_routing.size() > std::extent_v<decltype(MaterialVertexStreamRouting::data)>)
|
||||||
|
{
|
||||||
|
con::error("Vertex declaration can only have up to {} routing entries", std::extent_v<decltype(MaterialVertexStreamRouting::data)>);
|
||||||
|
return AssetCreationResult::Failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* vertexDecl = m_memory.Alloc<MaterialVertexDeclaration>();
|
||||||
|
|
||||||
|
for (const auto& commonRoutingEntry : commonVertexDecl->m_routing)
|
||||||
|
{
|
||||||
|
vertexDecl->routing.data[vertexDecl->streamCount].source = commonRoutingEntry.m_source;
|
||||||
|
vertexDecl->routing.data[vertexDecl->streamCount].dest = commonRoutingEntry.m_destination;
|
||||||
|
vertexDecl->hasOptionalSource = vertexDecl->hasOptionalSource || commonRoutingEntry.m_source >= STREAM_SRC_OPTIONAL_BEGIN;
|
||||||
|
|
||||||
|
vertexDecl->streamCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AssetCreationResult::Success(context.AddSubAsset(AssetRegistration<ASSET_NAME>(assetName, vertexDecl)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MemoryManager& m_memory;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateVertexDeclCompiler" + GAME
|
||||||
|
|
||||||
|
namespace techset
|
||||||
|
{
|
||||||
|
std::unique_ptr<INTERFACE_NAME> CREATE_COMPILER_METHOD(MemoryManager& memory)
|
||||||
|
{
|
||||||
|
return std::make_unique<COMPILER_CLASS_NAME>(memory);
|
||||||
|
}
|
||||||
|
} // namespace techset
|
||||||
41
src/ObjCompiling/Techset/VertexDeclCompiler.h.template
Normal file
41
src/ObjCompiling/Techset/VertexDeclCompiler.h.template
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#options GAME(T6)
|
||||||
|
|
||||||
|
#filename "Game/" + GAME + "/Techset/VertexDeclCompiler" + GAME + ".h"
|
||||||
|
|
||||||
|
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||||
|
|
||||||
|
#if GAME == "IW3"
|
||||||
|
#define FEATURE_IW3
|
||||||
|
#elif GAME == "IW4"
|
||||||
|
#define FEATURE_IW4
|
||||||
|
#elif GAME == "IW5"
|
||||||
|
#define FEATURE_IW5
|
||||||
|
#elif GAME == "T5"
|
||||||
|
#define FEATURE_T5
|
||||||
|
#elif GAME == "T6"
|
||||||
|
#define FEATURE_T6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This file was templated.
|
||||||
|
// See VertexDeclCompiler.h.template.
|
||||||
|
// Do not modify, changes will be lost.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IAssetCreator.h"
|
||||||
|
#include "Utils/MemoryManager.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#set CREATE_COMPILER_METHOD "CreateVertexDeclCompiler" + GAME
|
||||||
|
|
||||||
|
#if defined(FEATURE_T6)
|
||||||
|
#define INTERFACE_NAME ISubAssetCreator
|
||||||
|
#else
|
||||||
|
#define INTERFACE_NAME IAssetCreator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace techset
|
||||||
|
{
|
||||||
|
std::unique_ptr<INTERFACE_NAME> CREATE_COMPILER_METHOD(MemoryManager& memory);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ ObjCompilingTests = {}
|
|||||||
function ObjCompilingTests:include(includes)
|
function ObjCompilingTests:include(includes)
|
||||||
if includes:handle(self:name()) then
|
if includes:handle(self:name()) then
|
||||||
includedirs {
|
includedirs {
|
||||||
|
"%{wks.location}/src/ObjCompiling",
|
||||||
path.join(TestFolder(), "ObjCompilingTests")
|
path.join(TestFolder(), "ObjCompilingTests")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ TEST_CASE("TechsetCompilerT6", "[techset][t6][compiler]")
|
|||||||
AssetCreationContext context(zone, &creators, &ignoredAssets);
|
AssetCreationContext context(zone, &creators, &ignoredAssets);
|
||||||
MockSearchPath searchPath;
|
MockSearchPath searchPath;
|
||||||
TestMemoryManager memory;
|
TestMemoryManager memory;
|
||||||
const auto sut = techset::CreateCompilerT6(memory, searchPath);
|
const auto sut = techset::CreateTechsetCompilerT6(memory, searchPath);
|
||||||
|
|
||||||
SECTION("Sets correct worldVertFormat")
|
SECTION("Sets correct worldVertFormat")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user