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

Newegg Daily Deals

Reply
 
Thread Tools
Old 03-27-07, 11:00 AM   #1
alex31
Registered User
 
Join Date: Dec 2002
Posts: 47
Default array initialisation bug with glsl on 8800 cards

Hello, i have experienced a strange bug in glsl fragment shader on 8800 cards.

The bug affect array of initialization.

If i declare an array of floats, and after i initialize the array to 0.0 :

Code:
float f[9];
 for (i=0; i<=8; i++) {
f[i]=0.0;
}
the compiler discards the code, because it thinks that underlying layer should already give a null initialized array.

if i replace f[i]=0 by f[i] = 0.000001, the compiler of course don't discard the code.

in the following code :


Code:
void main (void)
{
  float red[9], green[9], blue[9];
  int col, lin, i;


  /* This init is not be DONE !!!
     if we put 0.00001 instead of 0.0 for init value, it works */
  for (i=0; i<=8; i++) {
    red[i] = green[i] =blue[i] = 0.0;
  }


  for (col=-1; col<=1; col++) {
    for (lin=-1; lin<=1; lin++) {
      if ((col == 0) && (lin ==0)) {
        vec3 color = vec3 (0.1, 0.1, 0.1);
        red[((col+1)*3)+lin+1] = color.r;
        green[((col+1)*3)+lin+1] = color.g;
        blue[((col+1)*3)+lin+1] = color.b;
      }
    }
  }

  vec3 sum = vec3 (0.0, 0.0, 0.0);

  for (i=0; i<=8; i++) {
    sum+= vec3 (red[i], green[i], blue[i]);
  }

  gl_FragColor.rgb = sum;
  gl_FragColor.a = 1;
}

the array is not alway nullified, so instead of having a uniform dark gray on the screen, i have some rubbish.

In fact, after a cold boot, the test app which use this shader behave correctly, but after launching some app which use big shader (shaders which need lot of temporary registry), the shader fail.

Of course the fix is easy, i just have to initialize the array to epsilon instead of 0.0, and all is correct.

Does anyone experienced similar bug in glsl ?

ps: driver version 9755.

Alexandre
alex31 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[GeForce 8800 GTS] 2D rendering regression (extreme slowdown) introduced with 295.49 Seb L. NVIDIA Linux 0 06-22-12 06:48 AM

All times are GMT -5. The time now is 12:38 AM.


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