mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Move statemap for technique loading to AssetLoaderTechniqueSet
This commit is contained in:
parent
d11f8122f3
commit
63f636d401
@ -883,7 +883,7 @@ namespace IW4
|
||||
|
||||
GfxStateBits GetStateBitsForTechnique(const std::string& techniqueName)
|
||||
{
|
||||
const auto* stateMap = GetStateMapForTechnique(techniqueName);
|
||||
const auto* stateMap = AssetLoaderTechniqueSet::GetStateMapForTechnique(techniqueName, m_search_path, m_state_map_cache);
|
||||
if (!stateMap)
|
||||
return m_base_state_bits;
|
||||
|
||||
@ -897,35 +897,6 @@ namespace IW4
|
||||
return stateBits;
|
||||
}
|
||||
|
||||
_NODISCARD const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const
|
||||
{
|
||||
const auto* preloadedStateMap = m_state_map_cache->GetStateMapForTechnique(techniqueName);
|
||||
if (preloadedStateMap)
|
||||
return preloadedStateMap;
|
||||
|
||||
const auto techniqueFileName = AssetLoaderTechniqueSet::GetTechniqueFileName(techniqueName);
|
||||
const auto file = m_search_path->Open(techniqueFileName);
|
||||
if (!file.IsOpen())
|
||||
{
|
||||
std::cerr << "Failed to find file for technique \"" << techniqueName << "\"\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
state_map::StateMapFromTechniqueExtractor extractor;
|
||||
const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor);
|
||||
if (!reader.ReadTechniqueDefinition())
|
||||
{
|
||||
m_state_map_cache->SetTechniqueUsesStateMap(techniqueName, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto stateMapName = extractor.RetrieveStateMap();
|
||||
const auto* loadedStateMap = AssetLoaderTechniqueSet::LoadStateMapDefinition(stateMapName, m_search_path, m_state_map_cache);
|
||||
m_state_map_cache->SetTechniqueUsesStateMap(techniqueName, loadedStateMap);
|
||||
|
||||
return loadedStateMap;
|
||||
}
|
||||
|
||||
GfxStateBits CalculateStateBitsWithStateMap(const state_map::StateMapDefinition* stateMap) const
|
||||
{
|
||||
const state_map::StateMapHandler stateMapHandler(stateMapLayout, *stateMap);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Techset/TechniqueFileReader.h"
|
||||
#include "Techset/TechsetFileReader.h"
|
||||
#include "Shader/D3D9ShaderAnalyser.h"
|
||||
#include "StateMap/StateMapFromTechniqueExtractor.h"
|
||||
#include "StateMap/StateMapReader.h"
|
||||
#include "Techset/TechniqueStateMapCache.h"
|
||||
#include "Techset/TechsetDefinitionCache.h"
|
||||
@ -1293,6 +1294,35 @@ bool AssetLoaderTechniqueSet::CreateTechsetFromDefinition(const std::string& ass
|
||||
return true;
|
||||
}
|
||||
|
||||
const state_map::StateMapDefinition* AssetLoaderTechniqueSet::GetStateMapForTechnique(const std::string& techniqueName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache)
|
||||
{
|
||||
const auto* preloadedStateMap = stateMapCache->GetStateMapForTechnique(techniqueName);
|
||||
if (preloadedStateMap)
|
||||
return preloadedStateMap;
|
||||
|
||||
const auto techniqueFileName = GetTechniqueFileName(techniqueName);
|
||||
const auto file = searchPath->Open(techniqueFileName);
|
||||
if (!file.IsOpen())
|
||||
{
|
||||
std::cerr << "Failed to find file for technique \"" << techniqueName << "\"\n";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
state_map::StateMapFromTechniqueExtractor extractor;
|
||||
const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor);
|
||||
if (!reader.ReadTechniqueDefinition())
|
||||
{
|
||||
stateMapCache->SetTechniqueUsesStateMap(techniqueName, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto stateMapName = extractor.RetrieveStateMap();
|
||||
const auto* loadedStateMap = LoadStateMapDefinition(stateMapName, searchPath, stateMapCache);
|
||||
stateMapCache->SetTechniqueUsesStateMap(techniqueName, loadedStateMap);
|
||||
|
||||
return loadedStateMap;
|
||||
}
|
||||
|
||||
techset::TechsetDefinition* AssetLoaderTechniqueSet::LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache)
|
||||
{
|
||||
auto* cachedTechsetDefinition = definitionCache->GetCachedTechsetDefinition(assetName);
|
||||
|
@ -20,6 +20,8 @@ namespace IW4
|
||||
static std::string GetTechniqueFileName(const std::string& techniqueName);
|
||||
static std::string GetStateMapFileName(const std::string& stateMapName);
|
||||
|
||||
static const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
|
||||
|
||||
static techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, ISearchPath* searchPath, techset::TechsetDefinitionCache* definitionCache);
|
||||
static const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, ISearchPath* searchPath, techset::TechniqueStateMapCache* stateMapCache);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user