From 3185e359b9171064b3e396a41ede43e9253cf3b4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 10 Jan 2020 13:52:17 +0200 Subject: [PATCH] - added workaround for GLSL noise functions on macOS There is no chance that Apple will fix their OpenGL drivers The only viable solution is to preprocess these functions out, and put zeroes instead of them --- src/rendering/gl/shaders/gl_shader.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rendering/gl/shaders/gl_shader.cpp b/src/rendering/gl/shaders/gl_shader.cpp index fc8d78720..2d2ceda41 100644 --- a/src/rendering/gl/shaders/gl_shader.cpp +++ b/src/rendering/gl/shaders/gl_shader.cpp @@ -321,6 +321,16 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * i_data += "#define brighttexture texture2\n"; i_data += "#endif\n"; +#ifdef __APPLE__ + // The noise functions are completely broken in macOS OpenGL drivers + // Garbage values are returned, and their infrequent usage causes extreme slowdown + // Also, these functions must return zeroes since GLSL 4.4 + i_data += "#define noise1(unused) 0.0\n"; + i_data += "#define noise2(unused) vec2(0)\n"; + i_data += "#define noise3(unused) vec3(0)\n"; + i_data += "#define noise4(unused) vec4(0)\n"; +#endif // __APPLE__ + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump, 0); if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); FMemLump vp_data = Wads.ReadLump(vp_lump); @@ -824,4 +834,4 @@ void gl_DestroyUserShaders() // todo } -} \ No newline at end of file +}