Developing Games on Intel Graphics
If you are gaming on graphics integrated in your Intel Processor, this is the place for you! Find answers to your questions or post your issues with PC games

OpenGL driver bugs with HD 4000

Nils_K_
Beginner
825 Views

I'm running this on a NUC DC53427HYE with Windows 8.1 64bit. Driver Version: 10.18.10.3379

The testcases use freeglut for creating a gl context and glew for extension loading.

First the driver doesn't accept variables declared as "varying in" or "varying out" in geometry shaders using the ARB_geometry_shader4 or EXT_geometry_shader4 extensions even though the syntax is given as an example in https://www.opengl.org/registry/specs/ARB/geometry_shader4.txt. The driver only accepts "in" or "out" as qualifiers.

#include "stdafx.h"
#include "GL/glew.h"
#include "GL/glut.h"
#include <vector>
#include <fstream>
#include <vector>
#include <iostream>

GLuint program;

const char *gs_source =
"#version 120\n"
"#extension GL_EXT_geometry_shader4 : require\n"
"varying in vec4 vtx_position[]; //doesn't compile\n"
"void main(void) {\n"
"}\n";

void printCompileError(GLuint obj){
    GLint logLength = 0;
    glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
    if(logLength){
        std::vector<GLcharARB> errorLog(logLength,0);
        glGetInfoLogARB(obj, logLength,0,&errorLog[0]);
        fprintf(stderr, &errorLog[0]);
    }
}

int init_resources(){
    GLint compile_ok = GL_FALSE, link_ok = GL_FALSE;
    program = glCreateProgram();
    
    glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
    glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
    glDisable(GL_CULL_FACE);


    GLuint geomObject = glCreateShaderObjectARB(GL_GEOMETRY_SHADER_ARB);
    glShaderSource(geomObject, 1, &gs_source, NULL);

    glCompileShader(geomObject);
    glGetShaderiv(geomObject, GL_COMPILE_STATUS, &compile_ok);
    if (0 == compile_ok){
        fprintf(stderr, "Error in geom shader\n");
        printCompileError(geomObject);
        __debugbreak();
        return 0;
    }
    return 0;
}


void onDisplay()
{
    glutReportErrors();
    glutSwapBuffers();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutCreateWindow("gltestcase");

    GLenum glew_status = glewInit();
    if (glew_status != GLEW_OK)
    {
        fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
        return EXIT_FAILURE;
    }

    if (1 == init_resources())    {
        glutDisplayFunc(onDisplay);
        glutMainLoop();
    }

    return 0;
}

The next bug happens when initializing a global variable in the fragment shader to the value of the build in varying "gl_Color". When running the test case a red and green triangle should be visible but they are just black. If the global is initialized inside main everything works as expected.

#include "stdafx.h"
#include "GL/glew.h"
#include "GL/glut.h"
#include <vector>
#include <fstream>
#include <vector>
#include <iostream>

GLuint program;

const char *vs_source =
"void main(void) {\n"
"  gl_FrontColor = gl_Color;\n"
"  gl_Position = ftransform();\n"
"  gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n"
"}\n";

const char *fs_source =
"vec4 globalColor = gl_Color; \n"
"vec4 fun(){\n"
"    vec4 localColor;\n"
"    localColor = globalColor;\n"
"    return localColor;\n"
"}\n"
"void main(void) {\n"
"    //globalColor = gl_Color; //if not commented out it works as expected\n"
"    gl_FragColor = fun();\n"
"}\n";

void printCompileError(GLuint obj){
    GLint logLength = 0;
    glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logLength);
    if(logLength){
        std::vector<GLcharARB> errorLog(logLength,0);
        glGetInfoLogARB(obj, logLength,0,&errorLog[0]);
        fprintf(stderr, &errorLog[0]);
    }
}

int init_resources(){
    GLint compile_ok = GL_FALSE, link_ok = GL_FALSE;
    program = glCreateProgram();
    
    GLuint vs = glCreateShader(GL_VERTEX_SHADER);

    glShaderSource(vs, 1, &vs_source, NULL);
    glCompileShader(vs);
    glGetShaderiv(vs, GL_COMPILE_STATUS, &compile_ok);
    if (0 == compile_ok){
        fprintf(stderr, "Error in vertex shader\n");
        printCompileError(vs);
        __debugbreak();
        return 0;
    }

    GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(fs, 1, &fs_source, NULL);
    glCompileShader(fs);
    glGetShaderiv(fs, GL_COMPILE_STATUS, &compile_ok);
    if (!compile_ok){
        fprintf(stderr, "Error in fragment shader\n");
        printCompileError(fs);
        __debugbreak();
        return 0;
    }

    glAttachShader(program, vs);
    glAttachShader(program, fs);

    glLinkProgram(program);
    glGetProgramiv(program, GL_LINK_STATUS, &link_ok);
    if (!link_ok) {
        fprintf(stderr, "glLinkProgram:");
        printCompileError(program);
        __debugbreak();
        return 0;
    }            
    glutReportErrors();
    return 1;
}


void onDisplay()
{
    glClearColor(0.0, 0.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);

    glUseProgram(program);
    glValidateProgram(program);
    int valid;
    glGetObjectParameterivARB(program, GL_OBJECT_VALIDATE_STATUS_ARB, &valid);
    if(!valid){
        fprintf(stderr, "validation failed");
        return;
    }

    glBegin(GL_TRIANGLES);
        glColor4f(1,0,0,0.5);
        glVertex3f(0,0,0);
        glVertex3f(1,0,0);
        glVertex3f(1,1,0);

        glColor4f(0,1,0,1);
        glVertex3f(0,0,0);
        glVertex3f(0,1,0);
        glVertex3f(1,1,0);
    glEnd();

    glutReportErrors();
    glutSwapBuffers();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutCreateWindow("gltestcase");

    GLenum glew_status = glewInit();
    if (glew_status != GLEW_OK)
    {
        fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
        return EXIT_FAILURE;
    }

    if (1 == init_resources())    {
        glutDisplayFunc(onDisplay);
        glutMainLoop();
    }

    return 0;
}

0 Kudos
5 Replies
Michael_C_Intel2
Employee
825 Views

Hi Nils K,

Thanks for bringing this up. I am unaware of any issues in our driver that could cause this. I have contacted our OpenGL driver development team and they will investigate.

0 Kudos
Michael_C_Intel2
Employee
825 Views

Hi Nils K,

A new driver has been released that has a fix for your issue.

https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=24245&lang=eng&ProdId=3720

 

 

0 Kudos
Nitish_J_
Beginner
825 Views

Hi,

We recently ran into the same issue with Intel driver version 10.18.10.3412. I have a few queries regarding this

- Is there a work around for this problem apart from updating the driver?
- Can you tell the driver version after which the problem was fixed?

--Nitish

 

 

0 Kudos
Michael_C_Intel2
Employee
825 Views

Hi Nitish,

There is no workaround that I am aware of. Driver version 3412 would still have he issue. Try 15.36.26.4294 released 2 weeks ago.

-Michael

0 Kudos
Nils_K_
Beginner
825 Views

As a workaround for the varying bug you can just use different shaders for different vendors (since everyone seems to cultivate their own bugs), for example with a bunch of defines.

The workaround for the gl_Color-bug is obviously just dumping your initialization code into main. If you can just stop using all OldGL fixed-function interop stuff and just use your own variables to pass data to the shader that's even better.

As for the driver version the bugs got fixed in, that didn't matter in my case because there are users that can't update drivers for whatever silly reason (i.e. moronic laptop vendors).

0 Kudos
Reply