Concat all found shaderlist.txt files to build the shader list
This commit is contained in:
parent
b566370748
commit
f86f8d9e29
|
|
@ -98,8 +98,8 @@ public:
|
||||||
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
/// \brief Detach an \p observer previously-attached by calling \c attach.
|
||||||
virtual void detach(ModuleObserver& observer) = 0;
|
virtual void detach(ModuleObserver& observer) = 0;
|
||||||
|
|
||||||
virtual Archive* getArchive(const char* archiveName) = 0;
|
virtual Archive* getArchive(const char* archiveName, bool pakonly=true) = 0;
|
||||||
virtual void forEachArchive(const ArchiveNameCallback& callback) = 0;
|
virtual void forEachArchive(const ArchiveNameCallback& callback, bool pakonly=true, bool reverse=false) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "modulesystem.h"
|
#include "modulesystem.h"
|
||||||
|
|
|
||||||
|
|
@ -1768,9 +1768,9 @@ void IfFound_dumpUnreferencedShader(bool& bFound, const char* filename)
|
||||||
if(!bFound)
|
if(!bFound)
|
||||||
{
|
{
|
||||||
bFound = true;
|
bFound = true;
|
||||||
globalOutputStream() << "Following shader files are not referenced in shaderlist.txt:\n";
|
globalOutputStream() << "Following shader files are not referenced in any shaderlist.txt:\n";
|
||||||
}
|
}
|
||||||
globalOutputStream() << filename << "\n";
|
globalOutputStream() << "\t" << filename << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typedef ReferenceCaller1<bool, const char*, IfFound_dumpUnreferencedShader> IfFoundDumpUnreferencedShaderCaller;
|
typedef ReferenceCaller1<bool, const char*, IfFound_dumpUnreferencedShader> IfFoundDumpUnreferencedShaderCaller;
|
||||||
|
|
@ -1840,6 +1840,30 @@ void FreeShaderList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShaderList_addFromArchive(const char *archivename)
|
||||||
|
{
|
||||||
|
const char *shaderpath = GlobalRadiant().getGameDescriptionKeyValue("shaderpath");
|
||||||
|
if (string_empty(shaderpath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
StringOutputStream shaderlist(256);
|
||||||
|
shaderlist << DirectoryCleaned(shaderpath) << "shaderlist.txt";
|
||||||
|
|
||||||
|
Archive *archive = GlobalFileSystem().getArchive(archivename, false);
|
||||||
|
if (archive)
|
||||||
|
{
|
||||||
|
ArchiveTextFile *file = archive->openTextFile(shaderlist.c_str());
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
globalOutputStream() << "Found shaderlist.txt in " << archivename << "\n";
|
||||||
|
BuildShaderList(file->getInputStream());
|
||||||
|
file->release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef FreeCaller1<const char *, ShaderList_addFromArchive> AddShaderListFromArchiveCaller;
|
||||||
|
|
||||||
#include "stream/filestream.h"
|
#include "stream/filestream.h"
|
||||||
|
|
||||||
bool shaderlist_findOrInstall(const char* enginePath, const char* toolsPath, const char* shaderPath, const char* gamename)
|
bool shaderlist_findOrInstall(const char* enginePath, const char* toolsPath, const char* shaderPath, const char* gamename)
|
||||||
|
|
@ -1898,23 +1922,9 @@ void Shaders_Load()
|
||||||
shaderlist_findOrInstall(enginePath, toolsPath, path.c_str(), gamename);
|
shaderlist_findOrInstall(enginePath, toolsPath, path.c_str(), gamename);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringOutputStream absShaderList(256);
|
GlobalFileSystem().forEachArchive(AddShaderListFromArchiveCaller(), false, true);
|
||||||
absShaderList << enginePath << gamename << '/' << path.c_str() << "shaderlist.txt";
|
|
||||||
|
|
||||||
{
|
|
||||||
globalOutputStream() << "Parsing shader files from " << absShaderList.c_str() << "\n";
|
|
||||||
TextFileInputStream shaderlistFile(absShaderList.c_str());
|
|
||||||
if(shaderlistFile.failed())
|
|
||||||
{
|
|
||||||
globalErrorStream() << "Couldn't find '" << absShaderList.c_str() << "'\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BuildShaderList(shaderlistFile);
|
|
||||||
DumpUnreferencedShaders();
|
DumpUnreferencedShaders();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalFileSystem().forEachFile(path.c_str(), g_shadersExtension, AddShaderFileCaller(), 0);
|
GlobalFileSystem().forEachFile(path.c_str(), g_shadersExtension, AddShaderFileCaller(), 0);
|
||||||
|
|
|
||||||
|
|
@ -661,29 +661,33 @@ public:
|
||||||
g_observers.detach(observer);
|
g_observers.detach(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive* getArchive(const char* archiveName)
|
Archive* getArchive(const char* archiveName, bool pakonly)
|
||||||
{
|
{
|
||||||
for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
|
for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
|
||||||
{
|
{
|
||||||
if((*i).is_pakfile)
|
if(pakonly && !(*i).is_pakfile)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
if(path_equal((*i).name.c_str(), archiveName))
|
if(path_equal((*i).name.c_str(), archiveName))
|
||||||
{
|
|
||||||
return (*i).archive;
|
return (*i).archive;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void forEachArchive(const ArchiveNameCallback& callback)
|
void forEachArchive(const ArchiveNameCallback& callback, bool pakonly, bool reverse)
|
||||||
{
|
{
|
||||||
|
if (reverse)
|
||||||
|
g_archives.reverse();
|
||||||
|
|
||||||
for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
|
for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i)
|
||||||
{
|
{
|
||||||
if((*i).is_pakfile)
|
if(pakonly && !(*i).is_pakfile)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
callback((*i).name.c_str());
|
callback((*i).name.c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (reverse)
|
||||||
|
g_archives.reverse();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user