Fix: GPU: Skip binaries larger than the shared memory

This commit is contained in:
Miguel Pozo 2024-06-24 18:33:05 +02:00
parent 65de0db503
commit d88150ce1f

@ -102,9 +102,11 @@ class SubprocessShader {
if (success_) {
glGetProgramiv(program_, GL_PROGRAM_BINARY_LENGTH, &bin->size);
if (bin->size <= sizeof(ShaderBinaryHeader::data)) {
glGetProgramBinary(program_, bin->size, nullptr, &bin->format, bin->data);
if (bin->size > sizeof(ShaderBinaryHeader::data)) {
bin->size = 0;
return nullptr;
}
glGetProgramBinary(program_, bin->size, nullptr, &bin->format, bin->data);
}
return bin;
@ -252,9 +254,11 @@ void GPU_compilation_subprocess_run(const char *subprocess_name)
end_semaphore.increment();
fstream file(cache_path, std::ios::binary | std::ios::out);
file.write(reinterpret_cast<char *>(shared_mem.get_data()),
binary->size + offsetof(ShaderBinaryHeader, data));
if (binary) {
fstream file(cache_path, std::ios::binary | std::ios::out);
file.write(reinterpret_cast<char *>(shared_mem.get_data()),
binary->size + offsetof(ShaderBinaryHeader, data));
}
}
GPU_exit();