[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Possible nVidia driver bug? - (code sample attached)



Heya people,



I've been messing around with some GLSL in my engine and I started getting machine hang ups when I upgraded my nVidia drivers. I currently use a GeForce 6800 GT, and the 66.29 drivers on Fedora Core 2.
My engine apps were doing fine using the previous 61.11 drivers, but the new version just locks up everything and needs a hard boot to clean up.
While I was unable to track down the source of the problem, I was able to replicate the faulty behaviour in a small, isolated program. I attached the source code to this small app, plus two sample vertex and
fragment shaders.
The tests I made show me this hang up occurs on *both* Linux and Win32 platforms, using a 6800 GT. FX cards work fine, and I was even able to test on a Radeon 9600 Pro, and it also worked fine. The following drivers work *without* any problems: 61.11 for Linux and 61.77 for Win32. Drivers that *don't* work include: 66.29 for Linux and 66.81,
66.93 and 67.02 for Win32.
I was wondering if any of you could further test this problem on other machines, or maybe even isolate the problem. Right now I'm guessing its' something wrong with the drivers, but I can't be sure. I'd appreciate any kind of help on this one, thanks.




Thank you for your attention,

Miguel A. Osorio.
SomniumStudio - www.somniumstudio.com



PS: Attached code follows, to run the program, just put both vertex and fragment shaders on the executable's base directory.


>>>>>>>>>> glsl_test.cpp <<<<<<<<<<

// GLSL Bug Test
// Author: Miguel A. Osorio - 11 Dec 2004


#include <SDL/SDL.h>

#include <GL/gl.h>
#include <GL/glext.h>

// Default screen settings
#define SCREEN_W 1024
#define SCREEN_H 768
#define COLOR_DEPTH 24

#define MAX_LINES 64
#define MAX_LINE_LEN 128


// GL extensions PFNGLACTIVETEXTUREARBPROC glActiveTexture; PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture; PFNGLBLENDEQUATIONEXTPROC glBlendEquation; PFNGLDELETEOBJECTARBPROC glDeleteObject; PFNGLGETHANDLEARBPROC glGetHandle; PFNGLDETACHOBJECTARBPROC glDetachOject; PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObject; PFNGLSHADERSOURCEARBPROC glShaderSource; PFNGLCOMPILESHADERARBPROC glCompileShader; PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObject; PFNGLATTACHOBJECTARBPROC glAttachObject; PFNGLLINKPROGRAMARBPROC glLinkProgram; PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObject; PFNGLVALIDATEPROGRAMARBPROC glValidateProgram; PFNGLUNIFORM1FARBPROC glUniform1f; PFNGLUNIFORM2FARBPROC glUniform2f; PFNGLUNIFORM3FARBPROC glUniform3f; PFNGLUNIFORM4FARBPROC glUniform4f; PFNGLUNIFORM1IARBPROC glUniform1i; PFNGLUNIFORM2IARBPROC glUniform2i; PFNGLUNIFORM3IARBPROC glUniform3i; PFNGLUNIFORM4IARBPROC glUniform4i; PFNGLUNIFORM1FVARBPROC glUniform1fv; PFNGLUNIFORM2FVARBPROC glUniform2fv; PFNGLUNIFORM3FVARBPROC glUniform3fv; PFNGLUNIFORM4FVARBPROC glUniform4fv; PFNGLUNIFORM1IVARBPROC glUniform1iv; PFNGLUNIFORM2IVARBPROC glUniform2iv; PFNGLUNIFORM3IVARBPROC glUniform3iv; PFNGLUNIFORM4IVARBPROC glUniform4iv; PFNGLUNIFORMMATRIX2FVARBPROC glUniformMatrix2fv; PFNGLUNIFORMMATRIX3FVARBPROC glUniformMatrix3fv; PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fv; PFNGLGETOBJECTPARAMETERFVARBPROC glGetObjectParameterfv; PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv; PFNGLGETINFOLOGARBPROC glGetInfoLog; PFNGLGETATTACHEDOBJECTSARBPROC glGetAttachedObjects; PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocation; PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniform; PFNGLGETUNIFORMFVARBPROC glGetUniformfv; PFNGLGETUNIFORMIVARBPROC glGetUniformiv; PFNGLGETSHADERSOURCEARBPROC glGetShaderSource;


// Load GLSL objects GLhandleARB LoadGLSLObject(const char *filename, GLenum type) { FILE *fp; char* strings[MAX_LINES]; int nlines = 0; GLhandleARB handle;

        // Open file
        if((fp = fopen(filename, "rt")) == NULL)
                return 0;

        // Allocate line buffers
        for(int i = 0; i < MAX_LINES; ++i)
                strings[i] = new char [MAX_LINE_LEN];

        // Read source
        while(fgets(strings[nlines], MAX_LINE_LEN, fp) != NULL)
                ++nlines;

        // Get object handle
        handle = glCreateShaderObject(type);

        // Set source
        glShaderSource(handle, nlines, (const GLcharARB**)strings, NULL);
        glCompileShader(handle);

        // Free line buffers
        for(nlines = 0; nlines < MAX_LINES; ++nlines)
                delete[] strings[nlines];

        // Return handle
        return(handle);
}




