Sign in to follow this  

GLSL vertex shader slowdown on Radeon 9800

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wrote a shader for doing vertex skinning with 4 weights per vertex in a GLSL vertex shader, and it does the right thing, but for some reason it is extremely slow (one frame every 3-4 seconds). Other vertex shaders work fine (normal mapping, for instance). If I comment out some of the shader code for the skinning, it goes back up to speed. I tried writing it a number of ways, but I can't get it to run at speed. If anyone has any ideas on why this is running so slow please let me know. Thanks, Jerec Here is the shader:
// Vertex Skinning GLSL shader
// weights in gl_MultiTexCoord1
// boneIds in gl_MultiTexCoord2

uniform vec4 boneMatrix[72];

void main()
{
    vec4 w    = gl_MultiTexCoord1;
    ivec4 idx = ivec4(gl_MultiTexCoord2[0], 
                      gl_MultiTexCoord2[1],
                      gl_MultiTexCoord2[2],
                      gl_MultiTexCoord2[3]);

    vec4 bonePosition;

    // weighted sum of x positions
    bonePosition.x = w[0] * dot(boneMatrix[idx[0] + 0], gl_Vertex) +
                     w[1] * dot(boneMatrix[idx[1] + 0], gl_Vertex) +
                     w[2] * dot(boneMatrix[idx[2] + 0], gl_Vertex) +
                     w[3] * dot(boneMatrix[idx[3] + 0], gl_Vertex);

    // weighted sum of y positions
    bonePosition.y = w[0] * dot(boneMatrix[idx[0] + 1], gl_Vertex) +
                     w[1] * dot(boneMatrix[idx[1] + 1], gl_Vertex) +
                     w[2] * dot(boneMatrix[idx[2] + 1], gl_Vertex) +
                     w[3] * dot(boneMatrix[idx[3] + 1], gl_Vertex);

    // weighted sum of z positions
    bonePosition.z = w[0] * dot(boneMatrix[idx[0] + 2], gl_Vertex) +
                     w[1] * dot(boneMatrix[idx[1] + 2], gl_Vertex) +
                     w[2] * dot(boneMatrix[idx[2] + 2], gl_Vertex) +
                     w[3] * dot(boneMatrix[idx[3] + 2], gl_Vertex);

    bonePosition.w = 1.0;


    gl_Position = gl_ModelViewProjectionMatrix * bonePosition;
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_FrontColor = vec4(1,1,1,1);
}


Share this post


Link to post
Share on other sites
ah ha!

I get the following:

"Link Successful. The GLSL shader will run in software - available number of temporary registers exceeded."

I guess I'll have to figure out how to fix that.

Thanks,
Jerec

Share this post


Link to post
Share on other sites
You can probably get rendermonkey to tell you how many regs/alu ops/texture fetches a shader uses.

Quote:
Original post by Jerec
Is there any way to figure out the number of temporary registers available, and how many a vertex shader is using?

Share this post


Link to post
Share on other sites

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this