GLSL vertex shader crashes computer

让人想犯罪 __ 提交于 2020-01-05 04:22:08

问题


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:


It sounds like an issue in 10.8.2 that has also been seen here: http://news.softpedia.com/news/OS-X-10-8-2-Broken-NVIDIA-Drivers-Causing-Pixelmator-to-Crash-312907.shtml There should be a Max OS 10.8.3 that will hopefully fix this.

UPDATES: http://www.cultofmac.com/214775/apple-releases-yet-another-10-8-3-os-x-beta-to-developers/



来源:https://stackoverflow.com/questions/15101939/glsl-vertex-shader-crashes-computer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!