mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-13 07:49:19 +01:00
Merge pull request #2164 from Armada651/cache-fix
ProgramShaderCache: Do plenty of error checking before writing shaders to the disk.
This commit is contained in:
commit
cc5a2f3411
@ -473,25 +473,33 @@ void ProgramShaderCache::Shutdown()
|
||||
{
|
||||
for (auto& entry : pshaders)
|
||||
{
|
||||
// Clear any prior error code
|
||||
glGetError();
|
||||
|
||||
if (entry.second.in_cache)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GLint binary_size;
|
||||
GLint link_status = GL_FALSE, delete_status = GL_TRUE, binary_size = 0;
|
||||
glGetProgramiv(entry.second.shader.glprogid, GL_LINK_STATUS, &link_status);
|
||||
glGetProgramiv(entry.second.shader.glprogid, GL_DELETE_STATUS, &delete_status);
|
||||
glGetProgramiv(entry.second.shader.glprogid, GL_PROGRAM_BINARY_LENGTH, &binary_size);
|
||||
if (!binary_size)
|
||||
if (glGetError() != GL_NO_ERROR || link_status == GL_FALSE || delete_status == GL_TRUE || !binary_size)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
u8 *data = new u8[binary_size+sizeof(GLenum)];
|
||||
u8 *binary = data + sizeof(GLenum);
|
||||
GLenum *prog_format = (GLenum*)data;
|
||||
std::vector<u8> data(binary_size + sizeof(GLenum));
|
||||
u8* binary = &data[sizeof(GLenum)];
|
||||
GLenum* prog_format = (GLenum*)&data[0];
|
||||
glGetProgramBinary(entry.second.shader.glprogid, binary_size, nullptr, prog_format, binary);
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
g_program_disk_cache.Append(entry.first, data, binary_size+sizeof(GLenum));
|
||||
delete [] data;
|
||||
g_program_disk_cache.Append(entry.first, &data[0], binary_size + sizeof(GLenum));
|
||||
}
|
||||
|
||||
g_program_disk_cache.Sync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user