glgsg: warn if Cg shader uses float4 vtx_normal

See #495; Cg's glslv profile does not handle a float4 vtx_normal well and causes garbage to be in the w coordinate.
This commit is contained in:
rdb 2018-12-31 13:11:33 +01:00
parent 4a7266d420
commit 0cfd86d0f4

View File

@ -157,6 +157,16 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte
break;
case 2: // gl_Normal
loc = CA_normal;
if (cgGetParameterColumns(p) == 4) {
// Don't declare vtx_normal with 4 coordinates; it results in it
// reading the w coordinate from random memory.
GLCAT.error()
<< "Cg varying " << cgGetParameterName(p);
if (cgGetParameterSemantic(p)) {
GLCAT.error(false) << " : " << cgGetParameterSemantic(p);
}
GLCAT.error(false) << " should be declared as float4, not float3!\n";
}
break;
case 3: // gl_Color
loc = CA_color;