• 1
name Punditsdkoslkdosdkoskdo

Error Linking shaders on NVidia vs Intel graphics

I'm having an issue with my GLFW/C++ program where I am having an issue where the shaders will compile and link properly on an NVIDIA gpu but not on an intel integrated graphics card. I have been trying to fix this for hours for a school project but it seems to be getting nowhere. The shaders will compile properly on the intel side but it fails to link the shaders.

I know the shaders themselves are fine because they work in other projects I've done, it just fails in this specific one.

Here's some code for the shader linking

void ResourceManager::LoadMaterial(const std::string name, const char *prefix){

    // Load vertex program source code
    std::string filename = std::string(prefix) + std::string(VERTEX_PROGRAM_EXTENSION);
    std::string vp = LoadTextFile(filename.c_str());

    // Load fragment program source code
    filename = std::string(prefix) + std::string(FRAGMENT_PROGRAM_EXTENSION);
    std::string fp = LoadTextFile(filename.c_str());

    // Create a shader from the vertex program source code
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);
    const char *source_vp = vp.c_str();
    glShaderSource(vs, 1, &source_vp, NULL);

    // Check if shader compiled successfully
    GLint status;
    glGetShaderiv(vs, GL_COMPILE_STATUS, &status);
    if (status != GL_TRUE){
        char buffer[512];
        glGetShaderInfoLog(vs, 512, NULL, buffer);
        throw(std::ios_base::failure(std::string("Error compiling vertex shader: ")+std::string(buffer)));

    // Create a shader from the fragment program source code
    GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    const char *source_fp = fp.c_str();
    glShaderSource(fs, 1, &source_fp, NULL);

    // Check if shader compiled successfully
    glGetShaderiv(fs, GL_COMPILE_STATUS, &status);
    if (status != GL_TRUE){
        char buffer[512];
        glGetShaderInfoLog(fs, 512, NULL, buffer);
        throw(std::ios_base::failure(std::string("Error compiling fragment shader: ")+std::string(buffer)));

    // Create a shader program linking both vertex and fragment shaders
    // together
    GLuint sp = glCreateProgram();
    glAttachShader(sp, vs);
    glAttachShader(sp, fs);

    // Check if shaders were linked successfully
    glGetProgramiv(sp, GL_LINK_STATUS, &status);
    if (status != GL_TRUE){
        char buffer[512];
        glGetShaderInfoLog(sp, 512, NULL, buffer);
        throw(std::ios_base::failure(std::string("Error linking shaders: ")+std::string(buffer)));

    // Delete memory used by shaders, since they were already compiled
    // and linked

    // Add a resource for the shader program
    AddResource(Material, name, sp, 0);

If you need other parts of the code I'll be happy to provide more but this is where it seems to fail on the intel side.

I really hope there's a dead simple fix to this that I have not found because this is a hair-pulling issue. Thanks in advance.

addendum #1: error code

Error linking shaders: ╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠

As clearly specified in GLSL specification version 1.30; 5.7 Structure and Array Operations; page 46length is a method and not a member and the correct syntax for to use is:

vec3 light_pos[2];

int l = light_pos.length();

Change light_pos.length by light_pos.length() to solve your issue.

Of course it is still surprising that the compiler doesn't generate an error message in this case.
In my case the NVIDIA driver accepted light_pos.length as if it were light_pos.length().
Of course the Intel HD driver accepted light_pos.length(). Using light_pos.length didn't give any error message, but it causes an access violation at glLinkProgram.

  • 0
Reply Report