NVIDIA Tegra samplerExternalOES Shader Linker Bug

On NVIDIA Tegra devices (nvidia shield),glLinkProgram incorrectly fails when both vertex and fragment shaders declare the same uniform samplerExternalOES, even if the vertex shader does not use it.

NVIDIA software Version: 9.2.2 (33.2.0.382)

The Bug

When linking a program where both shaders declare:

uniform samplerExternalOES tex;

and the vertex shader declares but never uses the uniform, the Tegra driver incorrectly reports a link error:

glLinkProgram FAILED:
Vertex info
-----------
error: struct type mismatch between shaders for uniform (named tex)

Expected behavior (per GLSL spec)

An unused uniform is valid. The program link should succeed.

Shaders

Both shaders declare the same uniform with the same type. The vertex shader’s declaration is intentionally unused to trigger the Tegra bug.

fragment.glsl

#version 320 es
#extension GL_OES_EGL_image_external_essl3 : require

precision highp float;
precision mediump sampler2D;
precision highp int;

uniform samplerExternalOES tex;

in vec2 v_texCoord;
out vec4 fragColor;

void main() {
    fragColor = texture(tex, v_texCoord);
}

vertex.glsl

#version 320 es
#extension GL_OES_EGL_image_external_essl3 : require

precision highp float;
precision mediump sampler2D;
precision highp int;

// This uniform is declared but NEVER used in the vertex shader.
// Same declaration exists in fragment shader. On NVIDIA Tegra, linking fails
// with "struct type mismatch between shaders for uniform (named tex)".
uniform samplerExternalOES tex;

in vec2 a_position;
out vec2 v_texCoord;

void main() {
    gl_Position = vec4(a_position, 0.0, 1.0);
    v_texCoord = a_position * 0.5 + 0.5;
}

To properly explain this issue, I opened a repository with the code to reproduce the issue AND I explained the issue in the README: GitHub - moi15moi/nvidia-tegra-repro-opengl · GitHub