1
votes

I've been trying to pinpoint the exact cause of a GLSL shader that crashes my computer. I'm running Mac OS X 10.8.2 with a NVIDIA GeForce 9400M. The shader renders correctly but will occasionally crash my computer, drawing regions of black over the display (including outside of the rendering window) until the computer becomes unresponsive.

I receive no errors from glGetError and no errors during shader compilation. It appears that the crash no longer occurs when I remove a uniform mat4 from the vertex shader, such as the model-view matrix, or one of the shadow matrices. Yet according to GL_MAX_VERTEX_UNIFORM_COMPONENTS my graphics card supports 4096 vertex uniform components.

Here is the vertex shader:

#version 120

attribute vec3 position;
attribute vec2 texcoord;
attribute vec3 normal;

varying vec2 v_texcoord;
varying vec3 v_normal;
varying vec3 v_halfVec;
varying vec4 v_shadowcoord0;
varying vec4 v_shadowcoord1;
varying vec4 v_shadowcoord2;
varying vec4 v_shadowcoord3;

uniform mat4 mv;
uniform mat3 nmv;
uniform mat4 mvp;
uniform mat4 shadowMatrix0;
uniform mat4 shadowMatrix1;
uniform mat4 shadowMatrix2;
uniform mat4 shadowMatrix3;
uniform vec3 lightDir;

void main()
{
    vec4 p4 = vec4(position, 1.0);

    v_texcoord = texcoord;
    v_normal = normalize(nmv * normal);

    vec3 vertexPos = vec3(mv * p4);
    vec3 eyeDir = normalize(-vertexPos);
    v_halfVec = normalize(eyeDir + lightDir);

    v_shadowcoord0 = shadowMatrix0 * p4;
    v_shadowcoord1 = shadowMatrix1 * p4;
    v_shadowcoord2 = shadowMatrix2 * p4;
    v_shadowcoord3 = shadowMatrix3 * p4;

    gl_Position = mvp * p4;
}

I would greatly appreciate any help in tracking down the cause of this bug. Thanks!

1
The only way that I have experienced crashing of this sort with GLSL is if you haven't bound a buffer to a varying vertex attribute and worth double checking. You may also find luck with tryin gDEBugger gremedy.com/download.php - Crog
I double-checked and my vertex buffers and attributes appear to be correctly bound. Unfortunately, gDEBugger is not available on this version of Mac OS X, but I have tried OpenGL Profiler. The difficulty is that my system locks up immediately when the bug occurs. I have tried almost identical shaders but without the shadow matrices and coordinates, and they have never crashed. - Chris Howard
This looks like a tricky one, have you tried glGetShaderInfoLog and glGetProgramInfoLog to check for any warnings. it may also be a similar issue to this: news.softpedia.com/news/… - Crog
Both the shader and program info logs are empty, and I'm looking into the NVIDIA driver issue. - Chris Howard

1 Answers

1
votes