Jump to content
  • Advertisement
Sign in to follow this  
FeanorLobelia

Problems with shader using debug mode in MDX

This topic is 4010 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'm using Managed Directx for one project, and although my bump, lighting and spec shader works quite well normally, if I turn on the debug version of DX (with max. debug output in Visual Studio) I get an error when rendering my first mesh with DrawSubset: Direct3D9: (ERROR) :Vertex shader function usage (D3DDECLUSAGE_TANGENT,0) does not have corresponding usage in the current vertex declaration Direct3D9: (INFO) :The vertex declaration is (Stream, Offset, Type, Method, Usage, UsageIndex): Direct3D9: (INFO) :0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 Direct3D9: (INFO) :0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 Direct3D9: (INFO) :0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 I don't understand. On retail versions, all the tangent, normal, position and TEXCOORD info was passed to my vertex shader just fine, without coding vertexelements and updating semantics. What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Still a really annoying problem. I have just found out that, still on DEBUG, it works if I turn OFF 'Maximum Validation' in the control panel. Obviously Directx has a way of ignoring the error. Any help would be appreciated.

Share this post


Link to post
Share on other sites
DirectX is a performance oriented API. It attempts to work as quickly as possible, and as such, it skips performing a lot of tests on input values you supply. Especially, the expensive types of tests are skipped most often.

In your case, you're doing something you're not allowed to do (use an input in the vertex shader that does not appear in the vertex declaration). The results for this case are not defined, and may very well vary between different hardware manufacturers, or even between driver versions on the same hardware.

When you run with the release runtime, DirectX doesn't perform the check to make sure all inputs appear in the declaration, I suppose because the DirectX team thought it wouldn't be worth doing. That's fine as far as DirectX is concerned. You need to make sure the values you pass methods are always valid, even if you don't get an actual error code from the release runtime. After all, this is what the debug runtimes (and REF device) are for. Use them.

Hope this helps.

Share this post


Link to post
Share on other sites
Thanks! That cleared up a lot.

However, I am still a bit confused. My mesh has tangent data (data which my shader uses just fine in retail to produce bump maps) and yet DX complains about it - is the ordering of DeclarationUsages important?

These are my inputs to my VS:

float4 Pos: POSITION0,
float2 TexCoords: TEXCOORD0,
float3 Normal: NORMAL0,
float3 Tangent: TANGENT0


I tried something like this, but all I'm doing is randomly messing up my vertex buffer and declaration :


VertexElement[] v = MyMesh.Declaration;

for (int ID = 0; ID <= (v.GetLength - 1); ID++) {
v(ID).DeclarationUsage = DeclarationUsage.Position & DeclarationUsage.TextureCoordinate & DeclarationUsage.Normal & DeclarationUsage.Tangent;
}

MyMesh.UpdateSemantics();

//......Render Loop
MyMesh.DrawSubset();



'......Render Loop
MyMesh.DrawSubset()

How do I sort out my vertex declaration for a mesh?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!