mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-10-04 11:25:34 +00:00
chore: use CommonTechset instead of TechsetDefinition
This commit is contained in:
40 files changed
+306
-301
No files matched your search
@@ -3,13 +3,14 @@
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "StateMap/StateMapLayout.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
inline const char* techniqueTypeNames[]{
|
||||
static inline const char* techniqueTypeNames[]{
|
||||
"depth prepass",
|
||||
"build floatz",
|
||||
"build shadowmap depth",
|
||||
@@ -60,8 +61,9 @@ namespace IW4
|
||||
"debug bumpmap instanced",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(techniqueTypeNames)> == TECHNIQUE_COUNT);
|
||||
static inline techset::CommonTechniqueTypeNames commonTechniqueTypeNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
||||
|
||||
static const char* materialStreamDestinationNames[]{
|
||||
static inline const char* materialStreamDestinationNames[]{
|
||||
"position",
|
||||
"normal",
|
||||
"color[0]",
|
||||
@@ -78,7 +80,7 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(materialStreamDestinationNames)> == STREAM_DST_COUNT);
|
||||
|
||||
static const char* materialStreamDestinationAbbreviation[]{
|
||||
static inline const char* materialStreamDestinationAbbreviation[]{
|
||||
"p",
|
||||
"n",
|
||||
"c0",
|
||||
@@ -95,7 +97,7 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(materialStreamDestinationAbbreviation)> == STREAM_DST_COUNT);
|
||||
|
||||
static const char* materialStreamSourceNames[]{
|
||||
static inline const char* materialStreamSourceNames[]{
|
||||
"position",
|
||||
"color",
|
||||
"texcoord[0]",
|
||||
@@ -108,7 +110,7 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(materialStreamSourceNames)> == STREAM_SRC_COUNT);
|
||||
|
||||
static const char* materialStreamSourceAbbreviation[]{
|
||||
static inline const char* materialStreamSourceAbbreviation[]{
|
||||
"p",
|
||||
"c",
|
||||
"t0",
|
||||
@@ -121,18 +123,18 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(materialStreamSourceAbbreviation)> == STREAM_SRC_COUNT);
|
||||
|
||||
inline CodeSamplerSource s_lightmapSamplers[]{
|
||||
static inline CodeSamplerSource s_lightmapSamplers[]{
|
||||
{"primary", TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY, nullptr, 0, 0},
|
||||
{"secondary", TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY, nullptr, 0, 0},
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeSamplerSource s_lightSamplers[]{
|
||||
static inline CodeSamplerSource s_lightSamplers[]{
|
||||
{"attenuation", TEXTURE_SRC_CODE_LIGHT_ATTENUATION, nullptr, 0, 0},
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeSamplerSource s_codeSamplers[]{
|
||||
static inline CodeSamplerSource s_codeSamplers[]{
|
||||
{"white", TEXTURE_SRC_CODE_WHITE, nullptr, 0, 0},
|
||||
{"black", TEXTURE_SRC_CODE_BLACK, nullptr, 0, 0},
|
||||
{"identityNormalMap", TEXTURE_SRC_CODE_IDENTITY_NORMAL_MAP, nullptr, 0, 0},
|
||||
@@ -155,7 +157,7 @@ namespace IW4
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeSamplerSource s_defaultCodeSamplers[]{
|
||||
static inline CodeSamplerSource s_defaultCodeSamplers[]{
|
||||
{"shadowmapSamplerSun", TEXTURE_SRC_CODE_SHADOWMAP_SUN, nullptr, 0, 0},
|
||||
{"shadowmapSamplerSpot", TEXTURE_SRC_CODE_SHADOWMAP_SPOT, nullptr, 0, 0},
|
||||
{"feedbackSampler", TEXTURE_SRC_CODE_FEEDBACK, nullptr, 0, 0},
|
||||
@@ -177,7 +179,7 @@ namespace IW4
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeConstantSource s_sunConsts[]{
|
||||
static inline CodeConstantSource s_sunConsts[]{
|
||||
{"position", CONST_SRC_CODE_LIGHT_POSITION, nullptr, 0, 0},
|
||||
{"diffuse", CONST_SRC_CODE_LIGHT_DIFFUSE, nullptr, 0, 0},
|
||||
{"specular", CONST_SRC_CODE_LIGHT_SPECULAR, nullptr, 0, 0},
|
||||
@@ -187,14 +189,14 @@ namespace IW4
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeConstantSource s_nearPlaneConsts[]{
|
||||
static inline CodeConstantSource s_nearPlaneConsts[]{
|
||||
{"org", CONST_SRC_CODE_NEARPLANE_ORG, nullptr, 0, 0},
|
||||
{"dx", CONST_SRC_CODE_NEARPLANE_DX, nullptr, 0, 0},
|
||||
{"dy", CONST_SRC_CODE_NEARPLANE_DY, nullptr, 0, 0},
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeConstantSource s_codeConsts[]{
|
||||
static inline CodeConstantSource s_codeConsts[]{
|
||||
{"nearPlane", CONST_SRC_NONE, s_nearPlaneConsts, 0, 0},
|
||||
{"light", CONST_SRC_NONE, s_sunConsts, 0, 0},
|
||||
{"baseLightingCoords", CONST_SRC_CODE_BASE_LIGHTING_COORDS, nullptr, 0, 0},
|
||||
@@ -313,7 +315,7 @@ namespace IW4
|
||||
{},
|
||||
};
|
||||
|
||||
inline CodeConstantSource s_defaultCodeConsts[]{
|
||||
static inline CodeConstantSource s_defaultCodeConsts[]{
|
||||
{"nearPlaneOrg", CONST_SRC_CODE_NEARPLANE_ORG, nullptr, 0, 0},
|
||||
{"nearPlaneDx", CONST_SRC_CODE_NEARPLANE_DX, nullptr, 0, 0},
|
||||
{"nearPlaneDy", CONST_SRC_CODE_NEARPLANE_DY, nullptr, 0, 0},
|
||||
@@ -328,7 +330,7 @@ namespace IW4
|
||||
{},
|
||||
};
|
||||
|
||||
inline MaterialUpdateFrequency s_codeConstUpdateFreq[]{
|
||||
static inline MaterialUpdateFrequency s_codeConstUpdateFreq[]{
|
||||
MTL_UPDATE_RARELY, // LIGHT_POSITION
|
||||
MTL_UPDATE_RARELY, // LIGHT_DIFFUSE
|
||||
MTL_UPDATE_RARELY, // LIGHT_SPECULAR
|
||||
@@ -464,7 +466,7 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(s_codeConstUpdateFreq)> == CONST_SRC_TOTAL_COUNT);
|
||||
|
||||
inline MaterialUpdateFrequency s_codeSamplerUpdateFreq[]{
|
||||
static inline MaterialUpdateFrequency s_codeSamplerUpdateFreq[]{
|
||||
MTL_UPDATE_RARELY, // BLACK
|
||||
MTL_UPDATE_RARELY, // WHITE
|
||||
MTL_UPDATE_RARELY, // IDENTITY_NORMAL_MAP
|
||||
@@ -495,14 +497,14 @@ namespace IW4
|
||||
};
|
||||
static_assert(std::extent_v<decltype(s_codeSamplerUpdateFreq)> == TEXTURE_SRC_CODE_COUNT);
|
||||
|
||||
inline MaterialTextureSource g_customSamplerSrc[]{
|
||||
static inline MaterialTextureSource g_customSamplerSrc[]{
|
||||
TEXTURE_SRC_CODE_REFLECTION_PROBE, // CUSTOM_SAMPLER_REFLECTION_PROBE
|
||||
TEXTURE_SRC_CODE_LIGHTMAP_PRIMARY, // CUSTOM_SAMPLER_LIGHTMAP_PRIMARY
|
||||
TEXTURE_SRC_CODE_LIGHTMAP_SECONDARY, // CUSTOM_SAMPLER_LIGHTMAP_SECONDARY
|
||||
};
|
||||
static_assert(std::extent_v<decltype(g_customSamplerSrc)> == CUSTOM_SAMPLER_COUNT);
|
||||
|
||||
inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
static inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
{"", "" },
|
||||
{"m/", "m_" },
|
||||
{"mc/", "mc_"},
|
||||
@@ -523,7 +525,7 @@ namespace IW4
|
||||
return std::make_pair(Common::R_HashString(name, 0u), KnownMaterialTextureMap{name, additionalPropertySuffix});
|
||||
}
|
||||
|
||||
inline std::unordered_map knownTextureMaps{
|
||||
static inline std::unordered_map knownTextureMaps{
|
||||
MakeKnownTextureMap("colorMap", "Color"),
|
||||
MakeKnownTextureMap("colorMap0", "Color00"),
|
||||
MakeKnownTextureMap("colorMap1", "Color01"),
|
||||
@@ -538,7 +540,7 @@ namespace IW4
|
||||
return std::make_pair(Common::R_HashString(name, 0u), name);
|
||||
}
|
||||
|
||||
inline std::unordered_map knownConstantNames{
|
||||
static inline std::unordered_map knownConstantNames{
|
||||
MakeKnownConstantName("distortionScale"),
|
||||
MakeKnownConstantName("eyeOffsetParms"),
|
||||
MakeKnownConstantName("falloffBeginColor"),
|
||||
@@ -560,7 +562,7 @@ namespace IW4
|
||||
WIREFRAME
|
||||
};
|
||||
|
||||
inline state_map::StateMapLayoutEntries stateMapEntryLayout({
|
||||
static inline state_map::StateMapLayoutEntries stateMapEntryLayout({
|
||||
{"alphaTest", 0, GFXS0_ATEST_MASK | GFXS0_ATEST_DISABLE, {"mtlAlphaTest"} },
|
||||
{"blendFunc", 0, GFXS0_BLEND_RGB_MASK, {"mtlBlendOp", "mtlSrcBlend", "mtlDestBlend"} },
|
||||
{"separateAlphaBlendFunc", 0, GFXS0_BLEND_ALPHA_MASK, {"mtlBlendOpAlpha", "mtlSrcBlendAlpha", "mtlDestBlendAlpha"}},
|
||||
@@ -598,7 +600,7 @@ namespace IW4
|
||||
} }
|
||||
});
|
||||
|
||||
inline state_map::StateMapLayoutVars stateMapVarLayout({
|
||||
static inline state_map::StateMapLayoutVars stateMapVarLayout({
|
||||
{"mtlAlphaTest",
|
||||
0, {
|
||||
{"Always", GFXS0_ATEST_DISABLE},
|
||||
@@ -818,5 +820,5 @@ namespace IW4
|
||||
}},
|
||||
});
|
||||
|
||||
inline state_map::StateMapLayout stateMapLayout(std::extent_v<decltype(GfxStateBits::loadBits.raw)>, stateMapEntryLayout, stateMapVarLayout);
|
||||
static inline state_map::StateMapLayout stateMapLayout(std::extent_v<decltype(GfxStateBits::loadBits.raw)>, stateMapEntryLayout, stateMapVarLayout);
|
||||
} // namespace IW4
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
inline const char* techniqueTypeNames[]{
|
||||
static inline const char* techniqueTypeNames[]{
|
||||
"depth prepass",
|
||||
"build shadowmap depth",
|
||||
"unlit",
|
||||
@@ -44,8 +45,9 @@ namespace T6
|
||||
"debug performance",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(techniqueTypeNames)> == TECHNIQUE_COUNT);
|
||||
static inline techset::CommonTechniqueTypeNames commonTechniqueTypeNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
||||
|
||||
static techset::CommonStreamRoutingSourceInfo streamRoutingSources[]{
|
||||
static inline techset::CommonStreamRoutingSourceInfo streamRoutingSources[]{
|
||||
{
|
||||
.name = "position",
|
||||
.abbreviation = "p",
|
||||
@@ -104,7 +106,7 @@ namespace T6
|
||||
};
|
||||
static_assert(std::extent_v<decltype(streamRoutingSources)> == STREAM_SRC_COUNT);
|
||||
|
||||
static techset::CommonStreamRoutingDestinationInfo streamRoutingDestinations[]{
|
||||
static inline techset::CommonStreamRoutingDestinationInfo streamRoutingDestinations[]{
|
||||
{
|
||||
.name = "position",
|
||||
.abbreviation = "p",
|
||||
@@ -188,7 +190,7 @@ namespace T6
|
||||
};
|
||||
static_assert(std::extent_v<decltype(streamRoutingDestinations)> == STREAM_DST_COUNT);
|
||||
|
||||
static techset::CommonCodeConstSourceInfo commonCodeConstSources[]{
|
||||
static inline techset::CommonCodeConstSourceInfo commonCodeConstSources[]{
|
||||
{
|
||||
.value = CONST_SRC_CODE_LIGHT_POSITION,
|
||||
.accessor = "lightPosition",
|
||||
@@ -1511,7 +1513,7 @@ namespace T6
|
||||
},
|
||||
};
|
||||
|
||||
static techset::CommonCodeSamplerSourceInfo commonCodeSamplerSources[]{
|
||||
static inline techset::CommonCodeSamplerSourceInfo commonCodeSamplerSources[]{
|
||||
{
|
||||
.value = TEXTURE_SRC_CODE_BLACK,
|
||||
.accessor = "black",
|
||||
@@ -1789,7 +1791,7 @@ namespace T6
|
||||
},
|
||||
};
|
||||
|
||||
inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
static inline MaterialTypeInfo g_materialTypeInfo[]{
|
||||
{"", "" },
|
||||
{"m/", "m_" },
|
||||
{"mc/", "mc_" },
|
||||
|
||||
@@ -2,21 +2,48 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
techset::CommonTechniqueTypeNames::CommonTechniqueTypeNames(const char** names, const size_t nameCount)
|
||||
: m_names(nameCount)
|
||||
namespace techset
|
||||
{
|
||||
std::copy(names, &names[nameCount], m_names.data());
|
||||
}
|
||||
CommonTechniqueTypeNames::CommonTechniqueTypeNames(const char** names, const size_t nameCount)
|
||||
: m_names(nameCount)
|
||||
{
|
||||
std::copy(names, &names[nameCount], m_names.data());
|
||||
|
||||
const char* techset::CommonTechniqueTypeNames::GetTechniqueTypeName(const size_t techniqueTypeIndex) const
|
||||
{
|
||||
if (techniqueTypeIndex >= m_names.size())
|
||||
return nullptr;
|
||||
m_technique_type_lookup.reserve(nameCount);
|
||||
for (size_t i = 0; i < nameCount; i++)
|
||||
m_technique_type_lookup.emplace(names[i], i);
|
||||
}
|
||||
|
||||
return m_names[techniqueTypeIndex];
|
||||
}
|
||||
const char* CommonTechniqueTypeNames::GetTechniqueTypeName(const size_t techniqueTypeIndex) const
|
||||
{
|
||||
if (techniqueTypeIndex >= m_names.size())
|
||||
return nullptr;
|
||||
|
||||
size_t techset::CommonTechniqueTypeNames::GetTechniqueTypeCount() const
|
||||
{
|
||||
return m_names.size();
|
||||
}
|
||||
return m_names[techniqueTypeIndex];
|
||||
}
|
||||
|
||||
[[nodiscard]] std::optional<size_t> CommonTechniqueTypeNames::GetTechniqueTypeByName(const std::string& name) const
|
||||
{
|
||||
const auto foundValue = m_technique_type_lookup.find(name);
|
||||
if (foundValue != m_technique_type_lookup.end())
|
||||
return foundValue->second;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
size_t CommonTechniqueTypeNames::GetTechniqueTypeCount() const
|
||||
{
|
||||
return m_names.size();
|
||||
}
|
||||
|
||||
CommonTechset::CommonTechset(const size_t techniqueTypeCount)
|
||||
: m_technique_names(techniqueTypeCount)
|
||||
{
|
||||
}
|
||||
|
||||
CommonTechset::CommonTechset(std::string name, std::vector<std::string> techniqueNames)
|
||||
: m_name(std::move(name)),
|
||||
m_technique_names(std::move(techniqueNames))
|
||||
{
|
||||
}
|
||||
} // namespace techset
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
@@ -12,15 +14,21 @@ namespace techset
|
||||
CommonTechniqueTypeNames(const char** names, size_t nameCount);
|
||||
|
||||
[[nodiscard]] const char* GetTechniqueTypeName(size_t techniqueTypeIndex) const;
|
||||
[[nodiscard]] std::optional<size_t> GetTechniqueTypeByName(const std::string& name) const;
|
||||
[[nodiscard]] size_t GetTechniqueTypeCount() const;
|
||||
|
||||
private:
|
||||
std::vector<const char*> m_names;
|
||||
std::unordered_map<std::string, size_t> m_technique_type_lookup;
|
||||
};
|
||||
|
||||
class CommonTechset
|
||||
{
|
||||
public:
|
||||
CommonTechset() = default;
|
||||
explicit CommonTechset(size_t techniqueTypeCount);
|
||||
CommonTechset(std::string name, std::vector<std::string> techniqueNames);
|
||||
|
||||
std::string m_name;
|
||||
std::vector<std::string> m_technique_names;
|
||||
};
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "Pool/GlobalAssetPool.h"
|
||||
#include "StateMap/StateMapFromTechniqueExtractor.h"
|
||||
#include "StateMap/StateMapHandler.h"
|
||||
#include "Techset/CommonTechsetCache.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Techset/TechsetDefinitionCache.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cassert>
|
||||
@@ -795,7 +795,7 @@ namespace
|
||||
m_registration.AddDependency(techset);
|
||||
m_material.techniqueSet = techset->Asset();
|
||||
|
||||
auto& definitionCache = m_context.GetZoneAssetCreationState<::techset::TechsetDefinitionCache>();
|
||||
auto& definitionCache = m_context.GetZoneAssetCreationState<::techset::CommonTechsetCache>();
|
||||
|
||||
bool failure = false;
|
||||
const auto* techsetDefinition = m_techset_creator->LoadTechsetDefinition(techsetName, m_context, failure);
|
||||
@@ -808,12 +808,12 @@ namespace
|
||||
SetTechniqueSetCameraRegion(techsetDefinition);
|
||||
}
|
||||
|
||||
void SetTechniqueSetStateBits(const ::techset::TechsetDefinition* techsetDefinition)
|
||||
void SetTechniqueSetStateBits(const techset::CommonTechset* commonTechset)
|
||||
{
|
||||
for (auto i = 0; i < TECHNIQUE_COUNT; i++)
|
||||
{
|
||||
std::string techniqueName;
|
||||
if (techsetDefinition->GetTechniqueByIndex(i, techniqueName))
|
||||
auto techniqueName = commonTechset->m_technique_names[i];
|
||||
if (!techniqueName.empty())
|
||||
{
|
||||
const auto stateBitsForTechnique = GetStateBitsForTechnique(techniqueName);
|
||||
const auto foundStateBits = std::ranges::find_if(m_state_bits,
|
||||
@@ -892,17 +892,17 @@ namespace
|
||||
return outBits;
|
||||
}
|
||||
|
||||
void SetTechniqueSetCameraRegion(const ::techset::TechsetDefinition* techsetDefinition) const
|
||||
void SetTechniqueSetCameraRegion(const techset::CommonTechset* commonTechset) const
|
||||
{
|
||||
std::string tempName;
|
||||
if (techsetDefinition->GetTechniqueByIndex(TECHNIQUE_LIT, tempName))
|
||||
if (!commonTechset->m_technique_names[TECHNIQUE_LIT].empty())
|
||||
{
|
||||
if (m_material.info.sortKey >= SORTKEY_TRANS_START)
|
||||
m_material.cameraRegion = CAMERA_REGION_LIT_TRANS;
|
||||
else
|
||||
m_material.cameraRegion = CAMERA_REGION_LIT_OPAQUE;
|
||||
}
|
||||
else if (techsetDefinition->GetTechniqueByIndex(TECHNIQUE_EMISSIVE, tempName))
|
||||
else if (!commonTechset->m_technique_names[TECHNIQUE_EMISSIVE].empty())
|
||||
{
|
||||
m_material.cameraRegion = CAMERA_REGION_EMISSIVE;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "Shader/ShaderCommon.h"
|
||||
#include "StateMap/StateMapReader.h"
|
||||
#include "Techset/CommonTechsetCache.h"
|
||||
#include "Techset/CommonTechsetLoader.h"
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Techset/TechsetDefinitionCache.h"
|
||||
#include "Techset/TechsetFileReader.h"
|
||||
#include "Utils/Alignment.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
@@ -1284,7 +1284,7 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const TechsetDefinition& definition, AssetCreationContext& context)
|
||||
AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const CommonTechset& definition, AssetCreationContext& context)
|
||||
{
|
||||
auto* techset = m_memory.Alloc<MaterialTechniqueSet>();
|
||||
techset->name = m_memory.Dup(assetName.c_str());
|
||||
@@ -1294,8 +1294,8 @@ namespace
|
||||
const TechniqueLoader techniqueLoader(m_search_path, m_memory, context, this);
|
||||
for (auto i = 0u; i < std::extent_v<decltype(MaterialTechniqueSet::techniques)>; i++)
|
||||
{
|
||||
std::string techniqueName;
|
||||
if (definition.GetTechniqueByIndex(i, techniqueName))
|
||||
const auto& techniqueName = definition.m_technique_names[i];
|
||||
if (!techniqueName.empty())
|
||||
{
|
||||
auto* technique = techniqueLoader.LoadMaterialTechnique(techniqueName);
|
||||
|
||||
@@ -1312,10 +1312,10 @@ namespace
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
|
||||
TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
|
||||
CommonTechset* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override
|
||||
{
|
||||
failure = false;
|
||||
auto& definitionCache = context.GetZoneAssetCreationState<TechsetDefinitionCache>();
|
||||
auto& definitionCache = context.GetZoneAssetCreationState<CommonTechsetCache>();
|
||||
auto* cachedTechsetDefinition = definitionCache.GetCachedTechsetDefinition(assetName);
|
||||
if (cachedTechsetDefinition)
|
||||
return cachedTechsetDefinition;
|
||||
@@ -1325,17 +1325,13 @@ namespace
|
||||
if (!file.IsOpen())
|
||||
return nullptr;
|
||||
|
||||
const TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
||||
auto techsetDefinition = reader.ReadTechsetDefinition();
|
||||
auto techsetDefinition = LoadCommonTechset(assetName, commonTechniqueTypeNames, m_search_path, failure);
|
||||
if (!techsetDefinition)
|
||||
{
|
||||
failure = true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* techsetDefinitionPtr = techsetDefinition.get();
|
||||
|
||||
definitionCache.AddTechsetDefinitionToCache(assetName, std::move(techsetDefinition));
|
||||
definitionCache.AddCommonTechsetToCache(assetName, std::move(techsetDefinition));
|
||||
|
||||
return techsetDefinitionPtr;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Game/IW4/IW4.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "StateMap/StateMapDefinition.h"
|
||||
#include "Techset/TechsetDefinition.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -18,7 +18,7 @@ namespace techset
|
||||
ICreatorIW4() = default;
|
||||
virtual ~ICreatorIW4() = default;
|
||||
|
||||
virtual TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0;
|
||||
virtual CommonTechset* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0;
|
||||
virtual const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Image/ImageIPakPostProcessor.h"
|
||||
#include "Image/ImageIwdPostProcessor.h"
|
||||
#include "KeyValuePairs/KeyValuePairsCompilerT6.h"
|
||||
#include "Techset/TechsetCompilerT6.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace
|
||||
auto& memory = zone.Memory();
|
||||
|
||||
collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates));
|
||||
collection.AddAssetCreator(techset::CreateCompilerT6(memory, searchPath));
|
||||
}
|
||||
|
||||
void ConfigurePostProcessors(AssetCreatorCollection& collection,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "TechsetCompilerT6.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
class TechsetCompilerT6 final : public AssetCreator<T6::AssetTechniqueSet>
|
||||
{
|
||||
public:
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
return AssetCreationResult::NoAction();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<IAssetCreator> CreateCompilerT6(MemoryManager& memory, ISearchPath& searchPath)
|
||||
{
|
||||
return std::make_unique<TechsetCompilerT6>();
|
||||
}
|
||||
} // namespace techset
|
||||
@@ -0,0 +1,12 @@
|
||||
#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
|
||||
@@ -0,0 +1 @@
|
||||
#include "CommonTechniqueLoader.h"
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Techset/CommonTechnique.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<CommonTechnique>
|
||||
LoadCommonTechnique(const AssetCreationContext& context, const CommonCodeSourceInfos& codeSourceInfos, const CommonStreamRoutingInfos& routingInfos);
|
||||
} // namespace techset
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "CommonTechsetLoader.h"
|
||||
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Techset/Parsing/TechsetFileParser.h"
|
||||
#include "Techset/TechsetCommon.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<CommonTechset>
|
||||
LoadCommonTechset(const std::string& assetName, const CommonTechniqueTypeNames& techniqueTypeNames, ISearchPath& searchPath, bool& failure)
|
||||
{
|
||||
failure = false;
|
||||
|
||||
const auto fileName = GetFileNameForTechniqueName(assetName);
|
||||
const auto techniqueFile = searchPath.Open(fileName);
|
||||
if (!techniqueFile.IsOpen())
|
||||
return nullptr;
|
||||
|
||||
SimpleLexer::Config lexerConfig;
|
||||
lexerConfig.m_emit_new_line_tokens = false;
|
||||
lexerConfig.m_read_strings = true;
|
||||
lexerConfig.m_string_escape_sequences = false;
|
||||
lexerConfig.m_read_integer_numbers = false;
|
||||
lexerConfig.m_read_floating_point_numbers = false;
|
||||
|
||||
ParserSingleInputStream baseStream(*techniqueFile.m_stream, fileName);
|
||||
CommentRemovingStreamProxy commentProxy(&baseStream);
|
||||
const auto lexer = std::make_unique<SimpleLexer>(&commentProxy, std::move(lexerConfig));
|
||||
|
||||
const auto parser = std::make_unique<TechsetParser>(*lexer, techniqueTypeNames);
|
||||
|
||||
const auto success = parser->Parse();
|
||||
if (success)
|
||||
return parser->GetParsingResult();
|
||||
|
||||
con::error("Parsing techset file \"{}\" failed!", fileName);
|
||||
failure = true;
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace techset
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::unique_ptr<CommonTechset>
|
||||
LoadCommonTechset(const std::string& assetName, const CommonTechniqueTypeNames& techniqueTypeNames, ISearchPath& searchPath, bool& failure);
|
||||
} // namespace techset
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -7,12 +7,12 @@ namespace techset
|
||||
class TechniqueParserState
|
||||
{
|
||||
public:
|
||||
explicit TechniqueParserState(ITechniqueDefinitionAcceptor* acceptor);
|
||||
|
||||
ITechniqueDefinitionAcceptor* const m_acceptor;
|
||||
|
||||
bool m_in_pass;
|
||||
bool m_in_shader;
|
||||
ShaderSelector m_current_shader;
|
||||
|
||||
explicit TechniqueParserState(ITechniqueDefinitionAcceptor* acceptor);
|
||||
};
|
||||
} // namespace techset
|
||||
+31
-28
@@ -4,7 +4,7 @@
|
||||
|
||||
using namespace techset;
|
||||
|
||||
namespace techset
|
||||
namespace
|
||||
{
|
||||
class SequenceTechniqueTypeName final : public TechsetParser::sequence_t
|
||||
{
|
||||
@@ -26,11 +26,11 @@ namespace techset
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE_NAME);
|
||||
|
||||
size_t techniqueTypeIndex;
|
||||
if (!state->FindTechniqueTypeIndex(typeNameToken.StringValue(), techniqueTypeIndex))
|
||||
const auto maybeTechniqueTypeIndex = state->m_technique_type_names.GetTechniqueTypeByName(typeNameToken.StringValue());
|
||||
if (!maybeTechniqueTypeIndex.has_value())
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown technique type name");
|
||||
|
||||
state->m_current_technique_types.push_back(techniqueTypeIndex);
|
||||
state->m_current_technique_types.push_back(maybeTechniqueTypeIndex.value());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -64,31 +64,34 @@ namespace techset
|
||||
techniqueNameToken.m_type == SimpleParserValueType::STRING ? techniqueNameToken.StringValue() : techniqueNameToken.IdentifierValue();
|
||||
|
||||
for (const auto techniqueTypeIndex : state->m_current_technique_types)
|
||||
state->m_definition->SetTechniqueByIndex(techniqueTypeIndex, techniqueName);
|
||||
state->m_definition->m_technique_names[techniqueTypeIndex] = techniqueName;
|
||||
state->m_current_technique_types.clear();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace techset
|
||||
{
|
||||
TechsetParser::TechsetParser(SimpleLexer& lexer, const CommonTechniqueTypeNames& techniqueTypeNames)
|
||||
: AbstractParser(&lexer, std::make_unique<TechsetParserState>(techniqueTypeNames))
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<TechsetParser::sequence_t*>& TechsetParser::GetTestsForState()
|
||||
{
|
||||
static std::vector<sequence_t*> allTests({
|
||||
new SequenceTechniqueTypeName(),
|
||||
new SequenceTechniqueName(),
|
||||
});
|
||||
static std::vector<sequence_t*> techniqueTypeNameOnlyTests({
|
||||
new SequenceTechniqueTypeName(),
|
||||
});
|
||||
|
||||
return m_state->m_current_technique_types.empty() ? techniqueTypeNameOnlyTests : allTests;
|
||||
}
|
||||
|
||||
std::unique_ptr<CommonTechset> TechsetParser::GetParsingResult() const
|
||||
{
|
||||
return std::move(m_state->m_definition);
|
||||
}
|
||||
} // namespace techset
|
||||
|
||||
TechsetParser::TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
||||
: AbstractParser(lexer, std::make_unique<TechsetParserState>(validTechniqueTypeNames, validTechniqueTypeNameCount))
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<TechsetParser::sequence_t*>& TechsetParser::GetTestsForState()
|
||||
{
|
||||
static std::vector<sequence_t*> allTests({
|
||||
new SequenceTechniqueTypeName(),
|
||||
new SequenceTechniqueName(),
|
||||
});
|
||||
static std::vector<sequence_t*> techniqueTypeNameOnlyTests({
|
||||
new SequenceTechniqueTypeName(),
|
||||
});
|
||||
|
||||
return m_state->m_current_technique_types.empty() ? techniqueTypeNameOnlyTests : allTests;
|
||||
}
|
||||
|
||||
std::unique_ptr<TechsetDefinition> TechsetParser::GetTechsetDefinition() const
|
||||
{
|
||||
return std::move(m_state->m_definition);
|
||||
}
|
||||
+4
-6
@@ -3,19 +3,17 @@
|
||||
#include "Parsing/Impl/AbstractParser.h"
|
||||
#include "Parsing/Simple/SimpleLexer.h"
|
||||
#include "Parsing/Simple/SimpleParserValue.h"
|
||||
#include "Techset/TechsetDefinition.h"
|
||||
#include "TechsetFileParserState.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetParser final : public AbstractParser<SimpleParserValue, TechsetParserState>
|
||||
{
|
||||
public:
|
||||
TechsetParser(SimpleLexer& lexer, const CommonTechniqueTypeNames& techniqueTypeNames);
|
||||
[[nodiscard]] std::unique_ptr<CommonTechset> GetParsingResult() const;
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
TechsetParser(SimpleLexer* lexer, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||
_NODISCARD std::unique_ptr<TechsetDefinition> GetTechsetDefinition() const;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "TechsetFileParserState.h"
|
||||
|
||||
namespace techset
|
||||
{
|
||||
TechsetParserState::TechsetParserState(const CommonTechniqueTypeNames& techniqueTypeNames)
|
||||
: m_technique_type_names(techniqueTypeNames),
|
||||
m_definition(std::make_unique<CommonTechset>(techniqueTypeNames.GetTechniqueTypeCount()))
|
||||
{
|
||||
}
|
||||
} // namespace techset
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetParserState
|
||||
{
|
||||
public:
|
||||
explicit TechsetParserState(const CommonTechniqueTypeNames& techniqueTypeNames);
|
||||
|
||||
const CommonTechniqueTypeNames& m_technique_type_names;
|
||||
std::unique_ptr<CommonTechset> m_definition;
|
||||
std::vector<size_t> m_current_technique_types;
|
||||
};
|
||||
} // namespace techset
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
#include "TechsetDefinitionCache.h"
|
||||
#include "CommonTechsetCache.h"
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechsetDefinition* TechsetDefinitionCache::GetCachedTechsetDefinition(const std::string& techsetName) const
|
||||
CommonTechset* CommonTechsetCache::GetCachedTechsetDefinition(const std::string& techsetName) const
|
||||
{
|
||||
const auto foundTechset = m_cache.find(techsetName);
|
||||
|
||||
@@ -12,7 +12,7 @@ TechsetDefinition* TechsetDefinitionCache::GetCachedTechsetDefinition(const std:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TechsetDefinitionCache::AddTechsetDefinitionToCache(std::string name, std::unique_ptr<TechsetDefinition> definition)
|
||||
void CommonTechsetCache::AddCommonTechsetToCache(std::string name, std::unique_ptr<CommonTechset> definition)
|
||||
{
|
||||
m_cache.emplace(std::make_pair(std::move(name), std::move(definition)));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IZoneAssetCreationState.h"
|
||||
#include "Techset/CommonTechset.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class CommonTechsetCache final : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] CommonTechset* GetCachedTechsetDefinition(const std::string& techsetName) const;
|
||||
void AddCommonTechsetToCache(std::string name, std::unique_ptr<CommonTechset> definition);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<CommonTechset>> m_cache;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1,25 +0,0 @@
|
||||
#include "TechsetFileParserState.h"
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechsetParserState::TechsetParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount)
|
||||
: m_definition(std::make_unique<TechsetDefinition>(validTechniqueTypeNameCount))
|
||||
{
|
||||
for (auto i = 0u; i < validTechniqueTypeNameCount; i++)
|
||||
{
|
||||
m_valid_technique_type_names.emplace(std::make_pair(std::string(validTechniqueTypeNames[i]), i));
|
||||
}
|
||||
}
|
||||
|
||||
bool TechsetParserState::FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const
|
||||
{
|
||||
const auto foundTechniqueType = m_valid_technique_type_names.find(techniqueTypeName);
|
||||
|
||||
if (foundTechniqueType != m_valid_technique_type_names.end())
|
||||
{
|
||||
techniqueTypeIndex = foundTechniqueType->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Techset/TechsetDefinition.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetParserState
|
||||
{
|
||||
public:
|
||||
std::map<std::string, size_t> m_valid_technique_type_names;
|
||||
std::unique_ptr<TechsetDefinition> m_definition;
|
||||
std::vector<size_t> m_current_technique_types;
|
||||
|
||||
TechsetParserState(const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||
|
||||
bool FindTechniqueTypeIndex(const std::string& techniqueTypeName, size_t& techniqueTypeIndex) const;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "TechsetDefinition.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechsetDefinition::TechsetDefinition(const size_t techniqueTypeCount)
|
||||
: m_has_technique(techniqueTypeCount),
|
||||
m_technique_names(techniqueTypeCount)
|
||||
{
|
||||
}
|
||||
|
||||
bool TechsetDefinition::GetTechniqueByIndex(const size_t index, std::string& techniqueName) const
|
||||
{
|
||||
assert(index < m_has_technique.size());
|
||||
if (index >= m_has_technique.size() || !m_has_technique[index])
|
||||
return false;
|
||||
|
||||
techniqueName = m_technique_names[index];
|
||||
return true;
|
||||
}
|
||||
|
||||
void TechsetDefinition::SetTechniqueByIndex(const size_t index, std::string techniqueName)
|
||||
{
|
||||
assert(index < m_has_technique.size());
|
||||
if (index >= m_has_technique.size())
|
||||
return;
|
||||
|
||||
m_has_technique[index] = true;
|
||||
m_technique_names[index] = std::move(techniqueName);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetDefinition
|
||||
{
|
||||
std::vector<bool> m_has_technique;
|
||||
std::vector<std::string> m_technique_names;
|
||||
|
||||
public:
|
||||
explicit TechsetDefinition(size_t techniqueTypeCount);
|
||||
bool GetTechniqueByIndex(size_t index, std::string& techniqueName) const;
|
||||
void SetTechniqueByIndex(size_t index, std::string techniqueName);
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Asset/IZoneAssetCreationState.h"
|
||||
#include "TechsetDefinition.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetDefinitionCache final : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
_NODISCARD TechsetDefinition* GetCachedTechsetDefinition(const std::string& techsetName) const;
|
||||
void AddTechsetDefinitionToCache(std::string name, std::unique_ptr<TechsetDefinition> definition);
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<TechsetDefinition>> m_cache;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "TechsetFileReader.h"
|
||||
|
||||
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
|
||||
#include "Parsing/Impl/ParserSingleInputStream.h"
|
||||
#include "Parsing/TechsetFileParser.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
using namespace techset;
|
||||
|
||||
TechsetFileReader::TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, const size_t validTechniqueTypeNameCount)
|
||||
: m_file_name(std::move(fileName)),
|
||||
m_valid_technique_type_names(validTechniqueTypeNames),
|
||||
m_valid_technique_type_name_count(validTechniqueTypeNameCount)
|
||||
{
|
||||
m_base_stream = std::make_unique<ParserSingleInputStream>(stream, m_file_name);
|
||||
m_comment_proxy = std::make_unique<CommentRemovingStreamProxy>(m_base_stream.get());
|
||||
}
|
||||
|
||||
std::unique_ptr<techset::TechsetDefinition> TechsetFileReader::ReadTechsetDefinition() const
|
||||
{
|
||||
SimpleLexer::Config lexerConfig;
|
||||
lexerConfig.m_emit_new_line_tokens = false;
|
||||
lexerConfig.m_read_strings = true;
|
||||
lexerConfig.m_string_escape_sequences = false;
|
||||
lexerConfig.m_read_integer_numbers = false;
|
||||
lexerConfig.m_read_floating_point_numbers = false;
|
||||
const auto lexer = std::make_unique<SimpleLexer>(m_comment_proxy.get(), std::move(lexerConfig));
|
||||
|
||||
const auto parser = std::make_unique<techset::TechsetParser>(lexer.get(), m_valid_technique_type_names, m_valid_technique_type_name_count);
|
||||
|
||||
const auto success = parser->Parse();
|
||||
if (success)
|
||||
return parser->GetTechsetDefinition();
|
||||
|
||||
con::error("Parsing techset file \"{}\" failed!", m_file_name);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/IParserLineStream.h"
|
||||
#include "TechsetDefinition.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
class TechsetFileReader
|
||||
{
|
||||
std::string m_file_name;
|
||||
const char** m_valid_technique_type_names;
|
||||
size_t m_valid_technique_type_name_count;
|
||||
std::unique_ptr<IParserLineStream> m_base_stream;
|
||||
std::unique_ptr<IParserLineStream> m_comment_proxy;
|
||||
|
||||
public:
|
||||
TechsetFileReader(std::istream& stream, std::string fileName, const char** validTechniqueTypeNames, size_t validTechniqueTypeNameCount);
|
||||
|
||||
_NODISCARD std::unique_ptr<TechsetDefinition> ReadTechsetDefinition() const;
|
||||
};
|
||||
} // namespace techset
|
||||
@@ -474,10 +474,7 @@ namespace
|
||||
techniqueNames[techniqueIndex] = technique->name;
|
||||
}
|
||||
|
||||
return techset::CommonTechset{
|
||||
.m_name = techset.name,
|
||||
.m_technique_names = std::move(techniqueNames),
|
||||
};
|
||||
return techset::CommonTechset(techset.name, std::move(techniqueNames));
|
||||
}
|
||||
|
||||
void DumpTechset(const AssetDumpingContext& context, const MaterialTechniqueSet& techset)
|
||||
|
||||
@@ -301,10 +301,7 @@ namespace
|
||||
techniqueNames[techniqueIndex] = technique->name;
|
||||
}
|
||||
|
||||
return techset::CommonTechset{
|
||||
.m_name = techset.name,
|
||||
.m_technique_names = std::move(techniqueNames),
|
||||
};
|
||||
return techset::CommonTechset(techset.name, std::move(techniqueNames));
|
||||
}
|
||||
|
||||
void DumpTechset(const AssetDumpingContext& context, const MaterialTechniqueSet& techset)
|
||||
|
||||
@@ -312,18 +312,14 @@ namespace
|
||||
techniqueNames[techniqueIndex] = technique->name;
|
||||
}
|
||||
|
||||
return techset::CommonTechset{
|
||||
.m_name = techset.name,
|
||||
.m_technique_names = std::move(techniqueNames),
|
||||
};
|
||||
return techset::CommonTechset(techset.name, std::move(techniqueNames));
|
||||
}
|
||||
|
||||
void DumpTechset(const AssetDumpingContext& context, const MaterialTechniqueSet& techset)
|
||||
{
|
||||
static techset::CommonTechniqueTypeNames commonNames(techniqueTypeNames, std::extent_v<decltype(techniqueTypeNames)>);
|
||||
const auto commonTechset = ConvertToCommonTechset(techset);
|
||||
|
||||
techset::DumpCommonTechset(commonNames, context, commonTechset);
|
||||
techset::DumpCommonTechset(commonTechniqueTypeNames, context, commonTechset);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Reference in new issue
Block a user