PDA

View Full Version : strange OGLSL problem with 66.93 NVIDIA's driver



Guido
12-03-2004, 09:03 AM
I have a NV 6800 GT.

I had writed a physics simulation on the GPU in OGLSL. This application seemed to correctly run on both
ATI's & NVIDIA's graphic boards until nowaday. Now i need to make the textures' lookup from my vertex program and
this is possible in OGLSL only with the latest Nvidia's driver(66.93). Actually the textures' lookup seems to go...
but all the rest of the application is dead...
In particular the run-time in nvoglnt.dll throws an "division by zero" exception...

I try to debug the fragment shader incrementally quoting the code and all i have got is the hell...
The uniform variable declared in the fragment shader appear and disappear without any logic(the following is
a fragment shader without any really sense...only for show the problem).

Ex.

if i write:


uniform bool drawpos;

void main(void)
{
if(!drawpos)
{
vec4 i = vec4(0.0);
}
else
{
vec4 j = vec4(0.0);
}
gl_FragColor = vec4(0.0);
}and in the application:


glUseProgramObjectARB(pobj);
GLint hvar = glGetUniformLocationARB(pobj,"drawpos");
glUniform1fARB(hvar,true); the hvar value is -1(drawpos variable not found)

even if i write:


uniform bool drawpos;

void main(void)
{
if(!drawpos)
{
gl_FragColor = vec4(0.0);
}
else
{
gl_FragColor = vec4(1.0);
}
}the hvar value is a correct handle for the drawpos varible...

From the NVidia site i have got the 61.77 driver and with this all two version of the fragment program goes right...

the following is a toy-exemple of my complete program including the c++,vertex and fragment code:

C++ CODE:


#include<string>

using namespace std;

GLhandleARB vsh = NULL;
GLhandleARB fsh = NULL;
GLhandleARB pobj = NULL;

const char** vt;
const char** ft;

void Init(void)
{
string s("/*varying vec2 texcoord;*/ void main(void){/*texcoord = gl_MultiTexCoord1.st;*/gl_Position = ftransform();}");
vt =(const char**) malloc(s.length() * sizeof(char));
(*vt) = s.c_str();

string s1("uniform bool drawpos;/*varying vec2 texcoord;*/void main(void){if(!drawpos){ vec4 i = vec4(0.0);} else { vec4 j = vec4(0.0);} gl_FragColor = vec4(0.0);}");
ft =(const char**) malloc(s1.length() * sizeof(char));
(*ft) = s1.c_str();
glEnable(GL_TEXTURE_2D);
glClearColor(0.0,0.0,0.0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-20,20);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

vsh = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glShaderSourceARB(vsh,1,vt,NULL);
glCompileShaderARB(vsh);

fsh = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB(fsh,1,ft,NULL);
glCompileShaderARB(fsh);

pobj = glCreateProgramObjectARB();

glAttachObjectARB(pobj,vsh);
glAttachObjectARB(pobj,fsh);

glLinkProgramARB(pobj);
glColor3f(1.0f,1.0f,1.0f);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glUseProgramObjectARB(pobj);
GLint hvar = glGetUniformLocationARB(pobj,"drawpos");
glUniform1fARB(hvar,true);
glutSwapBuffers();
glFlush();
}

void idle()
{
glutPostRedisplay();
}

void keyboardFunc(unsigned char key, int x, int y)
{
switch(key)
{
case 27:
{
exit(0);
break;
}
}
}

int main(int argc,char** argv)
{
glutInit(&amp;argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(800,800);
int in = glutCreateWindow("Springs Chain");
OGLSL::Init(in);
Init();
//glutFullScreen();
glutDisplayFunc(display);
//glutSpecialFunc(SpecialKey);
//glutMouseFunc(mouseFunc);
//glutMotionFunc(mouseMotionFunc);
//glutPassiveMotionFunc(passiveMotionFunc);
glutKeyboardFunc(keyboardFunc);
glutIdleFunc(idle);
glutMainLoop();
return 0;
} VERTEX PROGRAM CODE:


/*varying vec2 texcoord;*/

void main(void)
{
/*texcoord = gl_MultiTexCoord1.st;*/
gl_Position = ftransform();
}FRAGMENT PROGRAM CODE:


uniform bool drawpos;

/*varying vec2 texcoord;*/

void main(void)
{
if(!drawpos)
{
vec4 i = vec4(0.0);
}
else
{
vec4 j = vec4(0.0);
}
gl_FragColor = vec4(0.0);
}Are there some errors in my code???

THANKS...

Cab
12-03-2004, 12:00 PM
I don't know if your problem is related to mine, but I had problems with 66.xx drivers and glsl with GeForce 6800GT (it doesn't happen in GeforceFX family) that crashes the computer. It doesn't happen with 61.77 and doesn't happen with 70.41
I sent a demo program to NVIDIA and they have been able to reproduce the problem so hopefully they have investigated it.
Try searching for 70.41 with google and try if your problem is still there.
Hope this helps.

Relic
12-06-2004, 01:56 AM
It's completely correct to flag the uniform bool drawpos as unreferenced in the following case, because whatever you put into it, it's completely irrelevant to the final result.
The compiler has removed the whole if-else block along with the uniform, and right so.


uniform bool drawpos;
void main(void)
{
if(!drawpos) {
vec4 i = vec4(0.0);
} else {
vec4 j = vec4(0.0);
}
gl_FragColor = vec4(0.0);
}