int main(int argc, char *argv[]) {

        SDL_Surface *visual;
        SDL_Event event;

        // Init video
        SDL_Init(SDL_INIT_VIDEO);

        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

visual = SDL_SetVideoMode(SCREEN_W, SCREEN_H, COLOR_DEPTH, SDL_OPENGL);

        if(visual == NULL) {

                printf("error setting video mode\n");
                SDL_Quit();
                return 0;

                }

        int red, green, blue, alpha, dbuff, depth;
        SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &red);
        SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &green);
        SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &blue);
        SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &alpha);
        SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dbuff);
        SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);

printf("GL Init - RGBA: (%d, %d, %d, %d) - DEPTH: %d - DBUFF: %d\n", red, green, blue, alpha, depth, dbuff);

// Init GL extensions
glActiveTexture = (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glActiveTexture");
glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress("glClientActiveTexture");
glBlendEquation = (PFNGLBLENDEQUATIONEXTPROC)SDL_GL_GetProcAddress("glBlendEquation");


// GLSL //
glDeleteObject = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB");
glGetHandle = (PFNGLGETHANDLEARBPROC)SDL_GL_GetProcAddress("glGetHandleARB");
glDetachOject = (PFNGLDETACHOBJECTARBPROC)SDL_GL_GetProcAddress("glDetachObjectARB");
glCreateShaderObject = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB");
glShaderSource = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB");
glCompileShader = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB");
glCreateProgramObject = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB");
glAttachObject = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB");
glLinkProgram = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB");
glUseProgramObject = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB");
glValidateProgram = (PFNGLVALIDATEPROGRAMARBPROC)SDL_GL_GetProcAddress("glValidateProgramARB");
glUniform1f = (PFNGLUNIFORM1FARBPROC)SDL_GL_GetProcAddress("glUniform1fARB");
glUniform2f = (PFNGLUNIFORM2FARBPROC)SDL_GL_GetProcAddress("glUniform2fARB");
glUniform3f = (PFNGLUNIFORM3FARBPROC)SDL_GL_GetProcAddress("glUniform3fARB");
glUniform4f = (PFNGLUNIFORM4FARBPROC)SDL_GL_GetProcAddress("glUniform4fARB");
glUniform1i = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB");
glUniform2i = (PFNGLUNIFORM2IARBPROC)SDL_GL_GetProcAddress("glUniform2iARB");
glUniform3i = (PFNGLUNIFORM3IARBPROC)SDL_GL_GetProcAddress("glUniform3iARB");
glUniform4i = (PFNGLUNIFORM4IARBPROC)SDL_GL_GetProcAddress("glUniform4iARB");
glUniform1fv = (PFNGLUNIFORM1FVARBPROC)SDL_GL_GetProcAddress("glUniform1fvARB");
glUniform2fv = (PFNGLUNIFORM2FVARBPROC)SDL_GL_GetProcAddress("glUniform2fvARB");
glUniform3fv = (PFNGLUNIFORM3FVARBPROC)SDL_GL_GetProcAddress("glUniform3fvARB");
glUniform4fv = (PFNGLUNIFORM4FVARBPROC)SDL_GL_GetProcAddress("glUniform4fvARB");
glUniform1iv = (PFNGLUNIFORM1IVARBPROC)SDL_GL_GetProcAddress("glUniform1ivARB");
glUniform2iv = (PFNGLUNIFORM2IVARBPROC)SDL_GL_GetProcAddress("glUniform2ivARB");
glUniform3iv = (PFNGLUNIFORM3IVARBPROC)SDL_GL_GetProcAddress("glUniform3ivARB");
glUniform4iv = (PFNGLUNIFORM4IVARBPROC)SDL_GL_GetProcAddress("glUniform4ivARB");
glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVARBPROC)SDL_GL_GetProcAddress("glUniformMatrix2fvARB");
glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVARBPROC)SDL_GL_GetProcAddress("glUniformMatrix3fvARB");
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVARBPROC)SDL_GL_GetProcAddress("glUniformMatrix4fvARB");
glGetObjectParameterfv = (PFNGLGETOBJECTPARAMETERFVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterfvARB");
glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB");
glGetInfoLog = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB");
glGetAttachedObjects = (PFNGLGETATTACHEDOBJECTSARBPROC)SDL_GL_GetProcAddress("glGetAttachedObjectsARB");
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB");
glGetActiveUniform = (PFNGLGETACTIVEUNIFORMARBPROC)SDL_GL_GetProcAddress("glGetActiveUniformARB");
glGetUniformfv = (PFNGLGETUNIFORMFVARBPROC)SDL_GL_GetProcAddress("glGetUniformfvARB");
glGetUniformiv = (PFNGLGETUNIFORMIVARBPROC)SDL_GL_GetProcAddress("glGetUniformivARB");
glGetShaderSource = (PFNGLGETSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glGetShaderSourceARB");
// GLSL //


        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LESS);
        glEnable(GL_CULL_FACE);
        glCullFace(GL_BACK);
        glDepthMask(GL_TRUE);
        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
        glActiveTexture(GL_TEXTURE0_ARB);
        glClientActiveTexture(GL_TEXTURE0_ARB);
        glEnable(GL_TEXTURE_2D);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        glDisable(GL_LIGHTING);
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glDisable(GL_BLEND);
        glBlendEquation(GL_FUNC_ADD);
        glDisable(GL_ALPHA_TEST);
        glEnableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);

        // Load shaders
        GLhandleARB vshader, fshader, program_obj;
        vshader = LoadGLSLObject("glsl_test.frag", GL_FRAGMENT_SHADER_ARB);
        fshader = LoadGLSLObject("glsl_test.vert", GL_VERTEX_SHADER_ARB);

        program_obj = glCreateProgramObject();
        glAttachObject(program_obj, fshader);
        glAttachObject(program_obj, vshader);
        glLinkProgram(program_obj);

        // Uniform parameter
        int uparam = glGetUniformLocation(program_obj, "uniform_color");

