Skip to main content
gamedev.net
🔒 Locked

D3D10 Semantic debug error

Started by AriusMyst Sep 29, 2008 at 2:10 AM 3 replies 2.4k views
Original Post
AriusMyst
AriusMyst
Hello, I've started tinkering around in D3D10 and so far am having a nice time. But I've hit a snag. I keep getting the following error:

D3D10: CORRUPTION: ID3D10Device::CreateInputLayout: Semantic name cannot be NULL (or pointer is corrupt). Declaration entry [3]. [ MISCELLANEOUS CORRUPTION #13: CORRUPTED_PARAMETER1 ]
Now this is down to me trying to get tangent information in to my shader. Everything previously has worked. I am currently using an X file exported from Max9 using kw xport, I made sure the tangent data box was checked on export. I am loading it into D3D10 using the code found here: http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=316777&reply_id=2747161 Called in the following fashion:

	IDirect3DDevice9 *pDevice9;
	ID3DXMesh        *pMesh9;
	CreateD3D9NullRef(&pDevice9);
	D3DXLoadMeshFromX(Filename.c_str(), D3DXMESH_SYSTEMMEM, pDevice9, NULL, NULL, NULL, NULL, &pMesh9);

	ID3DXMesh        *sMesh;
	D3DVERTEXELEMENT9 test_decl[] =
	{
		{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
		{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
		{0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0},
		{0, 48, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0},
		D3DDECL_END() 
	};
	pMesh9->CloneMesh(D3DXMESH_MANAGED, test_decl, pDevice9, &sMesh);
	D3DXComputeTangent(sMesh, 0, 0, 0, 0, NULL);

	CreateD3DX10MeshFromD3DX9Mesh(sMesh, &geom_Mesh, p_Device);
	geom_Mesh->CommitToDevice();

I am setting the IA like this:

	D3D10_INPUT_ELEMENT_DESC layout[] =
	{    
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0},
		{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0},
		("TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 36, D3D10_INPUT_PER_VERTEX_DATA, 0)
	};

	UINT numElements     = 4;
	D3D10_PASS_DESC PassDesc;

	if(FAILED(p_Technique->GetPassByIndex(0)->GetDesc(&PassDesc))) ERR_OUT("PassDesc FAILED");
	p_Device->CreateInputLayout(layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &p_VertexLayout);

	p_Device->IASetInputLayout(p_VertexLayout);

If I don't try to send the tangent data the mesh draws correctly, so I assume the mesh conversion from 9 to 10 is successful, but I am not knowledgable enough yet to know how to check this. I've also tried not calling D3DXComputeTangent. I'm hoping it's something simple in my element description but google turns up no real results when I google the error. Anybody have any tips or advice for me on this issue? Thanks.
-...-Squeeged third eye.
Adam_42
Adam_42
One thing I've spotted is that the offset for your tangent data is 36, which is 12 bytes after the TEXCOORD. However the TEXCOORD is only 8 bytes (2 floats) so you probably want 32 instead.

Alternatively the documentation says you can just use D3D10_APPEND_ALIGNED_ELEMENT for all of the offsets.
AriusMyst
AriusMyst
Well spotted. Unfortunately it hasn't solved my problem, nor has D3D10_APPEND_ALIGNED_ELEMENT. It works if I don't attempt to pass tangent information so I'm pretty sure the shader itself is clean, but I'll post just in case.

	matrix World;	matrix View;	matrix Projection;	matrix wvp;	float3 LightPos = (0, 0, 5);	Texture2D Diffuse;	SamplerState sampleLinear	{	    Filter   = MIN_MAG_MIP_LINEAR;	    AddressU = Wrap;	    AddressV = Wrap;	};	         struct HOSTtoVERTEX        {                float4 PosOfVertex: POSITION;		float3 Normal     : NORMAL;//		float3 Tangent    : TANGENT;		float2 UV         : TEXCOORD;        };        struct VERTEXtoFRAGMENT        {                float4 PosOfVertex: SV_POSITION;		float3 Norm       : TEXCOORD0;		float3 LV         : TEXCOORD1;		float2 UV         : TEXCOORD2;        };                void VertexProgram(in HOSTtoVERTEX IN, out VERTEXtoFRAGMENT OUT)        {		float4 Pos      = mul(IN.PosOfVertex, World);		float4 PosWorld = mul(IN.PosOfVertex, World);		       Pos      = mul(Pos, View);                OUT.PosOfVertex = mul(Pos, Projection);		OUT.LV          = (PosWorld - LightPos);		OUT.Norm        = mul(IN.Normal, World);		OUT.UV          = IN.UV;        }                float4 FragmentProgram(in VERTEXtoFRAGMENT IN): SV_Target        {		float3 L  = normalize(IN.LV);		float3 N  = IN.Norm;		float  D  = dot(N, L);		float3 C  = Diffuse.Sample(sampleLinear, IN.UV);                return D * float4(C, 1);//		return float4(N, 1);        }                technique10 Render	{                pass pass0                {		        SetVertexShader(CompileShader(vs_4_0, VertexProgram()));		        SetGeometryShader(NULL);		        SetPixelShader(CompileShader(ps_4_0, FragmentProgram()));                }        }


-...-Squeeged third eye.
Adam_42
Adam_42
Just spotted something else with that data. The tangent is wrapped in round brackets while the other lines are in curly ones. That will make a big mess of the tangent data as it will combine it all into one with the comma operator!

Did it not produce any compiler warnings?
AriusMyst
AriusMyst
Quote:
Original post by Adam_42
Just spotted something else with that data. The tangent is wrapped in round brackets while the other lines are in curly ones. That will make a big mess of the tangent data as it will combine it all into one with the comma operator!

Did it not produce any compiler warnings?


You sir are a genius and I am a fool. I have no idea why I had () instead of {}. Compiles and runs now, thank you very much for your help. :D

-...-Squeeged third eye.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.