glsl: game RAGE crashes on startup
RAGE uses a vertex shader which redeclares gl_Position
as an output. I've created a shader test to replicate it using the exact vertex shader from the game:
[require]
GLSL >= 1.50
[vertex shader]
#version 150
float saturate( float v ) { return clamp( v, 0.0, 1.0 ); }
vec2 saturate( vec2 v ) { return clamp( v, 0.0, 1.0 ); }
vec3 saturate( vec3 v ) { return clamp( v, 0.0, 1.0 ); }
vec4 saturate( vec4 v ) { return clamp( v, 0.0, 1.0 ); }
float dot4 ( vec4 a, vec4 b ) { return dot( a, b ); }
float dot4 ( vec2 a, vec4 b ) { return dot( vec4( a, 0, 1 ), b ); }
uniform vec4 _va_ [4];
in vec4 in_Position;
in vec2 in_TexCoord;
out vec4 gl_Position;
out vec4 vofi_TexCoord0;
void main() {
gl_Position.x = dot4( in_Position, _va_[0 ] );
gl_Position.y = dot4( in_Position, _va_[1 ] );
gl_Position.z = dot4( in_Position, _va_[2 ] );
gl_Position.w = dot4( in_Position, _va_[3 ] );
vofi_TexCoord0 = vec4( in_TexCoord.x, in_TexCoord.y, 0, 0 );
}
[fragment shader]
#version 150
in vec4 in_TexCoord;
void main()
{
gl_FragColor = in_TexCoord;
}
[test]
draw rect -1 -1 2 2
This triggers a redeclaration error:
Failed to compile VS: 0:15(10): error:
gl_Position' redeclared`
According to the comments around ast_to_hir.cpp:4460 this shader violates spec, but this is a shipped game that is no longer receiving updates, so we should be able to ignore the redeclaration by one method or another.