Diagnosing an effect problem in SkinningSample

Last post 05-13-2008, 12:34 PM by jwatte. 6 replies.
Sort Posts: Previous Next
  •  03-28-2008, 12:52 AM

    Diagnosing an effect problem in SkinningSample

    I have modified the SkinningSample to accept more bones, and upped the shader version to vs_3_0 and ps_3_0 in the fx file. However, when I try to draw my model, the DrawIndexedPrimitives() throws an exception saying that both a valid vertex shader and a valid pixel shader needs to be set before drawing.

    At this point, I turn on Direct3D debugging in the DirectX control panel. However, I see no additional debug output from Direct3D.

    So I re-implement drawing of a mesh, instead of calling mesh.Draw(), to try to diagnose it. Here is the code:

                // Render the skinned mesh.
    foreach (ModelMesh mesh in currentModel.Meshes)
    {
    foreach (Effect effect in mesh.Effects)
    {
    effect.Parameters["Bones"].SetValue(bones);
    effect.Parameters["View"].SetValue(view);
    effect.Parameters["Projection"].SetValue(projection);
    }

    foreach (ModelMeshPart mmp in mesh.MeshParts)
    {
    mmp.Effect.Begin(SaveStateMode.None);
    EffectTechnique et = mmp.Effect.CurrentTechnique;
    foreach (EffectPass ep in mmp.Effect.CurrentTechnique.Passes)
    {
    ep.Begin();
    mmp.Effect.GraphicsDevice.Vertices[0].SetSource(
    mesh.VertexBuffer, mmp.StreamOffset, mmp.VertexStride);
    mmp.Effect.GraphicsDevice.VertexDeclaration = mmp.VertexDeclaration;
    mmp.Effect.GraphicsDevice.Indices = mesh.IndexBuffer;
    mmp.Effect.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList,
    mmp.BaseVertex, 0, mmp.NumVertices, mmp.StartIndex, mmp.PrimitiveCount);
    ep.End();
    }
    mmp.Effect.End();
    }
    }


    Note that the current technique is the correct technique, and the current pass is the correct pass, and the system doesn't throw when I call Begin() on either of them. Here is the every so slightly modified technique description, from the skinning sample .fx file:

    technique SkinnedModelTechnique
    {
    pass SkinnedModelPass
    {
    // note: MaxBones is set to 69 here and in the cs file, hence vs_3_0
    VertexShader = compile vs_3_0 VertexShader();
    PixelShader = compile ps_3_0 PixelShader();
    }
    }



    I don't get it. How am I supposed to debug this? As far as I can tell, all the building goes great (including the updated processor, that can take 69 bones). As far as I can tell, Direct3D has nothing against the state. As far as I can tell, the effect technique and pass are both being applied correctly. There is nothing in debug output. So how can I diagnose why I get this IllegalOperationException?


    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
  •  03-28-2008, 12:57 AM

    Re: Diagnosing an effect problem in SkinningSample

    I also made sure that my device does, indeed, support shader model 3, by adding the following set-up code:

                graphics.MinimumVertexShaderProfile = ShaderProfile.VS_3_0;
    graphics.MinimumPixelShaderProfile = ShaderProfile.PS_3_0;

    It's a GeForce 7xxx series, which clearly supports sm3.


    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
  •  03-28-2008, 2:47 PM

    Re: Diagnosing an effect problem in SkinningSample

    Because there is no D3D error output, and no error when compiling, or setting the effects, I don't know how to diagnose this. I know that the GraphicsDevice.VertexShader is NULL, so the shader doesn't get set, but I don't know why.

    Help?

    Btw: I've verified that I can work around this by turning the 4x4 matrices into 4x3 matrices, so it has something to do with some vertex shader register limit, but my question is the general "how can I debug this kind of problem," not the specific "how do I use N bones in a skinning shader."


    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
  •  05-09-2008, 8:19 PM

    Re: Diagnosing an effect problem in SkinningSample

    Have you tried switching cards? I'm having the same problem, but when I run on an on board intel GPU  i'm fine. 

    I currently have the bone count up to 254.  On an intel based system... it works fine...

    On my nVidia GPU I bring the bone count back down to 59 and it works just fine...  I haven't tried an in between number yet on my nVidia system...

    Shawn mentions that the Shader 2.0 only support 256 float4 constants...  at
        http://forums.xna.com/thread/4507.aspx


  •  05-10-2008, 2:11 AM

    Re: Diagnosing an effect problem in SkinningSample

    Specifically, it's the number of available vertex shader constants. On most hardware, you don't get enough for more than about 60 bones (80 if you're using 4x3 matrices). The Intel "chip," however, uses the CPU for transform, and has a whole lot of vertex shader constants (because it's just RAM). The draw-back, of course, is that the CPU does the work, and thus it runs slow when you try to push large amounts of vertices.

    You can turn on software vertex transform for your "hardware" card, too, by requesting software vertex processing instead of hardware vertex processing when you create the device.


    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
  •  05-13-2008, 10:27 AM

    Re: Diagnosing an effect problem in SkinningSample

    jwatte:
    Specifically, it's the number of available vertex shader constants. On most hardware, you don't get enough for more than about 60 bones (80 if you're using 4x3 matrices). The Intel "chip," however, uses the CPU for transform, and has a whole lot of vertex shader constants (because it's just RAM). The draw-back, of course, is that the CPU does the work, and thus it runs slow when you try to push large amounts of vertices.

    You can turn on software vertex transform for your "hardware" card, too, by requesting software vertex processing instead of hardware vertex processing when you create the device.



    jwatte,

    really good info there.  thanks.

    just pointing out/asking the obvious here...  but if the software vertex processing was requested instead of the hardware vertex processing then the game would use the CPU to perform the transforms and would therefore cause the game to run slow.
  •  05-13-2008, 12:34 PM

    Re: Diagnosing an effect problem in SkinningSample

    That's correct; the vertex transform performance of your hardware card would drop to that of the Intel built-in graphics. That's the cost you have to pay to get lots more vertex shader constants.

    --
    Jon Watte, Direct3D MVP
    kW X-port 3ds Max .X exporter
    14 days after getting my RROD box back, it's going back for service again. Grr.
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback