1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 05:49:34 +00:00

Change shaders storage format: add information about config options used on

the moment of storage creation.
If user changes option(s), which changes the way of shaders creation then
shaders storage have to be reset.
This commit is contained in:
Sergey Lipskiy 2015-10-05 22:49:37 +06:00
parent f267ca36fc
commit a12c9e7464
4 changed files with 34 additions and 1 deletions

View File

@ -339,9 +339,20 @@ void getStorageFileName(wchar_t * _fileName)
swprintf(_fileName, PLUGIN_PATH_SIZE, L"%ls/GLideN64.%08lx.shaders", pPath, std::hash<std::string>()(RSP.romname));
}
u32 CombinerInfo::_getConfigOptionsBitSet() const
{
std::vector<u32> vecOptions;
ShaderCombiner::getShaderCombinerOptionsSet(vecOptions);
u32 optionsSet = 0;
for (u32 i = 0; i < vecOptions.size(); ++i)
optionsSet |= vecOptions[i] << i;
return optionsSet;
}
/*
Storage format:
uint32 - format version;
uint32 - bitset of config options, which may change how shader is created.
uint32 - len of renderer string
char * - renderer string
uint32 - len of GL version string
@ -349,7 +360,7 @@ Storage format:
uint32 - number of shaders
shaders in binary form
*/
static const u32 CombinersCacheFormatVersion = 0x01U;
static const u32 CombinersCacheFormatVersion = 0x02U;
void CombinerInfo::_saveShadersStorage() const
{
if (m_shadersLoaded >= m_combiners.size())
@ -370,6 +381,9 @@ void CombinerInfo::_saveShadersStorage() const
fout.write((char*)&CombinersCacheFormatVersion, sizeof(CombinersCacheFormatVersion));
const u32 optionsSet = _getConfigOptionsBitSet();
fout.write((char*)&optionsSet, sizeof(optionsSet));
const char * strRenderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
u32 len = strlen(strRenderer);
fout.write((char*)&len, sizeof(len));
@ -409,6 +423,11 @@ bool CombinerInfo::_loadShadersStorage()
if (version != CombinersCacheFormatVersion)
return false;
u32 optionsSet;
fin.read((char*)&optionsSet, sizeof(optionsSet));
if (optionsSet != _getConfigOptionsBitSet())
return false;
const char * strRenderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
u32 len;
fin.read((char*)&len, sizeof(len));

View File

@ -148,6 +148,7 @@ private:
void _saveShadersStorage() const;
bool _loadShadersStorage();
u32 _getConfigOptionsBitSet() const;
ShaderCombiner * _compile(u64 mux) const;
bool m_bChanged;

View File

@ -38,6 +38,8 @@ public:
friend std::ostream & operator<< (std::ostream & _os, const ShaderCombiner & _combiner);
friend std::istream & operator>> (std::istream & _os, ShaderCombiner & _combiner);
static void getShaderCombinerOptionsSet(std::vector<u32> & _vecOptions);
private:
friend class UniformBlock;
friend class UniformSet;

View File

@ -791,6 +791,17 @@ std::istream & operator>> (std::istream & _is, ShaderCombiner & _combiner)
return _is;
}
void ShaderCombiner::getShaderCombinerOptionsSet(std::vector<u32> & _vecOptions)
{
// WARNING: Shader Storage format version must be increased after any change in this function.
_vecOptions.push_back(config.video.multisampling > 0 ? 1 : 0);
_vecOptions.push_back(config.texture.bilinearMode);
_vecOptions.push_back(config.generalEmulation.enableHWLighting);
_vecOptions.push_back(config.generalEmulation.enableNoise);
_vecOptions.push_back(config.generalEmulation.enableLOD);
_vecOptions.push_back(config.frameBufferEmulation.N64DepthCompare);
}
#ifdef GL_IMAGE_TEXTURES_SUPPORT
void SetDepthFogCombiner()
{