Problem with for-loops in PS2.0 and PS3.0 in GLSL

Hello all,

I developed a matrix-matrix multiplacation pixel shader using GLSL, which works under the restriction of PS2.0(GForce5200). When I try to run the same shader on a GForce 6600(PS3.0) i get only a black render winow, The code is the same and i use the same image. The only main difference is that i use Debian Sid with the NV driver 7676 and the 6600 system is Ubuntu-Breezy with 7667. It seems to be a problem with the for-loop that I use. I ran the shader through glslValidate from 3dLabs, and it produces no errors. I also have set up my program to check all GL errors and to retrieve all the messages that are available when a GLSL compile fails. The program reports absolutly no errors. When i comment out the for-loop and do only a componentwise multiplication of the two matrixes , i get what i expect. and that is a window that is completly black except for the diagnal from above left to bottom right that is the same as the image. Below is the for loop:

  
   for(k = 0.0; k <= 1.0; k += offset){
      texelA = texture2D(matA,vec2(x,k));
      A = mat2(texelA);
      texelB = texture2D(matB,vec2(k,y));
      B = mat2(texelB);
      C += (A*B);
   }

Where all the variables are set up correctly, and like said above, it works on PS 2.0, but not on the 6600. Is there a big difference with respect to for-loop syntax between PS 2.0 and PS3.0?

Thanks in advance,
Brian

Originally posted by big_daddy

Where all the variables are set up correctly, and like said above, it works on PS 2.0, but not on the 6600. Is there a big difference with respect to for-loop syntax between PS 2.0 and PS3.0?

Thats the beauty of using a high level language. Even if the lower level instruction set changes you don’t have to worry about anything because the compiler takes care of it (hopefully :wink: ). So there is no change in syntax.

As for your code, the A = mat2(texelA) and likewise the line with B = … and C += (A * B) are actually not being used, so the compiler might omit those in the final code that’s generated, in case you are not using these in any other part of the shader. The only other thing that i can think of, is that texture2D(…) returns a vec4 and you are casting it to a mat2, i don’t quite remeber what the official GLSL specification says about such a cast. Other than that i don’t find anything noticable about the shader.

Thank you for the reply Zulfiqar, but could you please be more specific about why A = mat2(texelA) and so forth aren’t used. Without them the shader would not perform correctly.

As for the casting of a vex4 to a mat2, at first i used B = mat2(texelB.r,texelB.g,texelB.b,texelB.a); as for the assignment, but it works with mat2(texelB) because i’m not casting, but using the constructor for a mat2 with a vector4 as argument. I got the the idea from the Orange book on pg. 75.

Thanks, Brian.

Originally posted by big_daddy:
…could you please be more specific about why A = mat2(texelA) and so forth aren’t used. Without them the shader would not perform correctly.

Means, you didn’t give the full shader source, so others will be unable to verify or fix your problem.

Originally posted by bigdaddy:

As for the casting of a vex4 to a mat2, at first i used B = mat2(texelB.r,texelB.g,texelB.b,texelB.a); as for the assignment, but it works with mat2(texelB) because i’m not casting, but using the constructor for a mat2 with a vector4 as argument. I got the the idea from the Orange book on pg. 75.

As far as i can remember there are no explicit C-style casts supported, so the only way is via the constructor, and that’s what i meant when i said casting.

Can you please post the entire source code, if there is no privacy involved.

Actually I would rather not post the entire shader because it is a research project. When it is done, then i can post the results and the shader.

I appriciate the help Relic and Zulfiqar,

Th problem is this, I have the shader and it works on the 5200, but when i try it on the 6600 it does not. Under both cards i can render matA to the screen or i can render matB to the screen. When i take the for-loop out, then i can multiply the two together component wise and render the results to the screen. The for-loop itself seems to be the problem. When you guys don’t see a problem there, then i would assume it could be a driver problem.

Is there a way to read out the assembly instruction-reprasentation from a compiled program_object??

Thanks, Brian.

Is there a way to read out the assembly instruction-reprasentation from a compiled program_object??
Yes, http://developer.nvidia.com/object/nvemulate.html
There is a mail address given at the end of the PDF on the same site where to send GLSL bug reports.

Can you please post the entire source code, if there is no privacy involved.

He has posted 3 times on these forums. And the last time was in 2005. Do you really expect him to respond?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.