Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 06-13-10, 03:13 PM   #1
emeiri
Registered User
 
Join Date: Mar 2008
Posts: 5
Default OpenGL app crashing with driver 195.36.31

Hi,

My OpenGL app is crashing with driver 195.36.31. The screen starts blinking and then the app crashes.

Machine details:
OS: 64 bit Ubuntu 10.04
Kernel: 2.6.32-22
GFX: 8500GT

Here's the core of my render function:

struct Vertex
{
Vector3f pos;
Vector3f tangent;
Vector3f normal;
Vector2f texC;
};

Vector3f and Vector2f are simply structs of 3 and 2 floats, respectively.

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);
glEnableVertexAttribArray(m_tangentLoc);

glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
glVertexAttribPointer(m_tangentLoc, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)sizeof(Vector3f));
glNormalPointer(GL_FLOAT, sizeof(Vertex), (GLvoid*)(sizeof(Vector3f) * 2));
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid*)(sizeof(Vector3f) * 3));
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);

glDisableClientState(GL_INDEX_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableVertexAttribArray(m_tangentLoc);

Note: m_tangentLoc was retrieved using glGetAttribLocation(prog, "Tangent")

Here's my vertex shader:

attribute vec3 Tangent;

varying vec3 NormalV;
varying vec3 TangentV;
varying vec3 PosV;

void main()
{
gl_Position = ftransform();

gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;

NormalV = (gl_NormalMatrix * gl_Normal).xyz;
TangentV = (gl_NormalMatrix * Tangent);
PosV = (gl_ModelViewMatrix * gl_Vertex).xyz;
}

If I comment out the line where the tangent is multiplied by the normal matrix the crash is gone.

Please let me know if you need any more details.

Thanks a lot,

Etay Meiri
emeiri is offline   Reply With Quote
Old 06-14-10, 12:21 PM   #2
danix
NVIDIA Corporation
 
danix's Avatar
 
Join Date: Feb 2010
Location: Santa Clara, CA
Posts: 237
Default Re: OpenGL app crashing with driver 195.36.31

Hi Etay,

Could you provide a complete test app that demonstrates this problem? It doesn't have to be your full app; just something that is ready to build, and demonstrates the problem.

Is this crash new in 195.36.31? (Is it a regression, and do older drivers like 195.36.24 work as expected?)
danix is offline   Reply With Quote
Old 06-18-10, 06:51 AM   #3
emeiri
Registered User
 
Join Date: Mar 2008
Posts: 5
Default Re: OpenGL app crashing with driver 195.36.31

Seems like I have a general problem with the 195.36.31 driver. I tried to run glxgears - CPU usage of the X server went up to 100% and the program ran at 2 FPS. Took me a while before I was able to stop it. I'll try to revert to the old driver and see if that helps.

Thanks,

Etay Meiri
emeiri is offline   Reply With Quote
Old 06-20-10, 02:09 PM   #4
emeiri
Registered User
 
Join Date: Mar 2008
Posts: 5
Default Re: OpenGL app crashing with driver 195.36.31

Hi,

I was finally able to reproduce the crash with the following program:

#define GL_GLEXT_PROTOTYPES

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>

GLuint m_shaderProg;
GLuint m_vertexVBO;
GLuint m_indexVBO;
GLint m_tangentLoc;


struct Vector3f
{
float x, y, z;

Vector3f() {}

Vector3f(float x1, float y1, float z1)
{
x = x1;
y = y1;
z = z1;
}
};

struct Vector2f
{
float x, y;

Vector2f() {}

Vector2f(float x1, float y1)
{
x = x1;
y = y1;
}
};

struct Vertex
{
Vertex(){}
Vertex(float x, float y, float z,
float tx, float ty, float tz,
float nx, float ny, float nz,
float u, float v)
: pos(x,y,z), tangent(tx, ty, tz), normal(nx,ny,nz), texC(u,v){}

Vector3f pos;
Vector3f tangent;
Vector3f normal;
Vector2f texC;
};

void CreateBox()
{
unsigned int NumVertices = 24;

Vertex v[24];

v[0] = Vertex(-0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f);
v[1] = Vertex(-0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f);
v[2] = Vertex( 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f);
v[3] = Vertex( 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f);
v[4] = Vertex(-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
v[5] = Vertex( 0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f);
v[6] = Vertex( 0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
v[7] = Vertex(-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
v[8] = Vertex(-0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f);
v[9] = Vertex(-0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
v[10] = Vertex( 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
v[11] = Vertex( 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f);
v[12] = Vertex(-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f);
v[13] = Vertex( 0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f);
v[14] = Vertex( 0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f);
v[15] = Vertex(-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f);
v[16] = Vertex(-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
v[17] = Vertex(-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[18] = Vertex(-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
v[19] = Vertex(-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f);
v[20] = Vertex( 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
v[21] = Vertex( 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[22] = Vertex( 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
v[23] = Vertex( 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f);

GLushort i[36];

i[0] = 0; i[1] = 1; i[2] = 2;
i[3] = 0; i[4] = 2; i[5] = 3;
i[6] = 4; i[7] = 5; i[8] = 6;
i[9] = 4; i[10] = 6; i[11] = 7;
i[12] = 8; i[13] = 9; i[14] = 10;
i[15] = 8; i[16] = 10; i[17] = 11;
i[18] = 12; i[19] = 13; i[20] = 14;
i[21] = 12; i[22] = 14; i[23] = 15;
i[24] = 16; i[25] = 17; i[26] = 18;
i[27] = 16; i[28] = 18; i[29] = 19;
i[30] = 20; i[31] = 21; i[32] = 22;
i[33] = 20; i[34] = 22; i[35] = 23;

glGenBuffers(1, &m_vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(v), v, GL_STATIC_DRAW);

glGenBuffers(1, &m_indexVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexVBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(i), i, GL_STATIC_DRAW);
}




static const char* pVS = " \n\
// vectors required by the fragment shader \n\
attribute vec3 Tangent; \n\
\n\
varying vec3 NormalV; \n\
varying vec3 TangentV; \n\
varying vec3 PosV; \n\
\n\
\n\
void main() \n\
{ \n\
gl_Position = ftransform(); \n\
\n\
gl_FrontColor = gl_Color; \n\
gl_TexCoord[0] = gl_MultiTexCoord0; \n\
\n\
NormalV = (gl_NormalMatrix * gl_Normal).xyz; \n\
TangentV = (gl_NormalMatrix * Tangent); \n\
PosV = (gl_ModelViewMatrix * gl_Vertex).xyz; \n\
}";


static const char* pFS = " \n\
uniform int gNumLights; \n\
\n\
varying vec3 NormalV; \n\
varying vec3 TangentV; \n\
varying vec3 PosV; \n\
\n\
uniform sampler2D ColorMap; \n\
uniform sampler2D BumpMap; \n\
\n\
void main() \n\
{ \n\
vec4 Texel = texture2D(ColorMap, gl_TexCoord[0].st); \n\
\n\
vec3 N = normalize(NormalV); \n\
vec3 T = normalize(TangentV - dot(TangentV, N) * N); \n\
vec3 B = cross(N, T); \n\
\n\
vec3 Normal = texture2D(BumpMap, gl_TexCoord[0].st).xyz; \n\
Normal = 2.0 * (Normal) - vec3(1.0, 1.0, 1.0); \n\
mat3 m = mat3(T,B,N); \n\
Normal = mul(Normal.xyz, m); \n\
\n\
if (Texel.x <= 0.001) { \n\
gl_FragColor = vec4(0.4, 0.4, 0.4, 1.0); \n\
} \n\
else { \n\
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); \n\
\n\
for (int i = 0 ; i < gNumLights ; i++) \n\
{ \n\
gl_FragColor += Texel; \n\
} \n\
} \n\
gl_FragColor = vec4(TangentV, 0.0) + vec4(1.0, 0, 0, 0); \n\
}";

bool AddShader(const char* pShaderText, GLenum ShaderType)
{
GLint NumActiveUniforms = 0;
GLuint ShaderObj = 0;
unsigned int ShaderSize = strlen(pShaderText);

// create the shader objects
ShaderObj = glCreateShader(ShaderType);

if (!ShaderObj) {
assert(0);
goto exit1;
}

// compile the shader
const GLchar* p[1];
p[0] = pShaderText;
GLint Lens[1];
Lens[0]= (GLint)ShaderSize;
glShaderSource(ShaderObj, 1, p, Lens);
glCompileShader(ShaderObj);
GLint success;
glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success);
if (!success) {
GLchar InfoLog[1024];
glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog);
fprintf(stderr, "Error compiling shader %d: %s\n", ShaderType, InfoLog);
assert(0);
goto exit2;
}

glAttachShader(m_shaderProg, ShaderObj);

glLinkProgram(m_shaderProg);
glGetShaderiv(m_shaderProg, GL_LINK_STATUS, &success);

if (!success) {
GLchar InfoLog[1024] = "";
glGetShaderInfoLog(m_shaderProg, 1024, NULL, InfoLog);
assert(0);
fprintf(stderr, "Error linking shader program: %s\n", InfoLog);
}

glGetShaderiv(m_shaderProg, GL_ACTIVE_UNIFORMS ,&NumActiveUniforms);
printf("Compiled shader %d, number of active uniforms: %d\n", ShaderType, NumActiveUniforms);

return true;

exit2:
glDeleteShader(ShaderObj);
exit1:
return false;
}



static void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnableClientState(GL_VERTEX_ARRAY);
glEnableVertexAttribArray(m_tangentLoc);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_INDEX_ARRAY);


glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
glVertexAttribPointer(m_tangentLoc, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)sizeof(Vector3f));
glNormalPointer(GL_FLOAT, sizeof(Vertex), (GLvoid*)(sizeof(Vector3f) * 2));
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid*)(sizeof(Vector3f) * 3));
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, 0);

glDisableClientState(GL_INDEX_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableVertexAttribArray(m_tangentLoc);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);


glutSwapBuffers();
}

static void ChangeSize(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

const GLfloat AspectRatio = (GLfloat)w / (GLfloat)h;

gluPerspective(90.0f, AspectRatio, 0.1f, 1000.0f);
}

static void TimerFunc(int Value)
{
glutPostRedisplay();
glutTimerFunc(10, TimerFunc, 0);
}


void InitCallbacksGL()
{
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glutTimerFunc(10, TimerFunc, 0);
}

int main(int argc, char** argv)
{
glutInit(&argc, (char**)argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEP TH);
glutInitWindowSize(800, 600);
glutCreateWindow("test");

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glFrontFace(GL_CW);
glEnable(GL_DEPTH_TEST);

InitCallbacksGL();

m_shaderProg = glCreateProgram();

if (!AddShader(pFS, GL_FRAGMENT_SHADER)) {
assert(0);
}

if (!AddShader(pVS, GL_VERTEX_SHADER)) {
assert(0);
}

m_tangentLoc = glGetAttribLocation(m_shaderProg, "Tangent");

printf("%d\n", m_tangentLoc);

CreateBox();

glutMainLoop();
}

You can compile it using: g++ main.cpp -o crash -lGL -lglut -lGLU

Thanks,

Etay Meiri
emeiri is offline   Reply With Quote
Old 06-21-10, 04:44 PM   #5
Ralph
Registered User
 
Join Date: Jul 2007
Posts: 74
Default Re: OpenGL app crashing with driver 195.36.31

Code:
g++ main.cpp -o crash -lGL -lglut -lGLU
main.cpp: In function ‘int main(int, char**)’:
main.cpp:293: error: ‘GLUT_DEP’ was not declared in this scope
Ok. Probably, you mean "GLUT_DEPTH".

I tried your example and I got your same result (GeForce 8400GS); the screen starts blinking and then the app crashes.

Code:
Compiled shader 35632, number of active uniforms: 0
Compiled shader 35633, number of active uniforms: 0
1
Aborted
Ralph is offline   Reply With Quote
Old 06-24-10, 05:27 AM   #6
emeiri
Registered User
 
Join Date: Mar 2008
Posts: 5
Default Re: OpenGL app crashing with driver 195.36.31

Thanks for taking a look, Ralph.

I have new info I can share - I played around with the code and found a way to make it work: simply comment out glEnableVertexAttribArray(m_tangentLoc) and glDisableVertexAttribArray(m_tangentLoc).
I'm not a GL expert but AFAIK, this shouldn't have worked. All the GL tutorials/books that I have seen tell you to get the attribute location from the program and enable it before it is used. For now I'm using it as a workaround but it will be great to get to the root cause of it.

Note: I'm using 8500GT.

Thanks,

Etay
emeiri is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:46 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.