workaround for nvidia shader compiler bug on very old windows drivers.

This commit is contained in:
Sasha Szpakowski
2024-08-10 11:12:27 -03:00
parent 1b8a5013a3
commit 36fa78f392
3 changed files with 29 additions and 1 deletions
+5
View File
@@ -905,6 +905,9 @@ public:
return (T *) scratchBuffer.data();
}
// Workaround for some very old nvidia drivers that aren't compliant with the GLSL 3.30 spec.
bool isUsingNoTextureCubeShadowBiasHack() const { return usingNoTextureCubeShadowBiasHack; }
static Graphics *createInstance();
STRINGMAP_CLASS_DECLARE(DrawMode);
@@ -1086,6 +1089,8 @@ protected:
Deprecations deprecations;
bool usingNoTextureCubeShadowBiasHack = false;
static const size_t MAX_USER_STACK_DEPTH = 128;
static const int MAX_TEMPORARY_RESOURCE_UNUSED_FRAMES = 16;
+5
View File
@@ -143,8 +143,10 @@ float Texel(sampler2DArrayShadow s, highp vec4 c) { return texture(s, c); }
uvec4 Texel(usampler2DArray s, highp vec3 c, float b) { return texture(s, c, b); }
float Texel(sampler2DShadow s, highp vec3 c, float b) { return texture(s, c, b); }
#ifndef LOVE_NO_TEXTURECUBESHADOWBIAS_HACK
float Texel(samplerCubeShadow s, highp vec4 c, float b) { return texture(s, c, b); }
#endif
#endif
uniform mediump float deprecatedTextureCall;
@@ -613,6 +615,9 @@ std::string Shader::createShaderStageCode(Graphics *gfx, ShaderStageType stage,
if (info.usesMRT)
ss << "#define LOVE_MULTI_RENDER_TARGETS 1\n";
if (gfx->isUsingNoTextureCubeShadowBiasHack())
ss << "#define LOVE_NO_TEXTURECUBESHADOWBIAS_HACK 1\n";
for (const auto &def : options.defines)
ss << "#define " + def.first + " " + def.second + "\n";
+19 -1
View File
@@ -383,7 +383,25 @@ bool Graphics::setMode(void */*context*/, int width, int height, int pixelwidth,
Shader::CompileOptions opts;
stages.push_back(Shader::getDefaultCode(stype, SHADERSTAGE_VERTEX));
stages.push_back(Shader::getDefaultCode(stype, SHADERSTAGE_PIXEL));
Shader::standardShaders[i] = newShader(stages, opts);
try
{
Shader::standardShaders[i] = newShader(stages, opts);
}
catch (love::Exception &)
{
// Attempted workaround for nvidia driver bug affecting old GPUs
// on Windows (e.g. the 300 series).
if (!isUsingNoTextureCubeShadowBiasHack())
{
usingNoTextureCubeShadowBiasHack = true;
Shader::standardShaders[i] = newShader(stages, opts);
}
else
{
throw;
}
}
}
}