PDA

View Full Version : Shader going into software mode?



GiGa
01-05-2005, 11:30 AM
Hi,

I'm writing a skeletal animation vertex shader. The most simple version -no lighting, just one bone per vertex- of it works fine (well except the model looks all "jaggy" cos theres really 4 bones per vertex). This is the shader:

attribute vec2 TexCoord;
attribute vec3 Normal;
attribute vec4 Indexes;
attribute vec4 Weights;

uniform vec4 BoneMatrix[87];

void main(void)
{
gl_TexCoord[0].xy = TexCoord;
vec3 Temp=Normal;
vec4 RealVertex=gl_Vertex;
vec4 TempVert1,TempVert2,TempVert3,TempVert4;
ivec4 RealIndexes=ivec4(Indexes)*3;

gl_FrontColor=vec4(1.0,1.0,1.0,1.0);

TempVert1.x=dot(RealVertex,BoneMatrix[RealIndexes.x]);
TempVert1.y=dot(RealVertex,BoneMatrix[RealIndexes.x+1]);
TempVert1.z=dot(RealVertex,BoneMatrix[RealIndexes.x+2]);

TempVert1=TempVert1*Weights.x;
TempVert1.w=1.0;

gl_Position = gl_ModelViewProjectionMatrix * TempVert1;
}But when I add the second vertex, like so:

attribute vec2 TexCoord;
attribute vec3 Normal;
attribute vec4 Indexes;
attribute vec4 Weights;

uniform vec4 BoneMatrix[87];

void main(void)
{
gl_TexCoord[0].xy = TexCoord;
vec3 Temp=Normal;
vec4 RealVertex=gl_Vertex;
vec4 TempVert1,TempVert2,TempVert3,TempVert4;
ivec4 RealIndexes=ivec4(Indexes)*3;

gl_FrontColor=vec4(1.0,1.0,1.0,1.0);

TempVert1.x=dot(RealVertex,BoneMatrix[RealIndexes.x]);
TempVert1.y=dot(RealVertex,BoneMatrix[RealIndexes.x+1]);
TempVert1.z=dot(RealVertex,BoneMatrix[RealIndexes.x+2]);


TempVert2.x=dot(RealVertex,BoneMatrix[RealIndexes.y]);
TempVert2.y=dot(RealVertex,BoneMatrix[RealIndexes.y+1]);
TempVert2.z=dot(RealVertex,BoneMatrix[RealIndexes.y+2]);

TempVert1=TempVert1*Weights.x;
TempVert1=TempVert1+TempVert2*Weights.y;
TempVert1.w=1.0;

gl_Position = gl_ModelViewProjectionMatrix * TempVert1;
}The model goes all black and the frame rate drops to like a frame every 2-3 seconds. What could be the reason? I was told this could be caused by ogl going into soft ware rendering mode, becouse the shader is too complex. But why? Is that shader really complex? Dont think so, becouse I've seen a shader do 4 bones per vertex and 2 bones for the normal, but only it was written in gpu asm. So I was thinking - maybe my drivers are compiling the asm version in some wierd way? I have a R9500 128mb with the latest drivers, or I think its the latest drivers, I updated 2 weeks ago i think. Can I somehow see the assembler version of the shader, after compilation, using some glsl command or some outside tool? Or could there be another reason? Am I using some stuff that glsl really doesnt like in hw mode? Any suggestions would be most welcome!

Thanks!

EDIT: now I know the problem is: going into software becouse availeable number of temporary registers exceeded. But how to solve that?

Corrail
01-05-2005, 06:03 PM
The fragment shader you wrote uses a sort dynamic branching (accessing dynamically array elements). This isn't supported by ATI cards in hardware right now. You need a graphics card which supports Shader Model 3.0 to do that.

bobvodka
01-05-2005, 07:30 PM
erm, just as a point of reference thats not a fragment shader, its a vertex shader, i'm not sure if that changes owt but I thought it was worth pointing out :)

spasi
01-06-2005, 02:09 AM
Originally posted by GiGa:
now I know the problem is: going into software becouse availeable number of temporary registers exceeded. But how to solve that?You'll have to wait for ATI to release new, optimized drivers. This is a known problem of their current implementation (it has been discussed here before, skeletal animation seems impossible right now).

The latest 4.12 catalyst has support for even GLSL 1.10, so they should be starting optimizations now.

bobvodka
01-06-2005, 07:21 AM
Originally posted by spasi:
The latest 4.12 catalyst has support for even GLSL 1.10, so they should be starting optimizations now.really?
What OGL version is that? I've got the 4.12's installed with build version 6.14.10.4773 and i'm only seeing version 1.00 right now..

GiGa
01-06-2005, 08:49 AM
Thanks. Any idea of when we could get out hands on a better compiler, with all these problems fixed?

spasi
01-07-2005, 01:55 AM
Originally posted by bobvodka:
I've got the 4.12's installed with build version 6.14.10.4773 and i'm only seeing version 1.00 right now..Yes, sorry, I wasn't too clear. The extension is not exposed yet in the extension string (probably not 100% ready), but if you run the 3DLabs parser test, the 1.1 tests execute correctly.

bobvodka
01-07-2005, 07:41 AM
ah, I wondered if it would be something like that, cheers for the info :)