diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index c3c19df8c..0af60e412 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -56,10 +56,24 @@ struct ProgramBinary TArray data; }; -const char *ShaderMagic = "ZDSC"; +static const char *ShaderMagic = "ZDSC"; static std::map> ShaderCache; // Not a TMap because it doesn't support unique_ptr move semantics +bool IsShaderCacheActive() +{ + static bool active = true; + static bool firstcall = true; + + if (firstcall) + { + const char *vendor = (const char *)glGetString(GL_VENDOR); + active = strstr(vendor, "Intel") == nullptr; + firstcall = false; + } + return active; +} + static FString CalcProgramBinaryChecksum(const FString &vertex, const FString &fragment) { const GLubyte *vendor = glGetString(GL_VENDOR); @@ -421,7 +435,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FGLDebug::LabelObject(GL_PROGRAM, hShader, name); uint32_t binaryFormat = 0; - TArray binary = LoadCachedProgramBinary(vp_comb, fp_comb, binaryFormat); + TArray binary; + if (IsShaderCacheActive()) + binary = LoadCachedProgramBinary(vp_comb, fp_comb, binaryFormat); bool linked = false; if (binary.Size() > 0 && glProgramBinary) @@ -481,7 +497,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * // only print message if there's an error. I_Error("Init Shader '%s':\n%s\n", name, error.GetChars()); } - else if (glProgramBinary) + else if (glProgramBinary && IsShaderCacheActive()) { int binaryLength = 0; glGetProgramiv(hShader, GL_PROGRAM_BINARY_LENGTH, &binaryLength); diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 126817b59..8068b3c2c 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -37,6 +37,7 @@ namespace OpenGLRenderer { +bool IsShaderCacheActive(); TArray LoadCachedProgramBinary(const FString &vertex, const FString &fragment, uint32_t &binaryFormat); void SaveCachedProgramBinary(const FString &vertex, const FString &fragment, const TArray &binary, uint32_t binaryFormat); @@ -142,7 +143,9 @@ void FShaderProgram::Link(const char *name) FGLDebug::LabelObject(GL_PROGRAM, mProgram, name); uint32_t binaryFormat = 0; - TArray binary = LoadCachedProgramBinary(mShaderSources[Vertex], mShaderSources[Fragment], binaryFormat); + TArray binary; + if (IsShaderCacheActive()) + binary = LoadCachedProgramBinary(mShaderSources[Vertex], mShaderSources[Fragment], binaryFormat); bool loadedFromBinary = false; if (binary.Size() > 0 && glProgramBinary) @@ -168,7 +171,7 @@ void FShaderProgram::Link(const char *name) { I_FatalError("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars()); } - else if (glProgramBinary) + else if (glProgramBinary && IsShaderCacheActive()) { int binaryLength = 0; glGetProgramiv(mProgram, GL_PROGRAM_BINARY_LENGTH, &binaryLength);