Iris should apply patches to shaders to fix driver compatibility issues
coderbot16 opened this issue ยท 4 comments
Most shader authors create their shader packs on NVIDIA hardware. NVIDIA drivers are notoriously lax in enforcing certain parts of the GLSL specification, leading to many shader authors creating subtly-invalid shaders as a result that fail to compile with more strict drivers such as Mesa on Linux.
While it's possible for shader authors to fix these errors itself, in practice this often doesn't happen for a variety of reasons. In particular, some of the packs that Iris tries to support just aren't maintained anymore. So, it might make more sense for Iris to apply many of these incredibly trivial compatibility fixes itself.
Here's some open questions:
- How do we represent these patches without infringing copyright? It seems likely that in many cases, the small (necessary) code fragments copied for recognition / replacement purposes would fall under fair use.
- Is there are more general way to fix some of these issues instead of just going on a case by case basis?
I'm going to be collecting patches in this issue report so that they can be added once such a system is actually implemented.
Continuum 2.0.4
shaders/InternalLib/Fragment/Sky.fsh, line 47:
This is a misunderstanding of what const
means in different contexts. In a function argument context, const
just means that the argument can't be modified. In a variable declaration context, const
means that the variable is initialized with a constant expression - an expression that cannot possibly change during the life of the shader program. So you can't assign a const argument to a const variable.
float sky_miePhase(float cosTheta, const float g) {
- const float gg = g * g;
+ float gg = g * g;
shaders/InternalLib/Fragment/Sky.fsh, line 101:
Pretty much the exact same thing as the previous mistake.
vec2 rsi(vec3 position, vec3 direction, const float radius) {
float PoD = dot(position, direction);
- const float radiusSquared = radius * radius;
+ float radiusSquared = radius * radius;
Also, I want to start the thread of incorrect/missing functionality in TriForcePatcher. TriforcePatcher should be defining the other sampler2d values to the generic Core ones yet it doesn't for all, only for (as far as i know) sampler2d and sampler2dlod.
A generic list of what needs to be changed (may not be complete:)
texture2D > texture (done)
shadow2D > texture (done)
texture3D > texture
texture2DLod > textureLod (done)
shadow2DLod > textureLod (done)
texture3DLod > textureLod
texture2DGrad > textureGrad
texture2DGradARB > textureGrad
texelFetch2D > texelFetch
texelFetch3D > texelFetch
Updated:
textureSize2D > textureSize
This is essentially implemented in modern release versions of Iris that use glsl-transformer with CompatibilityTransformer, thanks @douira!