PDA

View Full Version : NVIDIA Update Breaks Shader



`ZenoŽ
04-04-2016, 12:47 AM
Greetings!

I recently updated my NVIDIA GeForce driver to version 364.72, and a shader program that worked perfectly fine before does not seem to compile anymore. I haven't changed a thing to the script itself after the update, however now I get the following error:


error: Type mismatch between variable "i_Color" matched by location "1"

The vertex shader has a variable 'out vec4 o_Data1' bound to location 1, while the fragment shader has a variable 'in vec4 i_Color' bound there as well. I'll post my shaders below, but as you'll see, they're quite straightforward. I'm using it for font rendering from a single texture, allowing the font to change color in the fragment shader. I'm not sure what could possibly be going wrong. I've got other programs with a similar structure, that still work after the update. Note that these scripts were code-generated. That's why I use layout location on all of my data, it made the scripts much easier to mix and match.

My vertex shader:



#version 450 core

layout(location = 0)
uniform mat4 u_Matrix;

layout(location = 0)
in vec4 i_Vertex;

layout(location = 3)
in mat4 i_Matrix;

layout(location = 2)
in vec4 i_Data1;

layout(location = 1)
out vec4 o_Data1;

layout(location = 1)
in vec2 i_Data0;

layout(location = 0)
out vec2 o_Data0;

void main()
{
o_Data1 = i_Data1;
o_Data0 = i_Data0;

gl_Position = u_Matrix * i_Matrix * vec4(i_Vertex.x + 0.0, i_Vertex.y - 0.0, i_Vertex.z, 1.0);
}



My fragment shader:



#version 450 core

layout(location = 1)
uniform sampler2D u_Texture;

layout(location = 1)
in vec4 i_Color;

layout(location = 0)
in vec2 i_Coord;

out vec4 o_Color;

void main()
{
o_Color = texelFetch(u_Texture, ivec2(i_Coord), 0);
if(o_Color.a > 0.0)
{
o_Color.rgb = i_Color.rgb * (1.0 - o_Color.rgb);
}

if(o_Color.a == 0.0)
{
discard;
}
}


Does anyone have an idea what's going wrong here? Thanks in advance!

`ZenoŽ
04-04-2016, 10:32 AM
This issue 'sort of' got fixed, so I'm posting a solution here in case anyone else runs into this problem. It would seem there is an issue with how the driver is handling its interfaces. Once I changed the vec2 into a vec4, both the 'out o_Data0' in the vertex shader, and 'in i_Coord' in the fragment shader, the problem was fixed. Ofcourse I had to add two additional zeros in the vertex shader to fill the vec4. Props to Kai from the LWJGL forums for helping with this issue.

malexander
04-04-2016, 12:44 PM
Apparently 364.72 isn't the most stable of releases: http://www.fudzilla.com/news/graphics/40364-nvidia-geforce-364-72-drivers-come-with-plenty-of-issues