// Textures
unsigned int tex1;
unsigned char tex1data[64 * 64 * 4];
glGenTextures(1, &tex1);
glBindTexture(GL_TEXTURE_2D, tex1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex1data);


unsigned int tex2;
unsigned char tex2data[32 * 32 * 3];
glGenTextures(1, &tex2);
glBindTexture(GL_TEXTURE_2D, tex2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, tex2data);


        // Main loop
        bool exit = false;
        while(!exit) {

                // Check input
                while(SDL_PollEvent(&event)) {

                        if(event.type == SDL_KEYDOWN) {

                                switch(event.key.keysym.sym) {

                                        case SDLK_ESCAPE:

                                                exit = true;
                                                break;

                                        }
                                }
                        }

                glUseProgramObject(program_obj);
                glUniform3f(uparam, 1.0, 1.0, 0.0);

                // Render triangle
                glPushMatrix();
                glTranslated(0.0, 20.0, 0.0);
                glBegin(GL_TRIANGLES);

                        glVertex3d(0.0, 5.0, 0.0);
                        glVertex3d(-5.0, -5.0, 0.0);
                        glVertex3d(5.0, -5.0, 0.0);

                glEnd();
                glPopMatrix();

                // Unbind shader program
                glUseProgramObject(0);

                glPushAttrib(GL_ALL_ATTRIB_BITS);
                glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);

                glDepthMask(GL_FALSE);
                glEnable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

                // Texture
                glBindTexture(GL_TEXTURE_2D, tex1);

                float color[4] = {1.0, 0.0, 0.0, 1.0};
                glColor4fv(color);

                double tc0[2], tc1[2], tc2[2], tc3[2];
                tc0[0] = 0.0; tc0[1] = 0.0;
                tc1[0] = 1.0; tc1[1] = 0.0;
                tc2[0] = 1.0; tc2[1] = 1.0;
                tc3[0] = 0.0; tc3[1] = 1.0;

                glBegin(GL_QUADS);

                        glTexCoord2dv(tc0);
                        glVertex2f(-10.0, -10.0);
                        glTexCoord2dv(tc1);
                        glVertex2f(10.0, -10.0);
                        glTexCoord2dv(tc2);
                        glVertex2f(10.0, 10.0);
                        glTexCoord2dv(tc3);
                        glVertex2f(-10.0, 10.0);

                glEnd();

                glPopAttrib();
                glPopClientAttrib();

                // Swap
                SDL_GL_SwapBuffers();

                }

        SDL_FreeSurface(visual);
        SDL_Quit();

        return 0;

}

>>>>>>>>>> glsl_test.cpp <<<<<<<<<<


>>>>>>>>>> glsl_test.vert <<<<<<<<<<

varying vec4 the_color;

uniform vec3 uniform_color;

void main(void) {

        the_color = vec4(uniform_color, 1.0);

        gl_Position = ftransform();

        return;

}

>>>>>>>>>> glsl_test.vert <<<<<<<<<<


>>>>>>>>>> glsl_test.frag <<<<<<<<<<

varying vec4 the_color;

void main(void)
{

        gl_FragColor = the_color;

        return;

}

>>>>>>>>>> glsl_test.frag <<<<<<<<<<